Closed FabianKoestring closed 9 years ago
I recommend to:
The exclude patterns in PHP_CodeSniffer might only work, when you're passing a folder to be scanned to PHP_CodeSniffer, but PhpStorm is passing absolute file path and in that case PHP_CodeSniffer assumes that file needs to be checked anyway.
One other point: You can't include an exclude-pattern tag inside a coding standard, as you have done in your ruleset. That pattern will be assigned to the PSR2 standard, but nothing in PHPCS is actually checking that. Exclude patterns are either global, or specified inside a rule tag for a specific sniff. Examples of both are in here: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml
But the specific issue you are getting is also because of what @aik099 has said. If PHPCS is asked to check a file, it will check that file even if the global exclude patterns would normally exclude it.
What you really need is a new PHPCS feature to support the way you've defined your exclude pattern. In the meantime, you'll need to configure PHPStorm as @aik099 has said.
I'll turn this into a feature request so I don't forgot. It might be something I can do in the 3.0 branch.
After more detailed @gsherwood explanation I now realized, that per-sniff exclude patterns still work when file name is given directly to phpcs
or phpcbf
. The per-ruleset patterns aren't.
@gsherwood :+1:
@aik099 Thanks, works!
I've added this feature into the 3.0 branch.
I want to create a custom ruleset that would check PHP Files for compiliance with PSR-2. But it should only test
.php
files. I use PhpStorm as IDE. PhpStorm supports code sniffer integration but it seems likeexclude-pattern
doesnt work.Whats wrong? Is there an error my custom ruleset or is it a problem with PhpStorm?
Thanks