magento-coding-standard
magento-coding-standard copied to clipboard
Magento sniff codes do not match expected format (too many `.`)
Preconditions
- Use any version of the magento coding standard
Steps to reproduce
- 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
https://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 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.
Hi @convenient. Thank you for your report. To speed up processing of this issue, make sure that you provided sufficient information.
Add a comment to assign the issue: @magento I am working on this
- Join Magento Community Engineering Slack and ask your questions in #github channel.