[jsweep] Clean assign_agent_helpers.cjs#23315
Merged
Conversation
- 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>
Contributor
There was a problem hiding this comment.
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’sallowedAgentsfiltering 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Cleaned
actions/setup/js/assign_agent_helpers.cjsas part of the daily jsweep JavaScript unbloat process.Context: github-script (uses global
github,core,context)Changes
assign_agent_helpers.cjsFix variable shadowing (bug fix)
agentName→assigneeAgentNamein theallowedAgentsfilter callback insideassignAgentToIssue. The inner variable was shadowing the outeragentNamefunction parameter, which is a JavaScript anti-pattern that can lead to confusing bugs.Simplify debug message building
let debugMsg = ...; if (x) debugMsg += ...) with a declarative array spread pattern, making the conditional parts clearer and more readable.Property shorthand
assignableIdshorthand instead ofassignableId: assignableIdin the fallback mutation variables object.assign_agent_helpers.test.cjsAdded 5 new tests for
getPullRequestDetailsgetPullRequestDetailswas exported and used byassign_to_agent.cjsbut had zero test coverage.Test improvements
getPullRequestDetails)✅ Validation checks
npm run format:cjs✓npm run lint:cjs✓npm run typecheck✓