-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Sniff-specific ignore rules inside rulesets are filtering out too many files #2391
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
Comments
@wvega Thanks for setting up that unit test, I'm looking into this now. |
@jrfnl thank you for checking this issue so quickly. I just merged your PR. The solution looks great and fixes the problem I was having on my project. |
@wvega It's something I'd come across a few times myself, but I hadn't investigated to determine the cause yet. Your clear explanation of the issue made it an easy one to (finally) solve now ;-) |
While detecting (via debugging PHP_CodeSniffer) what Thanks for finding that out. |
…tering out too many files Moved is_array check earlier in shouldIgnorePath() as: $this->config->ignored was an array of pattern => string, where as $this->ruleset->getIgnorePatterns() was an array of ref => [pattern => string] Which meant the original array_merge was not merging the arrays correctly, which caused all files to be excluded as when the rule ref name appeared in the projects path.
fixed in PR #2392 |
Consider the following custom standard (
phpcs.xml
):If the path to the project using that standard file includes
wordpress
(the name of the referenced rule) at any level, PHPCS will ignore all files on that project. The list of files to check is empty, even if other rules are being referenced in the standard without using an exclude pattern.The way I understand it, on v3.4.0 and up to 8c94cf9 (at least), when exclude-patterns are defined for specific standards, categories or sniffs, the
Ruleset::getIgnorePatterns()
method returns an array with a structure similar to:That array is later used on the shouldIgnorePath() method, as follows:
So that the name of the standard, category or sniff ends up being used as the pattern to ignore.
When the exclude-pattern is specific to a category of sniffs or a single sniff, then is very unlikely that the name of that category or sniff matches the path of any file on the project, but when the exclude-pattern is specific to a standard with a single word name (like
WordPress
above) the problem is more likely to appear.I'll submit a PR with a test for this issue in a moment.
Related to #686.
The text was updated successfully, but these errors were encountered: