Skip to content

[duplicate-code] Duplicate Code Analysis Report #3155

@github-actions

Description

@github-actions

Analysis of commit 893fa02 — triggered by @lpcox

Summary

Analysis of the gh-aw-mcpg Go codebase found 1 significant duplication pattern meeting the reporting threshold (>10 lines or 3+ similar instances), plus 2 intentional/documented patterns that are acknowledged in the codebase already.

Detected Patterns

  1. list* MCP Operations Structural Duplication — Severity: Medium — See sub-issue [duplicate-code] Duplicate Code Pattern: list* MCP Operations Structural Duplication #3156

    • Three nearly-identical 17-line functions (listTools, listResources, listPrompts) in internal/mcp/connection.go share identical boilerplate with only type-level differences.
  2. withLock Method Boilerplate in Logger Types — Severity: Low (documented intentional pattern)

    • Four logger types each define an identical 3-line withLock method delegating to withMutexLock. Explicitly documented in internal/logger/common.go as the expected pattern.
  3. Log-Level Quad-Function Pattern — Severity: Low (documented intentional pattern)

    • Three sets of four one-liner functions (LogInfo/LogWarn/LogError/LogDebug, their Md and WithServer variants) across file_logger.go, markdown_logger.go, and server_file_logger.go. Also explicitly documented in internal/logger/common.go.

Overall Impact

  • Total Duplicated Lines (significant): ~51 lines (listTools/listResources/listPrompts, 17 lines × 3)
  • Affected Files: 1 file with actionable duplication (internal/mcp/connection.go)
  • Maintainability Risk: Medium — if the list-operation contract changes (e.g., new error handling, session refresh), all three functions must be updated in sync
  • Refactoring Priority: Low-Medium — the code is correct and the pattern is stable; a generic helper would improve maintainability but carries no immediate bug risk

Next Steps

  1. Review the sub-issue for the list* pattern and decide whether a generic helper is worth adding
  2. No action needed for the documented logger patterns (already intentional)

Analysis Metadata

  • Analyzed Files: All non-test .go files in internal/ (≈80 files)
  • Detection Method: Semantic and structural pattern analysis
  • Commit: 893fa02 (Guard coverage: classify create_agent_task as read-write and blocked)
  • Analysis Date: 2026-04-04
  • Note: The HEAD commit modifies only Rust files; Go analysis covers the full current codebase state

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