Duplicate Condition Branches (ARCH6190)
Esta página aún no está disponible en tu idioma.
Key ruby.quality.duplicate-branches · Severity warning · Category quality
Branches with identical bodies make the branching pointless; either the conditions should be merged or the duplicated logic collapsed into one path.
Incorrect
Section titled “Incorrect”def fee(plan) if plan == :free 0 elsif plan == :trial 0 else 20 endendCorrect
Section titled “Correct”def fee(plan) return 0 if [:free, :trial].include?(plan) 20endMerge branches that share a body into a single condition, or extract the common logic.