Rector: Impossible to load rules from sets

Created on 22 Jul 2020  路  5Comments  路  Source: rectorphp/rector

Bug Report

| Subject | Details |
| :------------- | :---------------------------------------------------------------|
| Rector version | e.g. v0.7.52 |
| Installed as | composer dependency |

It is impossible to run rector using only sets.
It always requires loading some rectors through services key.

parameters:
    paths:
        - 'src'
        - 'tests'
    sets:
        # architecture
        - code-quality
Rector v0.7.52
Config file: rector.yaml

PHP Fatal error:  Uncaught Rector\Core\Exception\NoRectorsLoadedException: We need some rectors to run:
* register them in rector.yaml under "services:"
* use "--set <set>"
* or use "--config <file>.yaml"

Also the online demo of Rector seems to be broke: go to https://getrector.org/demo/ and try to press "Process" without editing anything: it will return an error message:

rector.yaml parameters: sets: - 'dead-code'

bug

All 5 comments

What happens when you switch config to PHP?

Also the online demo of Rector seems to be broke:

Indeed, thanks for reporting.

I didn't tried to switch to PHP: I'm not ready yet.

I don't mean switch (yet, soon might be :D), just for debugging purposes, if there is a difference in behavior.

Try removing rector.yaml and use this:

// rector.php
use Rector\Core\Configuration\Option;
use Rector\Set\ValueObject\SetList;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
    $parameters = $containerConfigurator->parameters();

    $parameters->set(Option::PATHS, ['src', 'tests']);

    $parameters->set(Option::SETS, [SetList::CODE_QUALITY]);
};

Found a way to fix it.

Still the YAML syntax is deprecated now and will be removed in Rector 0.8


Switch is matter of 2 bash lines: https://twitter.com/VotrubaT/status/1283003111074922497

Yes: I just saw your tweet... tomorrow I will try to use migrify 馃挭馃徎

Was this page helpful?
0 / 5 - 0 ratings