Skip to content

[duplicate-code] Duplicate Code Analysis Report #4842

@github-actions

Description

@github-actions

Summary

Analysis of commit 303ac98 (refactor: split large monolithic files) identified 2 significant duplication patterns that persist after the file-splitting refactor. Overall severity is Low-to-Medium — the codebase is well-structured and already uses strong abstractions (makeLevelLogger, listMCPItems, withGlobalLogger, etc.), but two areas have residual duplication worth addressing.

Detected Patterns

  1. Logger Level Wrapper Functions — Severity: Medium — See sub-issue [duplicate-code] Duplicate Code Pattern: Logger Level Wrapper Functions #4843
    Twelve nearly-identical thin-wrapper functions spread across 3 logger files (~40 lines of structural duplication).

  2. Manual Logger Close Calls in root.go — Severity: Low-Medium — See sub-issue [duplicate-code] Duplicate Code Pattern: Manual Logger Close Calls Instead of CloseAllLoggers() #4844
    postRun() in internal/cmd/root.go explicitly calls 5 individual CloseXxxLogger() functions even though logger.CloseAllLoggers() already exists to perform the same operation.

Overall Impact

  • Total Duplicated Lines: ~45 lines
  • Affected Files: 4 files (internal/logger/file_logger.go, internal/logger/markdown_logger.go, internal/logger/server_file_logger.go, internal/cmd/root.go)
  • Maintainability Risk: Low-Medium — primary concern is drift risk when new loggers are added
  • Refactoring Priority: Low (both patterns have clear, simple fixes)

Next Steps

  1. Review individual pattern sub-issues for detailed analysis
  2. Prioritize root.go close-call fix first (1-line change, high value)
  3. Evaluate logger wrapper reduction for longer-term cleanup

Analysis Metadata

  • Analyzed Files: 97 Go files (excluding test files)
  • Detection Method: Manual semantic code analysis (grep, view, diff)
  • Commit: 303ac98 (refactor: split large monolithic files)
  • Analysis Date: 2026-04-30

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