Skip to content

[duplicate-code] Duplicate Code: Missing-Issue Handler Config in CJS Entrypoints #40262

@github-actions

Description

@github-actions

Analysis of commit 80f243c

Assignee: @copilot

Summary

create_missing_tool_issue.cjs, create_missing_data_issue.cjs, and create_report_incomplete_issue.cjs each build the same buildMissingIssueHandler(...) wrapper with only literals and item names changed. The repeated structure is roughly 18-20 lines per file and is easy to drift.

Duplication Details

Pattern: Missing-issue handler config wrapper

  • Severity: Medium
  • Occurrences: 3
  • Locations:
    • actions/setup/js/create_missing_tool_issue.cjs (lines 18-38)
    • actions/setup/js/create_missing_data_issue.cjs (lines 18-40)
    • actions/setup/js/create_report_incomplete_issue.cjs (lines 20-40)
  • Code Sample:
main = buildMissingIssueHandler({
  handlerType: HANDLER_TYPE,
  defaultTitlePrefix: "...",
  defaultLabels: ["agentic-workflows"],
  itemsField: "...",
  templatePath: getPromptPath("..."),
  templateListKey: "...",
  buildCommentHeader: runUrl => [...],
  renderCommentItem: (...) => {...},
  renderIssueItem: (...) => {...},
})

Impact Analysis

  • Maintainability: edits to one handler shape need to be mirrored in three files.
  • Bug Risk: drift in comment/issue rendering or default labels is easy to introduce.
  • Code Bloat: three near-identical config blocks add avoidable repetition.

Refactoring Recommendations

  1. Extract a small config factory for missing-issue handlers, e.g. buildMissingIssueConfig(kind, templates, renderers).
  2. Keep only the per-kind literals in each entrypoint.
  3. Consider a shared metadata table for the missing tool, missing data, and incomplete variants.

Implementation Checklist

  • Review duplication findings
  • Prioritize refactoring tasks
  • Create refactoring plan
  • Implement changes
  • Update tests
  • Verify no functionality broken

Analysis Metadata

  • Analyzed Files: 3
  • Detection Method: Serena semantic code analysis
  • Commit: 80f243c
  • Analysis Date: 2026-06-19 UTC

Generated by 🔍 Duplicate Code Detector · 15 AIC · ⌖ 2.59 AIC · ⊞ 14.8K ·

  • expires on Jun 20, 2026, 10:58 PM UTC-08:00

Metadata

Metadata

Type

No type
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