From 5593738f11fdfc24c95cf1a03ef64854358a2d24 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 3 Mar 2021 19:32:56 +0100 Subject: [PATCH] QA: remove redundant PHPCS ignore annotations ... and make two others more specific. --- WordPress-VIP-Go/ruleset-test.php | 1 - WordPressVIPMinimum/ruleset-test.inc | 2 +- WordPressVIPMinimum/ruleset-test.php | 2 +- tests/RulesetTest.php | 5 ++--- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/WordPress-VIP-Go/ruleset-test.php b/WordPress-VIP-Go/ruleset-test.php index 462bea51..bc299b71 100644 --- a/WordPress-VIP-Go/ruleset-test.php +++ b/WordPress-VIP-Go/ruleset-test.php @@ -342,7 +342,6 @@ // Run the tests! $test = new RulesetTest( 'WordPress-VIP-Go', $expected ); if ( $test->passes() ) { - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped printf( 'All WordPress-VIP-Go tests passed!' . PHP_EOL ); exit( 0 ); } diff --git a/WordPressVIPMinimum/ruleset-test.inc b/WordPressVIPMinimum/ruleset-test.inc index 955cd506..f1f833a0 100644 --- a/WordPressVIPMinimum/ruleset-test.inc +++ b/WordPressVIPMinimum/ruleset-test.inc @@ -443,7 +443,7 @@ add_filter( 'robots_txt', function() { // Warning. } ); // WordPressVIPMinimum.Performance.BatcacheWhitelistedParams -// phpcs:ignore WordPress.Security.NonceVerification.NoNonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotValidated +// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated $test = sanitize_text_field( $_GET["utm_medium"] ); // Warning. // WordPressVIPMinimum.Performance.CacheValueOverride diff --git a/WordPressVIPMinimum/ruleset-test.php b/WordPressVIPMinimum/ruleset-test.php index 601e1dc4..374a6e50 100644 --- a/WordPressVIPMinimum/ruleset-test.php +++ b/WordPressVIPMinimum/ruleset-test.php @@ -323,7 +323,7 @@ // Run the tests! $test = new RulesetTest( 'WordPressVIPMinimum', $expected ); if ( $test->passes() ) { - printf( 'All WordPressVIPMinimum tests passed!' . PHP_EOL ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + printf( 'All WordPressVIPMinimum tests passed!' . PHP_EOL ); exit( 0 ); } diff --git a/tests/RulesetTest.php b/tests/RulesetTest.php index 2cdc883f..d67a3454 100644 --- a/tests/RulesetTest.php +++ b/tests/RulesetTest.php @@ -92,7 +92,7 @@ public function __construct( $ruleset, $expected = [] ) { // Travis and Windows support. $phpcs_bin = getenv( 'PHPCS_BIN' ); if ( $phpcs_bin === false ) { - // phpcs:ignore + // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.runtime_configuration_putenv -- This is test code, not production. putenv( 'PHPCS_BIN=phpcs' ); } else { $this->phpcs_bin = realpath( $phpcs_bin ); @@ -101,7 +101,6 @@ public function __construct( $ruleset, $expected = [] ) { $output = $this->collect_phpcs_result(); if ( ! is_object( $output ) || empty( $output ) ) { - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped printf( 'The PHPCS command checking the ruleset hasn\'t returned any issues. Bailing ...' . PHP_EOL ); exit( 1 ); // Die early, if we don't have any output. } @@ -149,7 +148,7 @@ private function collect_phpcs_result() { $this->phpcs_bin, $this->ruleset ); - // phpcs:ignore + // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.system_calls_shell_exec -- This is test code, not production. $output = shell_exec( $shell ); return json_decode( $output );