mirror of
https://github.com/coollabsio/coolify.git
synced 2026-03-11 08:55:47 +00:00
chore(tooling): improve rector config a lot
- refactored rector laravel usage completely to use sets, which reduces imports, adds a few new options and makes everything much cleaner - started using composer-based sets for laravel which applies rules via rector laravel based on the laravel version - removed many unused or now duplicated manually added formatting rules - removed some rules that are not desired for our coding style - added some new manual rules that made sense - removed naming and phpunitCodeQuality prepared set as it caused issues (naming in DB migrations was changed...) - added typeDeclarationDocblocks prepared set (experimental) - added withAttributesSets() option
This commit is contained in:
parent
c02affe975
commit
5b051cec8d
1 changed files with 30 additions and 108 deletions
138
rector.php
138
rector.php
|
|
@ -4,64 +4,18 @@ declare(strict_types=1);
|
||||||
|
|
||||||
use Rector\Caching\ValueObject\Storage\FileCacheStorage;
|
use Rector\Caching\ValueObject\Storage\FileCacheStorage;
|
||||||
use Rector\Config\RectorConfig;
|
use Rector\Config\RectorConfig;
|
||||||
|
use Rector\Php80\Rector\NotIdentical\MbStrContainsRector;
|
||||||
use Rector\Php83\Rector\ClassMethod\AddOverrideAttributeToOverriddenMethodsRector;
|
use Rector\Php83\Rector\ClassMethod\AddOverrideAttributeToOverriddenMethodsRector;
|
||||||
use RectorLaravel\Rector\ArrayDimFetch\EnvVariableToEnvHelperRector;
|
use Rector\Php85\Rector\Expression\NestedFuncCallsToPipeOperatorRector;
|
||||||
use RectorLaravel\Rector\ArrayDimFetch\RequestVariablesToRequestFacadeRector;
|
use Rector\Php85\Rector\StmtsAwareInterface\SequentialAssignmentsToPipeOperatorRector;
|
||||||
use RectorLaravel\Rector\ArrayDimFetch\ServerVariableToRequestFacadeRector;
|
|
||||||
use RectorLaravel\Rector\ArrayDimFetch\SessionVariableToSessionFacadeRector;
|
|
||||||
use RectorLaravel\Rector\BooleanNot\AvoidNegatedCollectionContainsOrDoesntContainRector;
|
|
||||||
use RectorLaravel\Rector\Cast\DatabaseExpressionCastsToMethodCallRector;
|
|
||||||
use RectorLaravel\Rector\Class_\AddExtendsAnnotationToModelFactoriesRector;
|
|
||||||
use RectorLaravel\Rector\Class_\AddMockConsoleOutputFalseToConsoleTestsRector;
|
|
||||||
use RectorLaravel\Rector\Class_\AnonymousMigrationsRector;
|
|
||||||
use RectorLaravel\Rector\Class_\PropertyDeferToDeferrableProviderToRector;
|
|
||||||
use RectorLaravel\Rector\Class_\RemoveModelPropertyFromFactoriesRector;
|
use RectorLaravel\Rector\Class_\RemoveModelPropertyFromFactoriesRector;
|
||||||
use RectorLaravel\Rector\Class_\ReplaceExpectsMethodsInTestsRector;
|
|
||||||
use RectorLaravel\Rector\Class_\UnifyModelDatesWithCastsRector;
|
|
||||||
use RectorLaravel\Rector\ClassMethod\AddGenericReturnTypeToRelationsRector;
|
|
||||||
use RectorLaravel\Rector\ClassMethod\MigrateToSimplifiedAttributeRector;
|
|
||||||
use RectorLaravel\Rector\Empty_\EmptyToBlankAndFilledFuncRector;
|
use RectorLaravel\Rector\Empty_\EmptyToBlankAndFilledFuncRector;
|
||||||
use RectorLaravel\Rector\Expr\AppEnvironmentComparisonToParameterRector;
|
use RectorLaravel\Rector\FuncCall\ConfigToTypedConfigMethodCallRector;
|
||||||
use RectorLaravel\Rector\Expr\SubStrToStartsWithOrEndsWithStaticMethodCallRector\SubStrToStartsWithOrEndsWithStaticMethodCallRector;
|
|
||||||
use RectorLaravel\Rector\FuncCall\DispatchNonShouldQueueToDispatchSyncRector;
|
|
||||||
use RectorLaravel\Rector\FuncCall\FactoryFuncCallToStaticCallRector;
|
|
||||||
use RectorLaravel\Rector\FuncCall\HelperFuncCallToFacadeClassRector;
|
|
||||||
use RectorLaravel\Rector\FuncCall\NotFilledBlankFuncCallToBlankFilledFuncCallRector;
|
|
||||||
use RectorLaravel\Rector\FuncCall\NowFuncWithStartOfDayMethodCallToTodayFuncRector;
|
|
||||||
use RectorLaravel\Rector\FuncCall\RemoveDumpDataDeadCodeRector;
|
use RectorLaravel\Rector\FuncCall\RemoveDumpDataDeadCodeRector;
|
||||||
use RectorLaravel\Rector\FuncCall\RemoveRedundantValueCallsRector;
|
|
||||||
use RectorLaravel\Rector\FuncCall\RemoveRedundantWithCallsRector;
|
|
||||||
use RectorLaravel\Rector\FuncCall\SleepFuncToSleepStaticCallRector;
|
|
||||||
use RectorLaravel\Rector\FuncCall\TypeHintTappableCallRector;
|
|
||||||
use RectorLaravel\Rector\If_\AbortIfRector;
|
|
||||||
use RectorLaravel\Rector\If_\ReportIfRector;
|
|
||||||
use RectorLaravel\Rector\If_\ThrowIfRector;
|
|
||||||
use RectorLaravel\Rector\MethodCall\AssertSeeToAssertSeeHtmlRector;
|
|
||||||
use RectorLaravel\Rector\MethodCall\AssertStatusToAssertMethodRector;
|
|
||||||
use RectorLaravel\Rector\MethodCall\AvoidNegatedCollectionFilterOrRejectRector;
|
|
||||||
use RectorLaravel\Rector\MethodCall\DatabaseExpressionToStringToMethodCallRector;
|
|
||||||
use RectorLaravel\Rector\MethodCall\FactoryApplyingStatesRector;
|
|
||||||
use RectorLaravel\Rector\MethodCall\JsonCallToExplicitJsonCallRector;
|
|
||||||
use RectorLaravel\Rector\MethodCall\LumenRoutesStringActionToUsesArrayRector;
|
|
||||||
use RectorLaravel\Rector\MethodCall\LumenRoutesStringMiddlewareToArrayRector;
|
|
||||||
use RectorLaravel\Rector\MethodCall\RedirectBackToBackHelperRector;
|
|
||||||
use RectorLaravel\Rector\MethodCall\RedirectRouteToToRouteHelperRector;
|
|
||||||
use RectorLaravel\Rector\MethodCall\RefactorBlueprintGeometryColumnsRector;
|
|
||||||
use RectorLaravel\Rector\MethodCall\ReplaceWithoutJobsEventsAndNotificationsWithFacadeFakeRector;
|
|
||||||
use RectorLaravel\Rector\MethodCall\ResponseHelperCallToJsonResponseRector;
|
|
||||||
use RectorLaravel\Rector\MethodCall\ReverseConditionableMethodCallRector;
|
|
||||||
use RectorLaravel\Rector\MethodCall\UnaliasCollectionMethodsRector;
|
|
||||||
use RectorLaravel\Rector\MethodCall\UseComponentPropertyWithinCommandsRector;
|
|
||||||
use RectorLaravel\Rector\MethodCall\ValidationRuleArrayStringValueToArrayRector;
|
|
||||||
use RectorLaravel\Rector\MethodCall\WhereToWhereLikeRector;
|
use RectorLaravel\Rector\MethodCall\WhereToWhereLikeRector;
|
||||||
use RectorLaravel\Rector\Namespace_\FactoryDefinitionRector;
|
|
||||||
use RectorLaravel\Rector\PropertyFetch\OptionalToNullsafeOperatorRector;
|
|
||||||
use RectorLaravel\Rector\PropertyFetch\ReplaceFakerInstanceWithHelperRector;
|
|
||||||
use RectorLaravel\Rector\StaticCall\CarbonSetTestNowToTravelToRector;
|
|
||||||
use RectorLaravel\Rector\StaticCall\DispatchToHelperFunctionsRector;
|
|
||||||
use RectorLaravel\Rector\StaticCall\Redirect301ToPermanentRedirectRector;
|
|
||||||
use RectorLaravel\Rector\StaticCall\ReplaceAssertTimesSendWithAssertSentTimesRector;
|
|
||||||
use RectorLaravel\Rector\StaticCall\RequestStaticValidateToInjectRector;
|
use RectorLaravel\Rector\StaticCall\RequestStaticValidateToInjectRector;
|
||||||
|
use RectorLaravel\Set\LaravelSetList;
|
||||||
|
use RectorLaravel\Set\LaravelSetProvider;
|
||||||
|
|
||||||
return RectorConfig::configure()
|
return RectorConfig::configure()
|
||||||
->withPaths([
|
->withPaths([
|
||||||
|
|
@ -80,77 +34,45 @@ return RectorConfig::configure()
|
||||||
])
|
])
|
||||||
->withCache(__DIR__.'/storage/rector', FileCacheStorage::class)
|
->withCache(__DIR__.'/storage/rector', FileCacheStorage::class)
|
||||||
->withPhpSets()
|
->withPhpSets()
|
||||||
|
->withAttributesSets()
|
||||||
->withPreparedSets(
|
->withPreparedSets(
|
||||||
deadCode: true,
|
deadCode: true,
|
||||||
codeQuality: true,
|
codeQuality: true,
|
||||||
codingStyle: true,
|
codingStyle: true,
|
||||||
typeDeclarations: true,
|
typeDeclarations: true,
|
||||||
|
typeDeclarationDocblocks: true,
|
||||||
privatization: true,
|
privatization: true,
|
||||||
naming: true,
|
|
||||||
instanceOf: true,
|
instanceOf: true,
|
||||||
earlyReturn: true,
|
earlyReturn: true,
|
||||||
carbon: true,
|
carbon: true,
|
||||||
rectorPreset: true,
|
rectorPreset: true,
|
||||||
phpunitCodeQuality: true,
|
|
||||||
)
|
)
|
||||||
->withAttributesSets()
|
->withSetProviders(LaravelSetProvider::class)
|
||||||
|
->withComposerBased(laravel: true)
|
||||||
|
->withSets([
|
||||||
|
LaravelSetList::LARAVEL_ARRAYACCESS_TO_METHOD_CALL,
|
||||||
|
LaravelSetList::LARAVEL_ARRAY_STR_FUNCTION_TO_STATIC_CALL,
|
||||||
|
LaravelSetList::LARAVEL_CODE_QUALITY,
|
||||||
|
LaravelSetList::LARAVEL_COLLECTION,
|
||||||
|
LaravelSetList::LARAVEL_CONTAINER_STRING_TO_FULLY_QUALIFIED_NAME,
|
||||||
|
LaravelSetList::LARAVEL_FACADE_ALIASES_TO_FULL_NAMES,
|
||||||
|
LaravelSetList::LARAVEL_FACTORIES,
|
||||||
|
LaravelSetList::LARAVEL_IF_HELPERS,
|
||||||
|
LaravelSetList::LARAVEL_LEGACY_FACTORIES_TO_CLASSES,
|
||||||
|
LaravelSetList::LARAVEL_TESTING,
|
||||||
|
LaravelSetList::LARAVEL_TYPE_DECLARATIONS,
|
||||||
|
])
|
||||||
->withRules([
|
->withRules([
|
||||||
AbortIfRector::class,
|
// Core Rector Rules
|
||||||
AddExtendsAnnotationToModelFactoriesRector::class,
|
SequentialAssignmentsToPipeOperatorRector::class,
|
||||||
AddGenericReturnTypeToRelationsRector::class,
|
NestedFuncCallsToPipeOperatorRector::class,
|
||||||
AddMockConsoleOutputFalseToConsoleTestsRector::class,
|
MbStrContainsRector::class,
|
||||||
AnonymousMigrationsRector::class,
|
|
||||||
AppEnvironmentComparisonToParameterRector::class,
|
// Laravel Rector Rules
|
||||||
AssertSeeToAssertSeeHtmlRector::class,
|
|
||||||
AssertStatusToAssertMethodRector::class,
|
|
||||||
AvoidNegatedCollectionContainsOrDoesntContainRector::class,
|
|
||||||
AvoidNegatedCollectionFilterOrRejectRector::class,
|
|
||||||
CarbonSetTestNowToTravelToRector::class,
|
|
||||||
DatabaseExpressionCastsToMethodCallRector::class,
|
|
||||||
DatabaseExpressionToStringToMethodCallRector::class,
|
|
||||||
DispatchNonShouldQueueToDispatchSyncRector::class,
|
|
||||||
DispatchToHelperFunctionsRector::class,
|
|
||||||
EmptyToBlankAndFilledFuncRector::class,
|
EmptyToBlankAndFilledFuncRector::class,
|
||||||
EnvVariableToEnvHelperRector::class,
|
ConfigToTypedConfigMethodCallRector::class,
|
||||||
FactoryApplyingStatesRector::class,
|
|
||||||
FactoryDefinitionRector::class,
|
|
||||||
FactoryFuncCallToStaticCallRector::class,
|
|
||||||
HelperFuncCallToFacadeClassRector::class,
|
|
||||||
JsonCallToExplicitJsonCallRector::class,
|
|
||||||
LumenRoutesStringActionToUsesArrayRector::class,
|
|
||||||
LumenRoutesStringMiddlewareToArrayRector::class,
|
|
||||||
MigrateToSimplifiedAttributeRector::class,
|
|
||||||
NotFilledBlankFuncCallToBlankFilledFuncCallRector::class,
|
|
||||||
NowFuncWithStartOfDayMethodCallToTodayFuncRector::class,
|
|
||||||
OptionalToNullsafeOperatorRector::class,
|
|
||||||
PropertyDeferToDeferrableProviderToRector::class,
|
|
||||||
Redirect301ToPermanentRedirectRector::class,
|
|
||||||
RedirectBackToBackHelperRector::class,
|
|
||||||
RedirectRouteToToRouteHelperRector::class,
|
|
||||||
RefactorBlueprintGeometryColumnsRector::class,
|
|
||||||
RemoveDumpDataDeadCodeRector::class,
|
|
||||||
RemoveModelPropertyFromFactoriesRector::class,
|
RemoveModelPropertyFromFactoriesRector::class,
|
||||||
RemoveRedundantValueCallsRector::class,
|
|
||||||
RemoveRedundantWithCallsRector::class,
|
|
||||||
ReplaceAssertTimesSendWithAssertSentTimesRector::class,
|
|
||||||
ReplaceExpectsMethodsInTestsRector::class,
|
|
||||||
ReplaceFakerInstanceWithHelperRector::class,
|
|
||||||
ReplaceWithoutJobsEventsAndNotificationsWithFacadeFakeRector::class,
|
|
||||||
ReportIfRector::class,
|
|
||||||
RequestStaticValidateToInjectRector::class,
|
RequestStaticValidateToInjectRector::class,
|
||||||
RequestVariablesToRequestFacadeRector::class,
|
|
||||||
ResponseHelperCallToJsonResponseRector::class,
|
|
||||||
ReverseConditionableMethodCallRector::class,
|
|
||||||
ServerVariableToRequestFacadeRector::class,
|
|
||||||
SessionVariableToSessionFacadeRector::class,
|
|
||||||
SleepFuncToSleepStaticCallRector::class,
|
|
||||||
SubStrToStartsWithOrEndsWithStaticMethodCallRector::class,
|
|
||||||
ThrowIfRector::class,
|
|
||||||
TypeHintTappableCallRector::class,
|
|
||||||
UnaliasCollectionMethodsRector::class,
|
|
||||||
UnifyModelDatesWithCastsRector::class,
|
|
||||||
UseComponentPropertyWithinCommandsRector::class,
|
|
||||||
ValidationRuleArrayStringValueToArrayRector::class,
|
|
||||||
])
|
])
|
||||||
->withConfiguredRule(RemoveDumpDataDeadCodeRector::class, [
|
->withConfiguredRule(RemoveDumpDataDeadCodeRector::class, [
|
||||||
'dd',
|
'dd',
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue