Skip to content

[duplicate-code] Duplicate Code Analysis Report #3207

@github-actions

Description

@github-actions

Summary

Analysis of the codebase identified 3 significant duplication patterns across the internal/ packages. Patterns span the launcher, server, and related packages — all involving repeated logging idioms and HTTP body handling logic.

Detected Patterns

  1. Dual stdlib/structured logging — Severity: High — See sub-issue [duplicate-code] Duplicate Code Pattern: Dual stdlib/structured logging in launcher package #3209
  2. HTTP request body read-and-restore — Severity: Medium — See sub-issue [duplicate-code] Duplicate Code Pattern: HTTP request body read-and-restore logic #3208
  3. WASM guard env-var lookup — Severity: Low — See sub-issue [duplicate-code] Duplicate Code Pattern: WASM guard env-var lookup repeated in guard_init.go #3210

Overall Impact

  • Total Duplicated Lines: ~35–45 lines across the three patterns
  • Affected Files: 4 files (internal/launcher/launcher.go, internal/server/http_helpers.go, internal/server/sdk_logging.go, internal/server/guard_init.go)
  • Maintainability Risk: Medium — duplicated logging and body-read logic means that a bug fix or log-format change must be applied in multiple places
  • Refactoring Priority: High for Pattern 1 (widespread throughout launcher), Medium for Patterns 2 and 3

Next Steps

  1. Review individual pattern sub-issues for detailed analysis
  2. Prioritize eliminating the dual logging pattern first (largest surface area)
  3. Extract the body read-restore helper for Pattern 2
  4. Consolidate the WASM guard env-var lookup for Pattern 3

Analysis Metadata

  • Analyzed Files: ~85 non-test Go files in internal/
  • Detection Method: Semantic pattern search (grep + manual code review)
  • Commit: b25e54983c639d48beb0af20ef4b1d7619df5603
  • Analysis Date: 2026-04-05

Metadata

Metadata

Assignees

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