From 93767eaea5e792c7d69594487d1f4d992b286f67 Mon Sep 17 00:00:00 2001 From: Nilambar Sharma Date: Fri, 2 Jan 2026 12:26:36 +0545 Subject: [PATCH 1/2] Improve contributors check in readme --- includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php b/includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php index f51dbed9f..655d39eb4 100644 --- a/includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php +++ b/includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php @@ -754,9 +754,8 @@ private function check_for_contributors( Check_Result $result, string $readme_fi return; } - $usernames = explode( ',', $matches[1] ); - - $usernames = array_unique( array_map( 'trim', $usernames ) ); + $usernames = explode( ',', trim( $matches[1], ' ,' ) ); + $usernames = array_filter( array_unique( array_map( 'trim', $usernames ) ), 'strlen' ); $valid = true; From 9b9227b044eb96c9f0c59986146344b771fc217d Mon Sep 17 00:00:00 2001 From: Nilambar Sharma Date: Fri, 2 Jan 2026 12:43:05 +0545 Subject: [PATCH 2/2] Add unit test case for the changes --- .../Checks/Plugin_Repo/Plugin_Readme_Check.php | 2 +- .../load.php | 17 +++++++++++++++++ .../readme.txt | 13 +++++++++++++ .../Checks/Plugin_Readme_Check_Tests.php | 13 +++++++++++++ 4 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 tests/phpunit/testdata/plugins/test-plugin-readme-contributors-formatting/load.php create mode 100644 tests/phpunit/testdata/plugins/test-plugin-readme-contributors-formatting/readme.txt diff --git a/includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php b/includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php index 655d39eb4..eea1b489a 100644 --- a/includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php +++ b/includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php @@ -755,7 +755,7 @@ private function check_for_contributors( Check_Result $result, string $readme_fi } $usernames = explode( ',', trim( $matches[1], ' ,' ) ); - $usernames = array_filter( array_unique( array_map( 'trim', $usernames ) ), 'strlen' ); + $usernames = array_filter( array_unique( array_map( 'trim', $usernames ) ) ); $valid = true; diff --git a/tests/phpunit/testdata/plugins/test-plugin-readme-contributors-formatting/load.php b/tests/phpunit/testdata/plugins/test-plugin-readme-contributors-formatting/load.php new file mode 100644 index 000000000..f85762b73 --- /dev/null +++ b/tests/phpunit/testdata/plugins/test-plugin-readme-contributors-formatting/load.php @@ -0,0 +1,17 @@ +assertCount( 0, wp_list_filter( $warnings['readme.txt'][0][0], array( 'code' => 'readme_invalid_contributors' ) ) ); } + public function test_run_without_errors_readme_contributors_formatting() { + $readme_check = new Plugin_Readme_Check(); + $check_context = new Check_Context( UNIT_TESTS_PLUGIN_DIR . 'test-plugin-readme-contributors-formatting/load.php' ); + $check_result = new Check_Result( $check_context ); + + $readme_check->run( $check_result ); + + $warnings = $check_result->get_warnings(); + + // Should not contain contributors warning even with leading/trailing spaces and commas. + $this->assertCount( 0, wp_list_filter( $warnings['readme.txt'][0][0], array( 'code' => 'readme_invalid_contributors' ) ) ); + } + public function test_run_with_mismatched_requires_headers() { $check = new Plugin_Readme_Check(); $check_context = new Check_Context( UNIT_TESTS_PLUGIN_DIR . 'test-trademarks-plugin-readme-errors/load.php' );