Skip to content

[linter-miner] feat(linters): add stringsjoinone linter #47122

Description

@github-actions

Summary

Adds a new stringsjoinone custom linter that reports strings.Join([]string{s}, sep) calls with a single-element slice literal.

What it catches

When strings.Join is called with a slice literal that contains exactly one element, the separator is never used and the call is equivalent to just returning that element. This is a code smell — likely a refactoring artifact where a multi-element slice was reduced to one element, or a misuse of the API.

Before:

result := strings.Join([]string{name}, ", ")

After (suggested fix):

result := name

Evidence

This pattern was identified by scanning the codebase for redundant strings.Join calls. The linter is specific and actionable (clear fix), and has very low false-positive potential because a single-element strings.Join is always equivalent to the bare element.

Implementation

  • New package: pkg/linters/stringsjoinone/
  • Registered in pkg/linters/registry.go
  • Documented in pkg/linters/doc.go and pkg/linters/README.md
  • Tests with fixture and golden file pass
  • go build ./cmd/linters succeeds

Warning

Protected Files — Push Permission Denied

This was originally intended as a pull request, but the patch modifies protected files. A human must create the pull request manually.

Protected files
  • README.md

The push was rejected because GitHub Actions does not have workflows permission to push these changes, and is never allowed to make such changes, or other authorization being used does not have this permission.

Create the pull request manually
# Download the patch from the workflow run
gh run download 29854609552 -n agent -D /tmp/agent-29854609552

# Create a new branch
git checkout -b linter-miner/stringsjoinone-0e3c9b58b22ae9d5 main

# Apply the patch (--3way handles cross-repo patches)
git am --3way /tmp/agent-29854609552/aw-linter-miner-stringsjoinone.patch

# Push the branch and create the pull request
git push origin linter-miner/stringsjoinone-0e3c9b58b22ae9d5
gh pr create --title '[linter-miner] feat(linters): add stringsjoinone linter' --base main --head linter-miner/stringsjoinone-0e3c9b58b22ae9d5 --repo github/gh-aw

Generated by Linter Miner · sonnet46 92.1 AIC · ⌖ 10.6 AIC · ⊞ 5.6K ·

  • expires on Jul 28, 2026, 10:01 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