Add //nolint suppression parity to all CI-enforced custom linters#37237
Merged
Conversation
5 tasks
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix parity gap in CI-enforced custom linters handling of nolint directives
Add Jun 6, 2026
//nolint suppression parity to all CI-enforced custom linters
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aligns all CI-enforced custom analyzers with the shared internal/nolint suppression behavior so //nolint:<linter> works consistently (same-line and previous-line) across the enforced linter set.
Changes:
- Wired
nolint.BuildLineIndex(pass, "<linter>")andnolint.HasDirective(...)into nine analyzers to honor//nolint:<linter>///nolint:all. - Added/extended
analysistestfixtures for each updated analyzer to cover both previous-line and same-line suppression forms. - Minor fixture formatting adjustments (e.g., gofmt/whitespace alignment) while adding the new suppression cases.
Show a summary per file
| File | Description |
|---|---|
| pkg/linters/uncheckedtypeassertion/uncheckedtypeassertion.go | Adds internal/nolint directive suppression to unchecked type assertion diagnostics. |
| pkg/linters/uncheckedtypeassertion/testdata/src/uncheckedtypeassertion/uncheckedtypeassertion.go | Adds suppression fixtures for previous-line and same-line directives. |
| pkg/linters/strconvparseignorederror/strconvparseignorederror.go | Adds internal/nolint suppression for discarded-strconv error diagnostics. |
| pkg/linters/strconvparseignorederror/testdata/src/strconvparseignorederror/strconvparseignorederror.go | Adds suppression fixtures and tightens formatting of existing want comments. |
| pkg/linters/regexpcompileinfunction/regexpcompileinfunction.go | Adds internal/nolint suppression for regexp compilation-in-function diagnostics. |
| pkg/linters/regexpcompileinfunction/testdata/src/regexpcompileinfunction/regexpcompileinfunction.go | Adds suppression fixtures for both directive placements. |
| pkg/linters/rawloginlib/rawloginlib.go | Adds internal/nolint suppression for raw log.* calls in library packages. |
| pkg/linters/rawloginlib/testdata/src/rawloginlib/rawloginlib.go | Adds suppression fixture cases for raw logging calls. |
| pkg/linters/panic-in-library-code/panic-in-library-code.go | Adds internal/nolint suppression for panic() diagnostics in library packages. |
| pkg/linters/panic-in-library-code/testdata/src/panicinlibrarycode/panicinlibrarycode.go | Adds suppression fixtures and applies gofmt-style formatting to the fixture. |
| pkg/linters/osexitinlibrary/osexitinlibrary.go | Adds internal/nolint suppression for os.Exit diagnostics in library packages. |
| pkg/linters/osexitinlibrary/testdata/src/osexitinlibrary/osexitinlibrary.go | Adds suppression fixtures for os.Exit. |
| pkg/linters/manualmutexunlock/manualmutexunlock.go | Adds internal/nolint suppression for manual unlock (non-deferred) diagnostics. |
| pkg/linters/manualmutexunlock/testdata/src/manualmutexunlock/manualmutexunlock.go | Adds suppression fixtures and normalizes whitespace. |
| pkg/linters/fprintlnsprintf/fprintlnsprintf.go | Adds internal/nolint suppression for the Fprintln(Sprintf()) pattern. |
| pkg/linters/fprintlnsprintf/testdata/src/fprintlnsprintf/fprintlnsprintf.go | Adds suppression fixtures for both directive placements. |
| pkg/linters/fmterrorfnoverbs/fmterrorfnoverbs.go | Adds internal/nolint suppression for fmt.Errorf-without-verbs diagnostics. |
| pkg/linters/fmterrorfnoverbs/testdata/src/fmterrorfnoverbs/fmterrorfnoverbs.go | Adds suppression fixtures for both directive placements. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 18/18 changed files
- Comments generated: 1
Comment on lines
+65
to
+66
| if nolint.HasDirective(pos, noLintLinesByFile) { | ||
| return |
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.
Nine CI-enforced custom analyzers were not honoring
//nolint:<linter>directives, creating an enforcement gap versus linters already wired tointernal/nolint. This change aligns suppression behavior across all enforced linters with shared same-line/previous-line directive semantics.Suppression parity in enforced analyzers
nolint.BuildLineIndex(pass, "<linter>")+nolint.HasDirective(...)into:panicinlibrarycodemanualmutexunlockosexitinlibraryrawloginlibregexpcompileinfunctionfprintlnsprintfstrconvparseignorederroruncheckedtypeassertionfmterrorfnoverbsRegression coverage for directive handling
testdatafixtures for each updated linter covering both://nolint:<linter>... //nolint:<linter>Pattern applied