PHP_CodeSniffer icon indicating copy to clipboard operation
PHP_CodeSniffer copied to clipboard

Trigger a warning when ignorance doesn't apply

Open johnbillion opened this issue 6 years ago • 0 comments

Given a phpcs:ignore statement that does not apply to the given line or section of code, it would be great if PHPCS triggered a warning to the user so they could be alerted to the fact that the ignorance is not applicable.

For example, the following phpcs:ignore statement is useless:

// phpcs:ignore PEAR.Commenting.FunctionComment.Missing
echo 'Hello, World!';

Background

I've found that over time some phpcs:ignore statements can become unnecessary, for example when the underlying standard that's in use fixes bugs with its sniffs. When the standard gets updated some phpcs:ignore statements in the code are no longer needed, but there's no easy way (AFAIK) to find these, and they remain in the code.

As an example, the WordPress Coding Standard recently fixed a bug with the WordPress.WP.I18n.NoEmptyStrings sniff, meaning some pieces of code no longer need to ignore this rule.

johnbillion avatar Sep 30 '19 20:09 johnbillion