From 1a87845eb3dedb059f8c0c070a40eeda53e5b525 Mon Sep 17 00:00:00 2001 From: davidperezgar Date: Sun, 29 Sep 2024 12:02:38 +0200 Subject: [PATCH 01/48] tradermarks check with acronym allowed --- .../Checks/Plugin_Repo/Trademarks_Check.php | 37 ++++++++++++++++++- .../load.php | 16 ++++++++ .../Checker/Checks/Trademarks_Check_Tests.php | 6 +++ 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 tests/phpunit/testdata/plugins/test-trademarks-plugin-header-acronym/load.php diff --git a/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php b/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php index 16de65d2e..d092661e2 100644 --- a/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php +++ b/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php @@ -137,7 +137,8 @@ class Trademarks_Check extends Abstract_File_Check { 'wordpress', 'wordpess', 'wpress', - 'wp-', + 'wp', // it's allowed, but shows a warning. + 'wc', // it's allowed, but shows a warning. 'wp-mail-smtp-', 'yandex-', 'yahoo-', @@ -146,6 +147,18 @@ class Trademarks_Check extends Abstract_File_Check { 'you-tube-', ); + /** + * Lists of trademarks that are allowed but shows in acronym. + * + * @since n.e.x.t. + * + * @var string[] + */ + const FOR_USE_ACRONYM = array( + 'wp', + 'wc', + ); + /** * Lists of trademarks that are allowed as 'for-whatever' ONLY. * @@ -348,6 +361,17 @@ private function validate_name_has_no_trademarks( $plugin_name ) { esc_html( $plugin_name ), esc_html( trim( $check, '-' ) ) ); + } elseif ( + trim( $check, '-' ) === $check + && in_array( $check, self::FOR_USE_ACRONYM, true ) + ) { + // Trademarks that are allowed to use with Acronym. + $message = sprintf( + /* translators: 1: plugin slug, 2: found trademarked term */ + __( 'The plugin name includes a restricted term. Your plugin name - "%1$s" - contains the restricted term "%2$s" which can be used within your plugin name, unless your plugin name will not change to full name. For example: You can use WP but not WordPress.', 'plugin-check' ), + esc_html( $plugin_name ), + esc_html( trim( $check, '-' ) ) + ); } elseif ( trim( $check, '-' ) === $check ) { // Trademarks that do NOT end in "-" indicate slug cannot contain term at all. $message = sprintf( @@ -395,6 +419,17 @@ private function validate_slug_has_no_trademarks( $plugin_slug ) { esc_html( $plugin_slug ), esc_html( trim( $check, '-' ) ) ); + } elseif ( + trim( $check, '-' ) === $check + && in_array( $check, self::FOR_USE_ACRONYM, true ) + ) { + // Trademarks that are allowed to use with Acronym. + $message = sprintf( + /* translators: 1: plugin slug, 2: found trademarked term */ + __( 'The plugin slug includes a restricted term. Your plugin slug - "%1$s" - contains the restricted term "%2$s" which can be used within in your plugin slug, unless your plugin name will not change to the full name. For example: You can use WP but not WordPress.', 'plugin-check' ), + esc_html( $plugin_slug ), + esc_html( trim( $check, '-' ) ) + ); } elseif ( trim( $check, '-' ) === $check ) { // Trademarks that do NOT end in "-" indicate slug cannot contain term at all. $message = sprintf( diff --git a/tests/phpunit/testdata/plugins/test-trademarks-plugin-header-acronym/load.php b/tests/phpunit/testdata/plugins/test-trademarks-plugin-header-acronym/load.php new file mode 100644 index 000000000..ad7aa092f --- /dev/null +++ b/tests/phpunit/testdata/plugins/test-trademarks-plugin-header-acronym/load.php @@ -0,0 +1,16 @@ + array( + Trademarks_Check::TYPE_NAME, + 'test-trademarks-plugin-header-acronym/load.php', + 'load.php', + 'The plugin name includes a restricted term. Your plugin name - "WP Example String" - contains the restricted term "wp" which can be used within your plugin name, unless your plugin name will not change to full name. For example: You can use WP but not WordPress.', + ), 'Plugin headers - WooCommerce String for WooCommerce' => array( Trademarks_Check::TYPE_NAME, 'test-trademarks-plugin-header-woocommerce-string-for-woocommerce/load.php', From 5ae0f53b61cc2ebdd59879dc7ac400432b2b0630 Mon Sep 17 00:00:00 2001 From: davidperezgar Date: Sun, 29 Sep 2024 12:07:10 +0200 Subject: [PATCH 02/48] phplint --- tests/phpunit/tests/Checker/Checks/Trademarks_Check_Tests.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/tests/Checker/Checks/Trademarks_Check_Tests.php b/tests/phpunit/tests/Checker/Checks/Trademarks_Check_Tests.php index 2dd8b1903..787c721fe 100644 --- a/tests/phpunit/tests/Checker/Checks/Trademarks_Check_Tests.php +++ b/tests/phpunit/tests/Checker/Checks/Trademarks_Check_Tests.php @@ -75,7 +75,7 @@ public function data_trademarks_check() { 'load.php', 'The plugin name includes a restricted term. Your chosen plugin name - "WooCommerce Example String" - contains the restricted term "woocommerce" which cannot be used within in your plugin name, unless your plugin name ends with "for woocommerce". The term must still not appear anywhere else in your name.', ), - 'Plugin headers - WP Example String' => array( + 'Plugin headers - WP Example String' => array( Trademarks_Check::TYPE_NAME, 'test-trademarks-plugin-header-acronym/load.php', 'load.php', From 09aef008f20ad9cf588ad4234684a8944414e203 Mon Sep 17 00:00:00 2001 From: David Perez Date: Mon, 30 Sep 2024 08:17:44 +0200 Subject: [PATCH 03/48] Update includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php Co-authored-by: Nilambar Sharma --- includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php b/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php index d092661e2..f8c00d9a9 100644 --- a/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php +++ b/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php @@ -150,7 +150,7 @@ class Trademarks_Check extends Abstract_File_Check { /** * Lists of trademarks that are allowed but shows in acronym. * - * @since n.e.x.t. + * @since 1.2.0 * * @var string[] */ From 1af79deda41c6c623c8d673b7469516f1afff46e Mon Sep 17 00:00:00 2001 From: David Perez Date: Tue, 1 Oct 2024 10:41:22 +0200 Subject: [PATCH 04/48] Update includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php Co-authored-by: Pascal Birchler --- includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php b/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php index f8c00d9a9..2303b9ffd 100644 --- a/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php +++ b/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php @@ -365,7 +365,7 @@ private function validate_name_has_no_trademarks( $plugin_name ) { trim( $check, '-' ) === $check && in_array( $check, self::FOR_USE_ACRONYM, true ) ) { - // Trademarks that are allowed to use with Acronym. + // Trademarks that are allowed to use as an acronym. $message = sprintf( /* translators: 1: plugin slug, 2: found trademarked term */ __( 'The plugin name includes a restricted term. Your plugin name - "%1$s" - contains the restricted term "%2$s" which can be used within your plugin name, unless your plugin name will not change to full name. For example: You can use WP but not WordPress.', 'plugin-check' ), From 0428d7a56ed9c4240bc8029f6af5a7f4bb71d278 Mon Sep 17 00:00:00 2001 From: David Perez Date: Tue, 1 Oct 2024 10:41:33 +0200 Subject: [PATCH 05/48] Update includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php Co-authored-by: Pascal Birchler --- includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php b/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php index 2303b9ffd..953f7edec 100644 --- a/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php +++ b/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php @@ -368,7 +368,7 @@ private function validate_name_has_no_trademarks( $plugin_name ) { // Trademarks that are allowed to use as an acronym. $message = sprintf( /* translators: 1: plugin slug, 2: found trademarked term */ - __( 'The plugin name includes a restricted term. Your plugin name - "%1$s" - contains the restricted term "%2$s" which can be used within your plugin name, unless your plugin name will not change to full name. For example: You can use WP but not WordPress.', 'plugin-check' ), + __( 'The plugin name includes a restricted term. Your plugin name - "%1$s" - contains the restricted term "%2$s" which can be used , as long as you don\'t change it to the full name. For example: You can use WP but not WordPress.', 'plugin-check' ), esc_html( $plugin_name ), esc_html( trim( $check, '-' ) ) ); From c92dd13e5c70caf49501ca900a9624e86f8d7f28 Mon Sep 17 00:00:00 2001 From: David Perez Date: Tue, 1 Oct 2024 10:41:43 +0200 Subject: [PATCH 06/48] Update includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php Co-authored-by: Pascal Birchler --- includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php b/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php index 953f7edec..35f064d52 100644 --- a/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php +++ b/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php @@ -426,7 +426,7 @@ private function validate_slug_has_no_trademarks( $plugin_slug ) { // Trademarks that are allowed to use with Acronym. $message = sprintf( /* translators: 1: plugin slug, 2: found trademarked term */ - __( 'The plugin slug includes a restricted term. Your plugin slug - "%1$s" - contains the restricted term "%2$s" which can be used within in your plugin slug, unless your plugin name will not change to the full name. For example: You can use WP but not WordPress.', 'plugin-check' ), + __( 'The plugin slug includes a restricted term. Your plugin slug - "%1$s" - contains the restricted term "%2$s" which can be used within the plugin slug, as long as you don\'t use the full name in the plugin name. For example: You can use WP but not WordPress.', 'plugin-check' ), esc_html( $plugin_slug ), esc_html( trim( $check, '-' ) ) ); From 5a73db811c96ec8d2d39cce8ff5915f2ce8c39f6 Mon Sep 17 00:00:00 2001 From: David Perez Date: Tue, 1 Oct 2024 10:42:03 +0200 Subject: [PATCH 07/48] Update tests/phpunit/tests/Checker/Checks/Trademarks_Check_Tests.php Co-authored-by: Pascal Birchler --- tests/phpunit/tests/Checker/Checks/Trademarks_Check_Tests.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/tests/Checker/Checks/Trademarks_Check_Tests.php b/tests/phpunit/tests/Checker/Checks/Trademarks_Check_Tests.php index 787c721fe..2e8797af0 100644 --- a/tests/phpunit/tests/Checker/Checks/Trademarks_Check_Tests.php +++ b/tests/phpunit/tests/Checker/Checks/Trademarks_Check_Tests.php @@ -79,7 +79,7 @@ public function data_trademarks_check() { Trademarks_Check::TYPE_NAME, 'test-trademarks-plugin-header-acronym/load.php', 'load.php', - 'The plugin name includes a restricted term. Your plugin name - "WP Example String" - contains the restricted term "wp" which can be used within your plugin name, unless your plugin name will not change to full name. For example: You can use WP but not WordPress.', + 'The plugin name includes a restricted term. Your plugin name - "%1$s" - contains the restricted term "%2$s" which can be used , as long as you don\'t change it to the full name. For example: You can use WP but not WordPress.', ), 'Plugin headers - WooCommerce String for WooCommerce' => array( Trademarks_Check::TYPE_NAME, From a323a1eabdd836105e6471f9e4740133b5d1ba3c Mon Sep 17 00:00:00 2001 From: David Perez Date: Tue, 1 Oct 2024 10:43:21 +0200 Subject: [PATCH 08/48] Update includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php Co-authored-by: Pascal Birchler --- includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php b/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php index 35f064d52..cfd2f37b5 100644 --- a/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php +++ b/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php @@ -148,7 +148,7 @@ class Trademarks_Check extends Abstract_File_Check { ); /** - * Lists of trademarks that are allowed but shows in acronym. + * Lists of allowed acronyms of trademarks. * * @since 1.2.0 * From b21361d37957522463acbfb335fadccba0fe5f13 Mon Sep 17 00:00:00 2001 From: davidperezgar Date: Tue, 1 Oct 2024 10:45:02 +0200 Subject: [PATCH 09/48] changed name constant --- includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php b/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php index cfd2f37b5..296cb27e2 100644 --- a/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php +++ b/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php @@ -154,7 +154,7 @@ class Trademarks_Check extends Abstract_File_Check { * * @var string[] */ - const FOR_USE_ACRONYM = array( + const ALLOWED_ACRONYMS = array( 'wp', 'wc', ); @@ -363,7 +363,7 @@ private function validate_name_has_no_trademarks( $plugin_name ) { ); } elseif ( trim( $check, '-' ) === $check - && in_array( $check, self::FOR_USE_ACRONYM, true ) + && in_array( $check, self::ALLOWED_ACRONYMS, true ) ) { // Trademarks that are allowed to use as an acronym. $message = sprintf( @@ -421,7 +421,7 @@ private function validate_slug_has_no_trademarks( $plugin_slug ) { ); } elseif ( trim( $check, '-' ) === $check - && in_array( $check, self::FOR_USE_ACRONYM, true ) + && in_array( $check, self::ALLOWED_ACRONYMS, true ) ) { // Trademarks that are allowed to use with Acronym. $message = sprintf( From 9c107c2537ab7a86bb4792fb4963db7c42d55bf6 Mon Sep 17 00:00:00 2001 From: davidperezgar Date: Tue, 1 Oct 2024 22:13:50 +0200 Subject: [PATCH 10/48] fix tests --- tests/phpunit/tests/Checker/Checks/Trademarks_Check_Tests.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/tests/Checker/Checks/Trademarks_Check_Tests.php b/tests/phpunit/tests/Checker/Checks/Trademarks_Check_Tests.php index 2e8797af0..1470b2d3b 100644 --- a/tests/phpunit/tests/Checker/Checks/Trademarks_Check_Tests.php +++ b/tests/phpunit/tests/Checker/Checks/Trademarks_Check_Tests.php @@ -79,7 +79,7 @@ public function data_trademarks_check() { Trademarks_Check::TYPE_NAME, 'test-trademarks-plugin-header-acronym/load.php', 'load.php', - 'The plugin name includes a restricted term. Your plugin name - "%1$s" - contains the restricted term "%2$s" which can be used , as long as you don\'t change it to the full name. For example: You can use WP but not WordPress.', + 'The plugin name includes a restricted term. Your plugin name - "WP Example String" - contains the restricted term "wp" which can be used , as long as you don\'t change it to the full name. For example: You can use WP but not WordPress.', ), 'Plugin headers - WooCommerce String for WooCommerce' => array( Trademarks_Check::TYPE_NAME, From 0c49f42c705791e71519cc7028a2e3746703ba85 Mon Sep 17 00:00:00 2001 From: davidperezgar Date: Thu, 3 Oct 2024 22:42:57 +0200 Subject: [PATCH 11/48] convert errors less severity to warnings --- includes/CLI/Plugin_Check_Command.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/includes/CLI/Plugin_Check_Command.php b/includes/CLI/Plugin_Check_Command.php index 05f93faad..f01feb89a 100644 --- a/includes/CLI/Plugin_Check_Command.php +++ b/includes/CLI/Plugin_Check_Command.php @@ -678,6 +678,22 @@ function ( $item ) use ( $error_severity ) { } ); + // Converts errors to warnings if severity is less than the error severity level. + $errors_warning = array_filter( + $results, + function ( $item ) use ( $error_severity ) { + return ( 'ERROR' === $item['type'] && $item['severity'] < $error_severity ); + } + ); + + $errors_warning = array_map( + function ( $item ) { + $item['type'] = 'WARNING'; + return $item; + }, + $errors_warning + ); + $warnings = array_filter( $results, function ( $item ) use ( $warning_severity ) { @@ -685,6 +701,6 @@ function ( $item ) use ( $warning_severity ) { } ); - return array_merge( $errors, $warnings ); + return array_merge( $errors, $errors_warning, $warnings ); } } From 42ad9f60aa5d45e6b05395e740a3c5bf6303db04 Mon Sep 17 00:00:00 2001 From: davidperezgar Date: Thu, 3 Oct 2024 22:57:10 +0200 Subject: [PATCH 12/48] updated behat tests --- .../features/plugin-check-severity.feature | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/tests/behat/features/plugin-check-severity.feature b/tests/behat/features/plugin-check-severity.feature index 38323ae62..1e3f6113d 100644 --- a/tests/behat/features/plugin-check-severity.feature +++ b/tests/behat/features/plugin-check-severity.feature @@ -125,7 +125,7 @@ Feature: Test that the severity level in plugin check works. """ And STDOUT should not contain: """ - WordPress.WP.AlternativeFunctions.rand_mt_rand,ERROR,5 + WordPress.WP.AlternativeFunctions.rand_mt_rand,WARNING,5 """ And STDOUT should contain: """ @@ -151,7 +151,7 @@ Feature: Test that the severity level in plugin check works. """ And STDOUT should not contain: """ - WordPress.WP.AlternativeFunctions.rand_mt_rand,ERROR,5 + WordPress.WP.AlternativeFunctions.rand_mt_rand,WARNING,5 """ And STDOUT should contain: """ @@ -193,4 +193,27 @@ Feature: Test that the severity level in plugin check works. """ When I run the WP-CLI command `plugin check foo-bar-wp --format=csv --fields=code,type,severity --severity=10` - Then STDOUT should be empty + Then STDOUT should contain: + """ + allow_unfiltered_uploads_detected,WARNING,7 + """ + And STDOUT should contain: + """ + obfuscated_code_detected,WARNING,6 + """ + And STDOUT should contain: + """ + WordPress.WP.AlternativeFunctions.rand_mt_rand,WARNING,5 + """ + And STDOUT should contain: + """ + outdated_tested_upto_header,WARNING,7 + """ + And STDOUT should contain: + """ + default_readme_text,WARNING,7 + """ + And STDOUT should not contain: + """ + upgrade_notice_limit,WARNING,5 + """ From 56c77f7f2e8072c73abcdd1ed45b65edbc88db21 Mon Sep 17 00:00:00 2001 From: davidperezgar Date: Thu, 3 Oct 2024 23:04:12 +0200 Subject: [PATCH 13/48] updated tests --- tests/behat/features/plugin-check-severity.feature | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/behat/features/plugin-check-severity.feature b/tests/behat/features/plugin-check-severity.feature index 1e3f6113d..8a917fe5d 100644 --- a/tests/behat/features/plugin-check-severity.feature +++ b/tests/behat/features/plugin-check-severity.feature @@ -123,7 +123,7 @@ Feature: Test that the severity level in plugin check works. """ obfuscated_code_detected,ERROR,6 """ - And STDOUT should not contain: + And STDOUT should contain: """ WordPress.WP.AlternativeFunctions.rand_mt_rand,WARNING,5 """ @@ -149,7 +149,7 @@ Feature: Test that the severity level in plugin check works. """ obfuscated_code_detected,ERROR,6 """ - And STDOUT should not contain: + And STDOUT should contain: """ WordPress.WP.AlternativeFunctions.rand_mt_rand,WARNING,5 """ @@ -209,7 +209,7 @@ Feature: Test that the severity level in plugin check works. """ outdated_tested_upto_header,WARNING,7 """ - And STDOUT should contain: + And STDOUT should not contain: """ default_readme_text,WARNING,7 """ From 398ab67ed51e56db6fe14cb8ac80ad0ce561afbb Mon Sep 17 00:00:00 2001 From: davidperezgar Date: Thu, 10 Oct 2024 22:50:16 +0200 Subject: [PATCH 14/48] changes to show errors less severity --- includes/CLI/Plugin_Check_Command.php | 62 +++++++++++++++------------ 1 file changed, 35 insertions(+), 27 deletions(-) diff --git a/includes/CLI/Plugin_Check_Command.php b/includes/CLI/Plugin_Check_Command.php index f01feb89a..98baaf7fd 100644 --- a/includes/CLI/Plugin_Check_Command.php +++ b/includes/CLI/Plugin_Check_Command.php @@ -113,6 +113,9 @@ public function __construct( Plugin_Context $plugin_context ) { * [--warning-severity=] * : Warning severity level. * + * [--include-error-severity] + * : Include less level of severity issues as warning. + * * [--slug=] * : Slug to override the default. * @@ -140,15 +143,16 @@ public function check( $args, $assoc_args ) { $options = $this->get_options( $assoc_args, array( - 'checks' => '', - 'format' => 'table', - 'ignore-warnings' => false, - 'ignore-errors' => false, - 'include-experimental' => false, - 'severity' => '', - 'error-severity' => '', - 'warning-severity' => '', - 'slug' => '', + 'checks' => '', + 'format' => 'table', + 'ignore-warnings' => false, + 'ignore-errors' => false, + 'include-experimental' => false, + 'severity' => '', + 'error-severity' => '', + 'warning-severity' => '', + 'include-error-severity' => '', + 'slug' => '', ) ); @@ -256,8 +260,9 @@ static function ( $dirs ) use ( $excluded_files ) { $formatter = $this->get_formatter( $assoc_args, $default_fields ); // Severity. - $error_severity = ! empty( $options['error-severity'] ) ? $options['error-severity'] : $options['severity']; - $warning_severity = ! empty( $options['warning-severity'] ) ? $options['warning-severity'] : $options['severity']; + $error_severity = ! empty( $options['error-severity'] ) ? $options['error-severity'] : $options['severity']; + $warning_severity = ! empty( $options['warning-severity'] ) ? $options['warning-severity'] : $options['severity']; + $show_error_severity = ! empty( $options['include-error-severity'] ) ? true : false; // Print the formatted results. // Go over all files with errors first and print them, combined with any warnings in the same file. @@ -270,7 +275,7 @@ static function ( $dirs ) use ( $excluded_files ) { $file_results = $this->flatten_file_results( $file_errors, $file_warnings ); if ( '' !== $error_severity || '' !== $warning_severity ) { - $file_results = $this->get_filtered_results_by_severity( $file_results, intval( $error_severity ), intval( $warning_severity ) ); + $file_results = $this->get_filtered_results_by_severity( $file_results, intval( $error_severity ), intval( $warning_severity ), $show_error_severity ); } if ( ! empty( $file_results ) ) { @@ -670,7 +675,7 @@ private function has_runtime_check( array $checks ) { * @param int $warning_severity Warning severity level. * @return array Filtered results. */ - private function get_filtered_results_by_severity( $results, $error_severity, $warning_severity ) { + private function get_filtered_results_by_severity( $results, $error_severity, $warning_severity, $show_error_severity = false ) { $errors = array_filter( $results, function ( $item ) use ( $error_severity ) { @@ -679,20 +684,23 @@ function ( $item ) use ( $error_severity ) { ); // Converts errors to warnings if severity is less than the error severity level. - $errors_warning = array_filter( - $results, - function ( $item ) use ( $error_severity ) { - return ( 'ERROR' === $item['type'] && $item['severity'] < $error_severity ); - } - ); - - $errors_warning = array_map( - function ( $item ) { - $item['type'] = 'WARNING'; - return $item; - }, - $errors_warning - ); + $errors_warning = array(); + if ( $show_error_severity ) { + $errors_warning = array_filter( + $results, + function ( $item ) use ( $error_severity ) { + return ( 'ERROR' === $item['type'] && $item['severity'] < $error_severity ); + } + ); + + $errors_warning = array_map( + function ( $item ) { + $item['type'] = 'WARNING'; + return $item; + }, + $errors_warning + ); + } $warnings = array_filter( $results, From 9fed972cf968c401686640d7f0af6e436a8507f0 Mon Sep 17 00:00:00 2001 From: davidperezgar Date: Thu, 10 Oct 2024 22:56:50 +0200 Subject: [PATCH 15/48] phptests fixes --- includes/CLI/Plugin_Check_Command.php | 3 +- .../features/plugin-check-severity.feature | 33 +++---------------- 2 files changed, 7 insertions(+), 29 deletions(-) diff --git a/includes/CLI/Plugin_Check_Command.php b/includes/CLI/Plugin_Check_Command.php index 98baaf7fd..4639be4b6 100644 --- a/includes/CLI/Plugin_Check_Command.php +++ b/includes/CLI/Plugin_Check_Command.php @@ -673,6 +673,7 @@ private function has_runtime_check( array $checks ) { * @param array $results Check results. * @param int $error_severity Error severity level. * @param int $warning_severity Warning severity level. + * @param bool $show_error_severity Show error severity as warning. * @return array Filtered results. */ private function get_filtered_results_by_severity( $results, $error_severity, $warning_severity, $show_error_severity = false ) { @@ -692,7 +693,7 @@ function ( $item ) use ( $error_severity ) { return ( 'ERROR' === $item['type'] && $item['severity'] < $error_severity ); } ); - + $errors_warning = array_map( function ( $item ) { $item['type'] = 'WARNING'; diff --git a/tests/behat/features/plugin-check-severity.feature b/tests/behat/features/plugin-check-severity.feature index 8a917fe5d..46b0efde2 100644 --- a/tests/behat/features/plugin-check-severity.feature +++ b/tests/behat/features/plugin-check-severity.feature @@ -123,9 +123,9 @@ Feature: Test that the severity level in plugin check works. """ obfuscated_code_detected,ERROR,6 """ - And STDOUT should contain: + And STDOUT should not contain: """ - WordPress.WP.AlternativeFunctions.rand_mt_rand,WARNING,5 + WordPress.WP.AlternativeFunctions.rand_mt_rand,ERROR,5 """ And STDOUT should contain: """ @@ -149,9 +149,9 @@ Feature: Test that the severity level in plugin check works. """ obfuscated_code_detected,ERROR,6 """ - And STDOUT should contain: + And STDOUT should not contain: """ - WordPress.WP.AlternativeFunctions.rand_mt_rand,WARNING,5 + WordPress.WP.AlternativeFunctions.rand_mt_rand,ERROR,5 """ And STDOUT should contain: """ @@ -193,27 +193,4 @@ Feature: Test that the severity level in plugin check works. """ When I run the WP-CLI command `plugin check foo-bar-wp --format=csv --fields=code,type,severity --severity=10` - Then STDOUT should contain: - """ - allow_unfiltered_uploads_detected,WARNING,7 - """ - And STDOUT should contain: - """ - obfuscated_code_detected,WARNING,6 - """ - And STDOUT should contain: - """ - WordPress.WP.AlternativeFunctions.rand_mt_rand,WARNING,5 - """ - And STDOUT should contain: - """ - outdated_tested_upto_header,WARNING,7 - """ - And STDOUT should not contain: - """ - default_readme_text,WARNING,7 - """ - And STDOUT should not contain: - """ - upgrade_notice_limit,WARNING,5 - """ + Then STDOUT should be empty \ No newline at end of file From 2526c947bf57fec3fb4d154cf083d35f4123f111 Mon Sep 17 00:00:00 2001 From: davidperezgar Date: Fri, 11 Oct 2024 19:04:15 +0200 Subject: [PATCH 16/48] added behat testing --- tests/behat/features/plugin-check-severity.feature | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/behat/features/plugin-check-severity.feature b/tests/behat/features/plugin-check-severity.feature index 46b0efde2..0343141b9 100644 --- a/tests/behat/features/plugin-check-severity.feature +++ b/tests/behat/features/plugin-check-severity.feature @@ -192,5 +192,19 @@ Feature: Test that the severity level in plugin check works. upgrade_notice_limit,WARNING,5 """ + When I run the WP-CLI command `plugin check foo-bar-wp --format=csv --fields=code,type,severity --error-severity=7 --include-error-severity` + Then STDOUT should contain: + """ + allow_unfiltered_uploads_detected,ERROR,7 + """ + And STDOUT should contain: + """ + default_readme_text,WARNING,7 + """ + And STDOUT should contain: + """ + upgrade_notice_limit,WARNING,5 + """ + When I run the WP-CLI command `plugin check foo-bar-wp --format=csv --fields=code,type,severity --severity=10` Then STDOUT should be empty \ No newline at end of file From 5437ba4eb30e14fb99b734cbcfee15739733d537 Mon Sep 17 00:00:00 2001 From: davidperezgar Date: Fri, 11 Oct 2024 19:11:59 +0200 Subject: [PATCH 17/48] phpmd test fixed --- includes/CLI/Plugin_Check_Command.php | 81 +++++++++++++++++---------- 1 file changed, 52 insertions(+), 29 deletions(-) diff --git a/includes/CLI/Plugin_Check_Command.php b/includes/CLI/Plugin_Check_Command.php index 4639be4b6..d5b7eb69f 100644 --- a/includes/CLI/Plugin_Check_Command.php +++ b/includes/CLI/Plugin_Check_Command.php @@ -275,7 +275,7 @@ static function ( $dirs ) use ( $excluded_files ) { $file_results = $this->flatten_file_results( $file_errors, $file_warnings ); if ( '' !== $error_severity || '' !== $warning_severity ) { - $file_results = $this->get_filtered_results_by_severity( $file_results, intval( $error_severity ), intval( $warning_severity ), $show_error_severity ); + $file_results = $this->get_filtered_results( $file_results, intval( $error_severity ), intval( $warning_severity ), $show_error_severity ); } if ( ! empty( $file_results ) ) { @@ -288,7 +288,7 @@ static function ( $dirs ) use ( $excluded_files ) { $file_results = $this->flatten_file_results( array(), $file_warnings ); if ( '' !== $error_severity || '' !== $warning_severity ) { - $file_results = $this->get_filtered_results_by_severity( $file_results, intval( $error_severity ), intval( $warning_severity ) ); + $file_results = $this->get_filtered_results( $file_results, intval( $error_severity ), intval( $warning_severity ) ); } if ( ! empty( $file_results ) ) { @@ -666,9 +666,7 @@ private function has_runtime_check( array $checks ) { } /** - * Returns check results filtered by severity level. - * - * @since 1.1.0 + * Returns check results filtered by severity level, with optional error-to-warning conversion. * * @param array $results Check results. * @param int $error_severity Error severity level. @@ -676,40 +674,65 @@ private function has_runtime_check( array $checks ) { * @param bool $show_error_severity Show error severity as warning. * @return array Filtered results. */ - private function get_filtered_results_by_severity( $results, $error_severity, $warning_severity, $show_error_severity = false ) { + private function get_filtered_results( $results, $error_severity, $warning_severity, $show_error_severity = false ) { + // First, get the filtered errors and warnings. + $filtered_results = $this->get_filtered_results_by_severity( $results, $error_severity, $warning_severity ); + + // If requested, convert certain errors to warnings. + if ( $show_error_severity ) { + $errors_as_warnings = $this->convert_errors_to_warnings( $results, $error_severity ); + return array_merge( $filtered_results, $errors_as_warnings ); + } + + return $filtered_results; + } + /** + * Returns check results filtered by severity level. + * + * @param array $results Check results. + * @param int $error_severity Error severity level. + * @param int $warning_severity Warning severity level. + * @return array Filtered results. + */ + private function get_filtered_results_by_severity( $results, $error_severity, $warning_severity ) { $errors = array_filter( - $results, - function ( $item ) use ( $error_severity ) { - return ( 'ERROR' === $item['type'] && $item['severity'] >= $error_severity ); - } + $results, + function ( $item ) use ( $error_severity ) { + return ( 'ERROR' === $item['type'] && $item['severity'] >= $error_severity ); + } ); - // Converts errors to warnings if severity is less than the error severity level. - $errors_warning = array(); - if ( $show_error_severity ) { - $errors_warning = array_filter( + $warnings = array_filter( + $results, + function ( $item ) use ( $warning_severity ) { + return ( 'WARNING' === $item['type'] && $item['severity'] >= $warning_severity ); + } + ); + + return array_merge( $errors, $warnings ); + } + /** + * Converts errors below the severity threshold to warnings. + * + * @param array $results Check results. + * @param int $error_severity Error severity level threshold. + * @return array Converted results where applicable. + */ + private function convert_errors_to_warnings( $results, $error_severity ) { + $errors_warning = array_filter( $results, function ( $item ) use ( $error_severity ) { - return ( 'ERROR' === $item['type'] && $item['severity'] < $error_severity ); + return ( 'ERROR' === $item['type'] && $item['severity'] < $error_severity ); } - ); + ); - $errors_warning = array_map( + return array_map( function ( $item ) { - $item['type'] = 'WARNING'; - return $item; + $item['type'] = 'WARNING'; + return $item; }, $errors_warning - ); - } - - $warnings = array_filter( - $results, - function ( $item ) use ( $warning_severity ) { - return ( 'WARNING' === $item['type'] && $item['severity'] >= $warning_severity ); - } ); - - return array_merge( $errors, $errors_warning, $warnings ); } + } From a76a7e53729257c714840e0a54196d0dd25d8c06 Mon Sep 17 00:00:00 2001 From: davidperezgar Date: Fri, 11 Oct 2024 19:18:42 +0200 Subject: [PATCH 18/48] fix phplint --- includes/CLI/Plugin_Check_Command.php | 35 +++++++++++++-------------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/includes/CLI/Plugin_Check_Command.php b/includes/CLI/Plugin_Check_Command.php index d5b7eb69f..b40f8e150 100644 --- a/includes/CLI/Plugin_Check_Command.php +++ b/includes/CLI/Plugin_Check_Command.php @@ -696,17 +696,17 @@ private function get_filtered_results( $results, $error_severity, $warning_sever */ private function get_filtered_results_by_severity( $results, $error_severity, $warning_severity ) { $errors = array_filter( - $results, - function ( $item ) use ( $error_severity ) { - return ( 'ERROR' === $item['type'] && $item['severity'] >= $error_severity ); - } + $results, + function ( $item ) use ( $error_severity ) { + return ( 'ERROR' === $item['type'] && $item['severity'] >= $error_severity ); + } ); $warnings = array_filter( - $results, - function ( $item ) use ( $warning_severity ) { - return ( 'WARNING' === $item['type'] && $item['severity'] >= $warning_severity ); - } + $results, + function ( $item ) use ( $warning_severity ) { + return ( 'WARNING' === $item['type'] && $item['severity'] >= $warning_severity ); + } ); return array_merge( $errors, $warnings ); @@ -720,19 +720,18 @@ function ( $item ) use ( $warning_severity ) { */ private function convert_errors_to_warnings( $results, $error_severity ) { $errors_warning = array_filter( - $results, - function ( $item ) use ( $error_severity ) { - return ( 'ERROR' === $item['type'] && $item['severity'] < $error_severity ); - } + $results, + function ( $item ) use ( $error_severity ) { + return ( 'ERROR' === $item['type'] && $item['severity'] < $error_severity ); + } ); return array_map( - function ( $item ) { - $item['type'] = 'WARNING'; - return $item; - }, - $errors_warning + function ( $item ) { + $item['type'] = 'WARNING'; + return $item; + }, + $errors_warning ); } - } From 3984d64e17e37faae028b836a59db29b85b4c9a4 Mon Sep 17 00:00:00 2001 From: davidperezgar Date: Sat, 12 Oct 2024 13:12:06 +0200 Subject: [PATCH 19/48] fix phpmd test --- includes/CLI/Plugin_Check_Command.php | 61 ++++++++++++--------------- 1 file changed, 26 insertions(+), 35 deletions(-) diff --git a/includes/CLI/Plugin_Check_Command.php b/includes/CLI/Plugin_Check_Command.php index b40f8e150..ca2087877 100644 --- a/includes/CLI/Plugin_Check_Command.php +++ b/includes/CLI/Plugin_Check_Command.php @@ -275,7 +275,11 @@ static function ( $dirs ) use ( $excluded_files ) { $file_results = $this->flatten_file_results( $file_errors, $file_warnings ); if ( '' !== $error_severity || '' !== $warning_severity ) { - $file_results = $this->get_filtered_results( $file_results, intval( $error_severity ), intval( $warning_severity ), $show_error_severity ); + $file_results = $this->get_filtered_results_by_severity( $file_results, intval( $error_severity ), intval( $warning_severity ) ); + if ( $show_error_severity ) { + $file_warning_results = $this->convert_filtered_errors_by_severity( $file_results, intval( $error_severity ) ); + $file_results = array_merge( $file_results, $file_warning_results ); + } } if ( ! empty( $file_results ) ) { @@ -288,7 +292,7 @@ static function ( $dirs ) use ( $excluded_files ) { $file_results = $this->flatten_file_results( array(), $file_warnings ); if ( '' !== $error_severity || '' !== $warning_severity ) { - $file_results = $this->get_filtered_results( $file_results, intval( $error_severity ), intval( $warning_severity ) ); + $file_results = $this->get_filtered_results_by_severity( $file_results, intval( $error_severity ), intval( $warning_severity ) ); } if ( ! empty( $file_results ) ) { @@ -665,30 +669,11 @@ private function has_runtime_check( array $checks ) { return false; } - /** - * Returns check results filtered by severity level, with optional error-to-warning conversion. - * - * @param array $results Check results. - * @param int $error_severity Error severity level. - * @param int $warning_severity Warning severity level. - * @param bool $show_error_severity Show error severity as warning. - * @return array Filtered results. - */ - private function get_filtered_results( $results, $error_severity, $warning_severity, $show_error_severity = false ) { - // First, get the filtered errors and warnings. - $filtered_results = $this->get_filtered_results_by_severity( $results, $error_severity, $warning_severity ); - - // If requested, convert certain errors to warnings. - if ( $show_error_severity ) { - $errors_as_warnings = $this->convert_errors_to_warnings( $results, $error_severity ); - return array_merge( $filtered_results, $errors_as_warnings ); - } - - return $filtered_results; - } /** * Returns check results filtered by severity level. * + * @since 1.1.0 + * * @param array $results Check results. * @param int $error_severity Error severity level. * @param int $warning_severity Warning severity level. @@ -698,40 +683,46 @@ private function get_filtered_results_by_severity( $results, $error_severity, $w $errors = array_filter( $results, function ( $item ) use ( $error_severity ) { - return ( 'ERROR' === $item['type'] && $item['severity'] >= $error_severity ); + return ( 'ERROR' === $item['type'] && $item['severity'] >= $error_severity ); } ); $warnings = array_filter( $results, function ( $item ) use ( $warning_severity ) { - return ( 'WARNING' === $item['type'] && $item['severity'] >= $warning_severity ); + return ( 'WARNING' === $item['type'] && $item['severity'] >= $warning_severity ); } ); return array_merge( $errors, $warnings ); } + /** - * Converts errors below the severity threshold to warnings. + * Returns check results filtered by severity level. + * + * @since 1.1.0 * - * @param array $results Check results. - * @param int $error_severity Error severity level threshold. - * @return array Converted results where applicable. + * @param array $results Check results. + * @param int $error_severity Error severity level. + * @param int $warning_severity Warning severity level. + * @return array Filtered results. */ - private function convert_errors_to_warnings( $results, $error_severity ) { + private function convert_filtered_errors_by_severity( $results, $error_severity ) { $errors_warning = array_filter( $results, function ( $item ) use ( $error_severity ) { - return ( 'ERROR' === $item['type'] && $item['severity'] < $error_severity ); + return ( 'ERROR' === $item['type'] && $item['severity'] < $error_severity ); } ); - return array_map( + $errors_warning = array_map( function ( $item ) { - $item['type'] = 'WARNING'; - return $item; + $item['type'] = 'WARNING'; + return $item; }, $errors_warning ); + + return $errors_warning; } -} +} \ No newline at end of file From 9342ddaec59425cc3fcd279978cc42b78041b14b Mon Sep 17 00:00:00 2001 From: davidperezgar Date: Sat, 12 Oct 2024 13:14:41 +0200 Subject: [PATCH 20/48] fix phplint --- includes/CLI/Plugin_Check_Command.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/includes/CLI/Plugin_Check_Command.php b/includes/CLI/Plugin_Check_Command.php index ca2087877..99f38c95b 100644 --- a/includes/CLI/Plugin_Check_Command.php +++ b/includes/CLI/Plugin_Check_Command.php @@ -704,7 +704,6 @@ function ( $item ) use ( $warning_severity ) { * * @param array $results Check results. * @param int $error_severity Error severity level. - * @param int $warning_severity Warning severity level. * @return array Filtered results. */ private function convert_filtered_errors_by_severity( $results, $error_severity ) { @@ -725,4 +724,4 @@ function ( $item ) { return $errors_warning; } -} \ No newline at end of file +} From 9886683ae40ef8b4ff34edf68f1b86d4bb750b67 Mon Sep 17 00:00:00 2001 From: davidperezgar Date: Wed, 16 Oct 2024 21:15:32 +0200 Subject: [PATCH 21/48] changed as commented --- includes/CLI/Plugin_Check_Command.php | 79 ++++++------------- .../features/plugin-check-severity.feature | 4 +- 2 files changed, 28 insertions(+), 55 deletions(-) diff --git a/includes/CLI/Plugin_Check_Command.php b/includes/CLI/Plugin_Check_Command.php index 99f38c95b..e9cf63ff9 100644 --- a/includes/CLI/Plugin_Check_Command.php +++ b/includes/CLI/Plugin_Check_Command.php @@ -113,7 +113,7 @@ public function __construct( Plugin_Context $plugin_context ) { * [--warning-severity=] * : Warning severity level. * - * [--include-error-severity] + * [--include-low-severity-errors] * : Include less level of severity issues as warning. * * [--slug=] @@ -143,16 +143,16 @@ public function check( $args, $assoc_args ) { $options = $this->get_options( $assoc_args, array( - 'checks' => '', - 'format' => 'table', - 'ignore-warnings' => false, - 'ignore-errors' => false, - 'include-experimental' => false, - 'severity' => '', - 'error-severity' => '', - 'warning-severity' => '', - 'include-error-severity' => '', - 'slug' => '', + 'checks' => '', + 'format' => 'table', + 'ignore-warnings' => false, + 'ignore-errors' => false, + 'include-experimental' => false, + 'severity' => '', + 'error-severity' => '', + 'warning-severity' => '', + 'include-low-severity-errors' => '', + 'slug' => '', ) ); @@ -260,9 +260,9 @@ static function ( $dirs ) use ( $excluded_files ) { $formatter = $this->get_formatter( $assoc_args, $default_fields ); // Severity. - $error_severity = ! empty( $options['error-severity'] ) ? $options['error-severity'] : $options['severity']; - $warning_severity = ! empty( $options['warning-severity'] ) ? $options['warning-severity'] : $options['severity']; - $show_error_severity = ! empty( $options['include-error-severity'] ) ? true : false; + $error_severity = ! empty( $options['error-severity'] ) ? $options['error-severity'] : $options['severity']; + $warning_severity = ! empty( $options['warning-severity'] ) ? $options['warning-severity'] : $options['severity']; + $include_low_severity_errors = ! empty( $options['include-low-severity-errors'] ) ? true : false; // Print the formatted results. // Go over all files with errors first and print them, combined with any warnings in the same file. @@ -275,11 +275,7 @@ static function ( $dirs ) use ( $excluded_files ) { $file_results = $this->flatten_file_results( $file_errors, $file_warnings ); if ( '' !== $error_severity || '' !== $warning_severity ) { - $file_results = $this->get_filtered_results_by_severity( $file_results, intval( $error_severity ), intval( $warning_severity ) ); - if ( $show_error_severity ) { - $file_warning_results = $this->convert_filtered_errors_by_severity( $file_results, intval( $error_severity ) ); - $file_results = array_merge( $file_results, $file_warning_results ); - } + $file_results = $this->get_filtered_results_by_severity( $file_results, intval( $error_severity ), intval( $warning_severity ), $include_low_severity_errors ); } if ( ! empty( $file_results ) ) { @@ -677,15 +673,20 @@ private function has_runtime_check( array $checks ) { * @param array $results Check results. * @param int $error_severity Error severity level. * @param int $warning_severity Warning severity level. + * @param bool $include_low_severity_errors Include less level of severity issues as warning. * @return array Filtered results. */ - private function get_filtered_results_by_severity( $results, $error_severity, $warning_severity ) { - $errors = array_filter( - $results, - function ( $item ) use ( $error_severity ) { - return ( 'ERROR' === $item['type'] && $item['severity'] >= $error_severity ); + private function get_filtered_results_by_severity( $results, $error_severity, $warning_severity, $include_low_severity_errors = false ) { + $errors = array(); + foreach ( $results as $item ) { + if ( 'ERROR' === $item['type'] && $item['severity'] >= $error_severity ) { + $errors[] = $item; + } elseif ( $include_low_severity_errors && $item['severity'] < $error_severity ) { + $item['type'] = 'WARNING'; + $item['severity'] = 10; + $errors[] = $item; } - ); + } $warnings = array_filter( $results, @@ -696,32 +697,4 @@ function ( $item ) use ( $warning_severity ) { return array_merge( $errors, $warnings ); } - - /** - * Returns check results filtered by severity level. - * - * @since 1.1.0 - * - * @param array $results Check results. - * @param int $error_severity Error severity level. - * @return array Filtered results. - */ - private function convert_filtered_errors_by_severity( $results, $error_severity ) { - $errors_warning = array_filter( - $results, - function ( $item ) use ( $error_severity ) { - return ( 'ERROR' === $item['type'] && $item['severity'] < $error_severity ); - } - ); - - $errors_warning = array_map( - function ( $item ) { - $item['type'] = 'WARNING'; - return $item; - }, - $errors_warning - ); - - return $errors_warning; - } } diff --git a/tests/behat/features/plugin-check-severity.feature b/tests/behat/features/plugin-check-severity.feature index 0343141b9..91017f91d 100644 --- a/tests/behat/features/plugin-check-severity.feature +++ b/tests/behat/features/plugin-check-severity.feature @@ -192,7 +192,7 @@ Feature: Test that the severity level in plugin check works. upgrade_notice_limit,WARNING,5 """ - When I run the WP-CLI command `plugin check foo-bar-wp --format=csv --fields=code,type,severity --error-severity=7 --include-error-severity` + When I run the WP-CLI command `plugin check foo-bar-wp --format=csv --fields=code,type,severity --error-severity=7 --include-low-severity-errors` Then STDOUT should contain: """ allow_unfiltered_uploads_detected,ERROR,7 @@ -203,7 +203,7 @@ Feature: Test that the severity level in plugin check works. """ And STDOUT should contain: """ - upgrade_notice_limit,WARNING,5 + upgrade_notice_limit,WARNING,10 """ When I run the WP-CLI command `plugin check foo-bar-wp --format=csv --fields=code,type,severity --severity=10` From 68834e49496ed071b2741f16c1b74051c51f2915 Mon Sep 17 00:00:00 2001 From: davidperezgar Date: Wed, 16 Oct 2024 21:17:09 +0200 Subject: [PATCH 22/48] new line --- tests/behat/features/plugin-check-severity.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/behat/features/plugin-check-severity.feature b/tests/behat/features/plugin-check-severity.feature index 91017f91d..0f6494881 100644 --- a/tests/behat/features/plugin-check-severity.feature +++ b/tests/behat/features/plugin-check-severity.feature @@ -207,4 +207,4 @@ Feature: Test that the severity level in plugin check works. """ When I run the WP-CLI command `plugin check foo-bar-wp --format=csv --fields=code,type,severity --severity=10` - Then STDOUT should be empty \ No newline at end of file + Then STDOUT should be empty From e4275c1dba6257f4fa3d0aa35fa012747552bb79 Mon Sep 17 00:00:00 2001 From: davidperezgar Date: Wed, 16 Oct 2024 22:45:05 +0200 Subject: [PATCH 23/48] remove flag boolean --- includes/CLI/Plugin_Check_Command.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/includes/CLI/Plugin_Check_Command.php b/includes/CLI/Plugin_Check_Command.php index e9cf63ff9..3e9331098 100644 --- a/includes/CLI/Plugin_Check_Command.php +++ b/includes/CLI/Plugin_Check_Command.php @@ -674,6 +674,8 @@ private function has_runtime_check( array $checks ) { * @param int $error_severity Error severity level. * @param int $warning_severity Warning severity level. * @param bool $include_low_severity_errors Include less level of severity issues as warning. + * + * @SuppressWarnings(PHPMD.BooleanArgumentFlag) * @return array Filtered results. */ private function get_filtered_results_by_severity( $results, $error_severity, $warning_severity, $include_low_severity_errors = false ) { From 2df30000cf2fe6b16db3f1b8e263d3073b4f59a8 Mon Sep 17 00:00:00 2001 From: David Perez Date: Wed, 16 Oct 2024 23:36:19 +0200 Subject: [PATCH 24/48] Update includes/CLI/Plugin_Check_Command.php Co-authored-by: Felix Arntz --- includes/CLI/Plugin_Check_Command.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/CLI/Plugin_Check_Command.php b/includes/CLI/Plugin_Check_Command.php index 3e9331098..0cd8d9290 100644 --- a/includes/CLI/Plugin_Check_Command.php +++ b/includes/CLI/Plugin_Check_Command.php @@ -114,7 +114,7 @@ public function __construct( Plugin_Context $plugin_context ) { * : Warning severity level. * * [--include-low-severity-errors] - * : Include less level of severity issues as warning. + * : Include errors with lower severity than the threshold as warnings. * * [--slug=] * : Slug to override the default. From 37fd096a98e66eb447d10e7b3ffdd6285394bd53 Mon Sep 17 00:00:00 2001 From: davidperezgar Date: Wed, 16 Oct 2024 23:44:55 +0200 Subject: [PATCH 25/48] suggested changes --- includes/CLI/Plugin_Check_Command.php | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/includes/CLI/Plugin_Check_Command.php b/includes/CLI/Plugin_Check_Command.php index 0cd8d9290..a02cb8e72 100644 --- a/includes/CLI/Plugin_Check_Command.php +++ b/includes/CLI/Plugin_Check_Command.php @@ -151,7 +151,7 @@ public function check( $args, $assoc_args ) { 'severity' => '', 'error-severity' => '', 'warning-severity' => '', - 'include-low-severity-errors' => '', + 'include-low-severity-errors' => false, 'slug' => '', ) ); @@ -670,33 +670,30 @@ private function has_runtime_check( array $checks ) { * * @since 1.1.0 * - * @param array $results Check results. - * @param int $error_severity Error severity level. - * @param int $warning_severity Warning severity level. + * @param array $results Check results. + * @param int $error_severity Error severity level. + * @param int $warning_severity Warning severity level. * @param bool $include_low_severity_errors Include less level of severity issues as warning. - * + * * @SuppressWarnings(PHPMD.BooleanArgumentFlag) * @return array Filtered results. */ private function get_filtered_results_by_severity( $results, $error_severity, $warning_severity, $include_low_severity_errors = false ) { - $errors = array(); + $errors = array(); + $warnings = array(); + foreach ( $results as $item ) { if ( 'ERROR' === $item['type'] && $item['severity'] >= $error_severity ) { $errors[] = $item; } elseif ( $include_low_severity_errors && $item['severity'] < $error_severity ) { $item['type'] = 'WARNING'; $item['severity'] = 10; - $errors[] = $item; + $warnings[] = $item; + } elseif ( 'WARNING' === $item['type'] && $item['severity'] >= $warning_severity ) { + $warnings[] = $item; } } - $warnings = array_filter( - $results, - function ( $item ) use ( $warning_severity ) { - return ( 'WARNING' === $item['type'] && $item['severity'] >= $warning_severity ); - } - ); - return array_merge( $errors, $warnings ); } } From a62fd0bef2617771d44eb98503f9970e70679c75 Mon Sep 17 00:00:00 2001 From: David Perez Date: Thu, 17 Oct 2024 22:30:31 +0200 Subject: [PATCH 26/48] Update includes/CLI/Plugin_Check_Command.php Co-authored-by: Mukesh Panchal --- includes/CLI/Plugin_Check_Command.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/CLI/Plugin_Check_Command.php b/includes/CLI/Plugin_Check_Command.php index a02cb8e72..f636572fa 100644 --- a/includes/CLI/Plugin_Check_Command.php +++ b/includes/CLI/Plugin_Check_Command.php @@ -673,10 +673,10 @@ private function has_runtime_check( array $checks ) { * @param array $results Check results. * @param int $error_severity Error severity level. * @param int $warning_severity Warning severity level. - * @param bool $include_low_severity_errors Include less level of severity issues as warning. + * @param bool $include_low_severity_errors Include less level of severity issues as warning. Default false. + * @return array Filtered results. * * @SuppressWarnings(PHPMD.BooleanArgumentFlag) - * @return array Filtered results. */ private function get_filtered_results_by_severity( $results, $error_severity, $warning_severity, $include_low_severity_errors = false ) { $errors = array(); From 16a33d1b2cc949a6990b7a861311dec70049ec7b Mon Sep 17 00:00:00 2001 From: davidperezgar Date: Thu, 17 Oct 2024 22:32:10 +0200 Subject: [PATCH 27/48] fix conditional --- includes/CLI/Plugin_Check_Command.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/CLI/Plugin_Check_Command.php b/includes/CLI/Plugin_Check_Command.php index f636572fa..547373d5a 100644 --- a/includes/CLI/Plugin_Check_Command.php +++ b/includes/CLI/Plugin_Check_Command.php @@ -685,7 +685,7 @@ private function get_filtered_results_by_severity( $results, $error_severity, $w foreach ( $results as $item ) { if ( 'ERROR' === $item['type'] && $item['severity'] >= $error_severity ) { $errors[] = $item; - } elseif ( $include_low_severity_errors && $item['severity'] < $error_severity ) { + } elseif ( $include_low_severity_errors && 'ERROR' === $item['type'] && $item['severity'] < $error_severity ) { $item['type'] = 'WARNING'; $item['severity'] = 10; $warnings[] = $item; From 57950b15e21831bbb860494b39cd71275973b640 Mon Sep 17 00:00:00 2001 From: davidperezgar Date: Fri, 18 Oct 2024 17:56:28 +0200 Subject: [PATCH 28/48] changed to ERROR_EXTRA as suggested --- includes/CLI/Plugin_Check_Command.php | 5 ++--- tests/behat/features/plugin-check-severity.feature | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/includes/CLI/Plugin_Check_Command.php b/includes/CLI/Plugin_Check_Command.php index 547373d5a..28e8acf36 100644 --- a/includes/CLI/Plugin_Check_Command.php +++ b/includes/CLI/Plugin_Check_Command.php @@ -686,9 +686,8 @@ private function get_filtered_results_by_severity( $results, $error_severity, $w if ( 'ERROR' === $item['type'] && $item['severity'] >= $error_severity ) { $errors[] = $item; } elseif ( $include_low_severity_errors && 'ERROR' === $item['type'] && $item['severity'] < $error_severity ) { - $item['type'] = 'WARNING'; - $item['severity'] = 10; - $warnings[] = $item; + $item['type'] = 'ERROR_EXTRA'; + $warnings[] = $item; } elseif ( 'WARNING' === $item['type'] && $item['severity'] >= $warning_severity ) { $warnings[] = $item; } diff --git a/tests/behat/features/plugin-check-severity.feature b/tests/behat/features/plugin-check-severity.feature index 0f6494881..5b0a41baa 100644 --- a/tests/behat/features/plugin-check-severity.feature +++ b/tests/behat/features/plugin-check-severity.feature @@ -199,11 +199,11 @@ Feature: Test that the severity level in plugin check works. """ And STDOUT should contain: """ - default_readme_text,WARNING,7 + WordPress.WP.AlternativeFunctions.rand_mt_rand,ERROR_EXTRA,5 """ And STDOUT should contain: """ - upgrade_notice_limit,WARNING,10 + WordPress.Security.EscapeOutput.OutputNotEscaped,ERROR_EXTRA,5 """ When I run the WP-CLI command `plugin check foo-bar-wp --format=csv --fields=code,type,severity --severity=10` From 10ab255512f7496ed5a01eabdc93e1c4a909c615 Mon Sep 17 00:00:00 2001 From: davidperezgar Date: Fri, 18 Oct 2024 18:00:33 +0200 Subject: [PATCH 29/48] move to warnings --- includes/CLI/Plugin_Check_Command.php | 9 +++++---- tests/behat/features/plugin-check-severity.feature | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/includes/CLI/Plugin_Check_Command.php b/includes/CLI/Plugin_Check_Command.php index 28e8acf36..f2ca56a14 100644 --- a/includes/CLI/Plugin_Check_Command.php +++ b/includes/CLI/Plugin_Check_Command.php @@ -673,10 +673,10 @@ private function has_runtime_check( array $checks ) { * @param array $results Check results. * @param int $error_severity Error severity level. * @param int $warning_severity Warning severity level. - * @param bool $include_low_severity_errors Include less level of severity issues as warning. Default false. - * @return array Filtered results. + * @param bool $include_low_severity_errors Include less level of severity issues as warning. * * @SuppressWarnings(PHPMD.BooleanArgumentFlag) + * @return array Filtered results. */ private function get_filtered_results_by_severity( $results, $error_severity, $warning_severity, $include_low_severity_errors = false ) { $errors = array(); @@ -686,8 +686,9 @@ private function get_filtered_results_by_severity( $results, $error_severity, $w if ( 'ERROR' === $item['type'] && $item['severity'] >= $error_severity ) { $errors[] = $item; } elseif ( $include_low_severity_errors && 'ERROR' === $item['type'] && $item['severity'] < $error_severity ) { - $item['type'] = 'ERROR_EXTRA'; - $warnings[] = $item; + $item['type'] = 'WARNING'; + $item['severity'] = 10; + $warnings[] = $item; } elseif ( 'WARNING' === $item['type'] && $item['severity'] >= $warning_severity ) { $warnings[] = $item; } diff --git a/tests/behat/features/plugin-check-severity.feature b/tests/behat/features/plugin-check-severity.feature index 5b0a41baa..9fbe4f433 100644 --- a/tests/behat/features/plugin-check-severity.feature +++ b/tests/behat/features/plugin-check-severity.feature @@ -199,11 +199,11 @@ Feature: Test that the severity level in plugin check works. """ And STDOUT should contain: """ - WordPress.WP.AlternativeFunctions.rand_mt_rand,ERROR_EXTRA,5 + WordPress.WP.AlternativeFunctions.rand_mt_rand,WARNING,10 """ And STDOUT should contain: """ - WordPress.Security.EscapeOutput.OutputNotEscaped,ERROR_EXTRA,5 + WordPress.Security.EscapeOutput.OutputNotEscaped,WARNING,10 """ When I run the WP-CLI command `plugin check foo-bar-wp --format=csv --fields=code,type,severity --severity=10` From 0962f521b6c4d97e5edeff21e6e5b096237e0a49 Mon Sep 17 00:00:00 2001 From: Nilambar Sharma Date: Wed, 6 Nov 2024 11:29:48 +0545 Subject: [PATCH 30/48] Change error type for license check --- includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php b/includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php index f3f91218e..d8496c193 100644 --- a/includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php +++ b/includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php @@ -326,7 +326,7 @@ private function check_license( Check_Result $result, string $readme_file, Parse // Test for a valid SPDX license identifier. if ( ! $this->is_license_valid_identifier( $license ) ) { - $this->add_result_warning_for_file( + $this->add_result_error_for_file( $result, __( 'Your plugin has an invalid license declared.
Please update your readme with a valid SPDX license identifier.', 'plugin-check' ), 'invalid_license', @@ -371,7 +371,7 @@ private function check_license( Check_Result $result, string $readme_file, Parse // Check different license types. if ( ! empty( $plugin_license ) && ! empty( $license ) && $license !== $plugin_license ) { - $this->add_result_warning_for_file( + $this->add_result_error_for_file( $result, __( 'Your plugin has a different license declared in the readme file and plugin header.
Please update your readme with a valid GPL license identifier.', 'plugin-check' ), 'license_mismatch', From 3322caa195ce548a38478eb2f78f9912d5ff2068 Mon Sep 17 00:00:00 2001 From: Nilambar Sharma Date: Wed, 6 Nov 2024 11:35:28 +0545 Subject: [PATCH 31/48] Update unit test for changed error type --- .../Checks/Plugin_Readme_Check_Tests.php | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/phpunit/tests/Checker/Checks/Plugin_Readme_Check_Tests.php b/tests/phpunit/tests/Checker/Checks/Plugin_Readme_Check_Tests.php index 6bbb60c63..d33b7be89 100644 --- a/tests/phpunit/tests/Checker/Checks/Plugin_Readme_Check_Tests.php +++ b/tests/phpunit/tests/Checker/Checks/Plugin_Readme_Check_Tests.php @@ -148,18 +148,18 @@ public function test_run_with_errors_license() { $readme_check->run( $check_result ); - $warnings = $check_result->get_warnings(); + $errors = $check_result->get_errors(); - $this->assertNotEmpty( $warnings ); - $this->assertArrayHasKey( 'readme.txt', $warnings ); + $this->assertNotEmpty( $errors ); + $this->assertArrayHasKey( 'readme.txt', $errors ); - // Check for invalid license warning. - $this->assertArrayHasKey( 0, $warnings['readme.txt'] ); - $this->assertArrayHasKey( 0, $warnings['readme.txt'][0] ); - $this->assertCount( 1, wp_list_filter( $warnings['readme.txt'][0][0], array( 'code' => 'invalid_license' ) ) ); + // Check for invalid license. + $this->assertArrayHasKey( 0, $errors['readme.txt'] ); + $this->assertArrayHasKey( 0, $errors['readme.txt'][0] ); + $this->assertCount( 1, wp_list_filter( $errors['readme.txt'][0][0], array( 'code' => 'invalid_license' ) ) ); - // Check for not same license warning. - $this->assertCount( 1, wp_list_filter( $warnings['readme.txt'][0][0], array( 'code' => 'license_mismatch' ) ) ); + // Check for not same license. + $this->assertCount( 1, wp_list_filter( $errors['readme.txt'][0][0], array( 'code' => 'license_mismatch' ) ) ); } public function test_run_with_errors_no_license() { @@ -244,12 +244,12 @@ public function test_run_md_with_errors() { $this->assertCount( 1, wp_list_filter( $errors['readme.md'][0][0], array( 'code' => 'trunk_stable_tag' ) ) ); $this->assertCount( 1, wp_list_filter( $errors['readme.md'][0][0], array( 'code' => 'outdated_tested_upto_header' ) ) ); $this->assertCount( 1, wp_list_filter( $errors['readme.md'][0][0], array( 'code' => 'default_readme_text' ) ) ); + $this->assertCount( 1, wp_list_filter( $errors['readme.md'][0][0], array( 'code' => 'invalid_license' ) ) ); + $this->assertCount( 1, wp_list_filter( $errors['readme.md'][0][0], array( 'code' => 'license_mismatch' ) ) ); $this->assertNotEmpty( $warnings ); $this->assertArrayHasKey( 'readme.md', $warnings ); - $this->assertCount( 1, wp_list_filter( $warnings['readme.md'][0][0], array( 'code' => 'invalid_license' ) ) ); - $this->assertCount( 1, wp_list_filter( $warnings['readme.md'][0][0], array( 'code' => 'license_mismatch' ) ) ); $this->assertCount( 1, wp_list_filter( $warnings['readme.md'][0][0], array( 'code' => 'mismatched_plugin_name' ) ) ); $this->assertCount( 1, wp_list_filter( $warnings['readme.md'][0][0], array( 'code' => 'readme_invalid_contributors' ) ) ); } From 27f6d55c7bff787494afbdc1f635279979e3d0e2 Mon Sep 17 00:00:00 2001 From: Nilambar Sharma Date: Thu, 7 Nov 2024 12:49:22 +0545 Subject: [PATCH 32/48] Add check for missing license in plugin header --- .../Plugin_Repo/Plugin_Header_Fields_Check.php | 15 +++++++++++++++ .../Checks/Plugin_Repo/Plugin_Readme_Check.php | 16 ++++------------ .../load.php | 2 -- .../Checks/Plugin_Header_Fields_Check_Tests.php | 1 + 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/includes/Checker/Checks/Plugin_Repo/Plugin_Header_Fields_Check.php b/includes/Checker/Checks/Plugin_Repo/Plugin_Header_Fields_Check.php index 5f5be7c29..91fcf630e 100644 --- a/includes/Checker/Checks/Plugin_Repo/Plugin_Header_Fields_Check.php +++ b/includes/Checker/Checks/Plugin_Repo/Plugin_Header_Fields_Check.php @@ -67,6 +67,8 @@ public function run( Check_Result $result ) { 'RequiresPHP' => 'Requires PHP', 'UpdateURI' => 'Update URI', 'RequiresPlugins' => 'Requires Plugins', + 'License' => 'License', + 'LicenseURI' => 'License URI', ); $restricted_labels = array( @@ -249,6 +251,19 @@ public function run( Check_Result $result ) { } } + if ( empty( $plugin_header['License'] ) ) { + $this->add_result_error_for_file( + $result, + __( 'Your plugin has no license declared in Plugin Header.
Please update your plugin header with a GPLv2 (or later) compatible license.', 'plugin-check' ), + 'plugin_header_no_license', + $plugin_main_file, + 0, + 0, + 'https://developer.wordpress.org/plugins/wordpress-org/common-issues/#no-gpl-compatible-license-declared', + 9 + ); + } + $found_headers = array(); foreach ( $restricted_labels as $restricted_key => $restricted_label ) { diff --git a/includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php b/includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php index d8496c193..9a925faf4 100644 --- a/includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php +++ b/includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php @@ -338,20 +338,12 @@ private function check_license( Check_Result $result, string $readme_file, Parse ); } + $plugin_license = ''; + $pattern = preg_quote( 'License', '/' ); $has_license = self::file_preg_match( "/(*ANYCRLF)^.*$pattern\s*:\s*(.*)$/im", array( $plugin_main_file ), $matches_license ); - if ( ! $has_license ) { - $this->add_result_error_for_file( - $result, - __( 'Your plugin has no license declared in Plugin Header.
Please update your plugin header with a GPLv2 (or later) compatible license. It is necessary to declare the license of this plugin. You can do this by using the fields available both in the plugin readme and in the plugin headers.', 'plugin-check' ), - 'no_license', - $plugin_main_file, - 0, - 0, - 'https://developer.wordpress.org/plugins/wordpress-org/common-issues/#no-gpl-compatible-license-declared', - 9 - ); - } else { + + if ( $has_license ) { $plugin_license = $this->get_normalized_license( $matches_license[1] ); } diff --git a/tests/phpunit/testdata/plugins/test-plugin-header-fields-with-errors/load.php b/tests/phpunit/testdata/plugins/test-plugin-header-fields-with-errors/load.php index ce261dd5e..d2cf4b93e 100644 --- a/tests/phpunit/testdata/plugins/test-plugin-header-fields-with-errors/load.php +++ b/tests/phpunit/testdata/plugins/test-plugin-header-fields-with-errors/load.php @@ -8,8 +8,6 @@ * Version: 1.0.0 * Author: WordPress Performance Team * Author URI: This is not a valid URL - * License: GPLv2 or later - * License URI: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html * Text Domain: test-mismathed-textdomain-here * Domain Path: /nonexistent-folder * Network: random-value diff --git a/tests/phpunit/tests/Checker/Checks/Plugin_Header_Fields_Check_Tests.php b/tests/phpunit/tests/Checker/Checks/Plugin_Header_Fields_Check_Tests.php index 5b14cda8f..5732a4c09 100644 --- a/tests/phpunit/tests/Checker/Checks/Plugin_Header_Fields_Check_Tests.php +++ b/tests/phpunit/tests/Checker/Checks/Plugin_Header_Fields_Check_Tests.php @@ -27,6 +27,7 @@ public function test_run_with_errors() { $this->assertCount( 0, wp_list_filter( $errors['load.php'][0][0], array( 'code' => 'plugin_header_restricted_fields' ) ) ); $this->assertCount( 1, wp_list_filter( $errors['load.php'][0][0], array( 'code' => 'plugin_header_invalid_requires_wp' ) ) ); $this->assertCount( 1, wp_list_filter( $errors['load.php'][0][0], array( 'code' => 'plugin_header_invalid_requires_php' ) ) ); + $this->assertCount( 1, wp_list_filter( $errors['load.php'][0][0], array( 'code' => 'plugin_header_no_license' ) ) ); $this->assertCount( 1, wp_list_filter( $warnings['load.php'][0][0], array( 'code' => 'plugin_header_invalid_plugin_uri_domain' ) ) ); $this->assertCount( 1, wp_list_filter( $warnings['load.php'][0][0], array( 'code' => 'plugin_header_invalid_plugin_description' ) ) ); $this->assertCount( 1, wp_list_filter( $warnings['load.php'][0][0], array( 'code' => 'plugin_header_invalid_author_uri' ) ) ); From 8a8b8b584754886121ad1c4266f66de0317246a7 Mon Sep 17 00:00:00 2001 From: Nilambar Sharma Date: Thu, 7 Nov 2024 13:36:37 +0545 Subject: [PATCH 33/48] Add check for plugin header invalid license --- .../Plugin_Header_Fields_Check.php | 27 ++++++++++++++++++- .../Plugin_Repo/Plugin_Readme_Check.php | 14 ---------- .../Plugin_Header_Fields_Check_Tests.php | 14 ++++++++++ 3 files changed, 40 insertions(+), 15 deletions(-) diff --git a/includes/Checker/Checks/Plugin_Repo/Plugin_Header_Fields_Check.php b/includes/Checker/Checks/Plugin_Repo/Plugin_Header_Fields_Check.php index 91fcf630e..65e3eced6 100644 --- a/includes/Checker/Checks/Plugin_Repo/Plugin_Header_Fields_Check.php +++ b/includes/Checker/Checks/Plugin_Repo/Plugin_Header_Fields_Check.php @@ -12,6 +12,7 @@ use WordPress\Plugin_Check\Checker\Check_Result; use WordPress\Plugin_Check\Checker\Static_Check; use WordPress\Plugin_Check\Traits\Amend_Check_Result; +use WordPress\Plugin_Check\Traits\License_Utils; use WordPress\Plugin_Check\Traits\Stable_Check; /** @@ -21,6 +22,7 @@ */ class Plugin_Header_Fields_Check implements Static_Check { + use License_Utils; use Amend_Check_Result; use Stable_Check; @@ -254,7 +256,11 @@ public function run( Check_Result $result ) { if ( empty( $plugin_header['License'] ) ) { $this->add_result_error_for_file( $result, - __( 'Your plugin has no license declared in Plugin Header.
Please update your plugin header with a GPLv2 (or later) compatible license.', 'plugin-check' ), + sprintf( + /* translators: %s: plugin header field */ + __( 'Missing "%s" in Plugin Header.
Please update your Plugin Header with a valid GPLv2 (or later) compatible license.', 'plugin-check' ), + esc_html( $labels['License'] ) + ), 'plugin_header_no_license', $plugin_main_file, 0, @@ -262,6 +268,25 @@ public function run( Check_Result $result ) { 'https://developer.wordpress.org/plugins/wordpress-org/common-issues/#no-gpl-compatible-license-declared', 9 ); + } else { + $plugin_license = $this->get_normalized_license( $plugin_header['License'] ); + if ( ! $this->is_license_gpl_compatible( $plugin_license ) ) { + $this->add_result_error_for_file( + $result, + sprintf( + /* translators: 1: plugin header field, 2: license */ + __( 'Invalid %1$s: %2$s.
Please update your Plugin Header with a valid GPLv2 (or later) compatible license.', 'plugin-check' ), + esc_html( $labels['License'] ), + esc_html( $plugin_header['License'] ) + ), + 'plugin_header_invalid_license', + $plugin_main_file, + 0, + 0, + 'https://developer.wordpress.org/plugins/wordpress-org/common-issues/#no-gpl-compatible-license-declared', + 9 + ); + } } $found_headers = array(); diff --git a/includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php b/includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php index 9a925faf4..ba9c7b859 100644 --- a/includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php +++ b/includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php @@ -347,20 +347,6 @@ private function check_license( Check_Result $result, string $readme_file, Parse $plugin_license = $this->get_normalized_license( $matches_license[1] ); } - // Checks for a valid license in Plugin Header. - if ( ! empty( $plugin_license ) && ! $this->is_license_gpl_compatible( $plugin_license ) ) { - $this->add_result_error_for_file( - $result, - __( 'Your plugin has an invalid license declared in Plugin Header.
Please update your readme with a valid GPL license identifier. It is necessary to declare the license of this plugin. You can do this by using the fields available both in the plugin readme and in the plugin headers.', 'plugin-check' ), - 'invalid_license', - $plugin_main_file, - 0, - 0, - 'https://developer.wordpress.org/plugins/wordpress-org/common-issues/#no-gpl-compatible-license-declared', - 9 - ); - } - // Check different license types. if ( ! empty( $plugin_license ) && ! empty( $license ) && $license !== $plugin_license ) { $this->add_result_error_for_file( diff --git a/tests/phpunit/tests/Checker/Checks/Plugin_Header_Fields_Check_Tests.php b/tests/phpunit/tests/Checker/Checks/Plugin_Header_Fields_Check_Tests.php index 5732a4c09..1c2748412 100644 --- a/tests/phpunit/tests/Checker/Checks/Plugin_Header_Fields_Check_Tests.php +++ b/tests/phpunit/tests/Checker/Checks/Plugin_Header_Fields_Check_Tests.php @@ -58,4 +58,18 @@ public function test_run_with_valid_requires_plugins_header() { $this->assertCount( 0, wp_list_filter( $warnings['load.php'][0][0], array( 'code' => 'plugin_header_invalid_requires_plugins' ) ) ); } } + + public function test_run_with_invalid_license() { + $check = new Plugin_Header_Fields_Check(); + $check_context = new Check_Context( UNIT_TESTS_PLUGIN_DIR . 'test-plugin-plugin-readme-mpl1-license-with-errors/load.php' ); + $check_result = new Check_Result( $check_context ); + + $check->run( $check_result ); + + $errors = $check_result->get_errors(); + + $this->assertNotEmpty( $errors ); + + $this->assertCount( 1, wp_list_filter( $errors['load.php'][0][0], array( 'code' => 'plugin_header_invalid_license' ) ) ); + } } From 79c10db497e2f223275c9affce3fd25da183f1be Mon Sep 17 00:00:00 2001 From: Nilambar Sharma Date: Thu, 7 Nov 2024 15:20:26 +0545 Subject: [PATCH 34/48] Fix check for invalid MPL1 license --- .../Plugin_Repo/Plugin_Header_Fields_Check.php | 2 +- .../Plugin_Header_Fields_Check_Tests.php | 3 ++- .../Checks/Plugin_Readme_Check_Tests.php | 18 ------------------ 3 files changed, 3 insertions(+), 20 deletions(-) diff --git a/includes/Checker/Checks/Plugin_Repo/Plugin_Header_Fields_Check.php b/includes/Checker/Checks/Plugin_Repo/Plugin_Header_Fields_Check.php index 65e3eced6..363ec5d60 100644 --- a/includes/Checker/Checks/Plugin_Repo/Plugin_Header_Fields_Check.php +++ b/includes/Checker/Checks/Plugin_Repo/Plugin_Header_Fields_Check.php @@ -22,8 +22,8 @@ */ class Plugin_Header_Fields_Check implements Static_Check { - use License_Utils; use Amend_Check_Result; + use License_Utils; use Stable_Check; /** diff --git a/tests/phpunit/tests/Checker/Checks/Plugin_Header_Fields_Check_Tests.php b/tests/phpunit/tests/Checker/Checks/Plugin_Header_Fields_Check_Tests.php index 1c2748412..54ef73e85 100644 --- a/tests/phpunit/tests/Checker/Checks/Plugin_Header_Fields_Check_Tests.php +++ b/tests/phpunit/tests/Checker/Checks/Plugin_Header_Fields_Check_Tests.php @@ -59,7 +59,7 @@ public function test_run_with_valid_requires_plugins_header() { } } - public function test_run_with_invalid_license() { + public function test_run_with_invalid_mpl1_license() { $check = new Plugin_Header_Fields_Check(); $check_context = new Check_Context( UNIT_TESTS_PLUGIN_DIR . 'test-plugin-plugin-readme-mpl1-license-with-errors/load.php' ); $check_result = new Check_Result( $check_context ); @@ -70,6 +70,7 @@ public function test_run_with_invalid_license() { $this->assertNotEmpty( $errors ); + // Check for invalid license. $this->assertCount( 1, wp_list_filter( $errors['load.php'][0][0], array( 'code' => 'plugin_header_invalid_license' ) ) ); } } diff --git a/tests/phpunit/tests/Checker/Checks/Plugin_Readme_Check_Tests.php b/tests/phpunit/tests/Checker/Checks/Plugin_Readme_Check_Tests.php index d33b7be89..275da69c0 100644 --- a/tests/phpunit/tests/Checker/Checks/Plugin_Readme_Check_Tests.php +++ b/tests/phpunit/tests/Checker/Checks/Plugin_Readme_Check_Tests.php @@ -192,24 +192,6 @@ public function test_run_without_error_mpl2_license() { $this->assertEmpty( $errors ); } - public function test_run_with_errors_mpl1_license() { - $readme_check = new Plugin_Readme_Check(); - $check_context = new Check_Context( UNIT_TESTS_PLUGIN_DIR . 'test-plugin-plugin-readme-mpl1-license-with-errors/load.php' ); - $check_result = new Check_Result( $check_context ); - - $readme_check->run( $check_result ); - - $errors = $check_result->get_errors(); - - $this->assertNotEmpty( $errors ); - $this->assertArrayHasKey( 'load.php', $errors ); - - // Check for invalid license. - $this->assertArrayHasKey( 0, $errors['load.php'] ); - $this->assertArrayHasKey( 0, $errors['load.php'][0] ); - $this->assertCount( 1, wp_list_filter( $errors['load.php'][0][0], array( 'code' => 'invalid_license' ) ) ); - } - public function test_run_with_errors_tested_upto() { $readme_check = new Plugin_Readme_Check(); $check_context = new Check_Context( UNIT_TESTS_PLUGIN_DIR . 'test-plugin-plugin-readme-errors-tested-upto/load.php' ); From 8967e539c2b4fb6720e2c704b9c83d7b202007ee Mon Sep 17 00:00:00 2001 From: davidperezgar Date: Thu, 7 Nov 2024 23:13:26 +0100 Subject: [PATCH 35/48] errors-low-severity and warnings-low-severity --- includes/CLI/Plugin_Check_Command.php | 46 +++++++++++-------- .../features/plugin-check-severity.feature | 18 +++++++- 2 files changed, 43 insertions(+), 21 deletions(-) diff --git a/includes/CLI/Plugin_Check_Command.php b/includes/CLI/Plugin_Check_Command.php index f2ca56a14..4728aec16 100644 --- a/includes/CLI/Plugin_Check_Command.php +++ b/includes/CLI/Plugin_Check_Command.php @@ -114,7 +114,10 @@ public function __construct( Plugin_Context $plugin_context ) { * : Warning severity level. * * [--include-low-severity-errors] - * : Include errors with lower severity than the threshold as warnings. + * : Include errors with lower severity than the threshold as other type. + * + * [--include-low-severity-warnings] + * : Include errors with lower severity than the threshold as other type. * * [--slug=] * : Slug to override the default. @@ -143,16 +146,17 @@ public function check( $args, $assoc_args ) { $options = $this->get_options( $assoc_args, array( - 'checks' => '', - 'format' => 'table', - 'ignore-warnings' => false, - 'ignore-errors' => false, - 'include-experimental' => false, - 'severity' => '', - 'error-severity' => '', - 'warning-severity' => '', - 'include-low-severity-errors' => false, - 'slug' => '', + 'checks' => '', + 'format' => 'table', + 'ignore-warnings' => false, + 'ignore-errors' => false, + 'include-experimental' => false, + 'severity' => '', + 'error-severity' => '', + 'warning-severity' => '', + 'include-low-severity-errors' => false, + 'include-low-severity-warnings' => false, + 'slug' => '', ) ); @@ -260,9 +264,10 @@ static function ( $dirs ) use ( $excluded_files ) { $formatter = $this->get_formatter( $assoc_args, $default_fields ); // Severity. - $error_severity = ! empty( $options['error-severity'] ) ? $options['error-severity'] : $options['severity']; - $warning_severity = ! empty( $options['warning-severity'] ) ? $options['warning-severity'] : $options['severity']; - $include_low_severity_errors = ! empty( $options['include-low-severity-errors'] ) ? true : false; + $error_severity = ! empty( $options['error-severity'] ) ? $options['error-severity'] : $options['severity']; + $warning_severity = ! empty( $options['warning-severity'] ) ? $options['warning-severity'] : $options['severity']; + $include_low_severity_errors = ! empty( $options['include-low-severity-errors'] ) ? true : false; + $include_low_severity_warnings = ! empty( $options['include-low-severity-warnings'] ) ? true : false; // Print the formatted results. // Go over all files with errors first and print them, combined with any warnings in the same file. @@ -275,7 +280,7 @@ static function ( $dirs ) use ( $excluded_files ) { $file_results = $this->flatten_file_results( $file_errors, $file_warnings ); if ( '' !== $error_severity || '' !== $warning_severity ) { - $file_results = $this->get_filtered_results_by_severity( $file_results, intval( $error_severity ), intval( $warning_severity ), $include_low_severity_errors ); + $file_results = $this->get_filtered_results_by_severity( $file_results, intval( $error_severity ), intval( $warning_severity ), $include_low_severity_errors, $include_low_severity_warnings ); } if ( ! empty( $file_results ) ) { @@ -674,11 +679,12 @@ private function has_runtime_check( array $checks ) { * @param int $error_severity Error severity level. * @param int $warning_severity Warning severity level. * @param bool $include_low_severity_errors Include less level of severity issues as warning. + * @param bool $include_low_severity_warnings Include less level of severity issues as warning. * * @SuppressWarnings(PHPMD.BooleanArgumentFlag) * @return array Filtered results. */ - private function get_filtered_results_by_severity( $results, $error_severity, $warning_severity, $include_low_severity_errors = false ) { + private function get_filtered_results_by_severity( $results, $error_severity, $warning_severity, $include_low_severity_errors = false, $include_low_severity_warnings = false ) { $errors = array(); $warnings = array(); @@ -686,9 +692,11 @@ private function get_filtered_results_by_severity( $results, $error_severity, $w if ( 'ERROR' === $item['type'] && $item['severity'] >= $error_severity ) { $errors[] = $item; } elseif ( $include_low_severity_errors && 'ERROR' === $item['type'] && $item['severity'] < $error_severity ) { - $item['type'] = 'WARNING'; - $item['severity'] = 10; - $warnings[] = $item; + $item['type'] = 'ERRORS_LOW_SEVERITY'; + $errors[] = $item; + } elseif ( $include_low_severity_warnings && 'WARNING' === $item['type'] && $item['severity'] < $warning_severity ) { + $item['type'] = 'WARNINGS_LOW_SEVERITY'; + $warnings[] = $item; } elseif ( 'WARNING' === $item['type'] && $item['severity'] >= $warning_severity ) { $warnings[] = $item; } diff --git a/tests/behat/features/plugin-check-severity.feature b/tests/behat/features/plugin-check-severity.feature index 9fbe4f433..d39c17110 100644 --- a/tests/behat/features/plugin-check-severity.feature +++ b/tests/behat/features/plugin-check-severity.feature @@ -199,11 +199,25 @@ Feature: Test that the severity level in plugin check works. """ And STDOUT should contain: """ - WordPress.WP.AlternativeFunctions.rand_mt_rand,WARNING,10 + WordPress.WP.AlternativeFunctions.rand_mt_rand,ERRORS_LOW_SEVERITY,5 """ And STDOUT should contain: """ - WordPress.Security.EscapeOutput.OutputNotEscaped,WARNING,10 + WordPress.Security.EscapeOutput.OutputNotEscaped,ERRORS_LOW_SEVERITY,5 + """ + + When I run the WP-CLI command `plugin check foo-bar-wp --format=csv --fields=code,type,severity --warning-severity=7 --include-low-severity-warnings` + Then STDOUT should contain: + """ + allow_unfiltered_uploads_detected,ERROR,7 + """ + And STDOUT should contain: + """ + upgrade_notice_limit,WARNINGS_LOW_SEVERITY,5 + """ + And STDOUT should contain: + """ + default_readme_text,WARNING,7 """ When I run the WP-CLI command `plugin check foo-bar-wp --format=csv --fields=code,type,severity --severity=10` From 8883200238466d30eb2d9ba5fa01a71c9d4c6608 Mon Sep 17 00:00:00 2001 From: Nilambar Sharma Date: Thu, 7 Nov 2024 17:38:34 +0545 Subject: [PATCH 36/48] Add unit test for License_Utils --- .../tests/Traits/License_Utils_Tests.php | 115 ++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 tests/phpunit/tests/Traits/License_Utils_Tests.php diff --git a/tests/phpunit/tests/Traits/License_Utils_Tests.php b/tests/phpunit/tests/Traits/License_Utils_Tests.php new file mode 100644 index 000000000..1fb256639 --- /dev/null +++ b/tests/phpunit/tests/Traits/License_Utils_Tests.php @@ -0,0 +1,115 @@ +get_normalized_license( $raw ); + + $this->assertSame( $normalized, $result ); + } + + /** + * @dataProvider data_license_identifiers + */ + public function test_license_identifier( $license, $validity ) { + $result = $this->is_license_valid_identifier( $license ); + + $this->assertSame( $validity, $result ); + } + + /** + * @dataProvider data_license_gpl_compatibility + */ + public function test_license_gpl_compatibility( $license, $validity ) { + $result = $this->is_license_gpl_compatible( $license ); + + $this->assertSame( $validity, $result ); + } + + public function data_licenses_for_normalization() { + return array( + array( 'GPLv2', 'GPL2' ), + array( 'GPLv2 or later', 'GPL2' ), + array( 'GPLv2 or later', 'GPL2' ), + array( 'GPLv2-or-later', 'GPL2' ), + array( 'GPL v2 or later', 'GPL2' ), + array( 'GPL-2.0', 'GPL2' ), + array( 'GPL-2.0-or-later', 'GPL2' ), + array( 'GNU General Public License v2.0 or later', 'GPL2' ), + array( 'GPL-2.0+', 'GPL2' ), + array( 'GNU General Public License (GPL) 2.0', 'GPL2' ), + array( 'GPL version 2', 'GPL2' ), + array( 'GPL version 2 or later', 'GPL2' ), + + array( 'GPLv3', 'GPL3' ), + array( 'GPLv3 or later', 'GPL3' ), + array( 'GPLv3 or later', 'GPL3' ), + array( 'GPLv3-or-later', 'GPL3' ), + array( 'GPL v3 or later', 'GPL3' ), + array( 'GPL-3.0', 'GPL3' ), + array( 'GPL-3.0-or-later', 'GPL3' ), + array( 'GNU General Public License v3.0 or later', 'GPL3' ), + array( 'GPL-3.0+', 'GPL3' ), + array( 'GNU General Public License (GPL) 3.0', 'GPL3' ), + array( 'GPL version 3', 'GPL3' ), + array( 'GPL version 3 or later', 'GPL3' ), + + array( 'MPL-1.0', 'MPL10' ), + array( 'MPL-2.0', 'MPL20' ), + ); + } + + public function data_license_identifiers() { + return array( + array( 'GPLv2', true ), + array( 'GPL3', true ), + array( 'mpl-2.0', true ), + array( 'lgpl-3.0-or-later', true ), + array( 'artistic-license-2.0 or MIT', true ), + array( 'cc-by-sa-4.0 or cc-by-nc-4.0', true ), + array( 'public-domain or unlicense', true ), + array( 'eupl-1.1+', true ), + array( 'AGPL-3.0-only', true ), + + array( 'MIT License', false ), + array( 'GPL (v3)', false ), + array( 'my_custom_license', false ), + array( 'LGPL 3.0 or later', false ), + array( 'GPL-2.0+ with font exception', false ), + ); + } + + public function data_license_gpl_compatibility() { + return array( + array( 'GPL2', true ), + array( 'GPL3', true ), + array( 'MPL20', true ), + array( 'MIT', true ), + array( 'Apache', true ), + array( 'FreeBSD', true ), + array( 'New BSD', true ), + array( 'BSD-3-Clause', true ), + array( 'BSD 3 Clause', true ), + array( 'OpenLDAP', true ), + array( 'Expat', true ), + + array( 'EPL', false ), + array( 'EUPL', false ), + array( 'MPL10', false ), + array( 'YPL', false ), + array( 'ZPL', false ), + ); + } +} From 7a61a60a474bc76f1dd469af79d25165a4c5a864 Mon Sep 17 00:00:00 2001 From: Nilambar Sharma Date: Fri, 8 Nov 2024 15:50:35 +0545 Subject: [PATCH 37/48] Add documentation link for i18n check results --- .../Checks/General/I18n_Usage_Check.php | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/includes/Checker/Checks/General/I18n_Usage_Check.php b/includes/Checker/Checks/General/I18n_Usage_Check.php index 4521ba2a1..eaba6541e 100644 --- a/includes/Checker/Checks/General/I18n_Usage_Check.php +++ b/includes/Checker/Checks/General/I18n_Usage_Check.php @@ -103,6 +103,31 @@ protected function add_result_message_for_file( Check_Result $result, $error, $m $error = false; } + // Add documentation link. + switch ( $code ) { + case 'WordPress.WP.I18n.NonSingularStringLiteralDomain': + case 'WordPress.WP.I18n.NonSingularStringLiteralText': + case 'WordPress.WP.I18n.TooManyFunctionArgs': + $docs = __( 'https://developer.wordpress.org/plugins/internationalization/how-to-internationalize-your-plugin/#basic-strings', 'plugin-check' ); + break; + + case 'WordPress.WP.I18n.NonSingularStringLiteralContext': + $docs = __( 'https://developer.wordpress.org/plugins/internationalization/how-to-internationalize-your-plugin/#disambiguation-by-context', 'plugin-check' ); + break; + + case 'WordPress.WP.I18n.MissingTranslatorsComment': + $docs = __( 'https://developer.wordpress.org/plugins/internationalization/how-to-internationalize-your-plugin/#descriptions', 'plugin-check' ); + break; + + case 'WordPress.WP.I18n.UnorderedPlaceholdersText': + $docs = __( 'https://developer.wordpress.org/plugins/internationalization/how-to-internationalize-your-plugin/#variables', 'plugin-check' ); + break; + + default: + $docs = __( 'https://developer.wordpress.org/plugins/internationalization/how-to-internationalize-your-plugin/', 'plugin-check' ); + break; + } + parent::add_result_message_for_file( $result, $error, $message, $code, $file, $line, $column, $docs, $severity ); } } From ed6d75f360608aac3d6eaaeebf4557e5c5b828f6 Mon Sep 17 00:00:00 2001 From: davidperezgar Date: Fri, 8 Nov 2024 17:00:34 +0100 Subject: [PATCH 38/48] fix error and severity in warnings --- includes/CLI/Plugin_Check_Command.php | 2 +- tests/behat/features/plugin-check-severity.feature | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/CLI/Plugin_Check_Command.php b/includes/CLI/Plugin_Check_Command.php index 79bcacbc1..4c0bc288e 100644 --- a/includes/CLI/Plugin_Check_Command.php +++ b/includes/CLI/Plugin_Check_Command.php @@ -272,7 +272,7 @@ static function ( $dirs ) use ( $excluded_files ) { $file_results = $this->flatten_file_results( array(), $file_warnings ); if ( '' !== $error_severity || '' !== $warning_severity ) { - $file_results = $this->get_filtered_results_by_severity( $file_results, intval( $error_severity ), intval( $warning_severity ) ); + $file_results = $this->get_filtered_results_by_severity( $file_results, intval( $error_severity ), intval( $warning_severity ), $include_low_severity_errors, $include_low_severity_warnings ); } if ( ! empty( $file_results ) ) { diff --git a/tests/behat/features/plugin-check-severity.feature b/tests/behat/features/plugin-check-severity.feature index 88481da25..3e82d13f9 100644 --- a/tests/behat/features/plugin-check-severity.feature +++ b/tests/behat/features/plugin-check-severity.feature @@ -217,7 +217,7 @@ Feature: Test that the severity level in plugin check works. """ And STDOUT should contain: """ - default_readme_text,WARNING,7 + default_readme_text,ERROR,7 """ When I run the WP-CLI command `plugin check foo-bar-wp --format=csv --fields=code,type,severity --severity=10` From c4541ccf8b14145dd1f78e738b6435e30a68a461 Mon Sep 17 00:00:00 2001 From: davidperezgar Date: Sat, 9 Nov 2024 10:35:53 +0100 Subject: [PATCH 39/48] fix comment --- includes/CLI/Plugin_Check_Command.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/CLI/Plugin_Check_Command.php b/includes/CLI/Plugin_Check_Command.php index 4c0bc288e..e512fad6e 100644 --- a/includes/CLI/Plugin_Check_Command.php +++ b/includes/CLI/Plugin_Check_Command.php @@ -115,7 +115,7 @@ public function __construct( Plugin_Context $plugin_context ) { * : Include errors with lower severity than the threshold as other type. * * [--include-low-severity-warnings] - * : Include errors with lower severity than the threshold as other type. + * : Include warnings with lower severity than the threshold as other type. * * [--slug=] * : Slug to override the default. From 15d2d438c409a81cb8e7e4dd3620f0937c711b54 Mon Sep 17 00:00:00 2001 From: Felix Arntz Date: Mon, 11 Nov 2024 17:11:02 -0800 Subject: [PATCH 40/48] Ensure runtime environment is set up before testing Universal_Runtime_Preparation. --- .../Universal_Runtime_Preparation_Tests.php | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/tests/phpunit/tests/Checker/Preparations/Universal_Runtime_Preparation_Tests.php b/tests/phpunit/tests/Checker/Preparations/Universal_Runtime_Preparation_Tests.php index c805b0e21..0cd416c96 100644 --- a/tests/phpunit/tests/Checker/Preparations/Universal_Runtime_Preparation_Tests.php +++ b/tests/phpunit/tests/Checker/Preparations/Universal_Runtime_Preparation_Tests.php @@ -9,16 +9,43 @@ use WordPress\Plugin_Check\Checker\Check_Context; use WordPress\Plugin_Check\Checker\Preparations\Universal_Runtime_Preparation; +use WordPress\Plugin_Check\Checker\Runtime_Environment_Setup; use WP_UnitTestCase; class Universal_Runtime_Preparation_Tests extends WP_UnitTestCase { + /** + * Storage for preparation cleanups that need to be run after a test. + * + * @var array + */ + private $cleanups = array(); + + public function tear_down() { + if ( count( $this->cleanups ) > 0 ) { + $this->cleanups = array_reverse( $this->cleanups ); + foreach ( $this->cleanups as $cleanup ) { + $cleanup(); + } + $this->cleanups = array(); + } + parent::tear_down(); + } + public function test_prepare() { $check_context = new Check_Context( plugin_basename( WP_PLUGIN_CHECK_MAIN_FILE ) ); + // The runtime environment must be prepared manually before regular runtime preparations. + $runtime = new Runtime_Environment_Setup(); + $runtime->set_up(); + $this->cleanups[] = function () use ( $runtime ) { + $runtime->clean_up(); + }; + $universal_runtime_preparation = new Universal_Runtime_Preparation( $check_context ); - $cleanup = $universal_runtime_preparation->prepare(); + $cleanup = $universal_runtime_preparation->prepare(); + $this->cleanups[] = $cleanup; $this->assertTrue( has_filter( 'option_active_plugins' ) ); $this->assertTrue( has_filter( 'default_option_active_plugins' ) ); @@ -32,6 +59,9 @@ public function test_prepare() { $cleanup(); + // If this is reached, the universal runtime preparation cleanup was already done, so we can remove it again. + array_pop( $this->cleanups ); + $this->assertFalse( has_filter( 'option_active_plugins' ) ); $this->assertFalse( has_filter( 'default_option_active_plugins' ) ); $this->assertFalse( has_filter( 'stylesheet' ) ); From 6268281b13e088cf08f87c841c7ccca1272cf393 Mon Sep 17 00:00:00 2001 From: Nilambar Sharma Date: Tue, 12 Nov 2024 11:41:29 +0545 Subject: [PATCH 41/48] Fix spacing issues in function docs Co-authored-by: Felix Arntz --- includes/CLI/Plugin_Check_Command.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/includes/CLI/Plugin_Check_Command.php b/includes/CLI/Plugin_Check_Command.php index e512fad6e..0529611be 100644 --- a/includes/CLI/Plugin_Check_Command.php +++ b/includes/CLI/Plugin_Check_Command.php @@ -636,10 +636,10 @@ private function display_results( $formatter, $file_name, $file_results ) { * * @since 1.1.0 * - * @param array $results Check results. - * @param int $error_severity Error severity level. - * @param int $warning_severity Warning severity level. - * @param bool $include_low_severity_errors Include less level of severity issues as warning. + * @param array $results Check results. + * @param int $error_severity Error severity level. + * @param int $warning_severity Warning severity level. + * @param bool $include_low_severity_errors Include less level of severity issues as warning. * @param bool $include_low_severity_warnings Include less level of severity issues as warning. * * @SuppressWarnings(PHPMD.BooleanArgumentFlag) From 9703245dc5109f47747f36de8564f1605f962638 Mon Sep 17 00:00:00 2001 From: Felix Arntz Date: Tue, 12 Nov 2024 14:02:39 -0800 Subject: [PATCH 42/48] Fix another instance of missing Runtime_Environment_Setup. --- .../Plugin_Request_Utility_Tests.php | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/tests/phpunit/tests/Utilities/Plugin_Request_Utility_Tests.php b/tests/phpunit/tests/Utilities/Plugin_Request_Utility_Tests.php index fc760ca26..80a36513d 100644 --- a/tests/phpunit/tests/Utilities/Plugin_Request_Utility_Tests.php +++ b/tests/phpunit/tests/Utilities/Plugin_Request_Utility_Tests.php @@ -11,6 +11,7 @@ use WordPress\Plugin_Check\Checker\Checks; use WordPress\Plugin_Check\Checker\Checks\General\I18n_Usage_Check; use WordPress\Plugin_Check\Checker\CLI_Runner; +use WordPress\Plugin_Check\Checker\Runtime_Environment_Setup; use WordPress\Plugin_Check\Test_Data\Runtime_Check; use WordPress\Plugin_Check\Test_Utils\Traits\With_Mock_Filesystem; use WordPress\Plugin_Check\Utilities\Plugin_Request_Utility; @@ -90,6 +91,16 @@ public function test_initialize_runner_with_ajax() { $_REQUEST['action'] = 'plugin_check_run_checks'; $_REQUEST['plugin'] = 'plugin-check'; + /* + * The runtime environment must be prepared manually before regular runtime preparations. + * This is necessary because in reality it happens in a separate AJAX request before. + */ + $runtime = new Runtime_Environment_Setup(); + $runtime->set_up(); + $this->cleanups[] = function () use ( $runtime ) { + $runtime->clean_up(); + }; + Plugin_Request_Utility::initialize_runner(); $this->cleanups[] = function () { Plugin_Request_Utility::destroy_runner(); @@ -109,7 +120,7 @@ public function test_initialize_runner_with_ajax() { public function test_destroy_runner_with_cli() { define( 'WP_CLI', true ); - global $wpdb, $table_prefix, $wp_actions; + global $wp_actions; $this->set_up_mock_filesystem(); @@ -151,7 +162,6 @@ function ( $checks ) { unset( $_SERVER['argv'] ); $wp_actions['muplugins_loaded'] = $muplugins_loaded; - $wpdb->set_prefix( $table_prefix ); $this->assertTrue( $prepared ); $this->assertTrue( $cleanup ); @@ -159,7 +169,7 @@ function ( $checks ) { } public function test_destroy_runner_with_ajax() { - global $wpdb, $table_prefix, $wp_actions; + global $wp_actions; $this->set_up_mock_filesystem(); @@ -168,6 +178,16 @@ public function test_destroy_runner_with_ajax() { $_REQUEST['plugin'] = 'plugin-check'; $_REQUEST['checks'] = array( 'runtime_check' ); + /* + * The runtime environment must be prepared manually before regular runtime preparations. + * This is necessary because in reality it happens in a separate AJAX request before. + */ + $runtime = new Runtime_Environment_Setup(); + $runtime->set_up(); + $this->cleanups[] = function () use ( $runtime ) { + $runtime->clean_up(); + }; + add_filter( 'wp_plugin_check_checks', function ( $checks ) { @@ -196,7 +216,6 @@ function ( $checks ) { $cleanup = ! has_filter( 'option_active_plugins' ); $runner = Plugin_Request_Utility::get_runner(); - $wpdb->set_prefix( $table_prefix ); $wp_actions['muplugins_loaded'] = $muplugins_loaded; $this->assertTrue( $prepared ); From 7be1dc4a9a66bba7fae667b6109c0d7cee533c1e Mon Sep 17 00:00:00 2001 From: David Perez Date: Wed, 13 Nov 2024 22:19:54 +0100 Subject: [PATCH 43/48] Update includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php Co-authored-by: Nilambar Sharma --- includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php b/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php index afa03fb4a..cf181fa03 100644 --- a/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php +++ b/includes/Checker/Checks/Plugin_Repo/Trademarks_Check.php @@ -150,7 +150,7 @@ class Trademarks_Check extends Abstract_File_Check { /** * Lists of allowed acronyms of trademarks. * - * @since 1.2.0 + * @since 1.3.0 * * @var string[] */ From 7f56cb33981f30851606e5daa88925b635bb99b8 Mon Sep 17 00:00:00 2001 From: Nilambar Sharma Date: Mon, 18 Nov 2024 21:26:54 +0545 Subject: [PATCH 44/48] Bump min php support to 7.4 --- .github/workflows/behat-test.yml | 4 +--- .github/workflows/php-test.yml | 5 +---- CONTRIBUTING.md | 2 +- composer.json | 4 ++-- composer.lock | 6 +++--- phpcs-sniffs/composer.json | 6 +++--- phpcs-sniffs/composer.lock | 6 +++--- phpcs-sniffs/phpcs.xml.dist | 2 +- phpcs.xml.dist | 2 +- plugin.php | 4 ++-- 10 files changed, 18 insertions(+), 23 deletions(-) diff --git a/.github/workflows/behat-test.yml b/.github/workflows/behat-test.yml index de9b8c633..85e664fb6 100644 --- a/.github/workflows/behat-test.yml +++ b/.github/workflows/behat-test.yml @@ -60,8 +60,6 @@ jobs: fail-fast: true matrix: php: - - '7.2' - - '7.3' - '7.4' - '8.0' - '8.1' @@ -70,7 +68,7 @@ jobs: - php: '8.2' wordpress: 'latest' coverage: true - - php: '7.2' + - php: '7.4' wordpress: '6.3' - php: '8.3' wordpress: 'trunk' diff --git a/.github/workflows/php-test.yml b/.github/workflows/php-test.yml index bb7d48eec..03bc69be9 100644 --- a/.github/workflows/php-test.yml +++ b/.github/workflows/php-test.yml @@ -48,13 +48,12 @@ jobs: fail-fast: true matrix: php: - - '7.3' - '7.4' - '8.0' - '8.1' wordpress: [ 'latest' ] include: - - php: '7.2' + - php: '7.4' wordpress: '6.3' - php: '8.2' wordpress: 'latest' @@ -115,8 +114,6 @@ jobs: fail-fast: true matrix: php: - - '7.2' - - '7.3' - '7.4' - '8.0' - '8.1' diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 41a9bd898..c240bbeab 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,7 +7,7 @@ Thank you for your interest in contributing to the Plugin Check plugin! In general, all code must follow the [WordPress Coding Standards and best practices](https://developer.wordpress.org/coding-standards/). All code in the Plugin Check plugin must follow these requirements: - **WordPress**: The plugin's minimum WordPress version requirement is 6.3. -- **PHP**: Always match the latest WordPress version. The minimum required version right now is 7.2.24. +- **PHP**: The plugin's minimum PHP version requirement is 7.4. ## Guidelines diff --git a/composer.json b/composer.json index e654e06db..d23f2c8a7 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "license": "GPL-2.0-or-later", "type": "wordpress-plugin", "require": { - "php": ">=7.2.24", + "php": ">=7.4", "ext-json": "*", "afragen/wordpress-plugin-readme-parser": "dev-master#67fba498d0b112acf84386b95e4905c539a33f0b", "automattic/vipwpcs": "^3.0.0", @@ -56,7 +56,7 @@ "phpstan/extension-installer": true }, "platform": { - "php": "7.2.24" + "php": "7.4" } }, "scripts": { diff --git a/composer.lock b/composer.lock index f90aa24b8..2a01919ba 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "e1f6b4abdc63a16d7d5a7609f6df578a", + "content-hash": "3aab6089bbe13e7a4c81438da8f72ad6", "packages": [ { "name": "afragen/wordpress-plugin-readme-parser", @@ -6489,12 +6489,12 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=7.2.24", + "php": ">=7.4", "ext-json": "*" }, "platform-dev": [], "platform-overrides": { - "php": "7.2.24" + "php": "7.4" }, "plugin-api-version": "2.6.0" } diff --git a/phpcs-sniffs/composer.json b/phpcs-sniffs/composer.json index 321eea251..7258b4dba 100644 --- a/phpcs-sniffs/composer.json +++ b/phpcs-sniffs/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": ">=7.2.24", + "php": ">=7.4", "ext-libxml": "*", "ext-tokenizer": "*", "ext-xmlreader": "*", @@ -38,7 +38,7 @@ "dealerdirect/phpcodesniffer-composer-installer": true }, "platform": { - "php": "7.2.24" + "php": "7.4" } }, "scripts": { @@ -67,4 +67,4 @@ "lint": "Lint PHP files against parse errors.", "run-tests": "Run all the unit tests for the Plugin Check Coding Standards sniffs." } -} \ No newline at end of file +} diff --git a/phpcs-sniffs/composer.lock b/phpcs-sniffs/composer.lock index 4f32ab0cb..b76221c75 100644 --- a/phpcs-sniffs/composer.lock +++ b/phpcs-sniffs/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "e3f2033f9c52ac5eab10852c851d3007", + "content-hash": "49ca6c46b9685eb474d91448a1b9444f", "packages": [ { "name": "dealerdirect/phpcodesniffer-composer-installer", @@ -2050,14 +2050,14 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=7.2.24", + "php": ">=7.4", "ext-libxml": "*", "ext-tokenizer": "*", "ext-xmlreader": "*" }, "platform-dev": [], "platform-overrides": { - "php": "7.2.24" + "php": "7.4" }, "plugin-api-version": "2.6.0" } diff --git a/phpcs-sniffs/phpcs.xml.dist b/phpcs-sniffs/phpcs.xml.dist index 337d86812..9f61b589c 100644 --- a/phpcs-sniffs/phpcs.xml.dist +++ b/phpcs-sniffs/phpcs.xml.dist @@ -37,7 +37,7 @@ - + diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 178470c80..436717cd8 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -3,7 +3,7 @@ Sniffs for WordPress plugins, with minor modifications for Performance - + diff --git a/plugin.php b/plugin.php index 8de444180..a905b6c3d 100644 --- a/plugin.php +++ b/plugin.php @@ -4,7 +4,7 @@ * Plugin URI: https://github.com/WordPress/plugin-check * Description: Plugin Check is a WordPress.org tool which provides checks to help plugins meet the directory requirements and follow various best practices. * Requires at least: 6.3 - * Requires PHP: 7.2.24 + * Requires PHP: 7.4 * Version: 1.2.0 * Author: WordPress Performance Team and Plugin Review Team * License: GPLv2 or later @@ -17,7 +17,7 @@ use WordPress\Plugin_Check\Plugin_Main; define( 'WP_PLUGIN_CHECK_VERSION', '1.2.0' ); -define( 'WP_PLUGIN_CHECK_MINIMUM_PHP', '7.2.24' ); +define( 'WP_PLUGIN_CHECK_MINIMUM_PHP', '7.4' ); define( 'WP_PLUGIN_CHECK_MAIN_FILE', __FILE__ ); define( 'WP_PLUGIN_CHECK_PLUGIN_DIR_PATH', plugin_dir_path( WP_PLUGIN_CHECK_MAIN_FILE ) ); define( 'WP_PLUGIN_CHECK_PLUGIN_DIR_URL', plugin_dir_url( WP_PLUGIN_CHECK_MAIN_FILE ) ); From 805e6617eb8080b93f2a27ff7e665fed02162254 Mon Sep 17 00:00:00 2001 From: Nilambar Sharma Date: Tue, 19 Nov 2024 10:21:44 +0545 Subject: [PATCH 45/48] Update CONTRIBUTING.md Co-authored-by: Mukesh Panchal --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c240bbeab..f6ec40341 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,7 +7,7 @@ Thank you for your interest in contributing to the Plugin Check plugin! In general, all code must follow the [WordPress Coding Standards and best practices](https://developer.wordpress.org/coding-standards/). All code in the Plugin Check plugin must follow these requirements: - **WordPress**: The plugin's minimum WordPress version requirement is 6.3. -- **PHP**: The plugin's minimum PHP version requirement is 7.4. +- **PHP**: The minimum required version right now is 7.4. ## Guidelines From 59c529c826da058839d3bd76f5ff66671f343a6b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Nov 2024 18:34:44 +0000 Subject: [PATCH 46/48] Bump codecov/codecov-action from 4.6.0 to 5.0.2 Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 4.6.0 to 5.0.2. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Commits](https://github.com/codecov/codecov-action/compare/v4.6.0...v5.0.2) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/behat-test.yml | 2 +- .github/workflows/php-test.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/behat-test.yml b/.github/workflows/behat-test.yml index 85e664fb6..4f045338f 100644 --- a/.github/workflows/behat-test.yml +++ b/.github/workflows/behat-test.yml @@ -155,7 +155,7 @@ jobs: - name: Upload code coverage report if: ${{ matrix.coverage }} - uses: codecov/codecov-action@v4.6.0 + uses: codecov/codecov-action@v5.0.2 with: files: ${{ steps.coverage_files.outputs.files }} flags: feature diff --git a/.github/workflows/php-test.yml b/.github/workflows/php-test.yml index 03bc69be9..42aaefff9 100644 --- a/.github/workflows/php-test.yml +++ b/.github/workflows/php-test.yml @@ -100,7 +100,7 @@ jobs: - name: Upload code coverage report if: ${{ matrix.coverage }} - uses: codecov/codecov-action@68708a9f7a6b6b5fe33673f782f93725c5eff3c6 + uses: codecov/codecov-action@5c47607acb93fed5485fdbf7232e8a31425f672a with: file: build/logs/*.xml flags: unit @@ -146,7 +146,7 @@ jobs: - name: Upload code coverage report if: ${{ matrix.coverage }} - uses: codecov/codecov-action@68708a9f7a6b6b5fe33673f782f93725c5eff3c6 + uses: codecov/codecov-action@5c47607acb93fed5485fdbf7232e8a31425f672a with: file: build/logs/*.xml flags: phpcs-sniffs From 5121cccf114d66554f5394fd4ad3964037e2f24b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Nov 2024 17:57:41 +0000 Subject: [PATCH 47/48] Bump @wordpress/scripts from 30.4.0 to 30.5.1 Bumps [@wordpress/scripts](https://github.com/WordPress/gutenberg/tree/HEAD/packages/scripts) from 30.4.0 to 30.5.1. - [Release notes](https://github.com/WordPress/gutenberg/releases) - [Changelog](https://github.com/WordPress/gutenberg/blob/trunk/packages/scripts/CHANGELOG.md) - [Commits](https://github.com/WordPress/gutenberg/commits/@wordpress/scripts@30.5.1/packages/scripts) --- updated-dependencies: - dependency-name: "@wordpress/scripts" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package-lock.json | 79 +++++------------------------------------------ package.json | 2 +- 2 files changed, 8 insertions(+), 73 deletions(-) diff --git a/package-lock.json b/package-lock.json index cef620567..46c89297f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "license": "GPL-2.0-or-later", "devDependencies": { "@wordpress/env": "^10.11.0", - "@wordpress/scripts": "^30.4.0", + "@wordpress/scripts": "^30.5.1", "gherkin-lint": "^4.2.4", "patch-package": "^8.0.0" }, @@ -4639,9 +4639,9 @@ } }, "node_modules/@wordpress/scripts": { - "version": "30.4.0", - "resolved": "https://registry.npmjs.org/@wordpress/scripts/-/scripts-30.4.0.tgz", - "integrity": "sha512-hAX8XB8hWlxAyktT4KkBpGttRwSynmtkpLvbVKeKnj+BjABFs4TGb/HCF9hFpUK3huCAg8Ft/sjjczW+5tqspQ==", + "version": "30.5.1", + "resolved": "https://registry.npmjs.org/@wordpress/scripts/-/scripts-30.5.1.tgz", + "integrity": "sha512-VM5NViNfdQR69MWxLnptB8svvnrEV+oUVgWL8icsLdCt2CENgPwUIk/Gs0wzeAVK05cGjrCESapJnEgIXp5lzA==", "dev": true, "dependencies": { "@babel/core": "7.25.7", @@ -4686,7 +4686,6 @@ "npm-package-json-lint": "^6.4.0", "npm-packlist": "^3.0.0", "postcss": "^8.4.5", - "postcss-import": "^16.1.0", "postcss-loader": "^6.2.1", "prettier": "npm:wp-prettier@3.0.3", "puppeteer-core": "^23.1.0", @@ -14777,23 +14776,6 @@ "postcss": "^8.4.31" } }, - "node_modules/postcss-import": { - "version": "16.1.0", - "resolved": "https://registry.npmjs.org/postcss-import/-/postcss-import-16.1.0.tgz", - "integrity": "sha512-7hsAZ4xGXl4MW+OKEWCnF6T5jqBw80/EE9aXg1r2yyn1RsVEU8EtKXbijEODa+rg7iih4bKf7vlvTGYR4CnPNg==", - "dev": true, - "dependencies": { - "postcss-value-parser": "^4.0.0", - "read-cache": "^1.0.0", - "resolve": "^1.1.7" - }, - "engines": { - "node": ">=18.0.0" - }, - "peerDependencies": { - "postcss": "^8.0.0" - } - }, "node_modules/postcss-loader": { "version": "6.2.1", "resolved": "https://registry.npmjs.org/postcss-loader/-/postcss-loader-6.2.1.tgz", @@ -15771,24 +15753,6 @@ "node": ">=0.10.0" } }, - "node_modules/read-cache": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz", - "integrity": "sha512-Owdv/Ft7IjOgm/i0xvNDZ1LrRANRfew4b2prF3OWMQLxLfu3bS8FVhCsrSCMK4lR56Y9ya+AThoTpDCTxCmpRA==", - "dev": true, - "dependencies": { - "pify": "^2.3.0" - } - }, - "node_modules/read-cache/node_modules/pify": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/read-pkg": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-5.2.0.tgz", @@ -23060,9 +23024,9 @@ "requires": {} }, "@wordpress/scripts": { - "version": "30.4.0", - "resolved": "https://registry.npmjs.org/@wordpress/scripts/-/scripts-30.4.0.tgz", - "integrity": "sha512-hAX8XB8hWlxAyktT4KkBpGttRwSynmtkpLvbVKeKnj+BjABFs4TGb/HCF9hFpUK3huCAg8Ft/sjjczW+5tqspQ==", + "version": "30.5.1", + "resolved": "https://registry.npmjs.org/@wordpress/scripts/-/scripts-30.5.1.tgz", + "integrity": "sha512-VM5NViNfdQR69MWxLnptB8svvnrEV+oUVgWL8icsLdCt2CENgPwUIk/Gs0wzeAVK05cGjrCESapJnEgIXp5lzA==", "dev": true, "requires": { "@babel/core": "7.25.7", @@ -23107,7 +23071,6 @@ "npm-package-json-lint": "^6.4.0", "npm-packlist": "^3.0.0", "postcss": "^8.4.5", - "postcss-import": "^16.1.0", "postcss-loader": "^6.2.1", "prettier": "npm:wp-prettier@3.0.3", "puppeteer-core": "^23.1.0", @@ -30491,17 +30454,6 @@ "dev": true, "requires": {} }, - "postcss-import": { - "version": "16.1.0", - "resolved": "https://registry.npmjs.org/postcss-import/-/postcss-import-16.1.0.tgz", - "integrity": "sha512-7hsAZ4xGXl4MW+OKEWCnF6T5jqBw80/EE9aXg1r2yyn1RsVEU8EtKXbijEODa+rg7iih4bKf7vlvTGYR4CnPNg==", - "dev": true, - "requires": { - "postcss-value-parser": "^4.0.0", - "read-cache": "^1.0.0", - "resolve": "^1.1.7" - } - }, "postcss-loader": { "version": "6.2.1", "resolved": "https://registry.npmjs.org/postcss-loader/-/postcss-loader-6.2.1.tgz", @@ -31158,23 +31110,6 @@ "integrity": "sha512-jCvmsr+1IUSMUyzOkRcvnVbX3ZYC6g9TDrDbFuFmRDq7PD4yaGbLKNQL6k2jnArV8hjYxh7hVhAZB6s9HDGpZA==", "dev": true }, - "read-cache": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz", - "integrity": "sha512-Owdv/Ft7IjOgm/i0xvNDZ1LrRANRfew4b2prF3OWMQLxLfu3bS8FVhCsrSCMK4lR56Y9ya+AThoTpDCTxCmpRA==", - "dev": true, - "requires": { - "pify": "^2.3.0" - }, - "dependencies": { - "pify": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==", - "dev": true - } - } - }, "read-pkg": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-5.2.0.tgz", diff --git a/package.json b/package.json index e0477b1e8..6d99f1ee2 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ }, "devDependencies": { "@wordpress/env": "^10.11.0", - "@wordpress/scripts": "^30.4.0", + "@wordpress/scripts": "^30.5.1", "gherkin-lint": "^4.2.4", "patch-package": "^8.0.0" }, From d030548fa670a059a08ed4649e5f52e2e324738b Mon Sep 17 00:00:00 2001 From: Nilambar Sharma Date: Tue, 19 Nov 2024 12:28:13 +0545 Subject: [PATCH 48/48] Update @wordpress/env --- package-lock.json | 15 ++++++++------- package.json | 2 +- ...10.10.0.patch => @wordpress+env+10.12.0.patch} | 0 3 files changed, 9 insertions(+), 8 deletions(-) rename patches/{@wordpress+env+10.10.0.patch => @wordpress+env+10.12.0.patch} (100%) diff --git a/package-lock.json b/package-lock.json index 46c89297f..d32c52aa6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,7 +8,7 @@ "hasInstallScript": true, "license": "GPL-2.0-or-later", "devDependencies": { - "@wordpress/env": "^10.11.0", + "@wordpress/env": "^10.12.0", "@wordpress/scripts": "^30.5.1", "gherkin-lint": "^4.2.4", "patch-package": "^8.0.0" @@ -4448,10 +4448,11 @@ } }, "node_modules/@wordpress/env": { - "version": "10.11.0", - "resolved": "https://registry.npmjs.org/@wordpress/env/-/env-10.11.0.tgz", - "integrity": "sha512-Sd31oiYxy9/pNMfYw7XgtCBoD4PpvcK1UQ/FVFP+DsTTuo55Ma4UAHMKfg2NhnZWqhJTgPC6XXzicGpr/lK4RQ==", + "version": "10.12.0", + "resolved": "https://registry.npmjs.org/@wordpress/env/-/env-10.12.0.tgz", + "integrity": "sha512-+tsdVfngQYcysxdVonXRSwuJjqoqTSv7wwrcThCYXR1OBCMQ/xT2Ywfvf9a/yItJs5uicO9Vx8B5aIuvXiGVqg==", "dev": true, + "license": "GPL-2.0-or-later", "dependencies": { "chalk": "^4.0.0", "copy-dir": "^1.3.0", @@ -22905,9 +22906,9 @@ } }, "@wordpress/env": { - "version": "10.11.0", - "resolved": "https://registry.npmjs.org/@wordpress/env/-/env-10.11.0.tgz", - "integrity": "sha512-Sd31oiYxy9/pNMfYw7XgtCBoD4PpvcK1UQ/FVFP+DsTTuo55Ma4UAHMKfg2NhnZWqhJTgPC6XXzicGpr/lK4RQ==", + "version": "10.12.0", + "resolved": "https://registry.npmjs.org/@wordpress/env/-/env-10.12.0.tgz", + "integrity": "sha512-+tsdVfngQYcysxdVonXRSwuJjqoqTSv7wwrcThCYXR1OBCMQ/xT2Ywfvf9a/yItJs5uicO9Vx8B5aIuvXiGVqg==", "dev": true, "requires": { "chalk": "^4.0.0", diff --git a/package.json b/package.json index 6d99f1ee2..4e7460cfb 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "npm": ">=10.2.3" }, "devDependencies": { - "@wordpress/env": "^10.11.0", + "@wordpress/env": "^10.12.0", "@wordpress/scripts": "^30.5.1", "gherkin-lint": "^4.2.4", "patch-package": "^8.0.0" diff --git a/patches/@wordpress+env+10.10.0.patch b/patches/@wordpress+env+10.12.0.patch similarity index 100% rename from patches/@wordpress+env+10.10.0.patch rename to patches/@wordpress+env+10.12.0.patch