Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 3.7.2

Request #17903 Allow exclude patterns at sniff level
Submitted: 2010-09-29 01:31 UTC
From: jmfontaine Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.3.0RC1)
PHP Version: 5.3.3 OS: Kubuntu 10.04
Roadmaps: (Not assigned)    
Subscription  


 [2010-09-29 01:31 UTC] jmfontaine (Jean-Marc Fontaine)
Description: ------------ Sometimes it would be convenient to be able to exclude some files or directories only for some sniffs. For example, on a project we have some Doctrine entities that must comply to some Doctrine standard which is different from ours. In fact, the standards are quite the same except on one rule. We do not want to exclude the whole entities directory only for one rule. Test script: --------------- <?xml version="1.0"?> <ruleset name="Dummy"> <description>My Dummy coding standard.</description> <rule ref="PEAR"/> <rule ref="PEAR.NamingConventions.ValidVariableName"> <exclude-patterns> <pattern>/var/www/models/*</pattern> </exclude-patterns> </rule> </ruleset> Expected result: ---------------- PEAR.NamingConventions.ValidVariableName sniff should not be run on directory /var/www/models/.

Comments

 [2010-09-29 01:35 UTC] jmfontaine (Jean-Marc Fontaine)
 [2010-10-08 20:02 UTC] doconnor (Daniel O'Connor)
-Assigned To: +Assigned To: squiz
 [2010-10-12 10:17 UTC] squiz (Greg Sherwood)
-Status: Assigned +Status: Closed
I've committed this feature to SVN, but I've done if differently to you to keep it consistent with the way the current exclude patterns are defined. Here are some docs for the feature: <!-- You can also hard-code ignore patterns for specific sniffs, a feature not available on the command line. The code here will hide all messages from the Squiz DoubleQuoteUsageSniff for files that match either of the two exclude patterns. --> <rule ref="Squiz.Strings.DoubleQuoteUsage"> <exclude-pattern>*/tests/*</exclude-pattern> <exclude-pattern>*/data/*</exclude-pattern> </rule> <!-- You can also be more specific and just exclude some messages. The code here will just hide the ContainsVar error generated by the Squiz FileCommentSniff for files that match either of the two exclude patterns. --> <rule ref="Squiz.Strings.DoubleQuoteUsage.ContainsVar"> <exclude-pattern>*/tests/*</exclude-pattern> <exclude-pattern>*/data/*</exclude-pattern> </rule>
 [2010-10-18 19:28 UTC] jmfontaine (Jean-Marc Fontaine)
Thanks for adding this feature. It was my first time hacking PHP_CodeSniffer code base. I hope next time my patch will be better and would find its way to the repository. ;)