squizlabs / PHP_CodeSniffer

PHP_CodeSniffer tokenizes PHP files and detects violations of a defined set of coding standards.
BSD 3-Clause "New" or "Revised" License
10.66k stars 1.48k forks source link

Custom ruleset is not compatible with project path #2521

Closed TomPradat closed 5 years ago

TomPradat commented 5 years ago

Let's say i have a custom rule named "Toto".

If my project path has some path like workspace/toto/project, then this preg_match always evaluates to true.

https://github.com/squizlabs/PHP_CodeSniffer/blob/8ff9283ab30cd296293b57039efe573aaf669862/src/Filters/Filter.php#L270

It makes me impossible to use exclude-patterns for this custom rule 'Toto' because it ignores all my files.

For example :

<rule ref="Toto">
        <exclude-pattern>src/SomeFile.php<exclude-pattern>
</rule>
jrfnl commented 5 years ago

@TomPradat I believe this was fixed already via PR #2392, which will be included in the PHPCS 3.5.0 release.

gsherwood commented 5 years ago

@TomPradat are you able to test if that fix works for you?

TomPradat commented 5 years ago

Indeed it works on 8ff9283ab30cd296293b57039efe573aaf669862.

I should have checked it earlier. Thanks and sorry for the inconvenience

gsherwood commented 5 years ago

Thanks a lot for checking the fix.