Skip to content

[duplicate-code] Duplicate Code Analysis Report #5732

@github-actions

Description

@github-actions

🔍 Duplicate Code Analysis Report

Analysis of recent commit on branch main

Summary

Analysis of the Go codebase (excluding test files) identified 2 minor actionable duplication patterns in internal/config/guard_policy_parse.go. The codebase is generally well-structured with existing abstractions (e.g., applyIfConfigured, initTracingProviderWithFallback, configureWasmCompilationCache, withGlobalLogger). No critical duplication was found.

Detected Patterns

This analysis found 2 related duplication patterns in a single file:

  1. Mixed env var access (os.LookupEnv + envutil.GetEnv*) — Severity: Low — See sub-issue [duplicate-code] Duplicate Code Pattern: Mixed env var access and dual-form key checks in guard_policy_parse.go #5733
  2. Dual-form map key check pattern — Severity: Low — See sub-issue [duplicate-code] Duplicate Code Pattern: Mixed env var access and dual-form key checks in guard_policy_parse.go #5733

Note: The Log-Level Quad-Function Pattern across file_logger.go, markdown_logger.go, and server_file_logger.go (3 × ~16 lines) was reviewed but is explicitly documented as intentional design in internal/logger/common.go and requires no refactoring.

Overall Impact

  • Total Duplicated Lines: ~24 lines (2 patterns in guard_policy_parse.go)
  • Affected Files: 1 file (internal/config/guard_policy_parse.go)
  • Maintainability Risk: Low — patterns are isolated and self-consistent
  • Refactoring Priority: Low — cosmetic cleanup, no functional risk

Next Steps

  1. Review the sub-issue for detailed analysis of the guard_policy_parse.go patterns
  2. Consider adding envutil.HasEnvVar helper for consistency
  3. Consider extracting a hasMapKeyVariants helper for the dual-form key checks

Analysis Metadata

  • Analyzed Files: ~110 Go source files changed in HEAD commit
  • Detection Method: Manual semantic code analysis (grep, view, pattern matching)
  • Analysis Date: 2026-05-15

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