Skip to content

Commit

Permalink
Merge pull request #387 from WordPress/fix/checks-exclude-checks-over…
Browse files Browse the repository at this point in the history
…laps

Fix: Fatal error when in checks in `--checks` and `--exclude-checks` overlaps
  • Loading branch information
felixarntz committed Jan 12, 2024
2 parents bd43647 + 5fc1a14 commit 0e0f38d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 2 additions & 3 deletions includes/Checker/Abstract_Check_Runner.php
Expand Up @@ -410,6 +410,7 @@ final public function get_checks_to_run() {
$excluded_checks = $this->get_check_exclude_slugs();

$collection = $this->check_repository->get_checks( $check_flags )
->require( $check_slugs ) // Ensures all of the given slugs are valid.
->include( $check_slugs ) // Ensures only the checks with the given slugs are included.
->exclude( $excluded_checks ); // Exclude provided checks from list.

Expand All @@ -419,9 +420,7 @@ final public function get_checks_to_run() {
$collection = Check_Categories::filter_checks_by_categories( $collection, $categories );
}

return $collection
->require( $check_slugs ) // Ensures all of the given slugs are valid.
->to_map();
return $collection->to_map();
}

/**
Expand Down
9 changes: 9 additions & 0 deletions tests/behat/features/plugin-check.feature
Expand Up @@ -84,6 +84,15 @@ Feature: Test that the WP-CLI command works.
"""
WordPress.WP.AlternativeFunctions.rand_mt_rand
"""
When I run the WP-CLI command `plugin check hello.php --checks=plugin_review_phpcs,late_escaping --exclude-checks=late_escaping`
Then STDOUT should contain:
"""
WordPress.WP.AlternativeFunctions.rand_mt_rand
"""
And STDOUT should not contain:
"""
WordPress.Security.EscapeOutput.OutputNotEscaped
"""

Scenario: Check Akismet
Given a WP install with the Plugin Check plugin
Expand Down

0 comments on commit 0e0f38d

Please sign in to comment.