FAQ
Edit report at http://pear.php.net/bugs/bug.php?id=18145&edit=1

ID: 18145
Updated by: gsherwood@squiz.net
Reported By: mccammon at uoregon dot edu
Summary: Sniffs are not loaded for custom ruleset file
-Status: Open
+Status: Closed
Type: Bug
Package: PHP_CodeSniffer
Operating System: OSX 10.6.5
Package Version: 1.3.0RC1
PHP Version: 5.3.3
-Assigned To:
+Assigned To: squiz
Roadmap Versions:
New Comment:

-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.


Previous Comments:
------------------------------------------------------------------------

[2010-12-26 22:16:05] mccammos

Added #patch bug:18145;patch:Fix;revision:1293401765;.

------------------------------------------------------------------------

[2010-12-26 22:10:15] mccammos

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)

------------------------------------------------------------------------

Search Discussions

  • Gsherwood at Jan 17, 2011 at 10:43 pm
    Edit report at http://pear.php.net/bugs/bug.php?id=18145&edit=1

    ID: 18145
    Updated by: gsherwood@squiz.net
    Reported By: mccammon at uoregon dot edu
    Summary: Sniffs are not loaded for custom ruleset file
    Status: Closed
    Type: Bug
    Package: PHP_CodeSniffer
    Operating System: OSX 10.6.5
    Package Version: 1.3.0RC1
    PHP Version: 5.3.3
    Assigned To: squiz
    Roadmap Versions:
    New Comment:

    Turns out that this patch causes bug #18200


    Previous Comments:
    ------------------------------------------------------------------------

    [2011-01-12 00:36:54] squiz

    -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.

    ------------------------------------------------------------------------

    [2010-12-26 22:16:05] mccammos

    Added #patch bug:18145;patch:Fix;revision:1293401765;.

    ------------------------------------------------------------------------

    [2010-12-26 22:10:15] mccammos

    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)

    ------------------------------------------------------------------------
  • Gsherwood at Jan 17, 2011 at 10:58 pm
    Edit report at http://pear.php.net/bugs/bug.php?id=18145&edit=1

    ID: 18145
    Updated by: gsherwood@squiz.net
    Reported By: mccammon at uoregon dot edu
    Summary: Sniffs are not loaded for custom ruleset file
    Status: Closed
    Type: Bug
    Package: PHP_CodeSniffer
    Operating System: OSX 10.6.5
    Package Version: 1.3.0RC1
    PHP Version: 5.3.3
    Assigned To: squiz
    Roadmap Versions:
    New Comment:

    New patch only applies dirname is the ruleset's filename is ruleset.xml


    Previous Comments:
    ------------------------------------------------------------------------

    [2011-01-17 23:46:00] squiz

    Turns out that this patch causes bug #18200

    ------------------------------------------------------------------------

    [2011-01-12 00:36:54] squiz

    -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.

    ------------------------------------------------------------------------

    [2010-12-26 22:16:05] mccammos

    Added #patch bug:18145;patch:Fix;revision:1293401765;.

    ------------------------------------------------------------------------

    [2010-12-26 22:10:15] mccammos

    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)

    ------------------------------------------------------------------------

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedJan 11, '11 at 11:35p
activeJan 17, '11 at 10:58p
posts3
users1
websitepear.php.net

1 user in discussion

Gsherwood: 3 posts

People

Translate

site design / logo © 2022 Grokbase