Skip to content

feat: respect //nolint directives (diff mode)#39

Merged
peczenyj merged 7 commits into
develfrom
feature/nolint-respect
May 26, 2026
Merged

feat: respect //nolint directives (diff mode)#39
peczenyj merged 7 commits into
develfrom
feature/nolint-respect

Conversation

@peczenyj
Copy link
Copy Markdown
Owner

Diff mode now respects //nolint directives by default, matching golangci-lint: a struct whose type declaration carries a recognized directive is suppressed.

  • Default tokens: the named fieldalignment plus a bare //nolint (always honored).
  • -nolint-linters (default "fieldalignment") customizes the named token set, e.g. -nolint-linters=fieldalignment,betteralign.
  • -show-nolint reveals suppressed structs (audit mode).
  • Detection reads the type's doc comment (TypeSpec.Doc / grouped GenDecl.Doc) and any comment on the type's opening line — catching a trailing type T struct { //nolint, which the AST doesn't attach to TypeSpec.Comment (matched by line, like golangci-lint).
  • Inspect mode ignores these directives (a //nolint:fieldalignment is about the finding, which inspect doesn't produce).

New common.Options fields RespectNolint/NolintLinters carry the policy into internal/align; the short-circuit sits beside the existing filters in buildFinding.

Tests: 3 in internal/align (doc directive suppresses, unrelated //nolint:errcheck doesn't, bare trailing //nolint suppresses, configurable token set) + 4 in internal/app (hidden by default, -show-nolint reveals, -nolint-linters opt-out, inspect ignores). task ci green (103 tests).

⚠️ Stacked (base feature/threshold) during the GitHub Actions incident; base retargets to devel as the stack merges.

Closes #32

🤖 Generated with Claude Code

peczenyj and others added 4 commits May 26, 2026 14:21
-sort (default off) collects findings across all scanned packages and
presents them largest-first by absolute bytes saved (OldSize-NewSize),
using a stable sort so equal-savings structs keep source order and
unknown-size findings sink to the bottom. Diff mode only for now; inspect
support follows.

Part of #30

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
In -inspect mode, -sort now collects all layouts across packages and
orders them largest-first by Layout.Total (stable sort). Updates the flag
help to cover both modes. Diff behavior unchanged.

Closes #30

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
-threshold N (int, default 0, diff-only) drops findings that save fewer
than N bytes. Negative values are treated as 0 (no filtering). The filter
runs before sort and summary, so -summary counts only the kept structs and
the exit code is 0 when everything is filtered out.

Closes #31

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
In diff mode, a struct whose type declaration carries a recognized //nolint
directive is now suppressed by default, matching golangci-lint. Recognized:
the named token "fieldalignment" (configurable via -nolint-linters) and a
bare //nolint (always honored). -show-nolint reveals suppressed structs.

Detection reads the type's doc comment (TypeSpec.Doc / grouped GenDecl.Doc)
and any comment on the type's opening line (catching a trailing
`type T struct { //nolint`, which the AST doesn't attach to TypeSpec.Comment).
Inspect mode ignores these directives. New common.Options fields
RespectNolint/NolintLinters carry the policy into internal/align.

Closes #32

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@peczenyj peczenyj self-assigned this May 26, 2026
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 26, 2026

Codecov Report

❌ Patch coverage is 97.84173% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.90%. Comparing base (76d1a58) to head (f3d3b57).

Files with missing lines Patch % Lines
internal/align/nolint.go 96.77% 1 Missing and 1 partial ⚠️
internal/ui/printer.go 96.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            devel      #39      +/-   ##
==========================================
+ Coverage   85.71%   87.90%   +2.18%     
==========================================
  Files          10       12       +2     
  Lines         721      843     +122     
==========================================
+ Hits          618      741     +123     
+ Misses         65       63       -2     
- Partials       38       39       +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.

Add fixtures exercising mergeNolint's named-token union (a trailing
//nolint:fieldalignment on the struct's opening line) and nolintIndex's
skip of a non-struct type declaration, closing the patch-coverage gaps on
the //nolint feature (mergeNolint 50%->100%, nolintIndex 92%->96%; the
remaining branch is unreachable defensive code).

Closes #32

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@peczenyj peczenyj changed the base branch from feature/threshold to devel May 26, 2026 16:13
peczenyj and others added 2 commits May 26, 2026 18:14
* feat: themeable colors (cga/green/amber) via eggs and STRUCTALIGN_THEME

Route ui's hardcoded ANSI constants through a Theme over semantic roles
(Header/Added/Removed/Meta/Padding/Label); the default theme reproduces the
historical palette byte-for-byte, so golden output is unchanged. Add built-in
retro themes: cga (bright 16-color), green and amber (single-hue phosphor
emulations distinguished by intensity + the +/- prefixes).

Selection: hidden easter-egg flags -cga/-green/-amber (stripped pre-parse, so
invisible in -help) take precedence over the documented STRUCTALIGN_THEME env
var, else default. Unknown theme warns and falls back. Theme is orthogonal to
-color: it only chooses which colors are used when color is on.

Not a full theming system: a fixed set of built-ins and two ways to pick one.

Closes #33

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* test: cover non-default theme rendering and -green/-amber/-- egg paths

Add a ui test that renders through a Printer with a theme set (covering
Printer.theme()'s non-default branch, now 100%) and app tests for the
-green/-amber eggs, a valid STRUCTALIGN_THEME env (no warning), and the
"--" boundary in the egg-stripping loop — closing the themes patch-coverage
gaps.

Closes #33

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
@peczenyj peczenyj merged commit a307346 into devel May 26, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: respect //nolint directives (diff mode)

2 participants