Skip to content

fix: replace strings.Index == 0 with strings.HasPrefix; enforce stringsindexhasprefix linter - #49676

Merged
pelikhan merged 3 commits into
mainfrom
copilot/fix-strings-index-check
Aug 2, 2026
Merged

fix: replace strings.Index == 0 with strings.HasPrefix; enforce stringsindexhasprefix linter#49676
pelikhan merged 3 commits into
mainfrom
copilot/fix-strings-index-check

Conversation

CopilotAI commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

The stringsindexhasprefix analyzer had one remaining production violation — strings.Index(s, sub) == 0 in frontmatter_on_section_cleanup.go, which is less readable than strings.HasPrefix and leaves an unused idx binding.

Changes

  • pkg/workflow/frontmatter_on_section_cleanup.go: Replace the flagged pattern with strings.HasPrefix, dropping the now-unnecessary idx variable:
    // beforeifidx:=strings.Index(trimmedLine, "workflow_run:"); idx==0 {
    // afterifstrings.HasPrefix(trimmedLine, "workflow_run:") {
  • .github/workflows/cgo.yml: Add -stringsindexhasprefix to both the default and wasm LINTER_FLAGS gates, enforcing the rule in CI now that no production violations remain.

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 9.35 AIC · ⌖ 6.47 AIC · ⊞ 8.1K ·
Comment /souschef to run again

…gsindexhasprefix linter
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
CopilotAI changed the title [WIP] Fix violation in frontmatter_on_section_cleanup.go for strings.Indexfix: replace strings.Index == 0 with strings.HasPrefix; enforce stringsindexhasprefix linterAug 1, 2026
CopilotAI requested a review from pelikhanAugust 1, 2026 23:10
@pelikhan
pelikhan marked this pull request as ready for review August 1, 2026 23:12
CopilotAI review requested due to automatic review settings August 1, 2026 23:12
CopilotAI approved these changes Aug 1, 2026

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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.HasPrefix for clearer prefix detection.
  • Enable stringsindexhasprefix for native and wasm lint gates.
File summaries
FileDescription
pkg/workflow/frontmatter_on_section_cleanup.goSimplifies workflow_run: detection.
.github/workflows/cgo.ymlEnforces 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.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot
Please investigate this PR and move it toward merge readiness.
Failed checks:

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 9.35 AIC · ⌖ 6.47 AIC · ⊞ 8.1K ·
Comment /souschef to run again

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

CopilotAI commented Aug 2, 2026

Copy link
Copy Markdown
ContributorAuthor

@copilot
Please investigate this PR and move it toward merge readiness.
Failed checks:...

Addressed in 7a27f50.

I investigated the failed Unit tests (A-C) run and fixed the failure by updating pkg/cli/aw_failure_investigator_workflow_test.go to match current workflow behavior (FAILURE_CONCLUSIONS no longer includes cancelled).

Validation run locally:

  • make fmt
  • make lint
  • make test-unit
  • make test
  • make recompile
  • make agent-report-progress
  • parallel_validation (CodeQL skipped as trivial test-only change)

No unresolved in-scope review threads were present. The branch is not behind main.

@github-actions

Copy link
Copy Markdown
Contributor

🔍 Triage Summary

FieldValue
Categoryrefactor
Risklow
Prioritymedium
Score35/100 (impact 10 + urgency 10 + quality 15)
Recommended actiondefer
Batch

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.

Generated by 🔧 PR Triage Agent · auto · 40.3 AIC · ⌖ 4.01 AIC · ⊞ 8K ·

@pelikhan
pelikhan merged commit 4eeab10 into mainAug 2, 2026
7 checks passed
@pelikhan
pelikhan deleted the copilot/fix-strings-index-check branch August 2, 2026 09:51
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.84.3

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

4 participants

@gh-aw-bot@pelikhan