Repository navigation
Description
Summary
Five registered analyzers in pkg/linters/ emit diagnostics but import no internal/nolint and never call nolint.HasDirective, so their findings cannot be suppressed with a //nolint:<name> directive. Several of these report judgment-call diagnostics that are sometimes legitimately correct, so an unsuppressable report blocks otherwise-valid code and prevents promoting the linter to CI enforcement (the same blocker that motivated #41377 and #40734).
This is the direct continuation of the now-landed nolint-parity work: the four context-family linters from #41377 (execcommandwithoutcontext, ctxbackground, contextcancelnotdeferred, timesleepnocontext) and the two threshold linters from #40734 (largefunc, excessivefuncparams) now wire internal/nolint. The linters below were not part of those batches and were missed.
Affected linters (verified: no internal/nolint import)
| Linter | File | Sibling with nolint | Why suppression is needed |
|---|---|---|---|
fileclosenotdeferred |
pkg/linters/fileclosenotdeferred/fileclosenotdeferred.go |
contextcancelnotdeferred (has nolint) |
Manual Close() before defer is sometimes required — close-then-rename, close-then-reopen, explicit early release before further work. |
ossetenvlibrary |
pkg/linters/ossetenvlibrary/ossetenvlibrary.go |
osexitinlibrary (has nolint) |
os.Setenv/os.Unsetenv in a non-_test.go support file is occasionally required (e.g. TZ, child-process setup). |
sprintferrorsnew |
pkg/linters/sprintferrorsnew/sprintferrorsnew.go |
fprintlnsprintf (has nolint) |
Style rewrite (errors.New(fmt.Sprintf(...)) → fmt.Errorf); a developer may want to keep a specific form. |
sprintferrdot |
pkg/linters/sprintferrdot/sprintferrdot.go |
fmterrorfnoverbs (has nolint) |
Redundant-.Error() rewrite; edge cases (custom Stringer vs Error) may warrant opt-out. |
lenstringzero |
pkg/linters/lenstringzero/lenstringzero.go |
lenstringsplit (has nolint) |
len(s) == 0 vs s == "" is a readability preference; some call sites legitimately prefer the explicit length form. |
The two strongest cases are the sibling asymmetries: fileclosenotdeferred is structurally a near-twin of contextcancelnotdeferred (both are defer-detection state machines keyed by types.Object), and ossetenvlibrary is the policy-twin of osexitinlibrary. In each pair one linter wires nolint and the other does not.
Evidence
grep -rl internal/nolint pkg/lintersreturns 29 linters; the five above are absent.fileclosenotdeferred.goimports onlyinternal/astutilandinternal/filecheck(nonolint.BuildLineIndex, noHasDirective); cf.contextcancelnotdeferred.go:32,63,96which wire it correctly.ossetenvlibrary.goimports onlyastutil+filecheck; cf.osexitinlibrary.go:37,61(nolint wired).
Impact
- A single legitimate site (e.g. a deliberate close-before-rename) is unsuppressable, so the linter cannot be turned on in CI without code churn or carve-outs.
- Inconsistent developer experience: half the linter suite honours
//nolint:and half silently ignores it.
Recommendation
Wire internal/nolint into each of the five linters, mirroring the landed pattern from #41377:
noLintLines := nolint.BuildLineIndex(pass, "<name>")at the top ofrun.- Before each
pass.Report*, gate on!nolint.HasDirective(pass.Fset.PositionFor(pos, false), noLintLines). - Add a
//nolint:<name>testdata case proving suppression, mirroring the sibling linter's test.
Validation checklist
- Each of the 5 linters imports
internal/nolintand gates everyReportonHasDirective. - A
//nolint:<name>directive on a violating line suppresses the diagnostic (testdata). -
grep -rL internal/nolint pkg/linters/*/shows only domain/spec linters (e.g.ssljson) and non-reporting helpers.
Effort
Low — mechanical, ~5–8 lines per linter following the existing landed template; one testdata case each.
Note on ssljson
ssljson also lacks nolint but is a spec-domain validator with a different suppression model; excluded here intentionally — flag separately if desired.
Sergo R49 — new-exploration half (fresh nolint-parity audit across all 35 analyzers). Reconciled: #41377 and #40734 nolint portions have LANDED for their targets (issues still open).
Generated by 🤖 Sergo - Serena Go Expert · 231.1 AIC · ⌖ 14.3 AIC · ⊞ 5.9K · ◷
- expires on Jul 3, 2026, 9:09 PM UTC-08:00
Activity
github-actions commentedon Jun 27, 2026
🍪 Issue Monster selected this for Copilot
I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.
If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.
Om nom nom! 🍪
github-actions commentedon Jun 28, 2026
✅ Fix Confirmed — CI Passing
PR #41849 (Add nolint suppression parity for 5 remaining gh-aw analyzers) was merged 2026-06-27T14:30Z and CI has been passing since:
The nolint-suppression parity gap is resolved. This issue can be closed.
github-actions commentedon Jul 4, 2026
This issue was automatically closed because it expired on 2026-07-04T05:09:25.805Z.