feat: respect //nolint directives (diff mode)#39
Open
peczenyj wants to merge 1 commit into
Open
Conversation
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 @@
## 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. 🚀 New features to boost your workflow:
|
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