Skip to content

Commit

Permalink
AbstractSniffUnitTest: bug fix - warnings not counted in total
Browse files Browse the repository at this point in the history
At the bottom of a test run a message along the lines of `4 sniff test files generated 2 unique error codes; 0 were fixable (0%)` is shown.

The unique error codes, as well as the fixable count and percentage would only include `error` codes and would totally disregard the codes coming from `warning`s.

Fixed now.
  • Loading branch information
jrfnl committed Mar 11, 2020
1 parent 1dbc333 commit fac9db0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/Standards/AbstractSniffUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,17 @@ public function generateFailureMessages(LocalFile $file)
$warningsTemp = [];
foreach ($warnings as $warning) {
$warningsTemp[] = $warning['message'].' ('.$warning['source'].')';

$source = $warning['source'];
if (in_array($source, $GLOBALS['PHP_CODESNIFFER_SNIFF_CODES'], true) === false) {
$GLOBALS['PHP_CODESNIFFER_SNIFF_CODES'][] = $source;
}

if ($warning['fixable'] === true
&& in_array($source, $GLOBALS['PHP_CODESNIFFER_FIXABLE_CODES'], true) === false
) {
$GLOBALS['PHP_CODESNIFFER_FIXABLE_CODES'][] = $source;
}
}

$allProblems[$line]['found_warnings'] = array_merge($foundWarningsTemp, $warningsTemp);
Expand Down

0 comments on commit fac9db0

Please sign in to comment.