Edit report at https://pear.php.net/bugs/bug.php?id=20145&edit=1
ID: 20145
Updated by: [email protected]
Reported By: alan dot campbell at riskpoint dot co dot uk
Summary: Custom ruleset does not register PEAR sniffs
Status: Feedback
Type: Bug
Package: PHP_CodeSniffer
Operating System: OS X (10.9)
Package Version: 1.5.0
PHP Version: 5.4.17
Assigned To: squiz
Roadmap Versions:
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2013-12-11 23:05:51] squiz
-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-10 16:40:47] alancampbell
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-10 16:38:05] alancampbell
-Operating System:
+Operating System: OS X (10.9)
------------------------------------------------------------------------
[2013-12-10 16:35:33] alancampbell
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)
------------------------------------------------------------------------