-
Notifications
You must be signed in to change notification settings - Fork 21
Feat(CI): add rector #52
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
Conversation
rector.php
Outdated
| CodeQuality\Assign\CombinedAssignRector::class, | ||
| CodeQuality\BooleanAnd\RemoveUselessIsObjectCheckRector::class, | ||
| CodeQuality\BooleanAnd\SimplifyEmptyArrayCheckRector::class, | ||
| CodeQuality\BooleanNot\ReplaceMultipleBooleanNotRector::class, | ||
| CodeQuality\Catch_\ThrowWithPreviousExceptionRector::class, | ||
| CodeQuality\Empty_\SimplifyEmptyCheckOnEmptyArrayRector::class, | ||
| CodeQuality\Expression\InlineIfToExplicitIfRector::class, | ||
| CodeQuality\Expression\TernaryFalseExpressionToIfRector::class, | ||
| CodeQuality\For_\ForRepeatedCountToOwnVariableRector::class, | ||
| CodeQuality\Foreach_\ForeachItemsAssignToEmptyArrayToAssignRector::class, | ||
| CodeQuality\Foreach_\ForeachToInArrayRector::class, | ||
| CodeQuality\Foreach_\SimplifyForeachToCoalescingRector::class, | ||
| CodeQuality\Foreach_\UnusedForeachValueToArrayKeysRector::class, | ||
| CodeQuality\FuncCall\ChangeArrayPushToArrayAssignRector::class, | ||
| CodeQuality\FuncCall\CompactToVariablesRector::class, | ||
| CodeQuality\FuncCall\InlineIsAInstanceOfRector::class, | ||
| CodeQuality\FuncCall\IsAWithStringWithThirdArgumentRector::class, | ||
| CodeQuality\FuncCall\RemoveSoleValueSprintfRector::class, | ||
| CodeQuality\FuncCall\SetTypeToCastRector::class, | ||
| CodeQuality\FuncCall\SimplifyFuncGetArgsCountRector::class, | ||
| CodeQuality\FuncCall\SimplifyInArrayValuesRector::class, | ||
| CodeQuality\FuncCall\SimplifyStrposLowerRector::class, | ||
| CodeQuality\FuncCall\UnwrapSprintfOneArgumentRector::class, | ||
| CodeQuality\Identical\BooleanNotIdenticalToNotIdenticalRector::class, | ||
| CodeQuality\Identical\SimplifyArraySearchRector::class, | ||
| CodeQuality\Identical\SimplifyConditionsRector::class, | ||
| CodeQuality\Identical\StrlenZeroToIdenticalEmptyStringRector::class, | ||
| CodeQuality\If_\CombineIfRector::class, | ||
| CodeQuality\If_\CompleteMissingIfElseBracketRector::class, | ||
| CodeQuality\If_\ConsecutiveNullCompareReturnsToNullCoalesceQueueRector::class, | ||
| CodeQuality\If_\ExplicitBoolCompareRector::class, | ||
| CodeQuality\If_\ShortenElseIfRector::class, | ||
| CodeQuality\If_\SimplifyIfElseToTernaryRector::class, | ||
| CodeQuality\If_\SimplifyIfNotNullReturnRector::class, | ||
| CodeQuality\If_\SimplifyIfNullableReturnRector::class, | ||
| CodeQuality\If_\SimplifyIfReturnBoolRector::class, | ||
| CodeQuality\Include_\AbsolutizeRequireAndIncludePathRector::class, | ||
| CodeQuality\LogicalAnd\AndAssignsToSeparateLinesRector::class, | ||
| CodeQuality\LogicalAnd\LogicalToBooleanRector::class, | ||
| CodeQuality\NotEqual\CommonNotEqualRector::class, | ||
| CodeQuality\Ternary\UnnecessaryTernaryExpressionRector::class, | ||
| DeadCode\Assign\RemoveUnusedVariableAssignRector::class, |
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.
One thing I worry about with rector is the huge amount of rules to maintain.
Do we really want to update all plugins each time we find a new interesting rule to add?
I would prefer to reuse the rules from the core directory to have a single list to maintain (but it means that update from the core will breaks the plugins nightly CI run so it isn't perfect either).
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.
Honestly, there is no need to list all rules in plugins config. It has been done like this in GLPI because each rule may introduce a huge amount of code change.
See https://getrector.com/documentation/levels
For instance, for plugins, you can use something like this:
return RectorConfig::configure()
->withDeadCodeLevel(100)
->withCodeQualityLevel(100)
->withCodingStyleLevel(100);Type related rules cannot be used for the moment, we have to be 100% compliant with PHPStan level 6 rules in GLPI itself to be sure that they can be used safely.
rector.php
Outdated
| ->withPhpVersion(PhpVersion::PHP_82) | ||
| ->withCache( | ||
| cacheClass: FileCacheStorage::class, | ||
| cacheDirectory: sys_get_temp_dir() . '/empty-rector', |
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.
All others tools use the var folder for this, we should try to keep the same behavior (see phpunit config for example).
composer.lock
Outdated
| @@ -0,0 +1,885 @@ | |||
| { | |||
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.
I think we decided last time to not set the lock file because we have no dependabot on this repository (so the versions will never be updating, leading plugins to be created with outdated dependencies).
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.
It was just to test whether it affected the error with “Misc lint.”
Co-authored-by: Cédric Anne <cedric.anne@gmail.com>
You have to add the Line 90 in 528640e
|


add rector