feat: respect //nolint directives (diff mode)#39
Merged
Conversation
-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>
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
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>
* 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>
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.
Diff mode now respects
//nolintdirectives by default, matching golangci-lint: a struct whose type declaration carries a recognized directive is suppressed.fieldalignmentplus a bare//nolint(always honored).-nolint-linters(default"fieldalignment") customizes the named token set, e.g.-nolint-linters=fieldalignment,betteralign.-show-nolintreveals suppressed structs (audit mode).TypeSpec.Doc/ groupedGenDecl.Doc) and any comment on the type's opening line — catching a trailingtype T struct { //nolint, which the AST doesn't attach toTypeSpec.Comment(matched by line, like golangci-lint).//nolint:fieldalignmentis about the finding, which inspect doesn't produce).New
common.OptionsfieldsRespectNolint/NolintLinterscarry the policy intointernal/align; the short-circuit sits beside the existing filters inbuildFinding.Tests: 3 in
internal/align(doc directive suppresses, unrelated//nolint:errcheckdoesn't, bare trailing//nolintsuppresses, configurable token set) + 4 ininternal/app(hidden by default,-show-nolintreveals,-nolint-lintersopt-out, inspect ignores).task cigreen (103 tests).Closes #32
🤖 Generated with Claude Code