Skip to content

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

Open
peczenyj wants to merge 1 commit into
feature/thresholdfrom
feature/nolint-respect
Open

feat: respect //nolint directives (diff mode)#39
peczenyj wants to merge 1 commit into
feature/thresholdfrom
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

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 Report

❌ Patch coverage is 90.10989% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.05%. Comparing base (2a38ce5) to head (5e04c32).

Files with missing lines Patch % Lines
internal/align/nolint.go 87.67% 6 Missing and 3 partials ⚠️
Additional details and impacted files
@@                  Coverage Diff                  @@
##           feature/threshold      #39      +/-   ##
=====================================================
- Coverage              85.71%   85.05%   -0.67%     
=====================================================
  Files                     10       11       +1     
  Lines                    721      970     +249     
=====================================================
+ Hits                     618      825     +207     
- Misses                    65      104      +39     
- Partials                  38       41       +3     

☔ 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.

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.

2 participants