Skip to content

Commit f183444

Browse files
committed
Report Full: fix delimiter line bug
When determining the max message length, the calculation did not take potential explicit multi-line messages into account and would base the delimiter line length on the length of the complete message, not on the length of the individual lines. Fixed now.
1 parent 7fb9515 commit f183444

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/Reports/Full.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,21 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false,
6969
$length += (strlen($error['source']) + 3);
7070
}
7171

72+
// Handle multi-line message correctly.
73+
if (strpos($error['message'], "\n") !== false) {
74+
$errorLines = explode("\n", $error['message']);
75+
$length = max(array_map('strlen', $errorLines));
76+
77+
if ($showSources === true) {
78+
$lastLine = array_pop($errorLines);
79+
$length = max($length, (strlen($lastLine) + (strlen($error['source']) + 3)));
80+
}
81+
}
82+
7283
$maxErrorLength = max($maxErrorLength, ($length + 1));
7384
}
74-
}
75-
}
85+
}//end foreach
86+
}//end foreach
7687

7788
$file = $report['filename'];
7889
$fileLength = strlen($file);

0 commit comments

Comments
 (0)