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

Bug #18145 Sniffs are not loaded for custom ruleset file
Submitted: 2010-12-27 03:10 UTC
From: mccammos Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.3.0RC1)
PHP Version: 5.3.3 OS: OSX 10.6.5
Roadmaps: (Not assigned)    
Subscription  


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 27 - 12 = ?

 
 [2010-12-27 03:10 UTC] mccammos (Scott McCammon)
Description: ------------ Running code sniffer with a a custom ruleset.xml file fails to register anything in the standard's Sniffs directory. Looking at the code for setTokenListeners, this is due to setting the standardsDir property to the ruleset file rather than its parent directory. See attached diff for a one-liner fix. Test script: --------------- Create a custom standard using the tutorial at: http://pear.php.net/manual/en/package.php.php-codesniffer.coding-standard-tutorial.php Then test with: phpcs -v --standard=/path/to/MyStandard/ruleset.xml test.php Expected result: ---------------- Registering sniffs in MyStandard standard... DONE (1 sniffs registered) Processing test.php [71 tokens in 15 lines]... DONE in < 1 second (0 errors, 0 warnings) FILE: test.php -------------------------------------------------------------------------------- FOUND 3 ERROR(S) AFFECTING 3 LINE(S) -------------------------------------------------------------------------------- 3 | ERROR | Hash comments are prohibited; found # Check for valid contents. 7 | ERROR | Hash comments are prohibited; found # Value needs to be an array. 9 | ERROR | Hash comments are prohibited; found # Error. -------------------------------------------------------------------------------- Actual result: -------------- Registering sniffs in MyStandard standard... DONE (0 sniffs registered) Processing test.php [71 tokens in 15 lines]... DONE in < 1 second (0 errors, 0 warnings)

Comments

 [2010-12-27 03:16 UTC] mccammos (Scott McCammon)
Added patch Fix.
 [2011-01-12 05:36 UTC] squiz (Greg Sherwood)
-Status: Open +Status: Closed -Assigned To: +Assigned To: squiz
This bug has been fixed in SVN. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. Thanks for the patch.
 [2011-01-18 04:46 UTC] squiz (Greg Sherwood)
Turns out that this patch causes bug #18200
 [2011-01-18 05:00 UTC] squiz (Greg Sherwood)
New patch only applies dirname is the ruleset's filename is ruleset.xml