Skip to content

[duplicate-code] Duplicate Code: Discussion Comment Mutation Flow #43479

Description

@github-actions

🔍 Duplicate Code Detected: Discussion Comment Mutation Flow

Analysis of commit bd0c249

Assignee: @copilot

Summary

Two separate comment workflows reimplement the same discussion comment mutation flow: fetch discussion ID, optionally thread via replyToId, build addDiscussionComment, and return the created comment metadata.

Duplication Details

Pattern: shared discussion comment creation logic

  • Severity: Medium
  • Occurrences: 2
  • Locations:
    • actions/setup/js/add_comment.cjs (lines 359-414)
    • actions/setup/js/add_reaction_and_edit_comment.cjs (lines 217-283)
  • Code Sample:
    const mutation = replyToId
      ? `mutation ($dId: ID!, $body: String!, $replyToId: ID!) { addDiscussionComment(...) }`
      : `mutation ($dId: ID!, $body: String!) { addDiscussionComment(...) }`;

Impact Analysis

  • Maintainability: Discussion comment behavior is split across two implementations with slightly different surrounding logic.
  • Bug Risk: Reply threading, mutation shape, and output handling can diverge.
  • Code Bloat: The same GraphQL assembly appears in two modules that already share resolveTopLevelDiscussionCommentId.

Refactoring Recommendations

  1. Extract a shared createDiscussionComment helper that accepts the comment body and optional replyToId.
  2. Keep workflow-specific body assembly in the calling module.

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