From 41f9bc94a07cc61e6a4ed2423fe4f727673b5c0e Mon Sep 17 00:00:00 2001 From: Nilambar Sharma Date: Thu, 19 Sep 2024 10:20:38 +0545 Subject: [PATCH 1/2] Change type for ValidatedSanitizedInput rule --- phpcs-rulesets/plugin-review.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/phpcs-rulesets/plugin-review.xml b/phpcs-rulesets/plugin-review.xml index 9fdbef57f..c12f210e2 100644 --- a/phpcs-rulesets/plugin-review.xml +++ b/phpcs-rulesets/plugin-review.xml @@ -48,8 +48,7 @@ - error - 7 + warning From f232cd1dc740dbbae313735e05421cb2d4960df8 Mon Sep 17 00:00:00 2001 From: Nilambar Sharma Date: Thu, 19 Sep 2024 10:40:02 +0545 Subject: [PATCH 2/2] Update test to accommodate the change --- .../Checker/Checks/Plugin_Review_PHPCS_Check_Tests.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/phpunit/tests/Checker/Checks/Plugin_Review_PHPCS_Check_Tests.php b/tests/phpunit/tests/Checker/Checks/Plugin_Review_PHPCS_Check_Tests.php index 1860b3d77..00f870014 100644 --- a/tests/phpunit/tests/Checker/Checks/Plugin_Review_PHPCS_Check_Tests.php +++ b/tests/phpunit/tests/Checker/Checks/Plugin_Review_PHPCS_Check_Tests.php @@ -38,11 +38,10 @@ public function test_run_with_errors() { $this->assertArrayHasKey( 'code', $errors['load.php'][12][5][0] ); $this->assertEquals( 'WordPress.WP.DeprecatedFunctions.the_author_emailFound', $errors['load.php'][12][5][0]['code'] ); - // Check for WordPress.Security.ValidatedSanitizedInput.InputNotValidated error on Line no 15 and column no at 27. - $this->assertArrayHasKey( 15, $errors['load.php'] ); - $this->assertArrayHasKey( 27, $errors['load.php'][15] ); - $this->assertArrayHasKey( 'code', $errors['load.php'][15][27][0] ); - $this->assertEquals( 'WordPress.Security.ValidatedSanitizedInput.InputNotValidated', $errors['load.php'][15][27][0]['code'] ); + // Check for WordPress.Security.ValidatedSanitizedInput warnings on Line no 15 and column no at 27. + $this->assertCount( 1, wp_list_filter( $warnings['load.php'][15][27], array( 'code' => 'WordPress.Security.ValidatedSanitizedInput.InputNotValidated' ) ) ); + $this->assertCount( 1, wp_list_filter( $warnings['load.php'][15][27], array( 'code' => 'WordPress.Security.ValidatedSanitizedInput.MissingUnslash' ) ) ); + $this->assertCount( 1, wp_list_filter( $warnings['load.php'][15][27], array( 'code' => 'WordPress.Security.ValidatedSanitizedInput.InputNotSanitized' ) ) ); // Check for Squiz.PHP.DiscouragedFunctions.Discouraged warning on Line no 17 and column no at 1. $this->assertSame( 'Squiz.PHP.DiscouragedFunctions.Discouraged', $warnings['load.php'][17][1][0]['code'] );