Let phpcsfixer2 select the correct files and improve performance#386
Let phpcsfixer2 select the correct files and improve performance#386veewee wants to merge 2 commits intophpro:masterfrom
Conversation
veewee
commented
Jul 28, 2017
| Q | A |
|---|---|
| Branch | master for features and deprecations |
| Bug fix? | yes/no |
| New feature? | no |
| BC breaks? | yes |
| Deprecations? | no |
| Documented? | yes |
| Fixed tickets | #371, #327 |
|
Hi @Landerstraeten , @keradus, This is an attempt to fix the issues in #371 and #327. Thanks! |
| $result->isPassed()->shouldBe(true); | ||
| } | ||
|
|
||
| function it_runs_the_suite_for_changed_files( |
There was a problem hiding this comment.
why dropping the test instead of replacing it with test of new feature ?
doc/tasks/phpcsfixer2.md
Outdated
|
|
||
| Intersection mode can only be used when you have a configuration file which contains a Finder. | ||
| This mode works best since only files that are being commit and are in your configuration will be checked. | ||
| When there is no Finder in your configuration, all committed files will be checked. |
There was a problem hiding this comment.
when there is no finder in configuration, setting path-mode=intersection will crash the execution
| $arguments->addOptionalArgument('--path-mode=intersect', $config['can_intersect']); | ||
| $arguments->addOptionalArgument('--verbose', $config['verbose']); | ||
| $arguments->addOptionalArgument('--diff', $config['diff']); | ||
| $arguments->add('fix'); |
There was a problem hiding this comment.
did you try this out? please add tests to cover this change, as it is not working.
-intersect
+intersectionThere was a problem hiding this comment.
We currently don't have a system to do e2e tests with 3rd party tools. I looked over that one during commit and will test these changes thoroughly before merging.
|
Thanks for your feedback @keradus! I've changed the logic a bit:
I assume this will cover all cases at the moment, but will test this thoroughly. |
| This mode works best since only files that are being commit and are in your configuration will be checked. | ||
| When there is no Finder in your configuration, all committed files will be checked. | ||
| When there is no Finder in your configuration, you'll have set this parameter to false. | ||
| Otherwise php-cs-fixer will crash the execution. |
There was a problem hiding this comment.
btw, could there be consistency with naming? sometimes you use PHP-CS-Fixer, sometimes you use php-cs-fixer after binary file, while official name is PHP Coding Standards Fixer or PHP CS Fixer when one used shorter version.
There was a problem hiding this comment.
Sure, I'll try to keep that in mind.
Then, what is the purpose of passing files in grumphp integration together with can_intersect=true ? you are trying to use some extra logic on top of integration changing decision of user. |
I disagree: In run context, all files are being checked. That means that the task contains ALL files known to git. It is a bit overkill to paste them all the the CLI when there is a finder config in PHP CS Fixer. Besides that: Windows can't handle too many input characters. The PreCommit context only contains the changed files. In this context, the intersection path-mode is the best option. If this is not possible (can_intersect=false), the override path-mode will be used. Does this makes sense to you or would you still drop that logic? |
so, why this scenario is allowed by code ? |
|
I don't really understand your question. Can you give me some additional context? |
if ($context instanceof GitPreCommitContext || !$config['can_intersect']) {
$arguments->addFiles($files);
}let discuss not-precommit context, thus we have: if (!$config['can_intersect']) {
$arguments->addFiles($files);
}vs
No, looking at code, in run-context, the paths are sometimes passed, sometimes not |
|
could |
|
@keradus, I see what you are trying to say. Probably I explained incorrect:
So lets asume if ($context instanceof GitPreCommitContext || !$config['config_contains_finder']) {
$arguments->addFiles($files);
}Let's focus on RunContext: if (!$config['config_contains_finder']) {
$arguments->addFiles($files);
}As you can see: the files are being added when there is no finder configuration. If we don't do this, PHP CS Fixer will crash since it isn't validating any files. Off course: for PreComit context, we'll always pass the files since we only want to check a limited subset. |
|
cleaner to me, yet I do still not clear enough.
great, I do agree that if there is no finder, we shall pass the files. then, you have execution scenario:
what is gonna happen with current implementation? |
|
|
||
|
|
||
| **path_mode** | ||
| **can_intersect** |
There was a problem hiding this comment.
I think you forgot to change the example on line 25
| arguments: | ||
| - '@config' | ||
| - '@process_builder' | ||
| - '@async_process_runner' |
There was a problem hiding this comment.
You deleted the argument from another task. Delete line 244 instead.
| Intersection mode can only be used when you have a configuration file which contains a Finder. | ||
| This mode works best since only files that are being commit and are in your configuration will be checked. | ||
| When there is no Finder in your configuration, you'll have set this parameter to false. | ||
| Otherwise php-cs-fixer will crash the execution. |
Landerstraeten
left a comment
There was a problem hiding this comment.
By default, I wasn't able to run it correctly. I had some issues during a sanity check. I have left some remaks to fix it.
|
Fixed in #395 |