Skip to content

[duplicate-code] Duplicate Code Analysis Report #3309

@github-actions

Description

@github-actions

Summary

Analysis of commit 8c39c723f74fe5265b1667c4baafb44ec695512c identified 3 significant code duplication patterns across the Go codebase. The patterns range from medium to low severity and primarily affect startup code and HTTP response handling.

Detected Patterns

  1. Dual stdout/file logging pairs in cmd/root.go — Severity: Medium — See sub-issue [duplicate-code] Duplicate Code Pattern: Dual stdout/file logging pairs in cmd/root.go #3310
  2. Repeated logger initialisation error blocks in cmd/root.go — Severity: Medium — See sub-issue [duplicate-code] Duplicate Code Pattern: Repeated logger-initialisation error blocks in cmd/root.go and cmd/proxy.go #3311
  3. Manual JSON response writing bypassing httputil.WriteJSONResponse in proxy/handler.go — Severity: Low — See sub-issue [duplicate-code] Duplicate Code Pattern: Manual JSON response writing bypassing httputil.WriteJSONResponse in proxy/handler.go #3312

Overall Impact

  • Total Duplicated Lines: ~40 lines across 3 patterns
  • Affected Files: internal/cmd/root.go, internal/proxy/handler.go
  • Maintainability Risk: Medium — startup logic is particularly sensitive to inconsistency
  • Refactoring Priority: Medium — straightforward consolidations with low regression risk

Next Steps

  1. Review individual pattern sub-issues for detailed analysis
  2. Prioritise the dual-logging consolidation (Pattern 1) as it affects the most lines
  3. Consider a logger.InitAll(logDir) helper to address Pattern 2 in a single refactor
  4. Use httputil.WriteJSONResponse consistently across all HTTP handlers for Pattern 3

Analysis Metadata

  • Analysed Files: 90 non-test Go files modified in the commit
  • Detection Method: Semantic code analysis (grep, view, pattern search)
  • Commit: 8c39c723f74fe5265b1667c4baafb44ec695512c
  • Analysis Date: 2026-04-07

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