Skip to content

Commit fac9db0

Browse files
committed
AbstractSniffUnitTest: bug fix - warnings not counted in total
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.
1 parent 1dbc333 commit fac9db0

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tests/Standards/AbstractSniffUnitTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,17 @@ public function generateFailureMessages(LocalFile $file)
320320
$warningsTemp = [];
321321
foreach ($warnings as $warning) {
322322
$warningsTemp[] = $warning['message'].' ('.$warning['source'].')';
323+
324+
$source = $warning['source'];
325+
if (in_array($source, $GLOBALS['PHP_CODESNIFFER_SNIFF_CODES'], true) === false) {
326+
$GLOBALS['PHP_CODESNIFFER_SNIFF_CODES'][] = $source;
327+
}
328+
329+
if ($warning['fixable'] === true
330+
&& in_array($source, $GLOBALS['PHP_CODESNIFFER_FIXABLE_CODES'], true) === false
331+
) {
332+
$GLOBALS['PHP_CODESNIFFER_FIXABLE_CODES'][] = $source;
333+
}
323334
}
324335

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

0 commit comments

Comments
 (0)