-
-
Notifications
You must be signed in to change notification settings - Fork 687
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
Specifying no rules or sets still makes changes to codebase #3927
Comments
This is not the case as Rector anyway process files and may change them, also if printing them back with the same content. But as Rector doesn't take care of styles, the printed code is often ugly. The best approach would be to apply rector and immediately after the code styles. You say "breaks cs style": are you speaking of continuous integration? In this case, you should run rector in a job separate than the one that runs style checks. It is not a good idea to follow a path like this:
This way, in fact, you miss real style breaks in the code. The best approach is to rune rector separate from code style. Another approach would be to run rector after the style checks. |
It gets worse. This issue is not present when you don't specify rules only, but also when you do specify them. Even |
You should specify with code examples the changes in code: without them it is impossible to fix the issues. |
I don't want to fix specific cases, I want rector to not apply rules I didn't specify. |
Yes, I understand. But to fix those issues we need to know how your code is changed to find what in Rector is doing wrong it’s job. Post examples from your code, so it is possible to find what is broke in Rector. |
You are probably asking for reproducer? I can give you that.
As you can see at https://github.com/rectorphp/rector/blob/master/config/set/symfony50.php, this set defines two rectors only, but Rector is freely roaming over with completely different ones. |
Ok, I understand. Lets wait for @TomasVotruba ... |
@kbsali Unfortunatelly, there is now no way to preserve annotation format correctly, as described in README: https://github.com/rectorphp/rector#how-to-apply-coding-standards The same way php-parser 3 and bellow was very poor at keeping format for PHP code. Untill then, the best solution is to use coding standards: there is new Doctrine annotation standard in ECS: deprecated-packages/symplify#2078 # ecs.php
<?php
declare(strict_types=1);
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\EasyCodingStandard\Configuration\Option;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;
return static function (ContainerConfigurator $containerConfigurator): void {
$parameters = $containerConfigurator->parameters();
$parameters->set(Option::SETS, [
SetList::DOCTRINE_ANNOTATIONS,
]);
}; |
ok, very clear. Thanks @TomasVotruba |
rectorphp/rector-src@3c69a0f Remove AddPregQuoteDelimiterRector as very narrow area and has not context awareness, better handle manually (#3927)
Bug Report
I finally managed to get rector to work on our project using docker,
but when processing a subset of our codebase (Doctrine entities) without defining any rule or set, rector still applies changes to annotations, and sometimes break cs style.
Minimal PHP Code Causing Issue
docker run --rm -v $(pwd):/project rector/rector:latest process /project/src/EGB/Bundle/AppBundle/Entity/ --autoload-file=/project/vendor/autoload.php
ends up with changes on all the annotations,
and when dealing with compound indexes it ends up breaking the styling/indentation etc...
Expected Behaviour
I would have expected rector to do nothing when no rule or set are defined.
The text was updated successfully, but these errors were encountered: