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

Request #19144 multiple rulesets and pathing
Submitted: 2011-12-19 00:51 UTC
From: holybit Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.3.2)
PHP Version: 5.3.8 OS: unix
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 : 38 - 18 = ?

 
 [2011-12-19 00:51 UTC] holybit (Joe Crotty)
Description: ------------ You can specify XML ruleset via the --standard CLI option. However, the limit is one ruleset. --standard=ruleset1.xml,ruleset2.xml will not work The <rule ref=""/> allows the inclusion of external rulesets with the catch that if they are not relative to the PHP_CodeSniffer install directory they must be absolute. An example problem follows. Let's say we have four code repositories with php files in all on github. The same lead developer maintains all four and cooks up one generic XML ruleset, phpcs.xml, that lives in each repository. He puts it in WORKINGDIR/coding_conventions/phpcs.xml. The logic here is the lead developer can now apply his generic rules to any php repository and use another ruleset to fine tune the rules (i.e., exclusions and such). However, each repo has different directories to exclude and/or rules to fine tune. As the repos are cloned onto other developers machine they land at arbitrary locations. There is no way for WORKINGDIR/coding_conventions/phpcs.xml to contain a <rule ref=""/> pointing say exclude.xml relative to it's own location. The only solution is that each repos phpcs.xml will have be fixed in a one time fashion that breaks the ideal of a generic ruleset for a group of repositories. This is limiting given a repository checked out at an arbitrary location that contains a ruleset.xml file as part of the repositories coding conventions.

Comments

 [2013-03-20 07:55 UTC] squiz (Greg Sherwood)
This comment is pretty late, but ruleset.xml files do support relative paths in RULE tags. I'll leave this open as a request for specifying multiple standards on the command line.
 [2013-03-25 23:43 UTC] lstrojny_in (Lars Strojny)
What would be great is if we could use something like __DIR__ in PHP. That is: a relative include to the path where the ruleset.xml is located. This is especially helpful if you use e.g. composer to include another coding standard into your project. Maybe use ${basedir}?
 [2013-03-26 02:11 UTC] squiz (Greg Sherwood)
If you grab the latest code from github, all relative paths inside a ruleset file are relative to the location of the ruleset file itself and not to the main standard or the current working directory. So that may be what you are after now.
 [2013-03-27 05:13 UTC] squiz (Greg Sherwood)
I've added support for specifying multiple standards on the command line now: https://github.com/squizlabs/PHP_CodeSniffer/commit/bd7033edf17a84fe8ff03fb12f72 fd4fca18ea85 Will be released in 1.5.0, once it goes through some more RC releases. Usage is pretty basic: phpcs --standard=PEAR,PSR2,../mystandard.xml ...
 [2013-03-27 05:14 UTC] squiz (Greg Sherwood)
-Status: Open +Status: Closed -Assigned To: +Assigned To: squiz