github / github/gh-aw

Duplicate Code: Missing-issue wrapper pattern in actions/setup/js

Open
#28,254 0 comments 1 reaction 2 assignees Claimed by @pelikhan View on GitHub
automation refactoring workflows
Dominant language
Go
Stars
5.1k
Forks
541
Avg merge
5h 46m
Merged PRs (30d)
760

Description

### Overview
A semantic duplicate-code scan found a repeated wrapper pattern around `buildMissingIssueHandler(...)` in three production `.cjs` files. Each file is ~40 lines and largely differs only by configuration values and small item-rendering variations.

### Critical Information
- Pattern: missing/incomplete issue handler wrappers with duplicated scaffolding
- Severity: Medium
- Occurrences: 3
- Duplication size: ~25-30 repeated lines per file
- Commit analyzed: `0775d65c9572ac16c5fa3bd72df9c39db939e5b3`

### Duplication Details
- [create_missing_data_issue.cjs](/home/runner/work/gh-aw/gh-aw/actions/setup/js/create_missing_data_issue.cjs):18
- [create_missing_tool_issue.cjs](/home/runner/work/gh-aw/gh-aw/actions/setup/js/create_missing_tool_issue.cjs):18
- [create_report_incomplete_issue.cjs](/home/runner/work/gh-aw/gh-aw/actions/setup/js/create_report_incomplete_issue.cjs):20

Evidence

- All three files define `HANDLER_TYPE`, call `buildMissingIssueHandler({...})`, and export `main`.
- `diff -u` between these files shows only field-name/content substitutions, while the surrounding structure is duplicated.
- Serena symbol overview reports an equivalent symbol layout in all 3 files (`HANDLER_TYPE`, `main`, module export).

### Impact Analysis
- Maintainability: Updating shared behavior (headers, list rendering conventions, metadata fields) requires synchronized edits across multiple files.
- Bug risk: Divergence risk increases when one wrapper receives updates and others do not.
- Code bloat: Repeated boilerplate obscures the true per-handler deltas.

### Refactoring Recommendations
1. Move wrapper creation to a descriptor registry.
- Add a single map/array of handler descriptors (type, list key, template path, header builder, item renderer).
- Generate/export handlers via one shared factory loop.
2. Keep per-handler item formatting as isolated callbacks.
- Preserve current output behavior while reducing duplicated scaffolding.
3. Add focused tests for descriptor-driven registration.
- Validate each handler type still maps to expected fields and rendered sections.

### Implementation Checklist
- [ ] Create a descriptor-based registration utility for missing/incomplete issue handlers
- [ ] Replace the three near-identical wrapper files with minimal descriptor exports
- [ ] Add/update tests to lock expected rendering and issue metadata
- [ ] Verify no behavior change in safe output issue generation

### Analysis Metadata
- Analyzed files: 1001 production `.go`/`.cjs` files (tests/workflows excluded)
- Detection method: Serena semantic analysis + structural diff comparison
- Triggered by: `@pelikhan`
- Workflow run: [§24888375770](https://github.com/github/gh-aw/actions/runs/24888375770)

**References:**
- [§24888375770](https://github.com/github/gh-aw/actions/runs/24888375770)

> [!WARNING]
> **⚠️ Firewall blocked 4 domains**
>
> The following domains were blocked by the firewall during workflow execution:
>
> - `ab.chatgpt.com`
> - `api.github.com`
> - `chatgpt.com`
> - `github.com`
>
> To allow these domains, add them to the `network.allowed` list in your workflow frontmatter:
>
> ```yaml
> network:
> allowed:
> - defaults
> - "ab.chatgpt.com"
> - "api.github.com"
> - "chatgpt.com"
> - "github.com"
> ```
>
> See [Network Configuration](https://github.github.com/gh-aw/reference/network/) for more information.

> Generated by [Duplicate Code Detector](https://github.com/github/gh-aw/actions/runs/24888375770/agentic_workflow) · [◷](https://github.com/search?q=repo%3Agithub%2Fgh-aw+is%3Aissue+%22gh-aw-workflow-call-id%3A+github%2Fgh-aw%2Fduplicate-code-detector%22&type=issues)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.