-
-
Notifications
You must be signed in to change notification settings - Fork 687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Command line option to execute a single rule only #8899
Labels
Comments
Thanks for great summary. I think now I'm open to accept this feature, under 2 requirements:
If the feature is user-friendly, let's go 👍 |
cweiske
added a commit
to mogic-le/rector-src
that referenced
this issue
Nov 15, 2024
The option for the "process" and "list-rules" commands applies the single given rule only, without needing to modify the configuration file. The option value must be a fully classified class name: --only="Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodRector" A hint is given when the user forgot to escape the backslashes. ---- It is impossible to modify the injected "$rectors" after the command line configuration is parsed, so I had to introduce the ConfigurationRuleFilter singleton. Since both ListRulesCommand and ProcessCommand make use of the ConfigurationRuleFilter - but list-rules does not have a Configuration - I had to make the filterOnlyRule() method public to prevent code duplication. Resolves rectorphp/rector#8899
cweiske
added a commit
to mogic-le/rector-src
that referenced
this issue
Nov 15, 2024
The option for the "process" and "list-rules" commands applies the single given rule only, without needing to modify the configuration file. The option value must be a fully classified class name: --only="Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodRector" A hint is given when the user forgot to escape the backslashes. ---- It is impossible to modify the injected "$rectors" after the command line configuration is parsed, so I had to introduce the ConfigurationRuleFilter singleton. Since both ListRulesCommand and ProcessCommand make use of the ConfigurationRuleFilter - but list-rules does not have a Configuration - I had to make the filterOnlyRule() method public to prevent code duplication. Resolves rectorphp/rector#8899
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Feature Request
It should be possible to provide a command line option that causes rector to apply a single rule only.
Configuration file adjustments should not be necessary.
This is a feature needed for #8898 (automatically splitting up rector fixes into different commits).
History
rector once had such a parameter:
--rule
was added Add --rule option to process only single rule from set #1640--rule
was renamed to--only
Rename --rule argument into --only, add documentation. #2655--only
was removed with 9eaeb30--only
was re-added Re-add --only option #3539--only
was removed again [DX] Drop buggy --only option #4701Problems
#7366 (comment):
#3342 (comment):
#3342 (comment)
#4699 (comment)
Naming
--only
(--rule
was renamed to--only
in #2655).Accepted values
The option should accept a single value only: A fully qualified class name (not a short/relative one, see #7366).
Things to consider:
Affected commands
process
list-rules
❗ After reading the comments in the previous issues and patches, I have no idea what requirements regarding naming, functionality and stability you have for this feature.
The text was updated successfully, but these errors were encountered: