Skip to content

[duplicate-code] Duplicate Code Analysis Report #2361

@github-actions

Description

@github-actions

Analysis of recent commit in github/gh-aw-mcpg

Summary

This analysis found 3 significant duplication patterns in the non-test Go source files. The most critical finding is a concrete bug in internal/guard/noop.go where the wrong logger variable is used, causing log messages to be misattributed and leaving logNoop as dead code.

Detected Patterns

  1. NoopGuard Wrong Logger Usage (Dead Code + Misattributed Logs) — Severity: High — See sub-issue [duplicate-code] Duplicate Code Pattern: NoopGuard Uses Wrong Logger (Dead Code + Misattributed Logs) #2362
  2. Guard Interface Structural Duplication — Severity: Medium — See sub-issue [duplicate-code] Duplicate Code Pattern: Guard Interface Structural Duplication (LabelAgent / LabelResponse) #2363
  3. Trivial getDefault*() Wrapper Functions — Severity: Medium — See sub-issue [duplicate-code] Duplicate Code Pattern: Trivial getDefault*() Env-Var Wrapper Functions #2364

Overall Impact

  • Total Duplicated Lines: ~30–40 lines across patterns
  • Affected Files: 4 files (internal/guard/noop.go, internal/guard/write_sink.go, internal/cmd/flags_difc.go, internal/cmd/flags_logging.go)
  • Maintainability Risk: Medium — one pattern is an active bug; others increase maintenance burden
  • Refactoring Priority: High for pattern 1 (bug fix); Medium for patterns 2–3

Next Steps

  1. Fix the logger variable bug in noop.go (pattern 1 — priority)
  2. Review guard interface implementations for extraction opportunities (pattern 2)
  3. Consider consolidating trivial env-var getters (pattern 3)

Analysis Metadata

  • Analyzed Files: 87 non-test Go files
  • Detection Method: Semantic + pattern code analysis
  • Analysis Date: 2026-03-23

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