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 and internal/guard/write_sink.go both implement the Guard interface and contain near-identical structural duplication in LabelAgent (returns empty AgentLabelsPayload) and LabelResponse (returns nil, nil). The LabelAgent bodies differ only by the value of the DIFCMode field.
Part of duplicate code analysis: #2361
Summary
internal/guard/noop.goandinternal/guard/write_sink.goboth implement theGuardinterface and contain near-identical structural duplication inLabelAgent(returns emptyAgentLabelsPayload) andLabelResponse(returnsnil, nil). TheLabelAgentbodies differ only by the value of theDIFCModefield.Duplication Details
Pattern: Near-Identical
LabelAgentMethod BodySeverity: Medium
Occurrences: 2 implementations
Locations:
internal/guard/noop.golines 28–37internal/guard/write_sink.golines 71–79Code Sample:
Pattern: Identical
LabelResponseMethod BodySeverity: Low–Medium
Occurrences: 2 implementations
Locations:
internal/guard/noop.golines 60–65internal/guard/write_sink.golines 107–108Code Sample:
Impact Analysis
AgentLabelsPayloadstructure requires updating multiple placesRefactoring Recommendations
Extract
emptyAgentLabelsResult(mode string) *LabelAgentResulthelper ininternal/guard/guard.go:noop.gocalls:return emptyAgentLabelsResult(difc.ModeStrict), nilwrite_sink.gocalls:return emptyAgentLabelsResult(difc.ModeFilter), nilAgentLabelsPayloadinitializationConsider a
BaseGuardembedded struct if more guard implementations are added in the future, providing defaultLabelResponsereturningnil, nil.Implementation Checklist
emptyAgentLabelsResulthelper tointernal/guard/guard.gonoop.goLabelAgentto use helperwrite_sink.goLabelAgentto use helpermake 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.