rector icon indicating copy to clipboard operation
rector copied to clipboard

Support Question : Ability to exclude one rule from a set ?

Open arnaud-fr opened this issue 5 years ago • 5 comments

Hi,

Is it possible to exclude one rule from a set in a PHP configuration ?

I've found sample with old yaml configuration ... You can use a whole ruleset, except one rule:

rector.yaml

parameters: exclude_rectors: - 'Rector\CodeQuality\Rector\If_\SimplifyIfReturnBoolRector'__ ...

How can I do the same goal in a PHP configuration ? I try to use this kind of snipplet

rector.php

... $parameters->set(Option::SETS, [ SetList::PHP_52 ]); $parameters->set(Option::SKIP, [VarToPublicPropertyRector::class,]); ... but it does not work

arnaud-fr avatar Dec 09 '20 19:12 arnaud-fr

https://github.com/rectorphp/rector/issues/4744

tl;dr; try to use Option::EXCLUDE_RECTORS

lulco avatar Dec 09 '20 20:12 lulco

@lulco :+1: Thank you

TomasVotruba avatar Dec 09 '20 20:12 TomasVotruba

Thanks,

Note : the constant Option::EXCLUDE_RECTORS currently does not exist in the component Rector\Core\Configuration\Option in master branch.

arnaud-fr avatar Dec 09 '20 21:12 arnaud-fr

FYI the rector API has changed again over the years. This is the new way to skip rules from sets:


    $rectorConfig->sets([LevelSetList::UP_TO_PHP_81]);

    $rectorConfig->skip([
        // currently ignores and deletes symfony annotations for ORM
        ClassPropertyAssignToConstructorPromotionRector::class,
        // violates ecs
        MixedTypeRector::class,
        // diff is too big, wait for PHP 8.3 readonly classes
        ReadOnlyPropertyRector::class,
    ]);

techi602 avatar Sep 25 '24 16:09 techi602

This issue has been automatically locked because it has been closed for 150 days. Please open a new issue if you have a similar problem.

github-actions[bot] avatar Jan 04 '26 03:01 github-actions[bot]