change rector-ci.php to rector.php (#4994)

This commit is contained in:
Tomas Votruba 2020-12-25 19:11:33 +01:00 committed by GitHub
parent 51dd6b899a
commit d256bbd8c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 81 additions and 134 deletions

View File

@ -19,7 +19,7 @@ jobs:
-
name: 'Show command'
run: bin/rector show --config rector-ci.php --ansi
run: bin/rector show --ansi
-
name: Validate Fixtures

View File

@ -53,7 +53,7 @@ jobs:
- run: composer install --no-progress --ansi
## First run Rector - here can't be --dry-run !!! it would stop the job with it and not commit anything in the future
- run: bin/rector rectify ${{ matrix.directories }} --config rector-ci.php --ansi --no-progress-bar
- run: bin/rector rectify ${{ matrix.directories }} --ansi --no-progress-bar
- run: vendor/bin/ecs check --match-git-diff --fix --ansi
# see https://github.com/EndBug/add-and-commit

View File

@ -314,8 +314,8 @@
"bin/rector dump-nodes --output-file docs/nodes_overview.md --ansi",
"vendor/bin/ecs check-markdown docs/rector_rules_overview.md docs/nodes_overview.md --ansi --fix"
],
"rector-ci": "bin/rector process --config rector-ci.php --dry-run --ansi",
"rector": "bin/rector process --config rector-ci.php --ansi"
"rector-ci": "bin/rector process --dry-run --ansi",
"rector": "bin/rector process --ansi"
},
"config": {
"sort-packages": true

View File

@ -56,7 +56,6 @@ return static function (ContainerConfigurator $containerConfigurator): void {
__DIR__ . '/config',
__DIR__ . '/ecs.php',
__DIR__ . '/rector.php',
__DIR__ . '/rector-ci.php',
__DIR__ . '/config/set',
]);

View File

@ -463,9 +463,6 @@ parameters:
- packages/better-php-doc-parser/tests/PhpDocParser/AbstractPhpDocInfoTest.php
- packages/better-php-doc-parser/tests/PhpDocInfo/PhpDocInfoPrinter/AbstractPhpDocInfoPrinterTest.php
# bug in simplify - @todo fix
- '#Parameter 2 should use "Rector\\Core\\PhpParser\\Node\\CustomNode\\FileWithoutNamespace" type as the only type passed to this method#'
# false positives checked in another method
-
message: '#If condition is always false#'
@ -537,13 +534,6 @@ parameters:
- '#Access to an undefined property PhpParser\\Node\\Expr\\Error\|PhpParser\\Node\\Expr\\Variable\:\:\$name#'
# @todo resolve later
- '#Configurable rules must have configure code sample#'
- '#Configurable code sample is used but "Rector\\Core\\Contract\\Rector\\ConfigurableRectorInterface" interface is not implemented#'
# @todo bug in symplify, fix later
- '#Parameter 2 should use "PhpParser\\Node\\Stmt\\Namespace_" type as the only type passed to this method#'
-
message: '#Class cognitive complexity is 41, keep it under 40#'
paths:
@ -554,10 +544,6 @@ parameters:
message: '#Access to an undefined property PhpParser\\Node\:\:\$expr#'
paths:
- rules/php80/src/Rector/If_/NullsafeOperatorRector.php
-
message: '#Call to an undefined method PHPStan\\Type\\Type\:\:getClassName\(\)#'
paths:
- rules/strict-code-quality/src/Rector/ClassMethod/ParamTypeToAssertTypeRector.php
###################################################

View File

