Skip to content

fix: address bugs in nolint parsing, unicode alignment, and flag stripping#50

Merged
peczenyj merged 6 commits into
develfrom
fix/deep-review-improvements
May 27, 2026
Merged

fix: address bugs in nolint parsing, unicode alignment, and flag stripping#50
peczenyj merged 6 commits into
develfrom
fix/deep-review-improvements

Conversation

@peczenyj

Copy link
Copy Markdown
Owner

This PR addresses several bugs identified during a deep review:

CI is green locally (task ci passed).

peczenyj added 2 commits May 27, 2026 07:53
…pping

- internal/align: refine parseNolint to support block comments with
  leading stars and multiple lines (e.g., /* * nolint */).
- internal/ui: improve truncPad to account for double-width CJK
  characters, ensuring stable column alignment in side-by-side diffs.
- internal/app: refactor egg flag stripping to robustly handle
  both exact and -flag=value syntax.
- internal/match: deduplicate CSV splitting logic into a shared
  SplitCSV helper.
- internal/ui: ensure test predictability by handling nil *os.File
  in terminal width and color detection.
Refactor the preprocessing of command-line arguments to isolate the
retro-theme "easter egg" flag logic into a dedicated stripEggFlags
method. This improves the readability of the main Run orchestration
while switching the implementation to a more robust and concise
regular expression approach.
@codecov-commenter

codecov-commenter commented May 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.74074% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.15%. Comparing base (ad3263a) to head (b122644).

Files with missing lines Patch % Lines
internal/ui/term.go 50.00% 4 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            devel      #50      +/-   ##
==========================================
+ Coverage   92.88%   93.15%   +0.26%     
==========================================
  Files          12       12              
  Lines         871      876       +5     
==========================================
+ Hits          809      816       +7     
+ Misses         34       33       -1     
+ Partials       28       27       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

peczenyj and others added 4 commits May 27, 2026 08:19
Replace the custom, complex runeWidth logic with the industry-standard
go-runewidth library. This improves accuracy for visual width
calculations (especially for CJK characters and combining marks)
and removes an unrelated maintenance burden from the project.
The go-runewidth import was grouped with the local peczenyj imports; gci
(and `task ci`) wants third-party and local prefixes in separate blocks.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Regression tests for the three fixes in this branch, none of which had
tests:

- parseNolint: multiline star-prefixed block comments (/*\n * nolint\n */)
  and block comments carrying a token list, which the existing test (bare
  /* nolint */) did not exercise.
- truncPad: CJK (two-cell) runes in both the padding and truncation paths;
  the prior test's result was all narrow runes, so it passed even under the
  old rune-count implementation.
- WantColor / ResolveWidth: the nil *os.File path (non-*os.File writer),
  which previously would have dereferenced nil.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Address the codecov patch-coverage report on the changed lines:

- truncPad: restructure to pad-if-fits / else truncate-with-ellipsis-and-
  pad. This removes the previously unreachable trailing `return "…"` (dead
  code the coverage tool flagged) and fixes a real bug — a wide rune
  straddling the truncation boundary used to leave the column one cell
  short, misaligning side-by-side output. No golden fixture truncates, so
  output for existing cases is unchanged.
- add TestIsCharDeviceNil for the nil-file guard (stdoutFile passes nil for
  non-file writers; WantColor short-circuits so it was never exercised).
- add TestStdoutFile covering both the *os.File and non-file branches.

The remaining uncovered patch lines are the term.GetSize success branches
in ResolveWidth, which need a real terminal (PTY) to exercise; they were
uncovered on devel too and the patch only re-indented them.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@peczenyj peczenyj merged commit 81194dc into devel May 27, 2026
6 checks passed
@peczenyj peczenyj deleted the fix/deep-review-improvements branch May 27, 2026 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants