[sergo] Sergo Report: parameter-list-systematic-scan-plus-deep-nesting - 2026-05-11 #31426
Closed
Replies: 1 comment
-
|
This discussion has been marked as outdated by Sergo - Serena Go Expert. A newer discussion is available at Discussion #31634. |
Beta Was this translation helpful? Give feedback.
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.
-
Overview
Run 6 (2026-05-11) ran a two-pronged static-analysis strategy on
pkg/ofgithub/gh-aw: a cached extension of Run 5's flagged-but-not-completed parameter-list scan, paired with a new exploration into control-flow nesting depth. Both axes turned up actionable, distinct findings that complement Run 5's function-length tracker (#31300). Three issues were filed: a 3-function options-struct cluster, a depth-11 type-assertion ladder, and a tracker covering the remaining ≥10-param functions.Success score: 9/10 — high-coverage scan with concrete refactor targets and a survey artefact for future runs.
Summary
.gofiles inpkg/(1897 total.gofiles)🛠️ Serena Tools Update
Tools Snapshot
Tool list has been stable for 3 runs (4 through 6).
Tools Used Today
activate_project— session setupget_symbols_overview— discovered the(*ClaudeEngine).parseToolCallsWithSequencesymbol path inclaude_logs.gofind_symbol— confirmed body bounds333–425(93 lines)find_referencing_symbols— verified theRunUpdateWorkflows→UpdateWorkflows→updateWorkflowchain has exactly 1 prod + 2 test callers, and that the call sites really do pass 14 positional args📊 Strategy Selection (50/50 Split)
Cached Reuse Component (50%): Systematic parameter-list scan
Run 5's stats note explicitly flagged this: "No other functions sampled exceed 15. Worth a future scan." Run 5 only enumerated
DownloadWorkflowLogs(26 params) because its functioning-length scan happened to reveal it. Run 6 picked up that thread and ran a systematic scan instead of incidental sampling.find_referencing_symbolsto gauge blast radius)CompileConfiginpkg/cli/compile_pipeline.go— meaning the refactor target is already proven idiomatic for this codebase, not a foreign patternNew Exploration Component (50%): Control-flow nesting depth
None of Runs 1–5 explicitly looked at nesting depth or cognitive complexity. I used a tab-prefix heuristic as a proxy for nesting depth:
^\t{7}if→ depth 8^\t{8}if→ depth 9 (57 occurrences across 30 files)^\t{9}if→ depth 10 (rare, ~20 occurrences across ~10 files)The depth-9 set was broad enough to be uninteresting (most are JSON-shape probing where the alternative refactor doesn't actually help). The depth-10+ set clustered tightly in 3 files and revealed the
parseToolCallsWithSequencefinding.Combined Strategy Rationale
The two components are complementary: the parameter-list axis targets API shape (call-site readability), the nesting axis targets function-body shape (reader cognitive load). Neither overlaps with Run 5's line-count axis, so the three together now cover the three independent dimensions a function can be "too much": too wide, too tall, too deep.
🔍 Analysis Execution
Codebase Context
.gofiles inpkg/: 770Findings Summary
📋 Detailed Findings
High Priority:
RunUpdateWorkflows/UpdateWorkflows/updateWorkflowtrio (#31423)Three functions, all at 14 positional parameters, all in the same call chain (cobra →
RunUpdateWorkflows→UpdateWorkflows→updateWorkflow-in-loop), with arguments forwarded verbatim layer-to-layer. Test callers spell out the full 14 positional args:The
CompileConfigprecedent inpkg/cli/compile_pipeline.go:41,206is the obvious model.Medium Priority: depth-11 type-assertion ladder in
parseToolCallsWithSequence(#31424)pkg/workflow/claude_logs.go:333-425(93-line method) reaches depth 11 in a single branch — 7 nestedif x, ok := y.(T); okcasts to reach a single bash-command string. Same shape repeats inclaude_tools.goandlogs_metrics.go. A simplemapStringAt(m, path...)helper flattens all of them.Medium Priority: parameter-list tracker (#31425)
Full catalog of the remaining 8
pkg/functions with ≥10 positional params, including a recommended grouping for future refactors:auditcluster:AuditWorkflowRun(14),renderAuditReport(12),RunAuditDiff(12) — oneAuditOptionsstruct covers all threeDownload*cluster:DownloadWorkflowLogsFromStdin(19) is a sister ofDownloadWorkflowLogs(26, already Tracking: 14 production functions inpkg/are >400 lines (function-length hot-spots) #31300)fetchFrontmatterImportsRecursive(11, recursion amplifies the cost),writeMCPGatewayExports(13),showTrialConfirmation(11)Methodology details
^func [^(]*\([^)]*,(\s*[^)]*,){9,}[^)]*\)againstpkg/**/*.go(non-test)*_test.go) per Serena Go analysis guidelinesfind_referencing_symbolsLower-priority observations (not issued)
showTrialConfirmation(11 params,trial_confirmation.go:18) — interactive prompt only, likely fine until next touchedpkg/cli/codemod_*.gofiles have several depth-8/9 if-cast ladders, but they read more like YAML-shape probes than business logic; deferred✅ Improvement Tasks Generated
Task 1: Adopt
UpdateWorkflowsOptionsfor the update-workflows trio (#31423)go test ./pkg/cli/...covers — 2 test call sites become field-by-field instead of 14-positionalTask 2: Extract
mapStringAt(m, path...)helper and flatten 3 sites (#31424)pkg/workflow/claude_logs_test.go+ one new fixture for missing-field caseTask 3: Track ≥10-param functions in
pkg/(#31425)fetchFrontmatterImportsRecursive📈 Success Metrics
This Run
Reasoning for Score
CompileConfig) which makes adoption near-mechanical.compile_pipeline.goshowed those are mostly already adopting the options-struct pattern.📊 Historical Context
Cumulative Statistics
Strategy Evolution
Runs 1–3 focused on correctness (errors, context, type safety). Runs 4–6 shifted to maintainability shape (concurrency lifecycle, function length, parameter count, nesting depth). The correctness scans have largely returned diminishing results — the codebase is well-disciplined on
%werror wrapping (1704 calls, only 1 documented exception), type assertions (5 total, all comma-ok), context propagation (1 remaining, already tracked), goroutine recover (2 fixed).The maintainability axis still has runway — Runs 5 and 6 together opened 6 tracker/refactor issues that will keep paying out as authors touch each function.
🎯 Recommendations
Immediate Actions
RunUpdateWorkflows/UpdateWorkflows/updateWorkflowtrio each take ~14 positional params (options-struct candidate [Content truncated due to length] #31423 — the update-workflows trio has the most callers per line and the precedent is already in the codebase(*ClaudeEngine).parseToolCallsWithSequencenestsif x, ok := y.(T); ok7 levels deep (depth-11 control flow) #31424 — themapStringAthelper benefits 3 production sites and is genuinely smallpkg/take ≥10 positional parameters (parameter-list hot-spots) #31425 as a per-PR checklist when touching audit/logs codeLong-term Improvements
funcdeclarations with >12 positional params and (b)ifstatements at indentation depth >6. Prevents new entrants without forcing a refactor sprint.auditcluster and theDownload*cluster should share a more generalRunCommandOptionsshape — they have many overlapping fields.🔄 Next Run Preview
Suggested Focus Areas (Run 7)
find_referencing_symbolsto traverse the call graph. The Run 5+6 tracking issues will accumulate evidence for which packages get touched most.Strategy Evolution
Now that the three function-shape dimensions (width/height/depth) are catalogued, the next natural axis is inter-function shape — call graph topology, package fan-out, cyclic dependencies. This pivots from intra-function complexity to architectural complexity.
Generated by Sergo - The Serena Go Expert
Run ID: 25651209481
Strategy: parameter-list-systematic-scan-plus-deep-nesting
References:
pkg/are >400 lines (function-length hot-spots) #31300)Beta Was this translation helpful? Give feedback.
All reactions