phpphpcodesnifferphpundercontrol

How to call a custom ruleset.xml for php code sniffer


I'm trying to write an custom ruleset.xml for php code sniffer but calling it from the commandline without putting it in the default folder doesn't seem to work.

Since the documentations seems to state otherwise i'd like to ask if i'm doing something wrong here

:~/$ phpcs --standard=/home/edo/custom_ruleset.xml source/
===>
ERROR: the "/home/edo/custom_ruleset.xml" coding standard is not installed.
The installed coding standards are PEAR, PHPCS, Zend, Squiz and MySource

If that doesn't work: Any suggestions on how to ship your own coding standard with your source ? Thanks


Solution

  • You need at least version 1.3.0a1 of Code Sniffer to use annotated rulesets:

    • All CodingStandard.php files have been replaced by ruleset.xml files
      Custom standards will need to be converted over to this new format to continue working
    • You can specify a path to your own custom ruleset.xml file by using the --standard command line arg e.g., phpcs --standard=/path/to/my/ruleset.xml

    Before that, you had to copy your ruleset, as explained in this tutorial.