Skip to content

[duplicate-code] Duplicate Code Analysis Report #7359

@github-actions

Description

@github-actions

Analysis of the most recent commit: refactor: consolidate over-fragmented files in internal/ packages

Summary

Semantic analysis of the 120+ Go files changed in the recent refactoring commit identified 2 significant duplication patterns that affect maintainability. Both exceed the reporting threshold (>10 duplicated lines or 3+ similar patterns).

Detected Patterns

  1. rejectRequest with hardcoded constant category/error-type arguments — Severity: Medium — See sub-issue [duplicate-code] Duplicate Code Pattern: Hardcoded constant args in rejectRequest calls (server/hmac.go, server/middleware.go) #7360
  2. listTools/listResources/listPrompts structural duplication — Severity: Low-Medium — See sub-issue [duplicate-code] Duplicate Code Pattern: Structural duplication in listTools/listResources/listPrompts (mcp/connection_methods.go) #7361

Overall Impact

  • Total Duplicated Lines: ~60 (10 instances of the rejectRequest pattern + 3 × 12 lines for list methods)
  • Affected Files: 3 files (internal/server/hmac.go, internal/server/middleware.go, internal/mcp/connection_methods.go)
  • Maintainability Risk: Medium — the constant-arg repetition in rejectRequest calls risks divergence if error codes change; the list-method pattern is already partially refactored
  • Refactoring Priority: Medium for pattern 1 (server/hmac.go), Low for pattern 2 (mcp/connection_methods.go)

Next Steps

  1. Review sub-issue [duplicate-code] Duplicate Code Pattern: Hardcoded constant args in rejectRequest calls (server/hmac.go, server/middleware.go) #7360 — introduce rejectHMACRequest and rejectAuthRequest helpers in internal/server/
  2. Review sub-issue [duplicate-code] Duplicate Code Pattern: Structural duplication in listTools/listResources/listPrompts (mcp/connection_methods.go) #7361 — consider whether further table-driven reduction of the list methods is worth the added indirection
  3. Prioritize pattern 1 since it spans 7 near-identical call sites and poses a bug risk if categories/error-type strings diverge

Analysis Metadata

  • Analyzed Files: 120 non-test Go files changed in the HEAD commit
  • Detection Method: Manual semantic analysis (symbol listing, grep, content review)
  • Commit: 08bc2c4 (refactor: consolidate over-fragmented files in internal/ packages)
  • Analysis Date: 2026-06-11
  • Excluded: *_test.go files, .github/ files, test/ directory

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