Closed AntumDeluge closed 1 year ago
@AntumDeluge This is not a bug, but the documented, expected behaviour.
An error code is build up like so: StandardName.CategoryName.SniffName.ErrorCode
.
From a custom ruleset you can in-/exclude individual error codes (four part name), sniffs (three part name), categories (two part name) or even all sniffs from a standard (one part name) when one standard includes another.
However, from the command-line you can only in-/exclude complete sniffs (three part name).
Omitting the StandardName
will not turn an error code into a sniff name and will not work.
But then doesn't that disable all sniffs under
PEAR.Commenting.FileComment
?
There is only one PEAR.Commenting.FileComment
sniff (= file containing the code for the check(s)), though that one sniff can have, and in this case does have, multiple error codes.
And yes, excluding the PEAR.Commenting.FileComment
sniff from the command line will exclude all error codes from that sniff.
In other words, this is not a bug. I can imagine this could be seen as a feature request along the same lines as #1969, in which case, I'd suggest closing this ticket as a duplicate and continuing the feature request discussion there.
@jrfnl I appreciate the information. I will use a configuration file for more precise management & close this issue. Thank you for the reply.
Describe the bug
Using the
--exclude
option from command line has no effect on output.Code sample
test.php
:To reproduce
Steps to reproduce the behavior:
test.php
with the code sample above...phpcs -s --standard=PEAR --exclude=Commenting.FileComment.Missing test.php
Looking through some of the other issues, it appears they are using the full sniff name prefixed with the standard (e.g.
--exclude=PEAR.Commenting.FileComment.Missing
). But if I do that it reports sniff code is invalid:It works if I include the standard & omit the last (fourth) part:
But then doesn't that disable all sniffs under
PEAR.Commenting.FileComment
? E.g. it will also excludePEAR.Commenting.FileComment.WrongStyle
.Expected behavior
PEAR.Commenting.FileComment.Missing
errors not shown.Versions (please complete the following information)
Additional context
I have confirmed that using a
.phpcs.xml
configuration with<exclude name="PEAR.Commenting.FileComment.Missing"/>
does work.Issues that appear to be related:
3463
Please confirm:
master
branch of PHP_CodeSniffer (unable to build from source at this time).