Skip to content

Duplicate Code: Missing Issue Handlers in Actions Setup #17643

@github-actions

Description

@github-actions

🔍 Duplicate Code Detected: Missing Issue Handlers

Analysis of commit 964cbd7

Assignee: @copilot

Summary

The handler logic for creating/updating “missing data” issues and “missing tool” issues is nearly identical across two action scripts. The duplication spans the full handler pipeline (config parsing, search-or-create issue, comment/issue body construction, and max-count enforcement), with only template paths and item-specific field names differing.

Duplication Details

Pattern: Missing issue handler pipeline

  • Severity: Medium
  • Occurrences: 2
  • Locations:
    • actions/setup/js/create_missing_data_issue.cjs:21
    • actions/setup/js/create_missing_tool_issue.cjs:21
  • Code Sample:
    async function main(config = {}) {
      const titlePrefix = config.title_prefix || "[missing data]";
      const envLabels = config.labels ? (Array.isArray(config.labels) ? config.labels : config.labels.split(",")).map(label => String(label).trim()).filter(label => label) : [];
      const maxCount = config.max || 1;
      // ... shared search-or-create issue logic ...
    }

Impact Analysis

  • Maintainability: Changes to issue/comment formatting, limits, or search strategy must be duplicated in two files.
  • Bug Risk: Fixes or improvements may diverge between the “missing data” and “missing tool” handlers.
  • Code Bloat: ~200+ lines duplicated across two scripts.

Refactoring Recommendations

  1. Extract shared handler builder

    • Move common logic to actions/setup/js/missing_issue_helpers.cjs (or similar).
    • Parameterize: title prefix default, template path, item list renderers, and message field keys.
    • Estimated effort: 2-4 hours
    • Benefits: single source of truth for issue creation workflow and formatting.
  2. Define item-specific renderers

    • Provide small functions that build comment/issue list entries from item objects (data vs tool).
    • Estimated effort: 1-2 hours
    • Benefits: isolates the only real differences and keeps core logic stable.

Implementation Checklist

  • Review duplication findings
  • Prioritize refactoring tasks
  • Create refactoring plan
  • Implement shared helper module
  • Update handlers to use shared helper
  • Update tests
  • Verify no functionality broken

Analysis Metadata

  • Analyzed Files: 2
  • Detection Method: Serena semantic code analysis
  • Commit: 964cbd7
  • Analysis Date: February 22, 2026

Generated by Duplicate Code Detector

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions