Repository navigation
Closed
Closed
Copy link
Labels
automated-analysiscode-qualitycookieIssue Monster Loves Cookies!Issue Monster Loves Cookies!duplication
Description
🔍 Duplicate Code Detected: Gateway Config Entry Transformation Pattern
Analysis of commit 38aaae7
Summary
Three CommonJS converters in actions/setup/js repeat the same entry-cloning and URL-rewriting flow. Each file copies a gateway entry, conditionally rewrites url, then returns the transformed object with only a small provider-specific tweak.
Duplication Details
Pattern: provider-specific gateway entry normalization
- Severity: Medium
- Occurrences: 3
- Locations:
actions/setup/js/convert_gateway_config_claude.cjs(lines 34-43)actions/setup/js/convert_gateway_config_copilot.cjs(lines 55-66)actions/setup/js/convert_gateway_config_gemini.cjs(lines 40-49)
- Shared shape:
const transformed = { ...entry };- provider-specific field tweak
if (typeof transformed.url === "string") { transformed.url = rewriteUrl(...) }return transformed;
Impact Analysis
- Maintainability: any future URL/schema change must be repeated in three places.
- Bug Risk: a fix to one converter can easily drift from the others.
- Code Bloat: the same normalization logic is embedded in each provider file instead of being shared.
Refactoring Recommendations
-
Extract a shared helper for gateway entry normalization.
- Keep provider-specific field mutations as a small callback or options object.
- This should centralize the clone/rewrite logic.
-
Split the provider differences into tiny adapters.
- Example: one helper for
set type, one fordrop type, one forensure tools. - That keeps the shared transformation readable while removing copy-paste.
- Example: one helper for
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:
38aaae7 - Analysis Date: 2026-07-01
Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
awmgmcpg
To allow these domains, add them to the
network.allowedlist in your workflow frontmatter:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
Generated by 🔍 Duplicate Code Detector · 4.57 AIC · ⌖ 1.4 AIC · ⊞ 11.5K · ◷
- expires on Jul 2, 2026, 10:51 PM UTC-08:00
Reacted by Copilot
Metadata
Metadata
Labels
automated-analysiscode-qualitycookieIssue Monster Loves Cookies!Issue Monster Loves Cookies!duplication
Activity