Skip to content

Commit

Permalink
Report Full: remove duplicate function call
Browse files Browse the repository at this point in the history
... and comment the code little more.
  • Loading branch information
jrfnl committed Dec 10, 2023
1 parent f183444 commit 10fa198
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/Reports/Full.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,24 +64,26 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false,
foreach ($report['messages'] as $line => $lineErrors) {
foreach ($lineErrors as $column => $colErrors) {
foreach ($colErrors as $error) {
$length = strlen($error['message']);
// Start with the presumption of a single line error message.
$length = strlen($error['message']);
$srcLength = (strlen($error['source']) + 3);
if ($showSources === true) {
$length += (strlen($error['source']) + 3);
$length += $srcLength;
}

// Handle multi-line message correctly.
// ... but also handle multi-line messages correctly.
if (strpos($error['message'], "\n") !== false) {
$errorLines = explode("\n", $error['message']);
$length = max(array_map('strlen', $errorLines));

if ($showSources === true) {
$lastLine = array_pop($errorLines);
$length = max($length, (strlen($lastLine) + (strlen($error['source']) + 3)));
$length = max($length, (strlen($lastLine) + $srcLength));
}
}

$maxErrorLength = max($maxErrorLength, ($length + 1));
}
}//end foreach
}//end foreach
}//end foreach

Expand Down

0 comments on commit 10fa198

Please sign in to comment.