Skip to content

[code-simplifier] simplify: extract update_branch via destructuring in update_pull_request.cjs - #27281

Merged
pelikhan merged 1 commit into
mainfrom
code-simplifier/update-pr-destructuring-2026-04-20-668f8e98b739a726
Apr 20, 2026
Merged

[code-simplifier] simplify: extract update_branch via destructuring in update_pull_request.cjs#27281
pelikhan merged 1 commit into
mainfrom
code-simplifier/update-pr-destructuring-2026-04-20-668f8e98b739a726

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

This PR simplifies recently modified code from PR #27244 to improve clarity and eliminate post-destructuring mutation.

Files Simplified

  • actions/setup/js/update_pull_request.cjs — extract update_branch in the initial destructuring to avoid a delete mutation on apiData

Improvements Made

Eliminated Post-Destructuring Mutation

The update_branch field added in #27244 was extracted from updateData in two steps: first via spread into apiData, then separately deleted with delete apiData.update_branch. This is a code smell — it mutates the object after construction.

Before:

// Remove internal fieldsconst{ _operation, _rawBody, _includeFooter, _workflowRepo, ...apiData}=updateData;constupdateBranch=apiData.update_branch===true;deleteapiData.update_branch;

After:

// Remove internal fields (including update_branch which is handled separately below)const{ _operation, _rawBody, _includeFooter, _workflowRepo, update_branch, ...apiData}=updateData;constupdateBranch=update_branch===true;

The destructuring already extracted all the other internal fields; adding update_branch to that same pattern is consistent, eliminates the mutation, and makes the intent clearer.

Changes Based On

Recent changes from:

Testing

  • ✅ Prettier formatting check passes (npx prettier --check update_pull_request.cjs)
  • ✅ Logic is functionally equivalent — behavior is identical
  • ✅ No other files changed

Review Focus

Please verify:

  • Functionality is preserved (both approaches produce the same apiData without update_branch, and the same boolean updateBranch)
  • The simplification aligns with the project's destructuring convention for stripping internal fields

Automated by Code Simplifier Agent - analyzing code from the last 24 hours

Note

🔒 Integrity filter blocked 1 item

The following item was blocked because it doesn't meet the GitHub integrity level.

To allow these resources, lower min-integrity in your GitHub frontmatter:

tools:
github:
min-integrity: approved # merged | approved | unapproved | none

Generated by Code Simplifier · ● 2.7M ·

  • expires on Apr 21, 2026, 6:32 AM UTC

…ation
Removes the need for post-destructuring mutation by including update_branch
in the initial destructuring of updateData, keeping apiData clean from the start.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
ContributorAuthor

Hey @github-actions[bot] 👋 — nice cleanup! Eliminating the post-destructuring delete apiData.update_branch mutation in update_pull_request.cjs is a clean improvement — it's more idiomatic JS and keeps the destructuring pattern consistent with how the other internal fields are already stripped.

One thing to address before this is ready for merge:

  • Add or update tests — the diff doesn't touch any test files. Even though the logic is functionally equivalent, a regression test (or a check in an existing test) that asserts apiData does not contain update_branch and that updateBranch is set correctly would make the equivalence explicit and guard against future regressions.

If you'd like a hand, you can assign this prompt to your coding agent:

Add or update tests for the `executePRUpdate` function in `actions/setup/js/update_pull_request.cjs`.
Specifically, verify that after the refactored destructuring:
1. `apiData` does NOT contain an `update_branch` key.
2. `updateBranch` is `true` when `updateData.update_branch === true`.
3. `updateBranch` is `false` when `updateData.update_branch` is absent or falsy.
Place the tests in the appropriate test file alongside the existing tests for this module.

Generated by Contribution Check · ● 1.7M ·

@pelikhan
pelikhan marked this pull request as ready for review April 20, 2026 12:24
CopilotAI review requested due to automatic review settings April 20, 2026 12:24

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.

Pull request overview

This PR simplifies executePRUpdate in actions/setup/js/update_pull_request.cjs by extracting update_branch directly during destructuring, removing the need to mutate apiData via delete.

Changes:

  • Extract update_branch during the initial destructuring of updateData.
  • Remove the post-destructuring delete apiData.update_branch mutation while preserving updateBranch behavior.
Show a summary per file
FileDescription
actions/setup/js/update_pull_request.cjsSimplifies internal-field stripping by destructuring update_branch directly, avoiding mutation of apiData.

Copilot's findings

Tip

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

  • Files reviewed: 1/1 changed files
  • Comments generated: 0

@github-actionsgithub-actionsBot mentioned this pull request Apr 20, 2026
@pelikhan
pelikhan merged commit c130716 into mainApr 20, 2026
74 checks passed
@pelikhan
pelikhan deleted the code-simplifier/update-pr-destructuring-2026-04-20-668f8e98b739a726 branch April 20, 2026 12:53
Sign up for freeto 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

@pelikhan