[sergo] Sergo Report: Registry-Detector-Migrated + Untouched-Linter-Audit - 2026-08-03 #49903
Closed
Replies: 1 comment
|
This discussion has been marked as outdated by Sergo - Serena Go Expert. A newer discussion is available at Discussion #50179. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Executive Summary
R61 followed a 26-day gap since the last recorded run (R60, 2026-07-08). In that window the custom-linter registry grew from 43 to 62 analyzers, and — per
gh apireconciliation — 19 of those new linters were already fully audited and closed by other actors before this run started. Zero sergo issues were open pre-run. This run's job was to find what's genuinely still uncovered, and it found two:walkfuncerrshadow(61st) anduncheckedflushreturn(62nd), neither of which had ever appeared in a sergo issue. Both yielded strong, distinct, evidence-backed findings — 2 issues filed, 0 duplicates.Tool & Registry Updates
cmd/linters/main.gono longer enumerates analyzers directly — it now callslinters.All(). The canonical source of truth moved topkg/linters/registry.go'sallAnalyzersslice (62 entries, confirmed againstpkg/linters/doc.go's "All 62 active analyzers" header).pkg/linters/spec_test.goauto cross-checks the registry againstdocumentedAnalyzers(),doc.go, andREADME.md. This was a recurring finding category in R42-R59 (7+ issues); it no longer needs manual probing.Strategy: 50/50 Split
Cached component (proven pattern, new target): applied the historically successful "enforce-readiness" pattern — grep production code for the exact pattern a linter targets, check CI enforcement status — to
walkfuncerrshadow, the newest linter with an accompanying ADR.New exploration component: examined
uncheckedflushreturn's AST node-filter logic from scratch for structural coverage gaps, rather than reusing a known bug template.Both targets were selected because they are the only two of the 62 registered linters that have never been mentioned in any sergo issue (verified via
gh api ...issues?labels=sergoacross all pages, all 19 recently-added linters otherwise already covered).Findings
1.
walkfuncerrshadow— 10 unmigrated production violation sites (issue #49901)The linter (added via ADR-49633, still Draft, merged 2026-08-01) flags
filepath.Walk/WalkDircalls where the outer result variable and the callback's third parameter are both literally namederr. The ADR explicitly calls out that existing code needing this rename is a "one-time migration cost" — that migration never happened:10 production sites with exact err/err shadow
Notably, most other
filepath.Walkcall sites in the same package already usewalkErrfor the outer variable (e.g.logs_utils.go,copilot_agent.go:113), confirming this is an inconsistency, not an accepted idiom. The linter is also absent fromcgo.yml'sLINTER_FLAGS— it can't be enforced in CI until these sites are cleaned up.2.
uncheckedflushreturn—DeferStmtmissing from node filter entirely (issue #49902)The analyzer's
nodeFilteris[]ast.Node{(*ast.ExprStmt)(nil), (*ast.AssignStmt)(nil)}— it catches barew.Flush()and_ = w.Flush(), butast.DeferStmtis a distinct AST node type and is never registered.defer w.Flush()— arguably the single most common way Go code silently drops a flush error, and the case this linter's own doc string most naturally implies it should catch — passes through completely undetected.testdata/src/uncheckedflushreturn/has zero test cases exercisingdefer, confirming this is an untested gap rather than a documented scope decision. No current production hits inpkg/, so this is a latent coverage gap rather than an active false negative today.Tasks Generated (2)
walkfuncerrshadowuncheckedflushreturnMetrics
Historical Context
Recent run history
writebytestring). Found aSuggestedFixcompile-correctness bug (named-string type mismatch withio.WriteString). 1 issue, score 9.astutil.IsPkgSelector. 1 issue, score 9.FuncLitscope-boundary bugs — foundexeccommandwithoutcontextover-attributing outer context across closure boundaries. 1 issue, score 9.bytescomparestring,sprintfbool,trimleftright,mapclearloop,mapdeletecheck,stringsconcatloop,stringbytesroundtrip) were added, audited, and fully closed out — all with issues already resolved by the time of this run's reconciliation.Recommendations
#49901and#49902— both are small, mechanical fixes with clear validation checklists.walkfuncerrshadowsites are cleaned up, wire it intocgo.ymlLINTER_FLAGSso it stays enforced (it's currently one of the only recently-added linters without CI enforcement).Flush/Close/Sync-shaped APIs) for the sameDeferStmt-omission pattern found inuncheckedflushreturn— this may not be isolated.Next-Run Focus (R62)
sg61a1andsg61a2landed (gh apireconcile before selecting a strategy, per standard practice).pkg/linters/registry.goentry count (the oldmain.gogrep detector is obsolete).References:
All reactions