magento / magento-coding-standard

Magento Coding Standard
Open Software License 3.0
342 stars 153 forks source link

Magento sniff codes do not match expected format (too many `.`) #388

Open convenient opened 2 years ago

convenient commented 2 years ago

Preconditions

  1. Use any version of the magento coding standard

Steps to reproduce

  1. 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

  1. 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.

m2-assistant[bot] commented 2 years ago

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