Conversation
| 'mbstrrpos' => 'mb_strrpos', | ||
| 'mbsubstr' => 'mb_substr', | ||
| ]); | ||
| foreach (CodeQualityLevel::RULES_WITH_CONFIGURATION as $rectorClass => $configuration) { |
There was a problem hiding this comment.
Currently there is only one rule with configuration but I made this future proof by allowing to have an array of them in the CodeQualityLevel class
| ]); | ||
| // the rule order matters, as its used in withCodeQualityLevel() method | ||
| // place the safest rules first, follow by more complex ones | ||
| $rectorConfig->rules(CodeQualityLevel::RULES); |
There was a problem hiding this comment.
We use the list of rules defined in CodeQualityLevel instead of defining the list here
|
|
||
| $this->rules = array_merge($this->rules, $levelRules); | ||
|
|
||
| foreach (CodeQualityLevel::RULES_WITH_CONFIGURATION as $rectorClass => $configuration) { |
There was a problem hiding this comment.
To simplify level management I decided to always run the configured rules (currently there is only one) independently of the level chosen. If you would prefer to do something different, let me know
|
Looks very good, thank you @carlos-granados 👍 |
| return TypeDeclarationLevel::RULES; | ||
| } | ||
|
|
||
| if (realpath($setFile) === realpath(SetList::CODE_QUALITY)) { |
There was a problem hiding this comment.
please craete variable for repetitive realpath($setFile) early
| StaticToSelfStaticMethodCallOnFinalClassRector::class, | ||
| ]; | ||
|
|
||
| public const RULES_WITH_CONFIGURATION = [ |
There was a problem hiding this comment.
add @var doc:
| public const RULES_WITH_CONFIGURATION = [ | |
| /** | |
| * @var array<class-string<RectorInterface>, mixed[]> | |
| */ | |
| public const RULES_WITH_CONFIGURATION = [ |
|
I accidentally closed the PR, re-opened |
|
@samsonasik I added the changes you suggested |
|
Rebase seems needed to make CI green |
…he code quality rules one rule at a time
46acf39 to
f2dc51f
Compare
|
Rebased. When I did the rebase there were a couple of ECS failures due to the order of some imports. Even though this was unrelated to my PR, I have included the fixes here. If that is not OK, let me know and I will remove them |
|
Thank you @carlos-granados |
Add new
withCodeQualityLevel()config function that allows you to add the quality level rules one at a time, similar to what you can do with the dead code rules and the type coverage rules. This avoids the problem of having too many problems to solve if you usecodeQuality: trueinwithPreparedSets()