Closed
Description
PHPCS supports comment directives like:
// @codingStandardsIgnoreFile
// @codingStandardsIgnoreStart
// @codingStandardsIgnoreLine
However, these are all or nothing. What would be even more useful is if we can selectively ignore certain sniffs or errors within sniffs. For instance:
$q = new WP_Query( array(
'posts_per_page' => 200, // @codingStandardsIgnoreLine WordPress.VIP.SlowDBQuery.slow_db_query
) );
or
// @codingStandardsIgnoreStart WordPress.VIP.SlowDBQuery.slow_db_query
$q = new WP_Query( array(
'posts_per_page' => 200,
) );
// @codingStandardsIgnoreEnd WordPress.VIP.SlowDBQuery.slow_db_query
This draws inspiration from JSCS and its directives like:
//jscs:disable requireCamelCaseOrUpperCaseIdentifiers
We have this in the WordPress-Coding-Standards project in a sniff-specific ad hoc system of end-of-statement comments:
echo $foo; // xss ok
Which suppresses the WordPress.XSS.EscapeOutput
sniff. But it would be very useful if this was standardized in PHPCS itself and available to all sniffs