Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 384
edorian Avatar asked Oct 27 '10 17:10

edorian


1 Answers

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.

like image 199
Gordon Avatar answered Oct 06 '22 00:10

Gordon