From 60f7d8d59a1810f3064c3ea026c5985f26230839 Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Tue, 29 Aug 2023 14:06:08 -0700 Subject: [PATCH 1/8] Update to WPCS v3 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 451a30f3..9566eb9c 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "wp-cli/core-command": "^1 || ^2", "wp-cli/eval-command": "^1 || ^2", "wp-cli/wp-cli": "^2.5.1", - "wp-coding-standards/wpcs": "^2.3.0", + "wp-coding-standards/wpcs": "^3", "yoast/phpunit-polyfills": "^1.0.3" }, "require-dev": { From eb88d7bc1b5c712385d44f447023f4fad4c753c7 Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Tue, 29 Aug 2023 14:09:05 -0700 Subject: [PATCH 2/8] Remove legacy PHPCS sniff --- WP_CLI_CS/ruleset.xml | 3 --- 1 file changed, 3 deletions(-) diff --git a/WP_CLI_CS/ruleset.xml b/WP_CLI_CS/ruleset.xml index 1d9cf9ed..f03c93be 100644 --- a/WP_CLI_CS/ruleset.xml +++ b/WP_CLI_CS/ruleset.xml @@ -75,9 +75,6 @@ - - - From ddbeaaf34840fc689cb98dbc3e80587da128927d Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Tue, 29 Aug 2023 14:11:23 -0700 Subject: [PATCH 3/8] Revert "Remove legacy PHPCS sniff" This reverts commit eb88d7bc1b5c712385d44f447023f4fad4c753c7. --- WP_CLI_CS/ruleset.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/WP_CLI_CS/ruleset.xml b/WP_CLI_CS/ruleset.xml index f03c93be..1d9cf9ed 100644 --- a/WP_CLI_CS/ruleset.xml +++ b/WP_CLI_CS/ruleset.xml @@ -75,6 +75,9 @@ + + + From 0f14ebd7eaf984c34885b39dc13652fa2deb19ed Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Tue, 29 Aug 2023 14:15:31 -0700 Subject: [PATCH 4/8] Update some sniff references --- WP_CLI_CS/ruleset.xml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/WP_CLI_CS/ruleset.xml b/WP_CLI_CS/ruleset.xml index 1d9cf9ed..1088d8b6 100644 --- a/WP_CLI_CS/ruleset.xml +++ b/WP_CLI_CS/ruleset.xml @@ -73,10 +73,16 @@ - + - + + + + + + + From 2cf28975ffe77702568102afe82964f9d2d0cfc4 Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Tue, 29 Aug 2023 14:17:30 -0700 Subject: [PATCH 5/8] Auto-fix some violations --- src/Context/FeatureContext.php | 9 +++------ src/Context/Support.php | 2 +- src/Context/WhenStepDefinitions.php | 1 - tests/bootstrap.php | 1 - 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/Context/FeatureContext.php b/src/Context/FeatureContext.php index 9d87e229..88be31ae 100644 --- a/src/Context/FeatureContext.php +++ b/src/Context/FeatureContext.php @@ -1061,7 +1061,7 @@ private static function log_run_times_after_scenario( $scope ) { $scenario_key = self::get_scenario_key( $scope ); if ( $scenario_key ) { self::$scenario_run_times[ $scenario_key ] += microtime( true ); - self::$scenario_count++; + ++self::$scenario_count; if ( count( self::$scenario_run_times ) > self::$num_top_scenarios ) { arsort( self::$scenario_run_times ); array_pop( self::$scenario_run_times ); @@ -1094,11 +1094,9 @@ private static function dir_diff_copy( $upd_dir, $src_dir, $cop_dir ) { throw new RuntimeException( sprintf( "Failed to create copy directory '%s': %s. " . __FILE__ . ':' . __LINE__, $cop_file, $error['message'] ) ); } self::copy_dir( $upd_file, $cop_file ); - } else { - if ( ! copy( $upd_file, $cop_file ) ) { + } elseif ( ! copy( $upd_file, $cop_file ) ) { $error = error_get_last(); throw new RuntimeException( sprintf( "Failed to copy '%s' to '%s': %s. " . __FILE__ . ':' . __LINE__, $upd_file, $cop_file, $error['message'] ) ); - } } } elseif ( is_dir( $upd_file ) ) { self::dir_diff_copy( $upd_file, $src_file, $cop_file ); @@ -1229,7 +1227,7 @@ private static function log_proc_method_run_time( $key, $start_time ) { self::$proc_method_run_times[ $key ] = [ 0, 0 ]; } self::$proc_method_run_times[ $key ][0] += $run_time; - self::$proc_method_run_times[ $key ][1]++; + ++self::$proc_method_run_times[ $key ][1]; } } @@ -1301,7 +1299,6 @@ function wpcli_bootstrap_behat_feature_context() { wp_cli_behat_env_debug( "Project config file location: {$project_config}" ); wp_cli_behat_env_debug( "Project config:\n{$contents}" ); - } wpcli_bootstrap_behat_feature_context(); diff --git a/src/Context/Support.php b/src/Context/Support.php index 3e310a44..050c2847 100644 --- a/src/Context/Support.php +++ b/src/Context/Support.php @@ -200,7 +200,7 @@ protected function check_that_csv_string_contains_values( $actual_csv, $expected ); if ( $actual_row === $expected_row ) { - $expected_result++; + ++$expected_result; } } } diff --git a/src/Context/WhenStepDefinitions.php b/src/Context/WhenStepDefinitions.php index 42f430eb..a727e8c7 100644 --- a/src/Context/WhenStepDefinitions.php +++ b/src/Context/WhenStepDefinitions.php @@ -62,4 +62,3 @@ public function when_i_run_the_previous_command_again( $mode ) { list( $this->result->stdout, $this->email_sends ) = $this->wpcli_tests_capture_email_sends( $this->result->stdout ); } } - diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 9cf26389..73b76032 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -59,4 +59,3 @@ function wpcli_tests_include_config( array $config_filenames = [] ) { '.phpunit.xml.dist', ] ); - From 8626e7bc09a769f70bbad6c90efc0bb2ee04858e Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Tue, 29 Aug 2023 14:17:39 -0700 Subject: [PATCH 6/8] Ignore another sniff --- WP_CLI_CS/ruleset.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/WP_CLI_CS/ruleset.xml b/WP_CLI_CS/ruleset.xml index 1088d8b6..b04b28a6 100644 --- a/WP_CLI_CS/ruleset.xml +++ b/WP_CLI_CS/ruleset.xml @@ -81,6 +81,7 @@ + From 7660405712a252d0b7efd0f7b602fd340e1bfcc7 Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Tue, 29 Aug 2023 14:18:48 -0700 Subject: [PATCH 7/8] Update a few more sniffs --- src/Context/FeatureContext.php | 1 + src/Context/Support.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Context/FeatureContext.php b/src/Context/FeatureContext.php index 88be31ae..fab618e6 100644 --- a/src/Context/FeatureContext.php +++ b/src/Context/FeatureContext.php @@ -1231,6 +1231,7 @@ private static function log_proc_method_run_time( $key, $start_time ) { } } +// phpcs:ignore Universal.Files.SeparateFunctionsFromOO.Mixed function wp_cli_behat_env_debug( $message ) { if ( ! getenv( 'WP_CLI_TEST_DEBUG_BEHAT_ENV' ) ) { return; diff --git a/src/Context/Support.php b/src/Context/Support.php index 050c2847..43114896 100644 --- a/src/Context/Support.php +++ b/src/Context/Support.php @@ -25,14 +25,14 @@ protected function assert_not_regex( $regex, $actual ) { } protected function assert_equals( $expected, $actual ) { - // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- Deliberate loose comparison. + // phpcs:ignore Universal.Operators.StrictComparisons.LooseNotEqual -- Deliberate loose comparison. if ( $expected != $actual ) { throw new Exception( 'Actual value: ' . var_export( $actual, true ) ); } } protected function assert_not_equals( $expected, $actual ) { - // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- Deliberate loose comparison. + // phpcs:ignore Universal.Operators.StrictComparisons.LooseNotEqual -- Deliberate loose comparison. if ( $expected == $actual ) { throw new Exception( 'Actual value: ' . var_export( $actual, true ) ); } From 08e70818452afa48d448b5787802e2d3ce44e4b5 Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Tue, 29 Aug 2023 14:20:36 -0700 Subject: [PATCH 8/8] Fix one more sniff --- src/Context/Support.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Context/Support.php b/src/Context/Support.php index 43114896..6c9f3dd7 100644 --- a/src/Context/Support.php +++ b/src/Context/Support.php @@ -32,7 +32,7 @@ protected function assert_equals( $expected, $actual ) { } protected function assert_not_equals( $expected, $actual ) { - // phpcs:ignore Universal.Operators.StrictComparisons.LooseNotEqual -- Deliberate loose comparison. + // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual -- Deliberate loose comparison. if ( $expected == $actual ) { throw new Exception( 'Actual value: ' . var_export( $actual, true ) ); }