Duplicate Condition Branches (ARCH5190)
Esta página aún no está disponible en tu idioma.
Key go.quality.duplicate-branches · Severity warning · Category quality
Branches with identical bodies are usually redundant branching or hide a copy-paste mistake. Merge the branches.
Incorrect
Section titled “Incorrect”func label(s State) string { switch s { case Active: return "ok" case Pending: return "ok" default: return "unknown" }}Correct
Section titled “Correct”func label(s State) string { switch s { case Active, Pending: return "ok" default: return "unknown" }}Combine branches that produce the same result, or fix the logic that was meant to differ.