From 6867ce787966092025aead901dc9a75cf027f63b Mon Sep 17 00:00:00 2001 From: Nilambar Sharma Date: Tue, 30 Dec 2025 16:31:32 +0545 Subject: [PATCH] Make markdown file check case insensitive --- includes/Checker/Checks/Plugin_Repo/File_Type_Check.php | 9 +++++---- .../plugins/test-plugin-ai-instructions-errors/Readme.md | 3 +++ 2 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 tests/phpunit/testdata/plugins/test-plugin-ai-instructions-errors/Readme.md diff --git a/includes/Checker/Checks/Plugin_Repo/File_Type_Check.php b/includes/Checker/Checks/Plugin_Repo/File_Type_Check.php index 168ea3e11..f470b8dd5 100644 --- a/includes/Checker/Checks/Plugin_Repo/File_Type_Check.php +++ b/includes/Checker/Checks/Plugin_Repo/File_Type_Check.php @@ -577,9 +577,10 @@ protected function check_github_directory( Check_Result $result, array $files ) * @param array $files List of file paths. */ protected function check_unexpected_markdown_files( Check_Result $result, array $files ) { - $plugin_path = $result->plugin()->path(); - $allowed_root_md_files = array( 'README.md', 'readme.txt', 'LICENSE', 'LICENSE.md', 'CHANGELOG.md', 'CONTRIBUTING.md', 'SECURITY.md' ); - $root_md_files = array(); + $plugin_path = $result->plugin()->path(); + $allowed_root_md_files = array( 'README.md', 'readme.txt', 'LICENSE', 'LICENSE.md', 'CHANGELOG.md', 'CONTRIBUTING.md', 'SECURITY.md' ); + $allowed_root_md_files_lower = array_map( 'strtolower', $allowed_root_md_files ); + $root_md_files = array(); foreach ( $files as $file ) { $relative_path = str_replace( $plugin_path, '', $file ); @@ -587,7 +588,7 @@ protected function check_unexpected_markdown_files( Check_Result $result, array $basename = basename( $file ); if ( substr_count( $relative_path, '/' ) === 0 && pathinfo( $file, PATHINFO_EXTENSION ) === 'md' ) { - if ( ! in_array( $basename, $allowed_root_md_files, true ) ) { + if ( ! in_array( strtolower( $basename ), $allowed_root_md_files_lower, true ) ) { $root_md_files[] = $file; } } diff --git a/tests/phpunit/testdata/plugins/test-plugin-ai-instructions-errors/Readme.md b/tests/phpunit/testdata/plugins/test-plugin-ai-instructions-errors/Readme.md new file mode 100644 index 000000000..e52a2437d --- /dev/null +++ b/tests/phpunit/testdata/plugins/test-plugin-ai-instructions-errors/Readme.md @@ -0,0 +1,3 @@ +# Test Plugin + +This plugin is for testing purposes.