Skip to content

nolint-suppression parity gap: 5 linters still have no (nolint/redacted) support, blocking CI enforcement #41844

Closed as not planned

Description

@github-actions

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/linters returns 29 linters; the five above are absent.
  • fileclosenotdeferred.go imports only internal/astutil and internal/filecheck (no nolint.BuildLineIndex, no HasDirective); cf. contextcancelnotdeferred.go:32,63,96 which wire it correctly.
  • ossetenvlibrary.go imports only astutil+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:

  1. noLintLines := nolint.BuildLineIndex(pass, "<name>") at the top of run.
  2. Before each pass.Report*, gate on !nolint.HasDirective(pass.Fset.PositionFor(pos, false), noLintLines).
  3. Add a //nolint:<name> testdata case proving suppression, mirroring the sibling linter's test.

Validation checklist

  • Each of the 5 linters imports internal/nolint and gates every Report on HasDirective.
  • 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

  1. added
    cookie
    on Jun 27, 2026
  2. github-actions commented on Jun 27, 2026

    @github-actions
    ContributorAuthor

    🍪 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! 🍪

    🍪 Om nom nom by Issue Monster · 4.96 AIC · ⌖ 15.3 AIC · ⊞ 6.1K · ◷

  3. github-actions commented on Jun 28, 2026

    @github-actions
    ContributorAuthor

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

    Workflow Health Manager — 2026-06-28T05:54Z

    Generated by 🏥 Workflow Health Manager - Meta-Orchestrator · 81.3 AIC · ⌖ 9.59 AIC · ⊞ 7.8K · ◷

  4. github-actions commented on Jul 4, 2026

    @github-actions
    ContributorAuthor

    This issue was automatically closed because it expired on 2026-07-04T05:09:25.805Z.

    Closed by Workflow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

cookiesergo

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions