8000
Skip to content

[jsweep] Clean add_reaction_and_edit_comment.cjs#24228

Merged
pelikhan merged 1 commit intomainfrom
jsweep/clean-add-reaction-and-edit-comment-667bc4ff3cb44b92
Apr 3, 2026
Merged

[jsweep] Clean add_reaction_and_edit_comment.cjs#24228
pelikhan merged 1 commit intomainfrom
jsweep/clean-add-reaction-and-edit-comment-667bc4ff3cb44b92

Conversation

@github-actions
Copy link
Copy Markdown
Contributor
@github-actions github-actions bot commented Apr 3, 2026

Cleans add_reaction_and_edit_comment.cjs as part of the daily jsweep unbloat run.

Context

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

Changes

add_reaction_and_edit_comment.cjs

Removed redundant shouldCreateComment variable
shouldCreateComment was declared as false and set to true in every branch of the switch — making it dead code. Removed it and simplified the guard from if (shouldCreateComment && commentUpdateEndpoint) to if (commentUpdateEndpoint).

Inlined isDiscussionEvent boolean
The variable was used in a single if statement immediately after its declaration. Inlined it to reduce noise.

Simplified comment body construction
Replaced the imperative let commentBody = ...; if (...) commentBody += ... pattern with a clean array-spread + join("\n\n"):

const commentParts = [
  sanitizeContent(workflowLinkText),
  ...(lockForAgent && ... ? ["🔒 ..."] : []),
  ...(workflowId ? [generateWorkflowIdMarker(workflowId)] : []),
  ...(trackerId ? [`<!-- gh-aw-tracker-id: \$\{trackerId} -->`] : []),
  "<!-- gh-aw-comment-type: reaction -->",
];
const commentBody = commentParts.join("\n\n");

add_reaction_and_edit_comment.test.cjs

Added 1 new test:

  • "should default to 'eyes' reaction when GH_AW_REACTION is not set" — verifies the || "eyes" default is exercised.

Test count: 31 → 32 tests

Validation

  • Formatting: npm run format:cjs
  • Linting: npm run lint:cjs
  • Type checking: npm run typecheck
  • Tests: npm run test:js -- "add_reaction_and_edit_comment" ✅ (32/32 passed)

Generated by jsweep - JavaScript Unbloater · ● 2.2M ·

  • expires on Apr 5, 2026, 4:40 AM UTC

- Remove redundant shouldCreateComment variable (always true in all switch cases)
- Inline isDiscussionEvent boolean (used only once)
- Simplify comment body construction using array spread + join pattern
- Add test for default 'eyes' reaction when GH_AW_REACTION env var is unset

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@pelikhan pelikhan marked this pull request as ready for review April 3, 2026 04:41
Copilot AI review requested due to automatic review settings April 3, 2026 04:41
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

Refactors add_reaction_and_edit_comment.cjs to remove dead/duplicative logic and simplify comment-body construction, and adds a regression test to ensure the default reaction is applied when GH_AW_REACTION is unset.

Changes:

  • Removed redundant shouldCreateComment flag and simplified the comment-creation guard.
  • Inlined the discussion-event boolean and streamlined comment body assembly using a parts array joined with \n\n.
  • Added a test covering the default reaction ("eyes") when GH_AW_REACTION is not set.

Reviewed changes

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

File Description
actions/setup/js/add_reaction_and_edit_comment.cjs Removes dead state (shouldCreateComment), inlines discussion condition, and simplifies comment body construction.
actions/setup/js/add_reaction_and_edit_comment.test.cjs Adds a test to verify the "eyes" default reaction behavior.

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

@pelikhan pelikhan merged commit 1849b17 into main Apr 3, 2026
67 checks passed
@pelikhan pelikhan deleted the jsweep/clean-add-reaction-and-edit-comment-667bc4ff3cb44b92 branch April 3, 2026 04:49
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

0