Duplicate Condition Branches (ARCH4190)
Esta página aún no está disponible en tu idioma.
Key java.quality.duplicate-branches · Severity warning · Category quality
if/else or case branches with identical bodies are redundant and often hide a logic mistake. Merge the branches.
Incorrect
Section titled “Incorrect”String label(Status s) { if (s == Status.ACTIVE) return "ok"; else if (s == Status.PENDING) return "ok"; else return "no";}Correct
Section titled “Correct”String label(Status s) { return (s == Status.ACTIVE || s == Status.PENDING) ? "ok" : "no";}Merge the conditions of branches that share a body, or fix the logic if the duplication was a mistake.