Closed kanlukasz closed 2 years ago
Hey @kanlukasz,
When you run PHPCS against a specific file, your exclude-pattern
shouldn't work. You've declared the path as relative, but for specific files (instead of directories), there's nothing for the pattern to be relative to. You're checking /path/to/wordpress/wp-content/plugins/content/file.php
against a regex that uses a ^
and indicates that the string should begin with something. Since it can't use a relative path (as-per PHPCS itself), it fails to find anything meaningful in the regex.
You should see a similar effect if you ran phpcs /path/to/wordpress/wp-content/plugins/content/file.php
.
Thank you for your quick reply and detailed explanations. Yes, I corrected my regex and now works fine directly with cmd and with your extension in VsCode too. Sorry for the confusion 🙏
I am leaving the corrected regex here for others who looking for a similar case:
<exclude-pattern>^(?!.*\/wp-content\/plugins\/my-plugin-dir|.*\/wp-content\/themes\/my-theme-dir).*</exclude-pattern>
<exclude-pattern>^(.*\/wp-content\/themes\/my-theme-dir\/inc)</exclude-pattern>
<exclude-pattern>.*\.(?!(php$))</exclude-pattern>
Description
In my
.phpcs.xml
I use<exclude-pattern>
using negativeregex
. Thanks to this, I am able to exclude the entire project except specific folders. (This is very useful especially when you are working with a strange project structure like e.g. Wordpress)When I run
PHP Code Sniffer
from the command line, all my files are interpreted correctly - I mean my exclusions works fine. But when i use it in VsCode with your extension, every file is scanned while openReproduction Steps
.phpcs.xml
with<exclude-pattern>
My
.phpcs.xml
file:Work environment: