Skip to content

[duplicate-code] Duplicate Code Analysis Report #375

@github-actions

Description

@github-actions

🔍 Duplicate Code Analysis Report

Analysis of commit 4790c24

Summary

This analysis detected 3 significant duplication patterns in the server package that require refactoring. The patterns involve duplicated HTTP middleware, session extraction logic, and endpoint handlers across routed.go and transport.go. These duplications increase maintenance burden and bug risk.

Detected Patterns

This analysis found 3 significant duplication patterns:

  1. Authorization Header Parsing - Severity: High - See sub-issue #aw_dc02e3f4g5h6

    • Duplicated session ID extraction logic across 3 locations
    • ~20 lines of identical code repeated multiple times
  2. Response Writer Wrappers - Severity: Medium - See sub-issue #aw_dc03i4j5k6l7

    • Two nearly identical response writer implementations
    • ~15 lines duplicated with only field type differences
  3. HTTP Endpoint Handlers - Severity: High - See sub-issue #aw_dc04m5n6o7p8

    • Close endpoint and OAuth handler duplicated between modes
    • ~60+ lines of nearly identical shutdown logic

Overall Impact

  • Total Duplicated Lines: ~95+ lines across 3 patterns
  • Affected Files: 3 Go files (routed.go, transport.go, sdk_logging.go)
  • Maintainability Risk: High - Changes to auth/session logic require updates in multiple places
  • Refactoring Priority: High - Recent changes (Added frontend logging and testing #372) added new logging that would benefit from refactoring

Next Steps

  1. Review individual pattern sub-issues for detailed analysis
  2. Prioritize Pattern Configure as a Go CLI tool #1 (Authorization) and Pattern Lpcox/initial implementation #3 (Endpoints) due to high severity
  3. Create implementation plan starting with auth refactoring
  4. Consider extracting common server utilities package

Analysis Metadata

  • Analyzed Files: 50 Go files in internal/ directory
  • Detection Method: Static code analysis with pattern matching
  • Commit: 4790c24 (Merge pull request Added frontend logging and testing #372 - Added frontend logging and testing)
  • Analysis Date: 2026-01-20T10:13:21Z
  • Triggered By: @pelikhan

AI generated by Duplicate Code Detector

Sub-issues

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions