Skip to content

[duplicate-code] Duplicate Code Analysis Report #1948

@github-actions

Description

@github-actions

Analysis of commit a7412fa

Summary

This analysis detected 3 significant duplication patterns in the Go source code. The patterns span the MCP connection dispatch layer, server-side guard policy resolution, and DIFC label flow semantics. Overall severity is Medium — duplication is not critical but introduces maintenance risk when these code paths diverge.

Detected Patterns

  1. Parameterized SDK Dispatch Pattern — Severity: Medium — See sub-issue [duplicate-code] Duplicate Code Pattern: Parameterized SDK Dispatch in MCP Connection #1949
  2. Guard Policy Config Resolution Pattern — Severity: Medium — See sub-issue [duplicate-code] Duplicate Code Pattern: Guard Policy Config Resolution in UnifiedServer #1950
  3. Label CanFlowTo Iteration Pattern — Severity: Low — See sub-issue [duplicate-code] Duplicate Code Pattern: Label CanFlowTo Iteration in DIFC Labels #1951

Overall Impact

  • Total Duplicated Lines: ~120 lines across the three patterns
  • Affected Files: 3 non-test Go files (internal/mcp/connection.go, internal/server/unified.go, internal/difc/labels.go)
  • Maintainability Risk: Medium — a bug fix or protocol change in one function copy must be manually applied to the others
  • Refactoring Priority: Medium — Pattern 1 has the clearest abstraction path (a callParamMethod helper analogous to the existing callListMethod); Pattern 3 can reuse checkFlowHelper

Next Steps

  1. Review individual pattern sub-issues for detailed analysis and refactoring suggestions
  2. Prioritise Pattern 1 (connection dispatch) as the quickest win with the most occurrences
  3. Pattern 3 (label CanFlowTo) should be validated carefully to preserve DIFC correctness

Analysis Metadata

  • Analyzed Files: 30 non-test Go files changed in the commit
  • Detection Method: Structural/semantic source analysis (grep + manual review)
  • Commit: a7412fa49e4bfee127b1c4afa18392956cd3bb3e
  • Analysis Date: 2026-03-15T03:00:00Z

Metadata

Metadata

Assignees

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