Summary
pkg/linters/stringsindexhasprefix (a non-enforced analyzer, not yet in LINTER_FLAGS) has exactly one true-positive violation in production code, at pkg/workflow/frontmatter_on_section_cleanup.go:705:
if idx := strings.Index(trimmedLine, "workflow_run:"); idx == 0 {
This is precisely the pattern the analyzer targets: strings.Index(s, sub) == 0 is equivalent to, and less clear than, strings.HasPrefix(s, sub). The comparison result idx is also unused past the == 0 check (the idx := binding only exists to feed the comparison), so the fix also removes a small amount of indirection.
Evidence
Grep of all strings.Index(...) call sites in pkg/ (non-test) compared against literal 0 found exactly this one instance; every other production strings.Index use compares against a non-zero-implying pattern or checks for -1/>= 0 (substring existence, not prefix position), which stringsindexhasprefix correctly does not flag.
Recommendation
- Fix
pkg/workflow/frontmatter_on_section_cleanup.go:705:
if strings.HasPrefix(trimmedLine, "workflow_run:") {
(drop the now-unused idx binding)
- Once fixed,
stringsindexhasprefix has zero remaining production violations — add -stringsindexhasprefix to the CI LINTER_FLAGS in .github/workflows/cgo.yml (both the default and wasm gates), same pattern as the recent stringsindexcontains/stringscountcontains enforce-readiness rollouts.
Validation checklist
Effort
Trivial — one-line semantic-preserving rewrite plus a CI flag addition.
Generated by 🤖 Sergo - Serena Go Expert · agent · 250.3 AIC · ⌖ 6.22 AIC · ⊞ 6K · ◷
Summary
pkg/linters/stringsindexhasprefix(a non-enforced analyzer, not yet inLINTER_FLAGS) has exactly one true-positive violation in production code, atpkg/workflow/frontmatter_on_section_cleanup.go:705:This is precisely the pattern the analyzer targets:
strings.Index(s, sub) == 0is equivalent to, and less clear than,strings.HasPrefix(s, sub). The comparison resultidxis also unused past the== 0check (theidx :=binding only exists to feed the comparison), so the fix also removes a small amount of indirection.Evidence
Grep of all
strings.Index(...)call sites inpkg/(non-test) compared against literal0found exactly this one instance; every other productionstrings.Indexuse compares against a non-zero-implying pattern or checks for-1/>= 0(substring existence, not prefix position), whichstringsindexhasprefixcorrectly does not flag.Recommendation
pkg/workflow/frontmatter_on_section_cleanup.go:705:idxbinding)stringsindexhasprefixhas zero remaining production violations — add-stringsindexhasprefixto the CILINTER_FLAGSin.github/workflows/cgo.yml(both the default and wasm gates), same pattern as the recentstringsindexcontains/stringscountcontainsenforce-readiness rollouts.Validation checklist
go build/existing tests forfrontmatter_on_section_cleanup.gostill passmake golint-custom LINTER_FLAGS="-stringsindexhasprefix -test=false"and confirm zero remaining findings-stringsindexhasprefixto bothcgo.ymlLINTER_FLAGS invocationsEffort
Trivial — one-line semantic-preserving rewrite plus a CI flag addition.