@ -1,92 +0,0 @@
<?php
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
use Rector\CodingStyle\Rector\MethodCall\PreferThisOrSelfMethodCallRector;
use Rector\CodingStyle\Rector\String_\SplitStringClassConstantToClassConstFetchRector;
use Rector\Core\Configuration\Option;
use Rector\Core\Rector\AbstractRector;
use Rector\Core\ValueObject\PhpVersion;
use Rector\DeadCode\Rector\ClassConst\RemoveUnusedClassConstantRector;
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
use Rector\Restoration\Rector\ClassMethod\InferParamFromClassMethodReturnRector;
use Rector\Restoration\ValueObject\InferParamFromClassMethodReturn;
use Rector\Set\ValueObject\SetList;
use Rector\SymfonyPhpConfig\Rector\MethodCall\AutoInPhpSymfonyConfigRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$configuration = ValueObjectInliner::inline([
new InferParamFromClassMethodReturn(AbstractRector::class, 'refactor', 'getNodeTypes'),
]);
$services->set(InferParamFromClassMethodReturnRector::class)
->call('configure', [[
InferParamFromClassMethodReturnRector::INFER_PARAMS_FROM_CLASS_METHOD_RETURNS => $configuration,
]]);
$services->set(PreferThisOrSelfMethodCallRector::class)
->call('configure', [[
PreferThisOrSelfMethodCallRector::TYPE_TO_PREFERENCE => [
TestCase::class => PreferThisOrSelfMethodCallRector::PREFER_THIS,
],
]]);
$services->set(AutoInPhpSymfonyConfigRector::class);
$parameters = $containerConfigurator->parameters();
$parameters->set(Option::SETS, [
SetList::CODING_STYLE,
SetList::CODE_QUALITY,
SetList::CODE_QUALITY_STRICT,
SetList::DEAD_CODE,
SetList::DEAD_DOC_BLOCK,
SetList::NETTE_UTILS_CODE_QUALITY,
SetList::PRIVATIZATION,
SetList::NAMING,
SetList::DEFLUENT,
SetList::TYPE_DECLARATION,
SetList::PHPUNIT_CODE_QUALITY,
Setlist::SYMFONY_AUTOWIRE,
Setlist::PHP_71,
Setlist::PHP_72,
Setlist::PHP_73,
Setlist::EARLY_RETURN,
]);
$parameters->set(Option::PATHS, [
__DIR__ . '/src',
__DIR__ . '/rules',
__DIR__ . '/packages',
__DIR__ . '/tests',
__DIR__ . '/utils',
__DIR__ . '/config/set',
]);
$parameters->set(Option::AUTO_IMPORT_NAMES, true);
$parameters->set(Option::SKIP, [
StringClassNameToClassConstantRector::class,
SplitStringClassConstantToClassConstFetchRector::class,
// false positives on constants used in rector-ci.php
RemoveUnusedClassConstantRector::class,
// test paths
'*/Fixture/*',
'*/Source/*',
'*/Expected/*',
__DIR__ . '/packages/doctrine-annotation-generated/src',
// template files
__DIR__ . '/packages/rector-generator/templates',
__DIR__ . '/packages/rector-generator/src/ValueObject/RectorRecipe.php',
]);
# so Rector code is still PHP 7.2 compatible
$parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_72);
$parameters->set(Option::ENABLE_CACHE, true);
};

View File

@ -2,36 +2,90 @@
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
use Rector\CodingStyle\Rector\MethodCall\PreferThisOrSelfMethodCallRector;
use Rector\CodingStyle\Rector\String_\SplitStringClassConstantToClassConstFetchRector;
use Rector\Core\Configuration\Option;
use Rector\Core\Rector\AbstractRector;
use Rector\Core\ValueObject\PhpVersion;
use Rector\DeadCode\Rector\ClassConst\RemoveUnusedClassConstantRector;
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
use Rector\Restoration\Rector\ClassMethod\InferParamFromClassMethodReturnRector;
use Rector\Restoration\ValueObject\InferParamFromClassMethodReturn;
use Rector\Set\ValueObject\SetList;
use Rector\SymfonyPhpConfig\Rector\MethodCall\AutoInPhpSymfonyConfigRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$configuration = ValueObjectInliner::inline([
new InferParamFromClassMethodReturn(AbstractRector::class, 'refactor', 'getNodeTypes'),
]);
$services->set(InferParamFromClassMethodReturnRector::class)
->call('configure', [[
InferParamFromClassMethodReturnRector::INFER_PARAMS_FROM_CLASS_METHOD_RETURNS => $configuration,
]]);
$services->set(PreferThisOrSelfMethodCallRector::class)
->call('configure', [[
PreferThisOrSelfMethodCallRector::TYPE_TO_PREFERENCE => [
TestCase::class => PreferThisOrSelfMethodCallRector::PREFER_THIS,
],
]]);
$services->set(AutoInPhpSymfonyConfigRector::class);
$parameters = $containerConfigurator->parameters();
$parameters->set(Option::SETS, [
SetList::CODING_STYLE,
SetList::CODE_QUALITY,
SetList::CODE_QUALITY_STRICT,
SetList::DEAD_CODE,
SetList::DEAD_DOC_BLOCK,
SetList::NETTE_UTILS_CODE_QUALITY,
SetList::PRIVATIZATION,
SetList::NAMING,
SetList::DEFLUENT,
SetList::TYPE_DECLARATION,
SetList::PHPUNIT_CODE_QUALITY,
Setlist::SYMFONY_AUTOWIRE,
Setlist::PHP_71,
Setlist::PHP_72,
Setlist::PHP_73,
Setlist::EARLY_RETURN,
]);
$parameters->set(Option::PATHS, [
__DIR__ . '/src',
__DIR__ . '/tests',
__DIR__ . '/rules',
__DIR__ . '/utils',
__DIR__ . '/packages',
__DIR__ . '/bin/rector',
]);
$parameters->set(Option::SETS, [SetList::PHP_73]);
$parameters->set(Option::SKIP, [
'*/Source/*',
'*/Fixture/*',
'*/Expected/*',
__DIR__ . '/packages/doctrine-annotation-generated/src/*',
__DIR__ . '/packages/rector-generator/templates/*',
'*.php.inc',
__DIR__ . '/tests',
__DIR__ . '/utils',
__DIR__ . '/config/set',
]);
$parameters->set(Option::AUTO_IMPORT_NAMES, true);
# so Rector code is still PHP 7.2 compatible
$parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_72);
$parameters->set(Option::SKIP, [
StringClassNameToClassConstantRector::class,
SplitStringClassConstantToClassConstFetchRector::class,
// false positives on constants used in rector.php
RemoveUnusedClassConstantRector::class,
// test paths
'*/Fixture/*',
'*/Source/*',
'*/Expected/*',
__DIR__ . '/packages/doctrine-annotation-generated/src',
// template files
__DIR__ . '/packages/rector-generator/templates',
__DIR__ . '/packages/rector-generator/src/ValueObject/RectorRecipe.php',
]);
$parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_73);
$parameters->set(Option::ENABLE_CACHE, true);
};

View File

@ -4,7 +4,7 @@ sonar.projectKey=rectorphp_rector
# relative paths to source
# wildcards don't work :(
sonar.sources=src,rules/autodiscovery/src,rules/architecture/src,packages/attribute-aware-php-doc/src,packages/better-php-doc-parser/src,rules/cakephp/src,rules/code-quality/src,rules/coding-style/src,packages/console-differ/src,rules/dead-code/src,rules/doctrine/src,rules/doctrine-code-quality/src,packages/file-system-rector/src,rules/laravel/src,rules/legacy/src,rules/mysql-to-mysqli/src,rules/nette-tester-to-phpunit/src,rules/nette-to-symfony/src,rules/nette/src,packages/node-collector/src,packages/node-type-resolver/src,packages/node-name-resolver/src,packages/phpstan-static-type-mapper/src,rules/phpunit-symfony/src,rules/phpunit/src,rules/psr4/src,rules/php-spec-to-phpunit/src,rules/php52/src,rules/php53/src,rules/php54/src,rules/php55/src,rules/php56/src,rules/php70/src,rules/php71/src,rules/php72/src,rules/php73/src,rules/php74/src,rules/php80/src,rules/removing-static/src,rules/renaming/src,rules/restoration/src,rules/dependency-injection/src,rules/sensio/src,packages/static-type-mapper/src,rules/symfony-code-quality/src,rules/symfony-phpunit/src,rules/symfony/src,rules/twig/src,rules/type-declaration/src,packages/vendor-locker/src,packages/rector-generator/src,rules/strict-code-quality/src,rules/phalcon/src,rules/doctrine-gedmo-to-knplabs/src,rules/polyfill/src,rules/generic/src
sonar.sources=src,rules/autodiscovery/src,rules/architecture/src,packages/attribute-aware-php-doc/src,packages/better-php-doc-parser/src,rules/cakephp/src,rules/code-quality/src,rules/coding-style/src,packages/console-differ/src,rules/dead-code/src,rules/doctrine/src,rules/doctrine-code-quality/src,packages/file-system-rector/src,rules/laravel/src,rules/legacy/src,rules/mysql-to-mysqli/src,rules/nette-tester-to-phpunit/src,rules/nette-to-symfony/src,rules/nette/src,packages/node-collector/src,packages/node-type-resolver/src,packages/node-name-resolver/src,packages/phpstan-static-type-mapper/src,rules/phpunit-symfony/src,rules/phpunit/src,rules/psr4/src,rules/php-spec-to-phpunit/src,rules/php52/src,rules/php53/src,rules/php54/src,rules/php55/src,rules/php56/src,rules/php70/src,rules/php71/src,rules/php72/src,rules/php73/src,rules/php74/src,rules/php80/src,rules/removing-static/src,rules/renaming/src,rules/restoration/src,rules/dependency-injection/src,rules/sensio/src,packages/static-type-mapper/src,rules/symfony-code-quality/src,rules/symfony-phpunit/src,rules/symfony/src,rules/twig/src,rules/type-declaration/src,packages/vendor-locker/src,packages/rector-generator/src,rules/code-quality-strict/src,rules/phalcon/src,rules/doctrine-gedmo-to-knplabs/src,rules/polyfill/src,rules/generic/src
sonar.tests=tests,rules/autodiscovery/tests,rules/architecture/tests,packages/better-php-doc-parser/tests,rules/cakephp/tests,rules/code-quality/tests,rules/coding-style/tests,rules/dead-code/tests,rules/doctrine/tests,rules/doctrine-code-quality/tests,rules/laravel/tests,rules/legacy/tests,rules/mysql-to-mysqli/tests,rules/nette-tester-to-phpunit/tests,rules/nette-to-symfony/tests,rules/nette/tests,packages/node-type-resolver/tests,utils/phpstan-extensions/src,rules/phpunit-symfony/tests,rules/phpunit/tests,rules/psr4/tests,rules/php-spec-to-phpunit/tests,rules/php52/tests,rules/php53/tests,rules/php54/tests,rules/php55/tests,rules/php56/tests,rules/php70/tests,rules/php71/tests,rules/php72/tests,rules/php73/tests,rules/php74/tests,rules/php80/tests,rules/removing-static/tests,rules/renaming/tests,rules/restoration/tests,rules/dependency-injection/tests,rules/sensio/tests,rules/symfony-code-quality/tests,rules/symfony-phpunit/tests,rules/symfony/tests,rules/twig/tests,rules/type-declaration/tests,rules/code-quality-strict/tests,rules/phalcon/tests,utils/node-documentation-generator/src,utils/phpstan-attribute-type-syncer/src,utils/phpstan-type-mapper-checker/src,rules/doctrine-gedmo-to-knplabs/tests,rules/polyfill/tests,rules/generic/tests

View File

@ -15,9 +15,9 @@ services:
Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample: Rector\Core\Contract\Rector\ConfigurableRectorInterface
# open in Sypmlify 9.0.20 version
# -
# class: Symplify\PHPStanRules\Rules\IfImplementsInterfaceThenNewTypeRule
# tags: [phpstan.rules.rule]
# arguments:
# interfacesByNewTypes:
# Rector\Core\Contract\Rector\ConfigurableRectorInterface: Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample
-
class: Symplify\PHPStanRules\Rules\IfImplementsInterfaceThenNewTypeRule
tags: [phpstan.rules.rule]
arguments:
newTypesByInterface:
Rector\Core\Contract\Rector\ConfigurableRectorInterface: Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample