Duplicate Build Constraint
ID |
go.duplicate_build_constraint |
Severity |
low |
Remediation Complexity |
trivial |
Remediation Risk |
low |
Remediation Effort |
low |
Resource |
Code Smell |
Language |
Go |
Tags |
CWE:1164, build, dead-code, readability |
Description
Reports a build-constraint comment (//go:build … or the legacy // +build …) whose
constraint expression repeats one that already appeared earlier in the same file.
Rationale
A repeated build constraint is dead text: the second copy constrains nothing further, and its presence is almost always a copy-paste mistake or a leftover from a refactor that the author still believes is doing something. Keeping duplicate constraints around obscures the file’s real build conditions and invites confusion when one copy is later edited but the other is not.
//go:build linux && amd64
//go:build linux && amd64 // FLAW — identical constraint repeated
package main