Skip to content

[duplicate-code] Duplicate Code Analysis Report #4325

@github-actions

Description

@github-actions

Summary

Analysis of the latest commit (8f964e0) identified 2 significant duplication patterns in the Go codebase. Both patterns meet the threshold (>10 lines or 3+ similar occurrences) and affect maintainability.

Detected Patterns

  1. MCP Text Response Wrapping - Severity: Medium - See sub-issue [duplicate-code] Duplicate Code Pattern: Raw MCP Text-Content Envelope Construction #4326
    Raw map[string]interface{} construction for {"content":[{"type":"text","text":"..."}]} repeated in 4 locations across 3 files.

  2. Collaborator Permission Logging Block - Severity: Medium - See sub-issue [duplicate-code] Duplicate Code Pattern: Collaborator Permission Parse/Log/Wrap Block #4327
    Near-identical 15-line permission-parse/log/wrap block duplicated across internal/server/unified.go and internal/proxy/proxy.go.

Overall Impact

  • Total Duplicated Lines: ~40 lines
  • Affected Files: 4 files (internal/server/unified.go, internal/proxy/proxy.go, internal/server/system_tools.go, internal/server/circuit_breaker.go)
  • Maintainability Risk: Medium — both patterns are in active code paths; a bug fix or format change in one copy must be manually mirrored to the other(s)
  • Refactoring Priority: Low-Medium — no correctness issue today, but extraction into shared helpers reduces future maintenance burden

Next Steps

  1. Review individual pattern sub-issues for detailed analysis
  2. Prioritize refactoring based on severity and impact
  3. Consider adding a shared buildMCPTextResponse helper in internal/mcp/ or internal/server/

Analysis Metadata

  • Analyzed Files: 98 Go files (non-test, non-workflow)
  • Detection Method: Semantic code analysis + pattern search
  • Commit: 8f964e0
  • Analysis Date: 2026-04-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