Repository navigation
Check paths are accepted if no exclude-pattern matches - #2392
Conversation
…ame of a standard The file list filtering in the `Filter` class should only take global exclude patterns into account and should ignore sniff specific exclude patterns, which are used/handled in the `File::addMessage()` method. This commit fixes this. Includes: * Reworking the initial unit test to use `setUpBeforeClass()` for the fixtures and a data provider to easily allow for more test cases without code duplication. * Adding an additional unit test to verify that top-level exclude patterns are correctly respected. * Renaming the test ruleset file to use the `xml` file extension. * Adding the newly introduced unit test files to the `package.xml` file lists. Fixes 2391
|
Note: the build failure is not directly related to this PR and will be fixed by #2390. |
|
Thanks for the patch and for providing the update to package.xml I moved is_array check earlier in shouldIgnorePath() as: 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. |
|
You're welcome ? |
|
@peternolland thank you for merging this into master. I think the credit should go to @jrfnl as well. I reported the bug and submitted an initial version of a failing test, but she provided the patch, the update to package.xml and greatly improved the tests :) |
|
@jrfnl my bad - didn't notice the commit history. Thanks for the fix. |
This PR includes a test to check that paths that include the name of a standard with associated exclude-patterns are still accepted for the list of files to be checked.
The test reproduces #2391.
I followed the coding standards (
php bin/phpcsreports no problems) but I'm not sure if I added the test to the right place or used the correct approach by usingAcceptTest.incas the XML file with the custom standard that reproduces the problem.I'll be happy to make modifications if the test is considered valid and additional instructions are provided.
As for the solution, I could try to provide one, but I'm not sure what's the right approach in this case. It seems to me that the ignore patterns that are specific to a standard, category or sniff shouldn't be considered on
Filter::shouldIgnorePath()because that could cause some paths to be excluded entirely only because the custom standard says a subset of the sniffs shouldn't be used on that path.What do you think?