Skip to content

Commit

Permalink
suggested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
davidperezgar committed Oct 16, 2024
1 parent 2df3000 commit 37fd096
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions includes/CLI/Plugin_Check_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public function check( $args, $assoc_args ) {
'severity' => '',
'error-severity' => '',
'warning-severity' => '',
'include-low-severity-errors' => '',
'include-low-severity-errors' => false,
'slug' => '',
)
);
Expand Down Expand Up @@ -670,33 +670,30 @@ private function has_runtime_check( array $checks ) {
*
* @since 1.1.0
*
* @param array $results Check results.
* @param int $error_severity Error severity level.
* @param int $warning_severity Warning severity level.
* @param array $results Check results.
* @param int $error_severity Error severity level.
* @param int $warning_severity Warning severity level.
* @param bool $include_low_severity_errors Include less level of severity issues as warning.
*
*
* @SuppressWarnings(PHPMD.BooleanArgumentFlag)
* @return array Filtered results.
*/
private function get_filtered_results_by_severity( $results, $error_severity, $warning_severity, $include_low_severity_errors = false ) {
$errors = array();
$errors = array();
$warnings = array();

foreach ( $results as $item ) {
if ( 'ERROR' === $item['type'] && $item['severity'] >= $error_severity ) {
$errors[] = $item;

Check warning on line 687 in includes/CLI/Plugin_Check_Command.php

View check run for this annotation

Codecov / codecov/patch

includes/CLI/Plugin_Check_Command.php#L687

Added line #L687 was not covered by tests
} elseif ( $include_low_severity_errors && $item['severity'] < $error_severity ) {
$item['type'] = 'WARNING';
$item['severity'] = 10;
$errors[] = $item;
$warnings[] = $item;

Check warning on line 691 in includes/CLI/Plugin_Check_Command.php

View check run for this annotation

Codecov / codecov/patch

includes/CLI/Plugin_Check_Command.php#L689-L691

Added lines #L689 - L691 were not covered by tests
} elseif ( 'WARNING' === $item['type'] && $item['severity'] >= $warning_severity ) {
$warnings[] = $item;

Check warning on line 693 in includes/CLI/Plugin_Check_Command.php

View check run for this annotation

Codecov / codecov/patch

includes/CLI/Plugin_Check_Command.php#L693

Added line #L693 was not covered by tests
}
}

$warnings = array_filter(
$results,
function ( $item ) use ( $warning_severity ) {
return ( 'WARNING' === $item['type'] && $item['severity'] >= $warning_severity );
}
);

return array_merge( $errors, $warnings );
}
}

0 comments on commit 37fd096

Please sign in to comment.