Skip to content

Commit

Permalink
Merge pull request #417 from ernilambar/improve-readme-plugin-name-he…
Browse files Browse the repository at this point in the history
…ader-check

Improve readme plugin name header check
  • Loading branch information
mukeshpanchal27 authored Feb 7, 2024
2 parents 72968ef + 3e12127 commit 52b0e90
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
20 changes: 10 additions & 10 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions includes/Checker/Checks/Plugin_Readme_Check.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,11 @@ protected function check_files( Check_Result $result, array $files ) {
* @param Parser $parser The Parser object.
*/
private function check_name( Check_Result $result, string $readme_file, Parser $parser ) {
if ( isset( $parser->warnings['invalid_plugin_name_header'] ) ) {
if ( isset( $parser->warnings['invalid_plugin_name_header'] ) && false === $parser->name ) {
$message = sprintf(
/* translators: 1: 'Plugin Name' section title, 2: 'Plugin Name' */
__( 'Plugin name look like: "%1$s". Please change "%2$s" to reflect the actual name of your plugin.', 'plugin-check' ),
'=== Plugin Name ===',
'Plugin Name'
/* translators: %s: Example plugin name header */
__( 'Plugin name header in your readme is missing or invalid. Please update your readme with a valid plugin name header. Eg: "%s"', 'plugin-check' ),
'=== Example Name ==='
);

$this->add_result_error_for_file( $result, $message, 'invalid_plugin_name', $readme_file );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ public function test_run_with_errors_empty_name() {

$this->assertNotEmpty( $errors );
$this->assertArrayHasKey( 'readme.txt', $errors );
// Two errors are 'empty_plugin_name' and 'no_license'.
$this->assertEquals( 2, $check_result->get_error_count() );
$this->assertEmpty( $warnings );
$this->assertEquals( 0, $check_result->get_warning_count() );

Expand Down

0 comments on commit 52b0e90

Please sign in to comment.