Skip to content

Conversation

@Rom1-B
Copy link
Contributor

@Rom1-B Rom1-B commented Oct 29, 2025

add rector

@Rom1-B
Copy link
Contributor Author

Rom1-B commented Oct 29, 2025

I don't understand why the CI fails?

image

rector.php Outdated
Comment on lines 56 to 97
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,
Copy link
Contributor

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).

Copy link
Contributor

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',
Copy link
Contributor

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 @@
{
Copy link
Contributor

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).

Copy link
Contributor Author

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>
@cedric-anne
Copy link
Contributor

I don't understand why the CI fails?

image

You have to add the rector.php file here :

-i setup.php hook.php $LNAME.xml tools/HEADER README.md Makefile .github/workflows/continuous-integration.yml tests/bootstrap.php composer.json

@Rom1-B Rom1-B merged commit c294f7a into main Nov 3, 2025
3 checks passed
@Rom1-B Rom1-B deleted the rector branch November 3, 2025 09:25
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.

4 participants