Skip to content

nolint parity gap: 4 non-enforced context-family linters have no internal/nolint suppression (execcommandwithoutcontext, ctxback [Content truncated due to length] #41377

Description

@github-actions

Summary

The earlier nolint-parity sweeps (#37061, #37251) added internal/nolint support to the CI-enforced custom linters but were explicitly scoped to that set. Four active context-propagation linters were left out — none of them wires internal/nolint, so a developer who hits a legitimate false positive has no inline escape hatch (//nolint:<name>) and must restructure code or disable the linter wholesale. Their sibling in the same family, httpnoctx, does wire nolint, which makes the gap an inconsistency rather than a deliberate choice.

Affected linters (no internal/nolint import; no BuildLineIndex/HasDirective call)

Linter nolint wired? test-skip? Reports on prod code?
httpnoctx (reference, CI-enforced) ✅ yes yes
execcommandwithoutcontext ❌ no yes
ctxbackground ❌ no yes
contextcancelnotdeferred ❌ no yes
timesleepnocontext ❌ no yes

Location

  • pkg/linters/execcommandwithoutcontext/execcommandwithoutcontext.go — imports only internal/astutil + internal/filecheck; no nolint at all
  • pkg/linters/ctxbackground/ — no internal/nolint
  • pkg/linters/contextcancelnotdeferred/ — no internal/nolint
  • pkg/linters/timesleepnocontext/ — no internal/nolint
  • Contrast: pkg/linters/httpnoctx/httpnoctx.go:1 (header) wires internal/nolint

Impact

Recommendation

Mirror the established pattern already used by httpnoctx and ~20 other linters:

  1. noLintLinesByFile := nolint.BuildLineIndex(pass, "<analyzer-name>") at the top of run
  2. if nolint.HasDirective(pos, noLintLinesByFile) { return/continue } guarding each pass.Report
  3. Add a //nolint:<name> case to each linter's testdata to lock the behavior in

Validation checklist

  • Each of the 4 linters imports internal/nolint and consults it before every pass.Report
  • testdata adds a //nolint:<analyzer> line that is not reported
  • go test ./pkg/linters/{execcommandwithoutcontext,ctxbackground,contextcancelnotdeferred,timesleepnocontext}/... passes

Effort

Small–moderate — mechanical, one well-trodden pattern repeated across 4 packages; follow httpnoctx verbatim. Distinct from #40734 (threshold linters largefunc/excessivefuncparams) and from #37061 (CI-enforced set), which together leave this non-enforced context-family set uncovered.

Found via Serena suppression-parity audit (R47).

Generated by 🤖 Sergo - Serena Go Expert · 260.8 AIC · ⌖ 11 AIC · ⊞ 5.9K ·

  • expires on Jul 1, 2026, 9:12 PM UTC-08:00

Metadata

Metadata

Labels

cookieIssue Monster Loves Cookies!sergo

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions