Currently you can ignore certain warnings on a file, which is great. However, it is burdensome and violates DRY if you need to ignore the same warnings in very many files in your project. Desired is a way to set ignore rules in one place for an entire project.

For instance, the D7 Password Policy module does not currently specify types for parameters or return values. (This is consistent with most of Drupal core.) We would like to suppress these warnings currently in order to focus on other warnings.

Comments

klausi’s picture

Component: Coder Review » Coder Sniffer
Category: Feature request » Support request
Status: Active » Fixed

Unfortunately I don't see a command line option to specify sniff codes to be ignored. There is only the --sniffs switch which lets you select sniffs that you want, but cannot specify those that you don't want.

I would suggest to create your own PasswordPolicy Standard ruleset.xml file, register that as separate standard with PHPCS, include everything from Drupal and specify ignore rules for certain sniff codes.

aohrvetpv’s picture

I am not trying to use Coder Review from the command line. I think I may not have been clear in this request.

Coder Review currently has a feature that lets you ignore certain rules by adding a tag like:
@ignore some_rule_here:file

That causes the individual rule to be ignored for the entire file when running a review. The problem, though, is if you want to ignore the rule on a module level, you have to put that line in every code file.

A module (or project) scope is desired so you can just put @ignore some_rule_here:module and have the rule ignored for the entire project.

There are varying scopes for @ignore. You can also ignore with line or function scope. It would seem to make sense to have a module scope to complete the gamut of scopes from broad to narrow.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

aohrvetpv’s picture

Status: Closed (fixed) » Active

Setting back active because I think the original request may have not been clear. Please see #2.

aohrvetpv’s picture

Category: Support request » Feature request
mikeytown2’s picture

Would also like to ignore all rules if including some 3rd party code: js, etc...

klausi’s picture

Status: Active » Closed (works as designed)

What can do now is create a custom phpcs.xml file in your project and specify sinffs that you want applied, files you want to ignore etc. See for example Drupal core's phpcs.xml.dist file http://cgit.drupalcode.org/drupal/tree/core/phpcs.xml.dist

I think that should be enough flexibility for custom projects.