Skip to content

[duplicate-code] Duplicate Code Analysis Report #1283

@github-actions

Description

@github-actions

Analysis of latest commit on main

Summary

Static analysis of the internal/server package found 2 significant duplication patterns across transport.go and routed.go. These two files both implement HTTP servers for the MCP Gateway (unified and routed modes respectively) and share structural logic that has been copy-pasted rather than extracted into shared helpers.

Detected Patterns

  1. Session Establishment Callback Logic – Severity: Medium – See sub-issue [duplicate-code] Duplicate Code Pattern: Session Establishment Callback Logic #1282
  2. Middleware Chaining + HTTP Server Construction – Severity: Low – See sub-issue [duplicate-code] Duplicate Code Pattern: Middleware Chaining and HTTP Server Construction #1284

Overall Impact

  • Total Duplicated Lines: ~25 lines
  • Affected Files: 2 (internal/server/transport.go, internal/server/routed.go)
  • Maintainability Risk: Medium — any change to session logging format or middleware order must be made in two places, risking divergence
  • Refactoring Priority: Low-Medium — the duplication is contained, but repeated changes (e.g. adding middleware, changing log formats) will require touching both files

Next Steps

  1. Review individual pattern sub-issues for detailed analysis
  2. Consider extracting shared helper(s) into http_helpers.go or a new server_factory.go
  3. Prioritize refactoring alongside any planned changes to session handling or middleware

Analysis Metadata

  • Analyzed Files: 4 non-test Go files (transport.go, routed.go, http_helpers.go, handlers.go)
  • Detection Method: Manual semantic code analysis
  • Analysis Date: 2026-02-22

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions