driftingly / rector-laravel

Rector upgrades rules for Laravel
http://getrector.org
MIT License
469 stars 48 forks source link

[QUESTION] withTypeCoverageLevel and withDeadCodeLevel #200

Closed ezekel closed 4 months ago

ezekel commented 4 months ago

Hi

I'm started using rector-laravel. can I ask about the withTypeCoverageLevel and withDeadCodeLevel ? on what level should I stop ?

I'm on Laravel 11 just updated from Laravel 10

here is my config


return RectorConfig::configure()

    ->withPaths([
        __DIR__ . '/app',
        __DIR__ . '/config',
        __DIR__ . '/database',
        __DIR__ . '/public',
        __DIR__ . '/resources',
        __DIR__ . '/routes',
        __DIR__ . '/tests',
    ])
    ->withPhpSets()
    ->withTypeCoverageLevel(27)
    ->withDeadCodeLevel(35)
    ->withSets([
        LaravelSetList::LARAVEL_110,
        LaravelSetList::LARAVEL_CODE_QUALITY,
    ]);

    my composer version

    "require": {
        "php": "^8.2",

    And I installed php version 8.3 

    Thank you in advance
GeniJaho commented 4 months ago

Hi @ezekel 👋 You can dig deeper into those methods and check the available rules and levels. Currently, I think there are about 38 levels for type coverage and 41 levels for dead code. You can increase it as much as you want, until it throws an exception. In that case, you've reached the maximum level for the time being, since rules might change or get added to the list. Keep in mind you don't need to go to the max level, just where you are comfortable with your project. In any case, you can skip the rules you don't want.

You can find the rules in your vendor vendor/rector/rector/src/Config/Level/DeadCodeLevel.php and vendor/rector/rector/src/Config/Level/TypeDeclarationLevel.php. However, since you're making this question, maybe they need to be better documented.

ezekel commented 4 months ago

Thank you so much for enlighten my mind @GeniJaho