Skip to content

Check paths are accepted if no exclude-pattern matches - #2392

Merged
peternolland merged 2 commits into
squizlabs:masterfrom
wvega:issue-2391
May 23, 2019
Merged

peternolland merged 2 commits into
squizlabs:masterfrom
wvega:issue-2391

Conversation

@wvega

@wvega wvega commented Jan 28, 2019 •

Copy link
Copy Markdown
Contributor

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/phpcs reports no problems) but I'm not sure if I added the test to the right place or used the correct approach by using AcceptTest.inc as 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?

…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
@jrfnl

jrfnl commented Feb 5, 2019

Copy link
Copy Markdown
Contributor

Note: the build failure is not directly related to this PR and will be fixed by #2390.

@gsherwood gsherwood added this to the 3.5.0 milestone Mar 22, 2019
@peternolland
peternolland merged commit 1cad124 into squizlabs:master May 23, 2019
@peternolland peternolland self-assigned this May 23, 2019
@peternolland

Copy link
Copy Markdown
Contributor

Thanks for the patch and for providing the update to package.xml

I 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.

@jrfnl

jrfnl commented May 23, 2019

Copy link
Copy Markdown
Contributor

You're welcome ?

@wvega

wvega commented May 23, 2019

Copy link
Copy Markdown
Contributor Author

@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 :)

gsherwood added a commit that referenced this pull request May 23, 2019
@gsherwood

Copy link
Copy Markdown
Member

@jrfnl my bad - didn't notice the commit history. Thanks for the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants