Skip to content

[duplicate-code] Duplicate Code Analysis Report #7509

@github-actions

Description

@github-actions

Analysis of recent commits to github/gh-aw-mcpg

Summary

Analysis identified 2 related duplication patterns in internal/tracing/span_helpers.go that together exceed the reporting threshold (3+ similar patterns). The codebase is otherwise well-factored with strong anti-duplication abstractions throughout.

Detected Patterns

  1. Structural Duplication in Span Factory Functions – Severity: Low – See sub-issue [duplicate-code] Duplicate Code Pattern: Structural Duplication in Tracing Span Factory Functions #7510
  2. Dead Code: StartProxyForwardSpan vs Inline Span Creation – Severity: Low – See sub-issue [duplicate-code] Duplicate Code Pattern: StartProxyForwardSpan Dead Code vs Inline Span Creation in handler.go #7511

Overall Impact

  • Total Duplicated Lines: ~40 lines across 4 span factory functions + ~10 lines of dead code
  • Affected Files: 2 (internal/tracing/span_helpers.go, internal/proxy/handler.go)
  • Maintainability Risk: Low – patterns are contained in a dedicated helpers file; risk is drift if new spans are added inconsistently
  • Refactoring Priority: Low – functional, but worth cleaning up to reduce boilerplate and remove dead code

Next Steps

  1. Review the two sub-issues for detailed recommendations
  2. Optionally extract a private startSpan(ctx, tracer, name, kind, attrs...) helper in span_helpers.go
  3. Delete or fix StartProxyForwardSpan to resolve the dead-code/inconsistency

Analysis Metadata

  • Analyzed Files: All non-test .go files in internal/
  • Detection Method: Structural pattern search + dead-code analysis
  • Analysis Date: 2025-07-25

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