Skip to content

[duplicate-code] Duplicate Code Analysis Report #3685

@github-actions

Description

@github-actions

Summary

Analysis of commit 9e91827 found 3 significant duplication patterns, all concentrated in the internal/logger package. The patterns stem from the logger package's evolution across multiple specialized logger types (FileLogger, JSONLLogger, MarkdownLogger, ToolsLogger, ServerFileLogger). While much duplication has already been addressed via generics (closableLogger, initGlobalLogger, closeGlobalLogger, withGlobalLogger, withMutexLock in global_helpers.go), three structural patterns remain.

Detected Patterns

This analysis found 3 significant duplication patterns:

  1. withLock method across 4 logger types - Severity: Low - See sub-issue [duplicate-code] Duplicate Code Pattern: withLock delegation method across 4 logger types #3686
  2. Log{Info,Warn,Error,Debug} level dispatch quartet repeated 3 times - Severity: Medium - See sub-issue [duplicate-code] Duplicate Code Pattern: Log level dispatch quartet repeated across 3 logger façades #3687
  3. CloseXxxLogger global function pattern across 5 files - Severity: Low - See sub-issue [duplicate-code] Duplicate Code Pattern: CloseXxxLogger global function across 5 logger files #3688

Overall Impact

  • Total Duplicated Lines: ~70 lines across the internal/logger package
  • Affected Files: 5 logger files (file_logger.go, jsonl_logger.go, markdown_logger.go, tools_logger.go, server_file_logger.go)
  • Maintainability Risk: Low — existing generic helpers (global_helpers.go) have already mitigated the worst duplication; remaining patterns are structural and well-documented
  • Refactoring Priority: Low — the package is functional and well-tested; refactoring is a nice-to-have improvement

Next Steps

  1. Review individual pattern sub-issues for detailed analysis
  2. Consider consolidating level-dispatch wrappers (Pattern 2) as the highest-impact change
  3. Lower-priority: consolidate withLock delegation methods and CloseXxxLogger functions

Analysis Metadata

  • Analyzed Files: 98 Go files (non-test, non-workflow)
  • Detection Method: Manual semantic code analysis (ripgrep pattern search + file content review)
  • Commit: 9e91827 (feat: Maintainer reaction endorsement for integrity promotion/demotion)
  • Analysis Date: 2026-04-13

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