fix: pad the last table row and report tables at the right level - #188
Merged
Merged
Conversation
The padding of an AsciiTable applies to the rows added so far, so setting it inside the row loop left the row added last unpadded. The rendered table was also always logged at info, while the header of the category it belongs to was logged at warn, which dropped the violations of a quiet build. Extracts the parts shared by both console reporters into AbstractConsoleViolationReporter, and covers the rendered output with snapshot tests.
NicklasWallgren
enabled auto-merge (squash)
September 11, 2026 17:14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two output bugs in
ConsoleTableViolationReporter, plus test coverage of the rendered output.The last row of every table was rendered unpadded
table.setPadding(1)was called inside the row loop.AsciiTable.setPaddingLeftiterates the rows added so far and applies the padding retroactively — it is not a default for rows added later. Each iteration therefore padded everything up to the previous row, and the final violation never got padded:Now set once, after every row is in place. Note that hoisting the call above the loop would have been worse — only the header would have been padded.
Tables were logged at info even for non-permissive violations
The category header went through
logWithLevel(→warn), but the table itself was a hardcodedlog.info(...). Under a quiet build you got the warning header and lost the violations it referred to. Now routed throughlogWithLevel, matchingConsolePlainViolationReporter.Shared base class
report(),logViolationsForType(),logWithLevel(), thePermissiveTypeenum and the ANSI constants were byte-identical in both reporters. Extracted intoAbstractConsoleViolationReporterwith a single abstract hook,logViolations(log, violations, permissiveType)— the only thing the two reporters actually do differently.Also dropped the stale
Severity#MINORjavadoc (neither reporter filters by severity), corrected the column comments, and named the magicrender(200).Tests
11 tests over both reporters.
RecordingLogcaptures each message together with the level it was logged at, which is what makes the level bug assertable.UnitTest#snapshotTextsnapshots output verbatim rather than as JSON, so the rendered table is reviewable in the.snapfile.Both bugs were re-introduced to confirm the tests catch them — 4 of 6 failed:
givenPermissiveViolations_whenReport_thenTableIsReportedAsInfokept passing, since info is correct on that path.Not addressed
MessageUtils, which would mean addingmaven-shared-utilsas aprovideddependency.Violation.severity, thoughGitLabFileViolationReporterdoes.