Skip to content

Enforce-readiness: fileclosenotdeferred, timesleepnocontext, sprintferrorsnew are clean, type-resolved, zero prod violations — 2 [Content truncated due to length] #50481

Closed

Description

@github-actions

Summary

Three registered custom analyzers are type-resolved, nolint-wired, and currently produce zero violations against the current production tree (pkg/**/*.go, excluding _test.go), yet none of them appear in the CI enforcement gate (.github/workflows/cgo.yml LINTER_FLAGS). Two of the three previously had dedicated "enforce-readiness — add to CI" issues that were closed as resolved but the CI YAML was never actually updated — a process gap worth closing alongside the code gap.

Evidence

Linter Type-resolved? nolint wired? Prod violations found Prior "add to CI" issue CI status today
fileclosenotdeferred Yes (types.Object-keyed, shadowing-safe) Yes 0 (all ~20 prod os.Open/Create/OpenFile sites checked already defer Close() immediately) #35390 (closed) Not in LINTER_FLAGS
timesleepnocontext Yes (astutil.ContextParamName + IsGoOrDeferClosure FuncLit-boundary fix already applied) Yes 0 (4 prod time.Sleep sites checked — none in a ctx-receiving FuncDecl/non-go-or-defer FuncLit) #39324 (closed) Not in LINTER_FLAGS
sprintferrorsnew Yes (astutil.IsPkgSelector for both errors.New and fmt.Sprintf) Yes 0 (no errors.New(fmt.Sprintf(...)) sites in prod) (never filed — this is a first audit) Not in LINTER_FLAGS

Current enforcement list (.github/workflows/cgo.yml:1369, host build) has 43 linters; pkg/linters/registry.go registers 62. These three sit in the 19-wide gap.

Impact

Without CI enforcement, these clean analyzers provide no regression protection — a future PR can introduce a non-deferred file/response Close(), a time.Sleep bypassing context cancellation, or an errors.New(fmt.Sprintf(...)) and nothing will catch it, even though the tooling to catch it already exists and is proven safe (zero false positives against the current tree).

The closed-but-not-applied issues (#35390, #39324) also indicate a reconciliation gap: closing a sergo "add to CI" issue doesn't currently get verified against the actual cgo.yml state in later runs. Worth a lightweight check (e.g. grep the linter name in cgo.yml LINTER_FLAGS) before closing this class of issue in the future.

Recommendation

Add all three flags to both LINTER_FLAGS entries in .github/workflows/cgo.yml (line 1369 host build, and the WASM build at line 1372 where applicable — sprintferrorsnew/fileclosenotdeferred/timesleepnocontext all operate on stdlib packages available under GOOS=js GOARCH=wasm, consistent with siblings like writebytestring and stringreplaceminusone already present in both lists):

-fileclosenotdeferred -timesleepnocontext -sprintferrorsnew

Validation checklist

  • Add the three flags to the host LINTER_FLAGS string (cgo.yml:1369)
  • Add the three flags to the WASM LINTER_FLAGS string (cgo.yml:1372), matching existing sibling coverage
  • Run make golint-custom LINTER_FLAGS="..." locally to confirm zero violations before merging the gate
  • Confirm no //nolint:fileclosenotdeferred / timesleepnocontext / sprintferrorsnew suppressions exist that would need review

Effort

Small — a two-line CI config change, no linter code changes required.

Generated by 🤖 Sergo - Serena Go Expert · agent · 193.2 AIC · ⌖ 31.4 AIC · ⊞ 6K · ◷

  • expires on Aug 11, 2026, 9:01 PM UTC-08:00
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