Skip to content

Conversation

@TomasVotruba
Copy link
Member

@TomasVotruba TomasVotruba commented May 2, 2025

Not ready for review yet, WIP

@TomasVotruba TomasVotruba force-pushed the tv-kaizen branch 2 times, most recently from 342a3b4 to e7a625d Compare May 2, 2025 19:55
@TomasVotruba TomasVotruba changed the title typo [experimental] Add --kaizen option to apply only first X rules at a time May 2, 2025
@TomasVotruba TomasVotruba marked this pull request as ready for review May 2, 2025 20:04
@TomasVotruba TomasVotruba force-pushed the tv-kaizen branch 2 times, most recently from 3f68321 to 0d1d4f7 Compare May 2, 2025 20:47
@VincentLanglet
Copy link
Contributor

Please correct me if I understood badly the implementation but if I understand correctly the usage of the kaizen option will be to run

vendor/bin/rector --kaizen=1

then

vendor/bin/rector --kaizen=2

then

vendor/bin/rector --kaizen=3

and so on.

If the first 10 rules don't make any change, I would have run 10 times for nothing, until

vendor/bin/rector --kaizen=11

do some change that I can review.

That could do the job, but what I had in mind had some extra-automation.

Like just running

vendor/bin/rector --kaizen

and rector does:

  • Running rule 1, no change
  • Running rule 2, no change
  • ...
  • Running rule 10, no change
  • Running rule 11, a file change with the rule FooRule.
  • Stop the process

Then I can commit the changes or ignore the rule and run again the kaizen option and the behavior will be

  • Running rule 1, no change
  • Running rule 2, no change
  • ...
  • Running rule 10, no change
  • Running rule 11, no change (let's say I already commit the changes)
  • Running rule 12, no change (for instance)
  • Running rule 13, a file change with the rule BarRule

This way I'm saving rector runs.

@TomasVotruba
Copy link
Member Author

TomasVotruba commented May 2, 2025

It's a bit different. It should apply at least first X rules, where X is --kaizen X.

So if we run:

vendor/bin/rector --kaizen 2

It will apply first 2 rules that change anything.
So everyting you run this option, there will be some changes to review 👍

If there are no changes, it means all sets and rules are applied and vendor/bin/rector can be run instead.

@VincentLanglet
Copy link
Contributor

Ok, so basically my usage would be to run

vendor/bin/rector --kaizen 1

and commiting changes (or ignoring the rule) between every run until a

vendor/bin/rector --kaizen 1

run cannot change anything and it means vendor/bin/rector can be now be use.

@TomasVotruba
Copy link
Member Author

TomasVotruba commented May 2, 2025

Exactly 👍

If you feel like you want to progress faster, e.g. when codebase is stable,
you can run e.g. --kaizen 3 or --kaizen 5 to apply more rules at a time.

@TomasVotruba
Copy link
Member Author

Let's ship this to test in the wild 👍

@TomasVotruba TomasVotruba merged commit 108c9d0 into main Jun 19, 2025
45 checks passed
@TomasVotruba TomasVotruba deleted the tv-kaizen branch June 19, 2025 09:16
@shakaran
Copy link

shakaran commented Jun 25, 2025

@TomasVotruba @samsonasik @VincentLanglet

I am testing it, and it seems not work

image

# vendor/bin/rector --version
Rector 2.1.0
# vendor/bin/rector --kaizen 5

                               
  Command "5" is not defined.  
                               

@samsonasik
Copy link
Member

@shakaran it seems using = is needed:

-vendor/bin/rector --kaizen 5
+vendor/bin/rector --kaizen=5

@samsonasik
Copy link
Member

use = instead of space, see

Screenshot 2025-06-25 at 23 17 34

@shakaran
Copy link

use = instead of space, see

Screenshot 2025-06-25 at 23 17 34

ok, confirmed, it works with =, thanks

@samsonasik
Copy link
Member

I see, it because of missing "process", add "process" command and it works, so some trimming seems happen during it

Screenshot 2025-06-25 at 23 58 38

for now, you can use = instead of space if you don't use "process" command explicitly.

@samsonasik
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants