-
Notifications
You must be signed in to change notification settings - Fork 431
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
PhpCsFixer ignores stdout with finder defined #1027
Comments
@MeCapron potential other idea: if command arguments are accessible in the PHP-CS-Fixer config file, with |
Adding an env var to toggle config_contains_finder to false on CI could also do the trick. |
Sorry, I did not set the entire snippet but I use exclusion on the finder so I need to have the finder defined to true. Do you have another idea maybe?
Thats sounds great, I will check this if I don't have any other solution. However, I think that it can be convenient to have only the needed files to be checked even with a config finder set in : we could want to perform php-cs-fixer on a stdout but still exclude some folders. Isn't a misinterpretation of myself on how php-cs-fixer designed the usage of this finder? |
In that case, we might need a smarter way to set php-cs-fixer's intersection mode, which deals with the intersection of passing files and a finder grumphp/src/Task/PhpCsFixer.php Line 91 in 3ec61c1
|
Do you have any idea or thoughts on it? I can help you, but if you already have ideas... |
Hello, we encounter the kind of issues, any chance we can help ? |
After digging a bit, it seems that they are no chance to have the args because of the task launched in a subprocess. It seems that the best way would probably to add a tag to know whether or not the command was ran with a STDIN to add the flag and check if the files should be added or not. You are the expert here so this is just my coin. Maybe a Metadata to know if files are provided from STDIN? It could be done somewhere here : grumphp/src/Console/Command/RunCommand.php Lines 110 to 117 in e9f7c4d
And then in the PhpCsFixer : if ($context instanceof GitPreCommitContext || !$config['config_contains_finder'] || $files->getMetadata()->isFromStdin()) {
$arguments->addFiles($files);
} From now on until we have a proper solution I will just always pass the files to the arguments |
The problem with that solution is that files that are ignored in the finder might be checked as well. I don't think adding an Maybe better to fix it with configuration on the task?
If you don't configure them - the task will run as expected. |
Hello,
we are using grumphp in a Gitlab CI and we are facing an issue with the configuration of PhpCsFixer.
As we have a very very large code base which contains a lot of legacy code, even in the CI we are running GrumPHP ONLY in the files that are commited to avoid exploding the memory of the CI.
To do so, we are running Grumphp this way :
Howerver the PhpCsFixer is running over ALL files because of this line when you have a custom finder :
https://github.com/phpro/grumphp/blob/v1.13.0/src/Task/PhpCsFixer.php#L96
This is running fine when we are in a GitPreCommitContext or when we don't run any finder.
Could we add a configuration to list only files from the stdout even if we have a finder on or we are not in the GitPreCommitContext?
Does anyone has maybe another idea to solve this?
My configuration
Steps to reproduce:
Result:
Out of memory because running on all files
The text was updated successfully, but these errors were encountered: