diff --git a/.github/workflows/code_analysis.yaml b/.github/workflows/code_analysis.yaml index 74396444d5a..ba3fd276980 100644 --- a/.github/workflows/code_analysis.yaml +++ b/.github/workflows/code_analysis.yaml @@ -49,10 +49,6 @@ jobs: name: 'Compatible PHPStan versions' run: php bin/validate-phpstan-version.php - - - name: 'Detect Rules Missing in Set' - run: bin/rector missing-in-set --ansi - # see https://github.com/rectorphp/rector-generator - name: 'Rector Generate From Recipe' diff --git a/src/DependencyInjection/LazyContainerFactory.php b/src/DependencyInjection/LazyContainerFactory.php index 359b3f52a85..2205c076ec1 100644 --- a/src/DependencyInjection/LazyContainerFactory.php +++ b/src/DependencyInjection/LazyContainerFactory.php @@ -180,7 +180,6 @@ use Rector\StaticTypeMapper\PhpParser\StringNodeMapper; use Rector\StaticTypeMapper\PhpParser\UnionTypeNodeMapper; use Rector\StaticTypeMapper\StaticTypeMapper; -use Rector\Utils\Command\MissingInSetCommand; use Rector\Utils\Command\OutsideAnySetCommand; use Symfony\Component\Console\Application; use Symfony\Component\Console\Command\Command; @@ -421,8 +420,7 @@ public function create(): RectorConfig ->giveTagged(RectorInterface::class); // dev - if (class_exists(MissingInSetCommand::class)) { - $rectorConfig->singleton(MissingInSetCommand::class); + if (class_exists(OutsideAnySetCommand::class)) { $rectorConfig->singleton(OutsideAnySetCommand::class); } diff --git a/utils/Command/MissingInSetCommand.php b/utils/Command/MissingInSetCommand.php deleted file mode 100644 index 68f45b8c0c0..00000000000 --- a/utils/Command/MissingInSetCommand.php +++ /dev/null @@ -1,124 +0,0 @@ - - */ - private const SKIPPED_RULES = [ - ConfigurableRectorInterface::class, - // optional - IncreaseDeclareStrictTypesRector::class, - StaticClosureRector::class, - StaticArrowFunctionRector::class, - CallableThisArrayToAnonymousFunctionRector::class, - // changes behavior, should be applied on purpose regardless PHP 7.3 level - JsonThrowOnErrorRector::class, - // in confront with sub type safe belt detection on RemoveUseless*TagRector - RemoveNullTagValueNodeRector::class, - // personal preference, enable on purpose - ArraySpreadInsteadOfArrayMergeRector::class, - - // deprecated - InitializeDefaultEntityCollectionRector::class, - TypedPropertyFromDoctrineCollectionRector::class, - - // by guessing class detection - AddCoversClassAttributeRector::class, - ]; - - public function __construct( - private readonly SymfonyStyle $symfonyStyle - ) { - parent::__construct(); - } - - protected function configure(): void - { - $this->setName('missing-in-set'); - $this->setDescription('[DEV] Show rules from specific category that are not part of the set'); - } - - protected function execute(InputInterface $input, OutputInterface $output): int - { - $hasError = false; - - foreach (RectorDirectoryToSetFileMap::provide() as $rulesDirectory => $setFile) { - $classesInSetFile = SetRectorClassesResolver::resolve($setFile); - $existingRectorClasses = RectorClassFinder::find([$rulesDirectory]); - - $rectorClassesNotInSetConfig = array_diff($existingRectorClasses, $classesInSetFile); - - // remove deprecated and configurable rules - $rectorClassesNotInSetConfig = array_filter( - $rectorClassesNotInSetConfig, - static function (string $rectorClass): bool { - foreach (self::SKIPPED_RULES as $rule) { - if (is_a($rectorClass, $rule, true)) { - return false; - } - } - - return true; - } - ); - - if ($rectorClassesNotInSetConfig === []) { - continue; - } - - // probably in rector-preset? - $classesInSetFile = SetRectorClassesResolver::resolve(__DIR__ . '/../../config/set/rector-preset.php'); - $rectorClassesNotInSetConfig = array_diff($rectorClassesNotInSetConfig, $classesInSetFile); - if ($rectorClassesNotInSetConfig === []) { - continue; - } - - $hasError = true; - $this->symfonyStyle->title('We could not find there rules in configs'); - - $setRealpath = realpath($setFile); - $relativeFilePath = Strings::after($setRealpath, getcwd() . '/'); - - $this->symfonyStyle->writeln(' * ' . $relativeFilePath); - $this->symfonyStyle->newLine(1); - - $this->symfonyStyle->listing($rectorClassesNotInSetConfig); - $this->symfonyStyle->newLine(1); - } - - if ($hasError) { - return self::FAILURE; - } - - $setCount = count(RectorDirectoryToSetFileMap::provide()); - - $this->symfonyStyle->success(sprintf('All %d sets contains the rules from their category', $setCount)); - - return self::SUCCESS; - } -} diff --git a/utils/Enum/RectorDirectoryToSetFileMap.php b/utils/Enum/RectorDirectoryToSetFileMap.php deleted file mode 100644 index 2dcd2f55952..00000000000 --- a/utils/Enum/RectorDirectoryToSetFileMap.php +++ /dev/null @@ -1,82 +0,0 @@ - - */ - public static function provide(): array - { - return [ - __DIR__ . '/../../rules/CodeQuality/Rector' => __DIR__ . '/../../config/set/code-quality.php', - __DIR__ . '/../../rules/CodingStyle/Rector' => __DIR__ . '/../../config/set/coding-style.php', - __DIR__ . '/../../rules/DeadCode/Rector' => __DIR__ . '/../../config/set/dead-code.php', - __DIR__ . '/../../rules/EarlyReturn/Rector' => __DIR__ . '/../../config/set/early-return.php', - __DIR__ . '/../../rules/Naming/Rector' => __DIR__ . '/../../config/set/naming.php', - __DIR__ . '/../../rules/TypeDeclaration/Rector' => __DIR__ . '/../../config/set/type-declaration.php', - __DIR__ . '/../../rules/Privatization/Rector' => __DIR__ . '/../../config/set/privatization.php', - __DIR__ . '/../../rules/Php52/Rector' => __DIR__ . '/../../config/set/php52.php', - __DIR__ . '/../../rules/Php53/Rector' => __DIR__ . '/../../config/set/php53.php', - __DIR__ . '/../../rules/Php54/Rector' => __DIR__ . '/../../config/set/php54.php', - __DIR__ . '/../../rules/Php55/Rector' => __DIR__ . '/../../config/set/php55.php', - __DIR__ . '/../../rules/Php56/Rector' => __DIR__ . '/../../config/set/php56.php', - __DIR__ . '/../../rules/Php70/Rector' => __DIR__ . '/../../config/set/php70.php', - __DIR__ . '/../../rules/Php71/Rector' => __DIR__ . '/../../config/set/php71.php', - __DIR__ . '/../../rules/Php72/Rector' => __DIR__ . '/../../config/set/php72.php', - __DIR__ . '/../../rules/Php73/Rector' => __DIR__ . '/../../config/set/php73.php', - __DIR__ . '/../../rules/Php74/Rector' => __DIR__ . '/../../config/set/php74.php', - __DIR__ . '/../../rules/Php80/Rector' => __DIR__ . '/../../config/set/php80.php', - __DIR__ . '/../../rules/Php81/Rector' => __DIR__ . '/../../config/set/php81.php', - __DIR__ . '/../../rules/Php82/Rector' => __DIR__ . '/../../config/set/php82.php', - __DIR__ . '/../../rules/Strict/Rector' => __DIR__ . '/../../config/set/strict-booleans.php', - __DIR__ . '/../../rules/Instanceof_/Rector' => __DIR__ . '/../../config/set/instanceof.php', - - // doctrine - __DIR__ . '/../../vendor/rector/rector-doctrine/rules/CodeQuality' => __DIR__ . '/../../vendor/rector/rector-doctrine/config/sets/doctrine-code-quality.php', - - // phpunit - __DIR__ . '/../../vendor/rector/rector-phpunit/rules/PHPUnit50' => __DIR__ . '/../../vendor/rector/rector-phpunit/config/sets/phpunit50.php', - __DIR__ . '/../../vendor/rector/rector-phpunit/rules/PHPUnit60' => __DIR__ . '/../../vendor/rector/rector-phpunit/config/sets/phpunit60.php', - __DIR__ . '/../../vendor/rector/rector-phpunit/rules/PHPUnit70' => __DIR__ . '/../../vendor/rector/rector-phpunit/config/sets/phpunit70.php', - __DIR__ . '/../../vendor/rector/rector-phpunit/rules/PHPUnit80' => __DIR__ . '/../../vendor/rector/rector-phpunit/config/sets/phpunit80.php', - __DIR__ . '/../../vendor/rector/rector-phpunit/rules/PHPUnit90' => __DIR__ . '/../../vendor/rector/rector-phpunit/config/sets/phpunit90.php', - __DIR__ . '/../../vendor/rector/rector-phpunit/rules/PHPUnit100' => __DIR__ . '/../../vendor/rector/rector-phpunit/config/sets/phpunit100.php', - __DIR__ . '/../../vendor/rector/rector-phpunit/rules/AnnotationsToAttributes' => __DIR__ . '/../../vendor/rector/rector-phpunit/config/sets/annotations-to-attributes.php', - __DIR__ . '/../../vendor/rector/rector-phpunit/rules/CodeQuality' => __DIR__ . '/../../vendor/rector/rector-phpunit/config/sets/phpunit-code-quality.php', - - // rector-downgrade - __DIR__ . '/../../vendor/rector/rector-downgrade-php/rules/DowngradePhp72' => __DIR__ . '/../../vendor/rector/rector-downgrade-php/config/set/downgrade-php72.php', - __DIR__ . '/../../vendor/rector/rector-downgrade-php/rules/DowngradePhp73' => __DIR__ . '/../../vendor/rector/rector-downgrade-php/config/set/downgrade-php73.php', - __DIR__ . '/../../vendor/rector/rector-downgrade-php/rules/DowngradePhp74' => __DIR__ . '/../../vendor/rector/rector-downgrade-php/config/set/downgrade-php74.php', - __DIR__ . '/../../vendor/rector/rector-downgrade-php/rules/DowngradePhp80' => __DIR__ . '/../../vendor/rector/rector-downgrade-php/config/set/downgrade-php80.php', - __DIR__ . '/../../vendor/rector/rector-downgrade-php/rules/DowngradePhp81' => __DIR__ . '/../../vendor/rector/rector-downgrade-php/config/set/downgrade-php81.php', - __DIR__ . '/../../vendor/rector/rector-downgrade-php/rules/DowngradePhp82' => __DIR__ . '/../../vendor/rector/rector-downgrade-php/config/set/downgrade-php82.php', - __DIR__ . '/../../vendor/rector/rector-downgrade-php/rules/DowngradePhp83' => __DIR__ . '/../../vendor/rector/rector-downgrade-php/config/set/downgrade-php83.php', - - // symfony - __DIR__ . '/../../vendor/rector/rector-symfony/rules/Symfony25' => __DIR__ . '/../../vendor/rector/rector-symfony/config/sets/symfony/symfony25.php', - __DIR__ . '/../../vendor/rector/rector-symfony/rules/Symfony26' => __DIR__ . '/../../vendor/rector/rector-symfony/config/sets/symfony/symfony26.php', - __DIR__ . '/../../vendor/rector/rector-symfony/rules/Symfony27' => __DIR__ . '/../../vendor/rector/rector-symfony/config/sets/symfony/symfony27.php', - __DIR__ . '/../../vendor/rector/rector-symfony/rules/Symfony28' => __DIR__ . '/../../vendor/rector/rector-symfony/config/sets/symfony/symfony28.php', - __DIR__ . '/../../vendor/rector/rector-symfony/rules/Symfony30' => __DIR__ . '/../../vendor/rector/rector-symfony/config/sets/symfony/symfony30.php', - __DIR__ . '/../../vendor/rector/rector-symfony/rules/Symfony33' => __DIR__ . '/../../vendor/rector/rector-symfony/config/sets/symfony/symfony33.php', - __DIR__ . '/../../vendor/rector/rector-symfony/rules/Symfony34' => __DIR__ . '/../../vendor/rector/rector-symfony/config/sets/symfony/symfony34.php', - __DIR__ . '/../../vendor/rector/rector-symfony/rules/Symfony40' => __DIR__ . '/../../vendor/rector/rector-symfony/config/sets/symfony/symfony40.php', - __DIR__ . '/../../vendor/rector/rector-symfony/rules/Symfony42' => __DIR__ . '/../../vendor/rector/rector-symfony/config/sets/symfony/symfony42.php', - __DIR__ . '/../../vendor/rector/rector-symfony/rules/Symfony43' => __DIR__ . '/../../vendor/rector/rector-symfony/config/sets/symfony/symfony43.php', - __DIR__ . '/../../vendor/rector/rector-symfony/rules/Symfony44' => __DIR__ . '/../../vendor/rector/rector-symfony/config/sets/symfony/symfony44.php', - __DIR__ . '/../../vendor/rector/rector-symfony/rules/Symfony51' => __DIR__ . '/../../vendor/rector/rector-symfony/config/sets/symfony/symfony51.php', - __DIR__ . '/../../vendor/rector/rector-symfony/rules/Symfony52' => __DIR__ . '/../../vendor/rector/rector-symfony/config/sets/symfony/symfony52.php', - __DIR__ . '/../../vendor/rector/rector-symfony/rules/Symfony53' => __DIR__ . '/../../vendor/rector/rector-symfony/config/sets/symfony/symfony53.php', - __DIR__ . '/../../vendor/rector/rector-symfony/rules/Symfony60' => __DIR__ . '/../../vendor/rector/rector-symfony/config/sets/symfony/symfony60.php', - __DIR__ . '/../../vendor/rector/rector-symfony/rules/Symfony61' => __DIR__ . '/../../vendor/rector/rector-symfony/config/sets/symfony/symfony61.php', - __DIR__ . '/../../vendor/rector/rector-symfony/rules/Symfony62' => __DIR__ . '/../../vendor/rector/rector-symfony/config/sets/symfony/symfony62.php', - __DIR__ . '/../../vendor/rector/rector-symfony/rules/Symfony63' => __DIR__ . '/../../vendor/rector/rector-symfony/config/sets/symfony/symfony63.php', - __DIR__ . '/../../vendor/rector/rector-symfony/rules/Symfony64' => __DIR__ . '/../../vendor/rector/rector-symfony/config/sets/symfony/symfony64.php', - ]; - } -}