🔍 Duplicate Code Detected: Close-Handler REST Wrapper Functions
Analysis of commit 2b4a6df88d5ea6216b577a0af184f9cecff96771
Assignee: @copilot
Duplicate close-handler report - 2026-08-09
Summary
The close-handler modules already use createCloseEntityHandler, but they still duplicate thin REST wrappers for get*Details, add*Comment, and close* operations across both primary close handlers and close_older_* flows. The repeated wrappers are structurally identical and differ mainly in endpoint names and log strings.
Duplication Details
Pattern: repeated REST wrapper helpers for issue and pull request close flows
- Severity: Medium
- Occurrences: 4+ similar blocks
- Locations:
actions/setup/js/close_issue.cjs (lines 118-188)
actions/setup/js/close_pull_request.cjs (lines 21-66)
actions/setup/js/close_older_issues.cjs (lines 80-125)
actions/setup/js/close_older_pull_requests.cjs (lines 77-121)
- Code Sample:
async function addPullRequestComment(github, owner, repo, prNumber, message) {
const { data: comment } = await github.rest.issues.createComment({
owner,
repo,
issue_number: prNumber,
body: message,
});
return comment;
}
async function closePullRequest(github, owner, repo, prNumber) {
const { data: pr } = await github.rest.pulls.update({
owner,
repo,
pull_number: prNumber,
state: "closed",
});
return pr;
}
Impact Analysis
- Maintainability: every logging or error-handling change to close wrappers has to be copied into multiple files.
- Bug Risk: sanitization and response-shape behavior already diverge between the primary close handlers and the
close_older_* variants.
- Code Bloat: the transport code competes with the actual business rules for close policies.
Refactoring Recommendations
-
Extract shared REST close helpers for issue and pull request flows
- Provide common helpers for
getDetails, addComment, and close operations, with options for state reason and logging.
- Estimated effort: 2-4 hours
- Benefits: one implementation for response handling and sanitization.
-
Make close_older_* reuse the same transport helpers
- Keep only the policy-specific behavior in the
close_older_* modules and delegate API operations to shared helpers.
- Estimated effort: 1-2 hours
- Benefits: fewer drift points between normal close flows and cleanup flows.
Implementation Checklist
Analysis Metadata
- Analyzed Files: targeted review of 14 files within 1,599 eligible changed
.go/.cjs paths in the shallow initial-import snapshot
- Detection Method: Serena-guided analysis and targeted source inspection
- Commit:
2b4a6df88d5ea6216b577a0af184f9cecff96771
- Analysis Date:
2026-08-09T22:01:37Z
Generated by 🔍 Duplicate Code Detector · gpt54 · 103.8 AIC · ⊞ 12.8K · ◷
🔍 Duplicate Code Detected: Close-Handler REST Wrapper Functions
Analysis of commit
2b4a6df88d5ea6216b577a0af184f9cecff96771Assignee:
@copilotDuplicate close-handler report - 2026-08-09
Summary
The close-handler modules already use
createCloseEntityHandler, but they still duplicate thin REST wrappers forget*Details,add*Comment, andclose*operations across both primary close handlers andclose_older_*flows. The repeated wrappers are structurally identical and differ mainly in endpoint names and log strings.Duplication Details
Pattern: repeated REST wrapper helpers for issue and pull request close flows
actions/setup/js/close_issue.cjs(lines 118-188)actions/setup/js/close_pull_request.cjs(lines 21-66)actions/setup/js/close_older_issues.cjs(lines 80-125)actions/setup/js/close_older_pull_requests.cjs(lines 77-121)Impact Analysis
close_older_*variants.Refactoring Recommendations
Extract shared REST close helpers for issue and pull request flows
getDetails,addComment, andcloseoperations, with options for state reason and logging.Make
close_older_*reuse the same transport helpersclose_older_*modules and delegate API operations to shared helpers.Implementation Checklist
close_older_*modulesAnalysis Metadata
.go/.cjspaths in the shallow initial-import snapshot2b4a6df88d5ea6216b577a0af184f9cecff967712026-08-09T22:01:37Z