-
-
Notifications
You must be signed in to change notification settings - Fork 346
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
Code quality levels #5910
Code quality levels #5910
Conversation
'mbstrrpos' => 'mb_strrpos', | ||
'mbsubstr' => 'mb_substr', | ||
]); | ||
foreach (CodeQualityLevel::RULES_WITH_CONFIGURATION as $rectorClass => $configuration) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 👍 |
@@ -33,6 +34,10 @@ public static function resolve(string $setFile): array | |||
return TypeDeclarationLevel::RULES; | |||
} | |||
|
|||
if (realpath($setFile) === realpath(SetList::CODE_QUALITY)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please craete variable for repetitive realpath($setFile)
early
StaticToSelfStaticMethodCallOnFinalClassRector::class, | ||
]; | ||
|
||
public const RULES_WITH_CONFIGURATION = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's give it a try
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: true
inwithPreparedSets()