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

Bug #20145 Custom ruleset preferences directory over installed standard
Submitted: 2013-12-10 21:35 UTC
From: alancampbell Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.5.0)
PHP Version: 5.4.17 OS: OS X (10.9)
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


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 : 48 + 44 = ?

 
 [2013-12-10 21:35 UTC] alancampbell (Alan Campbell)
Description: ------------ Creating a very basic custom rules file loading only PEAR standard does not register any sniff when run with the following command: phpcs -v --standard=pear_ruleset.xml phpcs_rules_test.php Should give the same result as running the following: phpcs -v --standard=PEAR phpcs_rules_test.php Repeating the above test, replacing PEAR with all other standards works as expected and gives the same results. Expected result: ---------------- Registering sniffs in the PEAR standard... DONE (26 sniffs registered) Creating file list... DONE (1 files in queue) Actual result: -------------- Registering sniffs in the MyPEARStandardTest standard... DONE (0 sniffs registered) Creating file list... DONE (1 files in queue)

Comments

 [2013-12-10 21:38 UTC] alancampbell (Alan Campbell)
-Operating System: +Operating System: OS X (10.9)
 [2013-12-10 21:40 UTC] alancampbell (Alan Campbell)
pear_ruleset.xml <?xml version="1.0"?> <ruleset name="MyPEARStandardTest"> <description>Test PEAR coding standard.</description> <rule ref="PEAR"/> </ruleset> phpcs_rules_test.php <?php class PHPCS_Rules_Test { }
 [2013-12-12 04:05 UTC] squiz (Greg Sherwood)
-Status: Open +Status: Feedback -Assigned To: +Assigned To: squiz
This is working fine for me, on OS X (10.9) with the PHP 5.4.17 that ships with it. I get: $ phpcs -v --standard=pear_ruleset.xml phpcs_rules_test.php Registering sniffs in the MyPEARStandardTest standard... DONE (26 sniffs registered) Creating file list... DONE (1 files in queue) Changing into directory /.../PHP_CodeSniffer Processing phpcs_rules_test.php [10 tokens in 5 lines]... DONE in < 1 second (2 errors, 0 warnings) FILE: /.../phpcs_rules_test.php -------------------------------------------------------------------------------- FOUND 2 ERROR(S) AFFECTING 1 LINE(S) -------------------------------------------------------------------------------- 2 | ERROR | Missing file doc comment 2 | ERROR | Missing class doc comment -------------------------------------------------------------------------------- Time: 20 ms, Memory: 2.50Mb I'm not really sure what to suggest as it looks like we're using the exact same environment and sample code. You could try doing a git clone of the repo and running it directly from there instead of via PEAR: git clone git://github.com/squizlabs/PHP_CodeSniffer.git cd PHP_CodeSniffer php scripts/phpcs -v --standard=pear_ruleset.xml phpcs_rules_test.php
 [2013-12-12 22:24 UTC] alancampbell (Alan Campbell)
I have a PEAR directory in the directory where I was running the test. It seems that phpcs is trying to load the PEAR rules from the PEAR directory within current working directory and then not finding anyway as this is not a directory for CodeSniffer rules. Is this the new expected behaviour? Version 1.4.8 ignored the presence of my PEAR folder.
 [2013-12-13 04:18 UTC] squiz (Greg Sherwood)
Yep, that's the problem. Using -vv: Processing ruleset /.../pear_ruleset.xml Processing rule "PEAR" * rule is referencing a directory of sniffs * Adding sniff files from directory The ruleset processing code was rewritten from scratch because it didn't support relative paths and was constantly looking in the wrong places. But now it appears to be preferencing directories over installed standards, which it shouldn't. I'll get that fixed up. Thanks for getting back to me.
 [2013-12-13 04:33 UTC] squiz (Greg Sherwood)
-Summary: Custom ruleset does not register PEAR sniffs +Summary: Custom ruleset preferences directory over installed standard
 [2013-12-13 04:34 UTC] squiz (Greg Sherwood)
-Status: Feedback +Status: Closed
Fix committed to github repo: https://github.com/squizlabs/PHP_CodeSniffer/commit/227bc6e6f8c1c210fa36a5de4e 352bb3f5688265