fix: replace strings.Index == 0 with strings.HasPrefix; enforce stringsindexhasprefix linter - #49676
Conversation
…gsindexhasprefix linter Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this comment.
🟢 Ready to approve
The behavior-preserving rewrite is correct, tested by existing cases, and consistently enforced across CI targets.
This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.
Pull request overview
Replaces a redundant strings.Index prefix check and enforces the corresponding custom analyzer in CI.
Changes:
- Use
strings.HasPrefixfor clearer prefix detection. - Enable
stringsindexhasprefixfor native and wasm lint gates.
File summaries
| File | Description |
|---|---|
pkg/workflow/frontmatter_on_section_cleanup.go |
Simplifies workflow_run: detection. |
.github/workflows/cgo.yml |
Enforces the analyzer in both custom-linter jobs. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Balanced
We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.
|
@copilot
|
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Addressed in 7a27f50. I investigated the failed Unit tests (A-C) run and fixed the failure by updating Validation run locally:
No unresolved in-scope review threads were present. The branch is not behind |
🔍 Triage Summary
Tiny lint-compliance fix (strings.HasPrefix), reviewer approved but no CI run recorded — verify CI before merge. Automated triage — see the triage report for full context.
|
The
stringsindexhasprefixanalyzer had one remaining production violation —strings.Index(s, sub) == 0infrontmatter_on_section_cleanup.go, which is less readable thanstrings.HasPrefixand leaves an unusedidxbinding.Changes
pkg/workflow/frontmatter_on_section_cleanup.go: Replace the flagged pattern withstrings.HasPrefix, dropping the now-unnecessaryidxvariable:.github/workflows/cgo.yml: Add-stringsindexhasprefixto both the default and wasmLINTER_FLAGSgates, enforcing the rule in CI now that no production violations remain.