Skip to content

[Code Quality] refactor: replace += string concatenation in loops with strings.Builder (41 findings in pkg/workflow and pkg/cli) #48440

Description

@github-actions

Description

The custom-lint scanner (string-builder rule) found 41 instances of repeated += string concatenation inside loops across pkg/workflow (18 findings) and pkg/cli (23 findings). Each instance allocates a new string on every iteration; replacing with strings.Builder eliminates O(n2) allocations for long outputs.

Scope

  • 41 total findings (string-builder lint rule)
  • pkg/workflow/ — 18 findings
  • pkg/cli/ — 23 findings

Suggested Changes

Replace patterns like:

result := ""
for _, item := range items {
    result += item + "\n"  // new allocation each iteration
}

With:

var sb strings.Builder
for _, item := range items {
    sb.WriteString(item)
    sb.WriteByte('\n')
}
result := sb.String()

Validation

Run make golint-custom after changes to verify the string-builder findings are resolved.

Files Affected

  • Multiple files in pkg/workflow/ (18 sites)
  • Multiple files in pkg/cli/ (23 sites)
  • (Run make golint-custom 2>&1 | grep string-builder to get the exact list)

Success Criteria

  • make golint-custom reports 0 string-builder findings
  • make test-unit passes
  • No functional behavior changes

Source

Extracted from discussion #48252 — LintMonster Daily custom-lint scan summary 2026-07-27

Priority

Medium — 41 O(n2) allocation sites; low risk to fix, good performance improvement for larger inputs

🔍 Task mining by Discussion Task Miner - Code Quality Improvement Agent · sonnet46 · 42.7 AIC · ⌖ 5.66 AIC · ⊞ 7.2K ·

  • expires on Jul 28, 2026, 11:13 AM UTC-08:00

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions