add custom rector to cleanup command usages#348
Conversation
|
I am confused why the following rector config doesn't work anymore even though it previously did just fine: nothing in this PR changed anything about this config. I even tried adjusting the order of the rule configuration, but nothing helps. @samsonasik may I humbly request your help here please 😅 |
|
Could you show at https://getrector.com/demo for Tried here and seems working ok https://getrector.com/demo/bffbb6d3-022f-4810-959f-d134f06d4f0b |
|
Its not that the default RenameStringRector does not work, but it doesnt work anymore in combination with my custom rule. thats what i dont understand. if i remove my custom rule above my test related to that string change works fine |
|
Do you write unit test for it, you can register 2+ rules and test it, something like in rector-src: https://github.com/rectorphp/rector-src/tree/main/tests/Issues/RenameString |
|
We don't have unit tests for custom rector rules, but usually test the My custom rector rule above works fine, you can see that in the CI run as it just complains about the StringRector problem. As you can see with the latest commit CI, it now only complains about my new test files as the new rector rule has been disabled. |
|
I think you can add unit test so it easier to debug per expection output |
| if (! $node instanceof ClassMethod) { | ||
| return null; | ||
| } |
There was a problem hiding this comment.
The operating spacing here doesn't seem to be consistent with the cakephp cs rules. Perhaps we aren't running those phpcs rules on this repo?
There was a problem hiding this comment.
according to the phpcs.xml file everything inside the src folder should be checked. don't know why it doesn't fix this kind of cs violation.
|
@markstory there is a weird redeclare issue which I don't know how to fix (as can be seen in previous CI runs) And thanks to @samsonasik, actually adding unit tests for the new custom rule made me realize, that it didn't behave correctly in all cases, so i had to adjust the conditions when the rule applies and now everything seems to work as we want it 👍🏻 |
This reverts commit d68f12b.
6557ef8 to
3f1ce70
Compare
* add custom rector to cleanup command usages * test with disabled custom rector * add unit tests * adjust CI * adjust composer.json * Revert "adjust composer.json" This reverts commit d68f12b.
Refs: cakephp/cakephp#18983
With a lot of help from ChatGPT this miracle has been achieved.
Let me know which other kind of command structures we should add to the tests to see if everything is handled as we expect it to.