Try to use the --exclude flag on the CLI to exclude a magento sniff
$ ./vendor/bin/phpcs -s --standard=Magento2 --exclude=Magento2.Annotation.MethodArguments.MethodArguments src
ERROR: The specified sniff code "Magento2.Annotation.MethodAnnotationStructure.MethodArguments" is invalid
Run "phpcs --help" for usage information
Expected result
I can run phpcs with the specified rule excluded
Actual result
I get an error from phpcs as it doesnt expect this many . in the sniff codes
squizlabs/php_codesniffer only expects 2 . within a rule name
--exclude=Magento2.Annotation.MethodArguments.MethodArguments has 3
When I hack out the check in vendor/squizlabs/php_codesniffer/src/Config.php it seems to exclude the rule okay so not sure why they're being strict there. But it still seems like the way the Magento rules are defined they're not fully compatible with squizlabs/php_codesniffer
Workaround
Define my own ruleset which excludes the rules i'm suppressing.
Preconditions
Steps to reproduce
--exclude
flag on the CLI to exclude a magento sniffExpected result
phpcs
with the specified rule excludedActual result
I get an error from phpcs as it doesnt expect this many
.
in the sniff codeshttps://github.com/squizlabs/PHP_CodeSniffer/blob/b314140057170a81075556a71764f2f302e3b8be/src/Config.php#L851-L859
squizlabs/php_codesniffer
only expects 2.
within a rule name--exclude=Magento2.Annotation.MethodArguments.MethodArguments
has 3When I hack out the check in
vendor/squizlabs/php_codesniffer/src/Config.php
it seems to exclude the rule okay so not sure why they're being strict there. But it still seems like the way the Magento rules are defined they're not fully compatible withsquizlabs/php_codesniffer
Workaround
Define my own ruleset which excludes the rules i'm suppressing.