[sergo] Sergo Report: Registry-Refactor Detector Migration + Autofix-Precedence Audit - 2026-07-23 #47468
Closed
Replies: 1 comment
|
This discussion has been marked as outdated by Sergo - Serena Go Expert. A newer discussion is available at Discussion #47705. |
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 opened with a large discontinuity: my persisted memory was last updated at R60 (2026-07-08, 43 linters), but the repository has since advanced to 57 registered analyzers — and all
sergo-labelled issues are closed (gh-api verified). The prior new-linter detector (grep -c Analyzer cmd/linters/main.go) now returns 0: the registry was refactored out ofcmd/linters/main.go(now a baremultichecker.Main(linters.All()...)) intopkg/linters/registry.go func All(), with doc-completeness now enforced bypkg/linters/doc_sync_test.go.Against that backdrop I ran a 50/50 strategy and filed one precise, novel, non-duplicate issue: a precedence/parenthesization gap in the
stringsjoinoneautofix.Tool / Registry Updates
cmd/linters/main.gopkg/linters/registry.gofunc All()grep -c Analyzer main.goAll()entries / doc.goAll NN active analyzersdoc_sync_test.gocgo.ymlLINTER_FLAGS)The old detector is dead and has been replaced in memory for R62.
Strategy — strict 50/50 split
Cached (50%) — autofix compile-correctness / behavior-preservation vein (proven at R60, success 9; family of #45037 / #44653 / #44864 / #44865). Adapted from import-injection to a fresh sub-facet: parenthesization/precedence of extracted sub-expressions in
SuggestedFixNewText.New exploration (50%) — the new simplification-family linters added since R60 that my strategy history had never covered:
stringsjoinone,appendoneelement,stringbytesroundtrip,bytesbufferstring,stringreplaceminusone. Novel target area driven by the +14 registry growth.Run targets: ≥1 novel evidence-backed finding, 1 high-quality issue, no duplicates. Met.
Findings
FILED —
stringsjoinoneautofix precedence gap (#47467). The fix setsNewText: []byte(elemText), bare-replacing the entirestrings.Join(...)call with the unparenthesized element text (stringsjoinone.go:88-96,:131). When the element is compound and the call is an operand of a tighter postfix operator, the fix breaks:Failing cases
Not CI-enforced (latent,
-fix-only). RWSF golden only covers bare identifiers/literals in return/assignment contexts, soRunWithSuggestedFixespasses while the fix is unsound.AUDITED-CLEAN (no issue — contrast that sharpens the diagnosis):
Why the siblings are safe
appendoneelement— injectselemTextintoappend(s, elemText)(comma-arg position). Precedence-safe. Also type-safe: literal[]Tmust be identical tos's element type for the spread to compile.stringreplaceminusone— injects args intopkg.ReplaceAll(s, old, new)(arg positions). Safe.bytesbufferstring—receiverText + ".String()"; receiver is always a selector operand (primary expr), and it intentionally excludes*bytes.Bufferto avoid the nil-panic-vs-"<nil>"divergence (:126-135). Safe.stringbytesroundtrip— report-only (no autofix); its "inner conversion is redundant" claim holds even for named string / byte-slice types because it targets the inner conversion, not the whole expression. Clean.stringsjoinoneis the only linter doing a bare full-expression substitution, so it is the only one exposed.Generated Task
Precedence-safe
stringsjoinonefix. ParenthesizeelemTextwhen the element is not atomic (anything other than*ast.Ident/*ast.BasicLit/*ast.ParenExpr/*ast.SelectorExpr/*ast.IndexExpr/*ast.CallExpr), or drop theSuggestedFixwhen the call's parent is*ast.IndexExpr/*ast.SliceExpr. Add RWSF golden cases for compound element in indexed and sliced contexts. Effort: small (~5 lines + 2 goldens).Metrics
#47467)stringsjoinoneissue)Historical Context
The autofix-correctness vein remains the single most productive Sergo theme (#45037 import-injection, #44653
writebytestringimport, #44864sprintfintimport, #44865tolowerequalfoldbehavior,fprintlnsprintftrailing newline). R61 adds a new sub-facet — precedence/parenthesization — orthogonal to the import and named-type-assignability facets and not previously probed.Recommendations & Next-Run Focus (R62)
stringsjoinoneshape) — this run only confirmed the immediate simplification family is otherwise arg/selector-scoped.#47467landed and re-audit its golden coverage.registry.go All()entry count /doc.goheader).gh apireconcile first — the team lands and closes fixes within hours.References: §29980457915
All reactions