Skip to content

[jsweep] Clean assign_agent_helpers.cjs#23315

Merged
pelikhan merged 1 commit intomainfrom
jsweep/assign-agent-helpers-7ada000fce058c24
Mar 28, 2026
Merged

[jsweep] Clean assign_agent_helpers.cjs#23315
pelikhan merged 1 commit intomainfrom
jsweep/assign-agent-helpers-7ada000fce058c24

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

Summary

Cleaned actions/setup/js/assign_agent_helpers.cjs as part of the daily jsweep JavaScript unbloat process.

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


Changes

assign_agent_helpers.cjs

Fix variable shadowing (bug fix)

  • Renamed inner agentNameassigneeAgentName in the allowedAgents filter callback inside assignAgentToIssue. The inner variable was shadowing the outer agentName function parameter, which is a JavaScript anti-pattern that can lead to confusing bugs.

Simplify debug message building

  • Replaced imperative string concatenation (let debugMsg = ...; if (x) debugMsg += ...) with a declarative array spread pattern, making the conditional parts clearer and more readable.

Property shorthand

  • Used assignableId shorthand instead of assignableId: assignableId in the fallback mutation variables object.

assign_agent_helpers.test.cjs

Added 5 new tests for getPullRequestDetails

  • getPullRequestDetails was exported and used by assign_to_agent.cjs but had zero test coverage.
  • Added comprehensive tests: success case, null PR, empty assignees, GraphQL error re-throw, correct variables passed to GraphQL.

Test improvements

  • Before: 35 tests
  • After: 40 tests (+5 for getPullRequestDetails)

✅ Validation checks

  • Formatting: npm run format:cjs
  • Linting: npm run lint:cjs
  • Type checking: npm run typecheck
  • Tests: 40/40 passed ✓

Generated by jsweep - JavaScript Unbloater ·

  • expires on Mar 30, 2026, 4:37 AM UTC

- Fix variable shadowing: rename inner `agentName` to `assigneeAgentName`
  in the allowedAgents filter callback to avoid shadowing the outer parameter
- Simplify debug message building using array spread pattern instead of
  imperative string concatenation
- Use property shorthand in fallback mutation variables object
- Add 5 new tests for `getPullRequestDetails` (previously untested despite
  being exported and used in assign_to_agent.cjs)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@pelikhan pelikhan marked this pull request as ready for review March 28, 2026 10:38
Copilot AI review requested due to automatic review settings March 28, 2026 10:38
Copy link
Copy Markdown
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

This PR continues the jsweep “unbloat” effort by tightening up assign_agent_helpers.cjs and adding missing unit coverage for getPullRequestDetails, which is used by the assign-to-agent workflow.

Changes:

  • Fixes a variable-shadowing case inside assignAgentToIssue’s allowedAgents filtering logic.
  • Simplifies GraphQL debug logging construction and uses object property shorthand in the fallback mutation variables.
  • Adds 5 tests covering getPullRequestDetails (success, not-found, empty assignees, GraphQL error behavior, and variable passing).

Reviewed changes

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

File Description
actions/setup/js/assign_agent_helpers.cjs Small refactors/cleanup: remove shadowing, improve debug message construction, and minor object literal simplification.
actions/setup/js/assign_agent_helpers.test.cjs Adds targeted tests to cover getPullRequestDetails behavior and GraphQL invocation.

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

@pelikhan pelikhan merged commit 9b43bdb into main Mar 28, 2026
64 checks passed
@pelikhan pelikhan deleted the jsweep/assign-agent-helpers-7ada000fce058c24 branch March 28, 2026 10:46
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.

2 participants