Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update severity of certain checks in Plugin_Readme_Check #279

Merged
merged 2 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions includes/Checker/Checks/Plugin_Readme_Check.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ private function check_stable_tag( Check_Result $result, array $files ) {

if ( 'trunk' === $stable_tag ) {
$result->add_message(
false,
true,
__( "It's recommended not to use 'Stable Tag: trunk'.", 'plugin-check' ),
array(
'code' => 'trunk_stable_tag',
Expand All @@ -200,7 +200,7 @@ private function check_stable_tag( Check_Result $result, array $files ) {
$stable_tag !== $plugin_data['Version']
) {
$result->add_message(
false,
true,
__( 'The Stable Tag in your readme file does not match the version in your main plugin file.', 'plugin-check' ),
array(
'code' => 'stable_tag_mismatch',
Expand Down
63 changes: 34 additions & 29 deletions tests/phpunit/Checker/Checks/Plugin_Readme_Check_Tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,23 @@ public function test_run_with_errors_stable_tag() {

$readme_check->run( $check_result );

$warnings = $check_result->get_warnings();

$this->assertNotEmpty( $warnings );
$this->assertArrayHasKey( 'readme.txt', $warnings );
$this->assertEquals( 2, $check_result->get_warning_count() );

// Check for trunk stable tag warning.
$this->assertArrayHasKey( 0, $warnings['readme.txt'] );
$this->assertArrayHasKey( 0, $warnings['readme.txt'][0] );
$this->assertArrayHasKey( 'code', $warnings['readme.txt'][0][0][0] );
$this->assertEquals( 'trunk_stable_tag', $warnings['readme.txt'][0][0][0]['code'] );

// Check for stable tag mismatch file warning.
$this->assertArrayHasKey( 0, $warnings['readme.txt'] );
$this->assertArrayHasKey( 0, $warnings['readme.txt'][0] );
$this->assertArrayHasKey( 'code', $warnings['readme.txt'][0][0][1] );
$this->assertEquals( 'stable_tag_mismatch', $warnings['readme.txt'][0][0][1]['code'] );
$errors = $check_result->get_errors();

$this->assertNotEmpty( $errors );
$this->assertArrayHasKey( 'readme.txt', $errors );
$this->assertEquals( 2, $check_result->get_error_count() );

// Check for trunk stable tag error.
$this->assertArrayHasKey( 0, $errors['readme.txt'] );
$this->assertArrayHasKey( 0, $errors['readme.txt'][0] );
$this->assertArrayHasKey( 'code', $errors['readme.txt'][0][0][0] );
$this->assertEquals( 'trunk_stable_tag', $errors['readme.txt'][0][0][0]['code'] );

// Check for stable tag mismatch file error.
$this->assertArrayHasKey( 0, $errors['readme.txt'] );
$this->assertArrayHasKey( 0, $errors['readme.txt'][0] );
$this->assertArrayHasKey( 'code', $errors['readme.txt'][0][0][1] );
$this->assertEquals( 'stable_tag_mismatch', $errors['readme.txt'][0][0][1]['code'] );
}

public function test_run_with_errors_license() {
Expand Down Expand Up @@ -136,11 +136,16 @@ public function test_run_md_with_errors() {

$readme_check->run( $check_result );

$errors = $check_result->get_errors();
$warnings = $check_result->get_warnings();

$this->assertNotEmpty( $errors );
$this->assertArrayHasKey( 'readme.md', $errors );
$this->assertEquals( 2, $check_result->get_error_count() );

$this->assertNotEmpty( $warnings );
$this->assertArrayHasKey( 'readme.md', $warnings );
$this->assertEquals( 4, $check_result->get_warning_count() );
$this->assertEquals( 2, $check_result->get_warning_count() );

// Check for default text file warning.
$this->assertArrayHasKey( 0, $warnings['readme.md'] );
Expand All @@ -154,17 +159,17 @@ public function test_run_md_with_errors() {
$this->assertArrayHasKey( 'code', $warnings['readme.md'][0][0][1] );
$this->assertEquals( 'invalid_license', $warnings['readme.md'][0][0][1]['code'] );

// Check for trunk stable tag warning.
$this->assertArrayHasKey( 0, $warnings['readme.md'] );
$this->assertArrayHasKey( 0, $warnings['readme.md'][0] );
$this->assertArrayHasKey( 'code', $warnings['readme.md'][0][0][2] );
$this->assertEquals( 'trunk_stable_tag', $warnings['readme.md'][0][0][2]['code'] );

// Check for stable tag mismatch file warning.
$this->assertArrayHasKey( 0, $warnings['readme.md'] );
$this->assertArrayHasKey( 0, $warnings['readme.md'][0] );
$this->assertArrayHasKey( 'code', $warnings['readme.md'][0][0][3] );
$this->assertEquals( 'stable_tag_mismatch', $warnings['readme.md'][0][0][3]['code'] );
// Check for trunk stable tag error.
$this->assertArrayHasKey( 0, $errors['readme.md'] );
$this->assertArrayHasKey( 0, $errors['readme.md'][0] );
$this->assertArrayHasKey( 'code', $errors['readme.md'][0][0][0] );
$this->assertEquals( 'trunk_stable_tag', $errors['readme.md'][0][0][0]['code'] );

// Check for stable tag mismatch file error.
$this->assertArrayHasKey( 0, $errors['readme.md'] );
$this->assertArrayHasKey( 0, $errors['readme.md'][0] );
mukeshpanchal27 marked this conversation as resolved.
Show resolved Hide resolved
$this->assertArrayHasKey( 'code', $errors['readme.md'][0][0][1] );
$this->assertEquals( 'stable_tag_mismatch', $errors['readme.md'][0][0][1]['code'] );
}

public function test_run_root_readme_file_without_errors() {
Expand Down