If I run:
phpcs -s ...
I get output in part like this:
1082 | ERROR | Missing parameter type (Drupal.Commenting.FunctionComment.MissingParamType)

If I want to exclude this sniff, I think I ought to be able to run:
phpcs --exclude=Drupal.Commenting.FunctionComment.MissingParamType ...

But when I do, I get, in part:
ERROR: The specified sniff code "Drupal.Commenting.FunctionComment.MissingParamType" is invalid

How do I exclude this sniff?

Comments

Liam Morland created an issue. See original summary.

earelin’s picture

I have the same problem

vendor/bin/phpcs --bootstrap=vendor/autoload.php \
                 --runtime-set installed_paths vendor/drupal/coder/coder_sniffer/ \
                 --standard=Drupal,DrupalPractice \
                 --exclude=DrupalPractice.InfoFiles.NamespacedDependency.NonNamespaced \
                 .
kunalkursija’s picture

What version of PHPCS are you using?

If you refer this documentation https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#ignoring-parts-of-a-file then it says the following:

Note: Selective ignoring of codes/sniffs/categories/standards is only available from PHP_CodeSniffer version 3.2.0 onwards.

If your PHPCS version is lesser than 3.2.0, then excluding specific sniffs might not be done?

liam morland’s picture

I'm running 3.4.1.

$ phpcs --version
PHP_CodeSniffer version 3.4.1 (stable) by Squiz (http://www.squiz.net)
klausi’s picture

Version: 8.x-2.x-dev » 8.x-3.x-dev
Status: Active » Fixed

With the --exclude option you can only exclude full sniffs like Drupal.Commenting.FunctionComment. You cannot exclude parts like Drupal.Commenting.FunctionComment.MissingParamType.

To do that you need create a phpcs.xml.dist file in your project, see https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-Ruleset or https://git.drupalcode.org/project/drupal/blob/8.8.x/core/phpcs.xml.dist for example.

liam morland’s picture

Thanks

Status: Fixed » Closed (fixed)

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