Skip to content

[duplicate-code] Duplicate Code: Gateway Config Entry Transformation Pattern #42677

Description

@github-actions

🔍 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

  1. 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.
  2. Split the provider differences into tiny adapters.

    • Example: one helper for set type, one for drop type, one for ensure tools.
    • That keeps the shared transformation readable while removing copy-paste.

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.allowed list 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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions