Closed iMojtaba closed 9 months ago
Any comment?
Can you verify what the actual phpcs
command that gets executed by GrumPHP is and verify if this matches your expectations?
You could do this by adding the -vvv
flag to grumphp. (allthough you might want to disable parallel mode for that purpose)
Closing based on inactivity. Feel free to reopen if you are still blocked by this.
Sorry to reopen this, but I think there is a problem with inclusion and exclusion of files. The phpcs.xml is not read for that, because Phpcs.php uses
$files = $context->getFiles()->extensions($config['triggered_by'])->paths($config['whitelist_patterns'] ?? [])->notPaths($config['ignore_patterns'] ?? []);
to get the files. This is ignoring the include and exclude patterns in phpcs.xml
The command that is run is '/var/www/html/vendor/bin/phpcs' '--standard=phpcs.xml' '--extensions=php' '--report=full' '--report-json' '--file-list=/tmp/phpxJt5Dv'
So the problem here is that phpcs does not respect it's own configuration file when files are being passed in? I'm not sure that's something we can do much about here. I tend to avoid parsing various configuration files / formats in here tbh.
After some more debugging, I figured out that the reason is that the --file-list overrides the include/exclude of phpcs, and that is what you expect I guess. So because we only want to check staged files, we have to add the --file-list parameter, otherwise we check all the files all the time. I agree that this is not a grumphp issue. Can be closed again ;)
2.0.0
I am encountering an issue with GrumPhp not detecting the PHP CodeSniffer (phpcs) ruleset file in my project. The ruleset file, named
phpcs.xml
, is located in the root directory of my project and is successfully recognized and applied when runningvendor/bin/phpcs Author.php
. However, when I use the commandphp ./vendor/bin/grumphp git:pre-commit
, GrumPhp fails to detect and apply these rules. and it applies some other rules which I do not know what those are.I have verified that GrumPhp is properly installed and configured in my project, and I have the necessary dependencies installed. However, it seems that GrumPhp has its own ruleset file configuration or a different default ruleset file name.
I have already checked the GrumPhp documentation and configuration files but could not find a solution specific to this problem. The only thing that I found is
standard
ingrumphp.yml
file and it only accepts phpcs registered styles. I tried to set it asstandard: "/full/pathto/phpcs.xml"
orstandard: "phpcs.xml"
and none of them worked.Thank you in advance for your assistance and support!
My configuration