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

Request #20091 Excluding a message using the exclude tag
Submitted: 2013-10-11 15:24 UTC
From: derekwallace Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.4.7)
PHP Version: 5.4.20 OS: Linux
Roadmaps: (Not assigned)    
Subscription  


 [2013-10-11 15:24 UTC] derekwallace (Derek Wallace)
Description: ------------ Hi, I have attached a sample .php file and 2 ruleset files based on PSR2. The issue i have is with multi-line functional declaration. If i disable the following check <exclude name="Squiz.Functions.MultiLineFunctionDeclaration.ContentAfterComma" /> Then the ENTIRE Sniff "Squiz.Functions.MultiLineFunctionDeclaration" is disabled. Here is the commands to run to illustrate. # This finds 5 errors. # - Squiz.Functions.MultiLineFunctionDeclaration.Indent # - Squiz.Functions.MultiLineFunctionDeclaration.OneParamPerLine phpcs --standard ruleset.xml -s del.php # In this case the rulset1.xml excludes the OneParamPerLine # - In this case NO errors are reported. phpcs --standard ruleset1.xml -s del.php Thx Derek

Comments

 [2013-10-11 15:28 UTC] derekwallace (Derek Wallace)
Cant see how to upload files. Here are the 3 files. del.php <?php function getGood( $sParam1, $sParam11, $sParam12, $sParam2, $sParam3 ) { echo 123; return; } function getBad_Indent( $sParam1, $sParam11, $sParam12, $sParam2, $sParam3 ) { echo 123; return; } function getBad_Indent_MultiParamsOnOneLine( $sParam1, $sParam11, $sParam12, $sParam2, $sParam3 ) { echo 123; return; } ruleset.xml <?xml version="1.0"?> <ruleset name=""> <description></description> <rule ref="PSR2"> </rule> </ruleset> ruleset1.xml <?xml version="1.0"?> <ruleset name=""> <description></description> <rule ref="PSR2"> <exclude name="Squiz.Functions.MultiLineFunctionDeclaration.ContentAfterComma" /> </rule> </ruleset>
 [2013-10-23 04:00 UTC] squiz (Greg Sherwood)
-Summary: Excluding an error disables the entire Sniff +Summary: Excluding a message using the exclude tag -Type: Bug +Type: Feature/Change Request -Assigned To: +Assigned To: squiz
The exclude tag only allows you to exclude an entire sniff. From 1.5.0 onwards, you can also exclude an entire standard or directory of sniffs. But the way to mute a single error message is like this: <rule ref="Squiz.Functions.MultiLineFunctionDeclaration.ContentAfterComma"> <severity>0</severity> </rule> Excluding a single sniff using the exclude tag sounds like a good feature though, so I'll turn this into a feature request for adding that syntax.
 [2013-10-31 06:09 UTC] squiz (Greg Sherwood)
-Status: Assigned +Status: Closed
I've added support in for this to the 1.5 branch. Commit is here: https://github.com/squizlabs/PHP_CodeSniffer/commit/1d416db921cbde2f45ef06d104 633b2fc68db1e2