Skip to content

[jsweep] Clean assign_to_agent.cjs#20155

Merged
pelikhan merged 1 commit intomainfrom
jsweep/clean-assign-to-agent-bd055464bc313be7
Mar 9, 2026
Merged

[jsweep] Clean assign_to_agent.cjs#20155
pelikhan merged 1 commit intomainfrom
jsweep/clean-assign-to-agent-bd055464bc313be7

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Mar 9, 2026

Summary

Cleaned assign_to_agent.cjs as part of the jsweep JavaScript unbloat initiative.

Context: github-script context (uses core, github, context globals)

Changes

assign_to_agent.cjs

  • Modernized loop: Replaced for (let i = 0; i < itemsToProcess.length; i++) with for (const [i, item] of itemsToProcess.entries()) — removes redundant manual indexing and const item = itemsToProcess[i] declaration
  • Cleaner auth error check: Replaced 5-line || chain for isAuthError with a more readable array.some(msg => errorMessage.includes(msg)) pattern

assign_to_agent.test.cjs

  • Added test: "should reject per-item pull_request_repo not in allowed list" — covers the validation path in item.pull_request_repo handling that was previously untested (tests the E004 error when a per-item PR repo is not in the allowed list)

Test Results

  • 36 tests pass, 3 skipped (pre-existing it.skip tests)
  • Tests added: 1 new test case

✅ Validation Checks

  • Formatting: npm run format:cjs
  • Linting: npm run lint:cjs
  • Type checking: npm run typecheck
  • Tests: vitest run assign_to_agent.test.cjs — 36 passed, 3 skipped ✓

Generated by jsweep - JavaScript Unbloater ·

  • expires on Mar 11, 2026, 3:18 AM UTC

- Replace for loop with for...of entries() iteration
- Simplify isAuthError check using array .some() pattern
- Add test for per-item pull_request_repo rejection

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@pelikhan pelikhan marked this pull request as ready for review March 9, 2026 03:38
Copilot AI review requested due to automatic review settings March 9, 2026 03:38
@pelikhan pelikhan merged commit d17b081 into main Mar 9, 2026
1 check passed
@pelikhan pelikhan deleted the jsweep/clean-assign-to-agent-bd055464bc313be7 branch March 9, 2026 03:38
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Cleans up assign_to_agent as part of the jsweep JavaScript unbloat effort, and adds a regression test for per-item pull_request_repo allowlist validation.

Changes:

  • Refactors the per-item processing loop to use itemsToProcess.entries() for cleaner indexing + item access.
  • Simplifies authentication/permission error detection using an Array.some(...) substring match.
  • Adds a test covering rejection of per-item pull_request_repo values not present in the allowed list.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
actions/setup/js/assign_to_agent.cjs Refactors iteration style and streamlines auth-error substring detection logic.
actions/setup/js/assign_to_agent.test.cjs Adds coverage for the E004 validation path when a per-item PR repo is not allowlisted.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants