-
Notifications
You must be signed in to change notification settings - Fork 20
[duplicate-code] Duplicate Code Analysis Report #2825
Copy link
Copy link
Closed
3 / 33 of 3 issues completed
Copy link
Description
Analysis of latest commit on main branch
Summary
Analysis of the internal/ Go source files found 3 significant duplication patterns across the codebase. Two patterns carry correctness/safety implications beyond maintainability (inconsistent session-ID extraction can panic; inconsistent HTTP error formats break API contracts). The third pattern represents ~120+ lines of structural boilerplate that could be reduced to a shared helper.
Detected Patterns
- WASM Guard Dispatch Boilerplate – Severity: Medium – See sub-issue [duplicate-code] Duplicate Code Pattern: WASM Guard Function Dispatch Boilerplate #2826
- Session ID Context Extraction Inconsistency – Severity: High – See sub-issue [duplicate-code] Duplicate Code Pattern: Session ID Context Extraction Inconsistency #2827
- HTTP Error Response Inconsistency – Severity: Medium – See sub-issue [duplicate-code] Duplicate Code Pattern: HTTP Error Response Format Inconsistency #2828
Overall Impact
- Total Duplicated Lines: ~130+ lines across the three patterns
- Affected Files: 6 files (
internal/guard/wasm.go,internal/server/session.go,internal/server/unified.go,internal/server/routed.go,internal/server/auth.go,internal/server/handlers.go) - Maintainability Risk: High — the session-ID pattern already contains a latent panic (forced type assertion without
okcheck inrouted.go:91) - Refactoring Priority: High for session/HTTP patterns; Medium for WASM guard dispatch
Next Steps
- Review individual sub-issues for detailed analysis and concrete refactoring steps
- Fix the latent panic risk in
routed.go:91as a priority - Standardise JSON error responses in
auth.go - Optionally extract shared WASM dispatch preamble
Analysis Metadata
- Analyzed Files: Go source files under
internal/(excluding*_test.go) - Detection Method: Static pattern search + semantic code analysis
- Analysis Date: 2026-03-30
Reactions are currently unavailable
Metadata
Metadata
Type
Fields
Give feedbackNo fields configured for issues without a type.