Skip to content

[duplicate-code] Duplicate Code: Reaction Validation and Dispatch #43481

Description

@github-actions

🔍 Duplicate Code Detected: Reaction Validation and Dispatch

Analysis of commit bd0c249

Assignee: @copilot

Summary

The reaction-only and reaction-plus-comment scripts both perform the same initial reaction workflow: read GH_AW_REACTION, validate the reaction set, resolve the invocation context, and dispatch the reaction.

Duplication Details

Pattern: repeated reaction workflow setup

  • Severity: Medium
  • Occurrences: 2
  • Locations:
    • actions/setup/js/add_reaction.cjs (lines 26-61)
    • actions/setup/js/add_reaction_and_edit_comment.cjs (lines 140-186)
  • Code Sample:
    const reaction = process.env.GH_AW_REACTION || "eyes";
    const invocationContext = resolveInvocationContext(context);
    if (!validReactions.includes(reaction)) { ... }

Impact Analysis

  • Maintainability: Reaction validation and context resolution can drift between two entry points.
  • Bug Risk: A change to supported reactions or event lookup has to be updated in both files.
  • Code Bloat: Both modules carry the same setup logic before diverging into their specific comment behavior.

Refactoring Recommendations

  1. Extract a shared reaction setup helper that returns the validated reaction and resolved invocation context.
  2. Keep reaction-specific side effects in thin entry points.

Analysis Metadata

  • Analyzed Files: 2
  • Detection Method: Serena semantic code analysis
  • Commit: bd0c249

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • awmgmcpg

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

Generated by 🔍 Duplicate Code Detector · 13 AIC · ⌖ 6.29 AIC · ⊞ 13.3K ·

  • expires on Jul 6, 2026, 10:33 PM UTC-08:00

Metadata

Metadata

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions