🔍 Duplicate Code Detected: closeOlder Adapter Wrappers
Analysis of commit bc7d2db
Summary
The closeOlderIssues and closeOlderPullRequests wrappers are structurally the same: they pass the same config shape into closeOlderEntities, differ only in entity names and callback targets, and return the same mapped result shape. This is a copy-paste adapter pattern that can be parameterized.
Duplication Details
Pattern: closeOlder adapter wiring
Severity : Medium
Occurrences : 2
Locations :
actions/setup/js/close_older_issues.cjs (lines 188-214)
actions/setup/js/close_older_pull_requests.cjs (lines 187-213)
Code Sample :
const result = await closeOlderEntities ( github , owner , repo , workflowId , newIssue , workflowName , runUrl , {
entityType : "issue" ,
entityTypePlural : "issues" ,
searchOlderEntities : ( gh , o , r , wid , excludeNumber ) => searchOlderIssues ( gh , o , r , wid , excludeNumber , callerWorkflowId , closeOlderKey ) ,
getCloseMessage : params => getCloseOlderIssueMessage ( { ... } ) ,
addComment : addIssueComment ,
closeEntity : closeIssueAsNotPlanned ,
delayMs : API_DELAY_MS ,
getEntityId : entity => entity . number ,
getEntityUrl : entity => entity . html_url ,
} ) ;
Impact Analysis
Maintainability : Any change to the adapter contract has to be repeated in both files.
Bug Risk : Small mismatches between the two wrappers can diverge behavior for issues vs. PRs.
Code Bloat : The wrappers are mostly repeated configuration data with different names.
Refactoring Recommendations
Extract a typed wrapper factory
Extract common logic to: actions/setup/js/close_older_entity_factory.cjs
Estimated effort: small
Benefits: one shared adapter path for entity naming, message construction, and close callbacks
Pass entity-specific config objects
Replace per-file wiring with a config object for entity label, message builder, search function, and close handler
Estimated effort: small to medium
Benefits: less duplication and simpler future entity additions
Implementation Checklist
Analysis Metadata
Analyzed Files : 5
Detection Method : Serena semantic code analysis
Commit : bc7d2db
Analysis Date : 2026-07-12
Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
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 · 14.7 AIC · ⌖ 1.17 AIC · ⊞ 11.5K · ◷
🔍 Duplicate Code Detected: closeOlder Adapter Wrappers
Analysis of commit bc7d2db
Summary
The
closeOlderIssuesandcloseOlderPullRequestswrappers are structurally the same: they pass the same config shape intocloseOlderEntities, differ only in entity names and callback targets, and return the same mapped result shape. This is a copy-paste adapter pattern that can be parameterized.Duplication Details
Pattern: closeOlder adapter wiring
actions/setup/js/close_older_issues.cjs(lines 188-214)actions/setup/js/close_older_pull_requests.cjs(lines 187-213)Impact Analysis
Refactoring Recommendations
Extract a typed wrapper factory
actions/setup/js/close_older_entity_factory.cjsPass entity-specific config objects
Implementation Checklist
Analysis Metadata
Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
awmgmcpgSee Network Configuration for more information.