[repository-quality] Repository Quality Improvement: Options Struct Pattern Adoption for High-Arity Functions (2026-07-16) #46005
Closed
Replies: 1 comment
|
This discussion was automatically closed because it expired on 2026-07-17T13:26:46.467Z.
|
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.
🎯 Repository Quality Improvement Report - Options Struct Pattern Adoption for High-Arity Functions
Analysis Date: 2026-07-16
Focus Area: Options Struct Pattern Adoption for High-Arity Functions
Strategy Type: Custom
Custom Area: Yes — the
excessivefuncparamslinter (DefaultMaxParams=8) already enforces this boundary, yet 2 functions actively violate the threshold and 21 sit exactly at the limit. A repeatingowner, repo, hostname, verbosequad appears verbatim in 4+ functions acrosslogs_download.go, a clear options-struct extraction opportunity.Executive Summary
The
excessivefuncparamslinter is configured but not fully effective: 2 production functions (9 parameters each) escape enforcement with//nolint:excessivefuncparamssuppressions, and 21 functions sit exactly at the 8-parameter limit — at threshold but not yet over. The most concentrated problem is inpkg/cli/logs_download.gowhere four sibling functions repeat an identical(ctx, runID, outputDir, verbose, owner, repo, hostname, artifactFilter)signature, making every call-site update expensive and error-prone.Beyond
logs_download.go, the pattern recurs inupdate_actions.go(both public and private variants carryworkflowsDir, engineOverride, verbose, disableReleaseBump, noCompile, coolDown, approve),workflow/copilot_engine_execution.go(boolean-flag explosion with 4boolpositionals), andworkflow/nodejs.go(8 primitive positionals with no grouping).Introducing options structs at these hotspots reduces parameter count at call sites, improves readability, enables future extension without signature churn, and allows the nolint suppressions to be deleted.
Full Analysis Report
Focus Area: Options Struct Pattern Adoption for High-Arity Functions
Current State Assessment
Metrics Collected:
//nolint:excessivefuncparamssuppressionsowner, repo, hostname, verbosequadlogs_download.goverbose, disableReleaseBump, noCompile, coolDown, approvegroupupdate_actions.goTrialOptions,AddOptions)Highest-priority violators:
pkg/cli/logs_run_processor.go:104downloadRunArtifactsConcurrentpkg/cli/update_actions.go:606updateActionsInWorkflowFilespkg/cli/logs_download.go:551,598,649,968pkg/workflow/copilot_engine_execution.go:463buildCopilotStepEnvboolpositionalspkg/workflow/nodejs.go:270GenerateNpmInstallStepsWithScopeboolprimitives at endFindings
Strengths
excessivefuncparamslinter exists, is registered inspec_test.go, and has a configurablemax-paramsflag.AddOptions,TrialOptions,UpdateWorkflowsOptions,AuditOptions.Areas for Improvement
logs_download.goshare an identical(ctx, runID, outputDir, verbose, owner, repo, hostname, artifactFilter)signature — adownloadArtifactsOptionsstruct would collapse these call sites.buildCopilotStepEnv(method onCopilotEngine) passesisBYOKMode, sandboxEnabled, modelConfigured boolas three consecutive positional booleans — swapping argument order silently changes behavior.GenerateNpmInstallStepsWithScopeends withincludeNodeSetup, isGlobal, runInstallScripts, cooldownEnabled bool— four booleans with no names at call sites.RunWorkflowInteractively(public API inrun_interactive.go) exposes 7 non-context parameters; an options struct would ease future extension without a breaking API change.Detailed Analysis
pkg/cli/logs_download.go— sharedowner/repo/hostname/verbosequadThe four functions
downloadArtifactsByName,retryCriticalArtifacts,downloadRunArtifacts, andensureUsageAwInfoFallbackall accept(ctx, runID, outputDir, verbose bool, owner, repo, hostname string, artifactFilter []string). Every internal call thread passes all eight arguments individually. A small struct:would collapse each signature to
(ctx context.Context, opts downloadArtifactsOptions)— well under the 8-param limit.pkg/cli/update_actions.go— public+private mirror pairUpdateActionsInWorkflowFiles(public, 8 params) delegates toupdateActionsInWorkflowFiles(private, 9 params). Both carryworkflowsDir, engineOverride string, verbose, disableReleaseBump bool, noCompile bool, coolDown time.Duration, approve bool. AnUpdateActionsOptionsstruct already follows the establishedXxxOptionsconvention.pkg/workflow/copilot_engine_execution.go:463— boolean positional explosionbuildCopilotStepEnvpassesisBYOKMode, sandboxEnabled, modelConfigured boolas three consecutive booleans. If a caller swaps any two, the compiler accepts it silently.🤖 Tasks for Copilot Agent
NOTE TO PLANNER AGENT: Split the following tasks into individual work items.
Improvement Tasks
Task 1: Introduce
downloadArtifactsOptionsstruct inlogs_download.goPriority: High
Estimated Effort: Medium
Focus Area: Options Struct Pattern Adoption
Description: Four sibling functions in
pkg/cli/logs_download.go—downloadArtifactsByName(line 551),retryCriticalArtifacts(line 598),downloadRunArtifacts(line 649), andensureUsageAwInfoFallback(line 968) — all share the parameter quad(verbose bool, owner, repo, hostname string)alongsiderunID int64andartifactFilter []string. Introduce an unexporteddownloadArtifactsOptionsstruct carryingRunID,OutputDir,Verbose,Owner,Repo,Hostname, andArtifactFilter, and refactor all four functions to accept(ctx context.Context, opts downloadArtifactsOptions). Update all internal call sites. This brings all four functions below the 8-param linter threshold.Acceptance Criteria:
downloadArtifactsOptionsstruct defined inpkg/cli/logs_download.go(ctx, opts downloadArtifactsOptions)signatureslogs_download.goupdatedpkg/cli/forecast_compute.go:248(forecastDownloadUsageArtifact) andpkg/cli/audit_diff.go:930(loadRunSummaryForDiff) which share the sameowner, repo, hostname, verbosepatternmake fmt && make lintpass with no new suppressionsmake test)Code Region:
pkg/cli/logs_download.go,pkg/cli/forecast_compute.go,pkg/cli/audit_diff.goTask 2: Extract
UpdateActionsOptionsto fix the 9-paramupdateActionsInWorkflowFilesPriority: High
Estimated Effort: Small
Focus Area: Options Struct Pattern Adoption
Description:
updateActionsInWorkflowFilesatpkg/cli/update_actions.go:606has 9 parameters (ctx, deps, workflowsDir, engineOverride, verbose, disableReleaseBump, noCompile, coolDown, approve) and violates theexcessivefuncparamslinter threshold. Its public wrapperUpdateActionsInWorkflowFiles(line 602) has 8 parameters. Introduce anUpdateActionsOptionsstruct (following the establishedXxxOptionspattern in the package) carrying the non-context fields, collapse both signatures, and update all call sites.Acceptance Criteria:
UpdateActionsOptionsstruct defined inpkg/cli/update_actions.go(orupdate_actions_options.go)UpdateActionsInWorkflowFiles(public) andupdateActionsInWorkflowFiles(private) refactoredpkg/cli/updated//nolint:excessivefuncparamssuppressions neededmake fmt && make lint && make testpassCode Region:
pkg/cli/update_actions.goTask 3: Replace boolean positionals in
buildCopilotStepEnvwith a config structPriority: Medium
Estimated Effort: Small
Focus Area: Options Struct Pattern Adoption
Description:
(e *CopilotEngine) buildCopilotStepEnvatpkg/workflow/copilot_engine_execution.go:463takes 3 consecutiveboolpositionals (isBYOKMode, sandboxEnabled, modelConfigured) plus a stringcopilotSDKServerArgsJSON. Swapping any two booleans compiles silently. Introduce an unexportedcopilotStepEnvConfigstruct and refactor the method to accept it as a single config argument.Acceptance Criteria:
copilotStepEnvConfigstruct introduced inpkg/workflow/copilot_engine_execution.gobuildCopilotStepEnvsignature simplified to(workflowData *WorkflowData, llmProvider, modelEnvVar, timeoutValue string, cfg copilotStepEnvConfig) map[string]stringpkg/workflow/updatedmake fmt && make lint && make testpassCode Region:
pkg/workflow/copilot_engine_execution.goTask 4: Refactor
GenerateNpmInstallStepsWithScopeto use a config structPriority: Medium
Estimated Effort: Small
Focus Area: Options Struct Pattern Adoption
Description:
GenerateNpmInstallStepsWithScopeatpkg/workflow/nodejs.go:270has 8 parameters ending with fourboolvalues (includeNodeSetup, isGlobal, runInstallScripts, cooldownEnabled). These boolean positionals are indistinguishable at call sites without looking up the signature. IntroduceNpmInstallOptionsand refactor.Acceptance Criteria:
NpmInstallOptionsstruct (orNpmInstallStepsConfig) defined inpkg/workflow/nodejs.goGenerateNpmInstallStepsWithScoperefactored to accept the structpkg/workflow/updatedmake fmt && make lint && make testpassCode Region:
pkg/workflow/nodejs.goTask 5: Refactor
downloadRunArtifactsConcurrent(9 params) inlogs_run_processor.goPriority: High
Estimated Effort: Small
Focus Area: Options Struct Pattern Adoption
Description:
downloadRunArtifactsConcurrentatpkg/cli/logs_run_processor.go:104has 9 parameters, violating the linter threshold. ParametersoutputDir, verbose, maxRuns, repoOverride, artifactFilter, evalsOnly, artifactSetsshould be grouped into aconcurrentDownloadOptionsstruct (or reusedownloadArtifactsOptionsfrom Task 1 if appropriate).Acceptance Criteria:
pkg/cli/logs_run_processor.go(or shared file)downloadRunArtifactsConcurrentrefactored to(ctx context.Context, runs []WorkflowRun, opts concurrentDownloadOptions) []DownloadResultpkg/cli/updated//nolint:excessivefuncparamssuppressionsmake fmt && make lint && make testpassCode Region:
pkg/cli/logs_run_processor.go📊 Historical Context
Previous Focus Areas
🎯 Recommendations
Immediate Actions (This Week)
updateActionsInWorkflowFiles,downloadRunArtifactsConcurrent) — Priority: HighdownloadArtifactsOptionsto collapse thelogs_download.gosibling quartet — Priority: HighShort-term Actions (This Month)
buildCopilotStepEnvandGenerateNpmInstallStepsWithScope— Priority: MediumLong-term Actions (This Quarter)
boolparameters regardless of total count — Priority: Low📈 Success Metrics
Next Steps
References:
Generated by Repository Quality Improvement Agent
All reactions