-
-
Notifications
You must be signed in to change notification settings - Fork 359
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
Add "--only" option to process only a single rule #6441
Conversation
985e2db
to
e5b3888
Compare
There should be kind of e2e tests that passes and that fails if data are incorrect |
e5b3888
to
7de7a84
Compare
I've added an end-to-end test that fails when e.g. the ConfigurationRuleFilter simply returns all rectors instead of filtering them. I had to extend the e2eTestRunner to support additional command line options. |
Register new e2e path to rector-src/.github/workflows/e2e.yaml Line 26 in 37226f1
|
7de7a84
to
86e10d9
Compare
e2e-test is registered. |
86e10d9
to
19e7820
Compare
Class name quoting on LinuxHow to input backslashes in a terminal (bash) Works
Does not work
Class name quoting on WindowsStandard cmd.exe shell Works
|
This input should be handled to work, as we can narrow slashes to 1.
This input should make a not about slahes or quotes, to guide user to success. These error were reasons to remove the old feature, so they should be covered now with helpful response 👍 |
The error message consists of 2 lines:
It mentions backslashes. How shall I phrase it better? |
is |
Ideally with copy paste response. The missing quotes are more helpful in this case, as slashes are correct. |
19e7820
to
18de334
Compare
I've adjusted the code and the tests:
|
18de334
to
acf0bb4
Compare
I've tested all combinations on Windows (see comment above) and found that when using single quotes, the single quotes appear in the parameter value:
So I've adjusted the code to remove them if necessary, and using single quotes on windows works now, too. |
acf0bb4
to
5849c7e
Compare
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
.. but throw an exception if the name is ambiguous
5849c7e
to
6ffbc3a
Compare
Anyone? |
@TomasVotruba what do you say? |
@TomasVotruba Wouldn't this be nice to have in rector 2.0.0? |
Thanks for the ping and your work. I'll look into this today and will merge 👍 |
Very well done feature, thank you for your work @cweiske 👏 |
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:
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
Test it: