You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
internal/guard/noop.go defines its own logNoop logger variable but all three of its methods call log.Printf() instead — resolving to the package-level log variable defined in internal/guard/context.go (namespace "guard:context"). This leaves logNoop as dead code and causes all NoopGuard log messages to appear under the wrong namespace.
Duplication Details
Pattern: Wrong Logger Variable Used (Copy-Paste Bug)
Severity: High
Occurrences: 4 misattributed log calls in noop.go
Locations:
internal/guard/noop.go line 10 — defines var logNoop = logger.New("guard:noop") (never used)
internal/guard/noop.go line 29 — calls log.Printf(...) (should be logNoop.Printf)
internal/guard/noop.go line 42 — calls log.Printf(...) (should be logNoop.Printf)
internal/guard/noop.go line 52 — calls log.Printf(...) (should be logNoop.Printf)
internal/guard/noop.go line 61 — calls log.Printf(...) (should be logNoop.Printf)
internal/guard/context.go line 29 — defines package-level var log = logger.New("guard:context")
Code Sample:
// noop.go — defines own logger but never uses itvarlogNoop=logger.New("guard:noop") // line 10: DEFINED but unusedfunc (g*NoopGuard) LabelAgent(...) (*LabelAgentResult, error) {
log.Printf("Initializing agent labels with noop guard") // line 29: uses context.go's `log`...
}
func (g*NoopGuard) LabelResource(...) (...) {
log.Printf("Labeling resource: ...") // line 42: uses context.go's `log`...log.Printf("Resource labeled with no restrictions: ...") // line 52: uses context.go's `log`...
}
func (g*NoopGuard) LabelResponse(...) (...) {
log.Printf("Labeling response: ...") // line 61: uses context.go's `log`...
}
Impact Analysis
Maintainability: logNoop variable is dead code; developers cannot filter noop guard logs with DEBUG=guard:noop
Bug Risk: Log messages from NoopGuard are silently swallowed under guard:context namespace, making debugging misleading
Part of duplicate code analysis: #2361
Summary
internal/guard/noop.godefines its ownlogNooplogger variable but all three of its methods calllog.Printf()instead — resolving to the package-levellogvariable defined ininternal/guard/context.go(namespace"guard:context"). This leaveslogNoopas dead code and causes all NoopGuard log messages to appear under the wrong namespace.Duplication Details
Pattern: Wrong Logger Variable Used (Copy-Paste Bug)
Severity: High
Occurrences: 4 misattributed log calls in noop.go
Locations:
internal/guard/noop.goline 10 — definesvar logNoop = logger.New("guard:noop")(never used)internal/guard/noop.goline 29 — callslog.Printf(...)(should belogNoop.Printf)internal/guard/noop.goline 42 — callslog.Printf(...)(should belogNoop.Printf)internal/guard/noop.goline 52 — callslog.Printf(...)(should belogNoop.Printf)internal/guard/noop.goline 61 — callslog.Printf(...)(should belogNoop.Printf)internal/guard/context.goline 29 — defines package-levelvar log = logger.New("guard:context")Code Sample:
Impact Analysis
logNoopvariable is dead code; developers cannot filter noop guard logs withDEBUG=guard:noopNoopGuardare silently swallowed underguard:contextnamespace, making debugging misleadinglogNoopvariable adds confusionRefactoring Recommendations
log.Printfcalls withlogNoop.Printfinnoop.go:log.Printf(...)→logNoop.Printf(...)log.Printf(...)→logNoop.Printf(...)log.Printf(...)→logNoop.Printf(...)log.Printf(...)→logNoop.Printf(...)logNoopno longer dead code,DEBUG=guard:noopfiltering worksImplementation Checklist
log.PrintfwithlogNoop.Printfon lines 29, 42, 52, 61 ofnoop.gologNoopis now used (no dead code)DEBUG=guard:noopcorrectly shows NoopGuard logsmake testto verify no regressionsParent Issue
See parent analysis report: #2361
Related to #2361
Warning
The following domain was blocked by the firewall during workflow execution:
proxy.golang.orgTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.