Aller au contenu

Duplicate Condition Branches (ARCH6190)

Ce contenu n’est pas encore disponible dans votre langue.

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.

def fee(plan)
if plan == :free
0
elsif plan == :trial
0
else
20
end
end
def fee(plan)
return 0 if [:free, :trial].include?(plan)
20
end

Merge branches that share a body into a single condition, or extract the common logic.