Skip to content

[duplicate-code] Duplicate Code Analysis Report #4247

@github-actions

Description

@github-actions

Analysis of commit baa83f9

Summary

Analysis of the repository's Go source files found 2 significant duplication patterns. The most impactful is the 6-phase DIFC enforcement pipeline, which is duplicated across two separate execution paths (MCP tool calls and REST proxy calls) with ~120-150 lines of near-identical logic. A secondary pattern is the repetitive 4-function public logging API that is reproduced three times in the logger package with only naming differences.

Detected Patterns

This analysis found 2 significant duplication patterns:

  1. DIFC 6-Phase Pipeline — Severity: High — See sub-issue [duplicate-code] Duplicate Code Pattern: 6-Phase DIFC Pipeline in proxy/handler.go and server/unified.go #4248
  2. Logger Public API 4-Wrapper Pattern — Severity: Medium — See sub-issue [duplicate-code] Duplicate Code Pattern: Logger Public API 4-Wrapper Pattern and Inconsistent Tag Initialization #4249

Overall Impact

  • Total Duplicated Lines: ~150–175 lines
  • Affected Files: 4 Go source files (internal/proxy/handler.go, internal/server/unified.go, internal/logger/file_logger.go, internal/logger/markdown_logger.go, internal/logger/server_file_logger.go)
  • Maintainability Risk: Medium–High — changes to DIFC policy enforcement logic must be replicated in two places, increasing the risk of divergence
  • Refactoring Priority: High for DIFC pipeline, Low for logger wrappers

Next Steps

  1. Review individual pattern sub-issues for detailed analysis
  2. Prioritize refactoring the DIFC pipeline duplication (higher impact)
  3. Logger wrapper consolidation can be addressed incrementally

Analysis Metadata

  • Analyzed Files: 107 non-test Go files across internal/
  • Detection Method: Semantic analysis of function structure, phase comments, and control flow
  • Commit: baa83f9f260c1741199284a0e7a13f53926b7c98
  • Analysis Date: 2026-04-21

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