Skip to content

Use strings.Cut for the first path component - #75920

Merged
pelikhan merged 2 commits into
mainfrom
copilot/linter-minersplit-index-zero-prefer-cut
Nov 8, 2026
Merged

pelikhan merged 2 commits into
mainfrom
copilot/linter-minersplit-index-zero-prefer-cut

Conversation

Copilot AI commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

The existing stringssplitfirst analyzer flags strings.Split(s, sep)[0] when a non-empty separator is known. Replace the remaining production occurrence in the source-managed edit check while preserving its comparison behavior.

  • Change: Extract the first path component with strings.Cut instead of allocating a split slice.
  • Example:
    if first, _, _ := strings.Cut(change.path, "."); first == "source" {

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Copilot AI changed the title [WIP] Add split-index-zero-prefer-cut custom linter Use strings.Cut for the first path component Nov 8, 2026
Copilot AI requested a review from gh-aw-bot November 8, 2026 17:04
@pelikhan
pelikhan marked this pull request as ready for review November 8, 2026 17:09
Copilot AI dynamic review requested due to automatic review settings November 8, 2026 17:09
@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Specification Reviewer completed successfully!

PR Specification Reviewer

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from PR Specification Reviewer · gpt56 · ~1 AIC · ⌖ ~1 AIC · ◇ ~1 AIC · ⊞ 1.7K · ◷

Generated by PR Specification Reviewer for #75920

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Test Quality Sentinel · routed: gpt56 max · ~2 AIC · ⌖ ~2 AIC · ◇ ~1 AIC · ⊞ 6.3K · ◷

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Code Quality Reviewer completed the code quality review.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft.

Design Decision Gate 🏗️

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Design Decision Gate 🏗️ · routed: opus55 medium · ~11 AIC · ⌖ ~2 AIC · ◇ ~1 AIC · ⊞ 7.7K · ◷

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

Ponytail Reviewer

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Ponytail Reviewer · routed: gpt56 max · ~2 AIC · ⌖ ~1 AIC · ◇ ~1 AIC · ⊞ 118 · ◷

Generated by Ponytail Reviewer for #75920

Copilot AI 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.

🟢 Approval recommended

The focused strings.Cut substitution preserves existing comparison behavior and source-edit protections, with no active review issues identified.

No open issues 🎉

What changed in this PR

This pull request replaces the remaining strings.Split(...)[0] usage in the source-managed workflow edit check with strings.Cut, preserving existing comparison behavior while avoiding an unnecessary allocation.

Changes:

  • Extracts the first path component with strings.Cut.
  • Preserves protection for direct and nested source edits.
File Description
pkg/​cli/​edit_command.go Replaces split-index extraction with strings.Cut in the source-managed edit check.

Review effort: Lite (auto)

@github-actions github-actions Bot 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.

Reviewed the one-line optimization in pkg/cli/edit_command.go. strings.Cut(change.path, ".") preserves the first-component comparison behavior of strings.Split(...)[0] for all relevant inputs while avoiding the allocation. No blocking issues found.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~1 AIC · ⌖ ~1 AIC · ⊞ 1.6K
Comment /review to run again

@pelikhan
pelikhan merged commit d964d9a into main Nov 8, 2026
135 of 136 checks passed
@pelikhan
pelikhan deleted the copilot/linter-minersplit-index-zero-prefer-cut branch November 8, 2026 17:16
Copilot AI added a commit that referenced this pull request Nov 8, 2026
Co-authored-by: gh-aw-bot <15877973+gh-aw-bot@users.noreply.github.com>
lpcox added a commit that referenced this pull request Nov 8, 2026
* Initial plan

* Bump gh-aw-firewall to v0.29.10 with verified release pins

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>

* Refresh firewall pins in workflow locks

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

* Fix stale workflow pins and registry tests

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

* Use strings.Cut for the first path component (#75920)
Co-authored-by: gh-aw-bot <15877973+gh-aw-bot@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v1.2.2

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[linter-miner] Add split-index-zero-prefer-cut custom linter

4 participants