Skip to content

[duplicate-code] Duplicate Code Analysis Report #4135

@github-actions

Description

@github-actions

Analysis of commit 18b19a6

Summary

Analysis of the latest commit (a major refactoring to consolidate shared helpers) found 2 significant duplication patterns remaining in non-test Go files. The commit itself reduced substantial duplication, but two patterns remain actionable.

Detected Patterns

This analysis found 2 significant duplication patterns:

  1. JSON Marshal/Unmarshal Policy-to-Map Roundtrip – Severity: Medium – See sub-issue [duplicate-code] Duplicate Code Pattern: JSON Policy-to-Map Roundtrip in Guard Package #4136
  2. Log-Level Quad-Function Wrappers Across Three Logger Variants – Severity: Low – See sub-issue [duplicate-code] Duplicate Code Pattern: Log-Level Quad-Function Wrappers Across Three Logger Variants #4137

Overall Impact

  • Total Duplicated Lines: ~40 lines across 3–4 call sites
  • Affected Files: 4 files (internal/guard/wasm.go, internal/proxy/proxy.go, internal/server/guard_init.go, plus 3 logger files)
  • Maintainability Risk: Low-Medium — existing duplication is contained and unlikely to diverge, but adding future guard callers or log levels will propagate the pattern further
  • Refactoring Priority: Low — the codebase is already well-refactored; these are the remaining outliers

Next Steps

  1. Review individual pattern sub-issues for detailed analysis
  2. Prioritize the JSON roundtrip helper (Pattern 1) as the higher-value refactor
  3. Pattern 2 (log wrappers) is explicitly documented as intentional in internal/logger/common.go — verify before acting

Analysis Metadata

  • Analyzed Files: 56 Go files changed in this commit (test files, workflow files, and agent config files excluded)
  • Detection Method: Semantic code analysis — grep, AST-level function listing, manual cross-file pattern matching
  • Commit: 18b19a68d8642759400df581e172f00047738acb
  • Analysis Date: 2026-04-19

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