Skip to content

[Code Quality] Refactor GenerateNpmInstallStepsWithScope to use NpmInstallOptions struct (4 trailing bool positionals) #46113

Description

@github-actions

Description

GenerateNpmInstallStepsWithScope at pkg/workflow/nodejs.go:270 ends with four bool values (includeNodeSetup, isGlobal, runInstallScripts, cooldownEnabled) as positional parameters. These are indistinguishable at call sites without looking up the signature, making incorrect argument order a silent compile-time bug.

Suggested Changes

Introduce a NpmInstallOptions struct:

type NpmInstallOptions struct {
    PackageName       string
    Version           string
    StepName          string
    CacheKeyPrefix    string
    IncludeNodeSetup  bool
    IsGlobal          bool
    RunInstallScripts bool
    CooldownEnabled   bool
}

Refactor GenerateNpmInstallStepsWithScope to accept (opts NpmInstallOptions) []GitHubActionStep.

Files Affected

  • pkg/workflow/nodejs.go (line 270 and all callers within pkg/workflow/)

Success Criteria

  • NpmInstallOptions struct defined
  • GenerateNpmInstallStepsWithScope refactored
  • All callers in pkg/workflow/ updated
  • make fmt && make lint && make test pass

Source

Extracted from [repository-quality] Options Struct Pattern Adoption — discussion #46005

Priority

Medium — four consecutive unnamed booleans at call sites are a readability and correctness risk

🔍 Task mining by Discussion Task Miner - Code Quality Improvement Agent · 117.9 AIC · ⌖ 7.65 AIC · ⊞ 7K ·

  • expires on Jul 17, 2026, 5:25 PM UTC-08:00

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions