Skip to content

[duplicate-code] Duplicate Code Analysis Report #1661

@github-actions

Description

@github-actions

Summary

Analysis of commit 4b13882bac5052cd1febf6bf92b5a3727f16b1a3 (refactor: consolidate micro-files and extract Docker helpers) identified 2 significant duplication patterns in internal/server/unified.go. Both patterns represent structural duplication of backend request/response handling logic.

Detected Patterns

  1. Backend tool call execution pattern — Severity: High — See sub-issue [duplicate-code] Duplicate Code Pattern: Backend Tool Call Execution Block #1662
  2. Sys tool sysServer delegation pattern — Severity: Medium — See sub-issue [duplicate-code] Duplicate Code Pattern: Sys Tool sysServer Delegation Block #1663

Overall Impact

  • Total Duplicated Lines: ~40–50 lines across the two patterns
  • Affected Files: 1 file (internal/server/unified.go)
  • Maintainability Risk: High — Both patterns are in hot paths. A bug fix or behavioral change in one copy is unlikely to be applied consistently to the others without a helper extraction.
  • Refactoring Priority: Medium — The code works correctly today but will accumulate drift. Extracting shared helpers is low-risk and follows the existing codebase idiom (e.g., newErrorCallToolResult, parseToolArguments, writeJSONResponse).

Next Steps

  1. Review individual pattern sub-issues for detailed analysis
  2. Extract executeBackendToolCall helper to unify the backend call block (sub-issue [duplicate-code] Duplicate Code Pattern: Backend Tool Call Execution Block #1662)
  3. Extract callSysServer helper to unify sysServer delegation (sub-issue [duplicate-code] Duplicate Code Pattern: Sys Tool sysServer Delegation Block #1663)

Analysis Metadata

  • Analyzed Files: 70 non-test Go files changed in commit
  • Primary Finding Location: internal/server/unified.go
  • Detection Method: Semantic pattern comparison + structural diff
  • Commit: 4b13882bac5052cd1febf6bf92b5a3727f16b1a3
  • Analysis Date: 2026-03-08

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