Summary
ctxbackground (flags context.Background() calls inside functions that already receive a context.Context parameter) is clean, type-resolved, and has zero production violations, but is absent from the CI-enforced linter set in .github/workflows/cgo.yml.
Verification performed
- Both previously-filed precision bugs for this linter are already fixed in the current code (
pkg/linters/ctxbackground/ctxbackground.go):
- The
FuncDecl-only enclosing-scope walk (prior false negative for closures) is fixed: the analyzer now walks cur.Enclosing((*ast.FuncDecl)(nil), (*ast.FuncLit)(nil)) and stops at the nearest enclosing function (breaking after the first match), so it no longer crosses FuncLit boundaries.
- The syntactic-name-match bug (matching the identifier
"context" textually) is fixed: isContextBackgroundCall (ctxbackground.go:83-101) resolves the selector via pass.TypesInfo.ObjectOf and checks *types.PkgName.Imported().Path() == "context" — a type-resolved check, immune to aliasing/shadowing.
- nolint + generated/test-file skip parity: the analyzer calls
nolint.HasDirectiveForLinter and filecheck.ShouldSkipFilename (which covers both generated files and _test.go files) — consistent with its enforced siblings.
- Zero production violations: searched all non-test, non-linter-testdata occurrences of
context.Background() under pkg/ for cases where the enclosing function also declares a context.Context parameter (the analyzer's trigger condition). Every hit inspected (pkg/parser/remote_workflow_spec.go, pkg/workflow/repository_features_validation.go, pkg/actionpins/resolve.go, etc.) is a function that does not take a context.Context parameter (several have an explicit comment noting context-threading is a tracked follow-up), or passes a non-context.Context-typed value (e.g. *PinContext) — correctly outside the analyzer's scope. No true-positive sites exist today.
Recommendation
Add -ctxbackground to the LINTER_FLAGS list in both the default-build and wasm-build make golint-custom invocations in .github/workflows/cgo.yml (~lines 1370 and 1373), matching the pattern used for its already-enforced ctx-family siblings (execcommandwithoutcontext, timesleepnocontext, httpnoctx, contextcancelnotdeferred).
Validation checklist
Effort: trivial — CI config change only, no source changes.
Generated by 🤖 Sergo - Serena Go Expert · agent · 326.7 AIC · ⌖ 30.4 AIC · ⊞ 5.9K · ◷
Summary
ctxbackground(flagscontext.Background()calls inside functions that already receive acontext.Contextparameter) is clean, type-resolved, and has zero production violations, but is absent from the CI-enforced linter set in.github/workflows/cgo.yml.Verification performed
pkg/linters/ctxbackground/ctxbackground.go):FuncDecl-only enclosing-scope walk (prior false negative for closures) is fixed: the analyzer now walkscur.Enclosing((*ast.FuncDecl)(nil), (*ast.FuncLit)(nil))and stops at the nearest enclosing function (breaking after the first match), so it no longer crossesFuncLitboundaries."context"textually) is fixed:isContextBackgroundCall(ctxbackground.go:83-101) resolves the selector viapass.TypesInfo.ObjectOfand checks*types.PkgName.Imported().Path() == "context"— a type-resolved check, immune to aliasing/shadowing.nolint.HasDirectiveForLinterandfilecheck.ShouldSkipFilename(which covers both generated files and_test.gofiles) — consistent with its enforced siblings.context.Background()underpkg/for cases where the enclosing function also declares acontext.Contextparameter (the analyzer's trigger condition). Every hit inspected (pkg/parser/remote_workflow_spec.go,pkg/workflow/repository_features_validation.go,pkg/actionpins/resolve.go, etc.) is a function that does not take acontext.Contextparameter (several have an explicit comment noting context-threading is a tracked follow-up), or passes a non-context.Context-typed value (e.g.*PinContext) — correctly outside the analyzer's scope. No true-positive sites exist today.Recommendation
Add
-ctxbackgroundto theLINTER_FLAGSlist in both the default-build and wasm-buildmake golint-custominvocations in.github/workflows/cgo.yml(~lines 1370 and 1373), matching the pattern used for its already-enforced ctx-family siblings (execcommandwithoutcontext,timesleepnocontext,httpnoctx,contextcancelnotdeferred).Validation checklist
-ctxbackgroundadded to bothLINTER_FLAGSstrings incgo.ymlGOOS=js GOARCH=wasmbuildpkg/linters/doc.go/README.mdalready list it as active (registry doc-sync is currently correct at 64 analyzers — no drift found)Effort: trivial — CI config change only, no source changes.