تخطَّ إلى المحتوى

Duplicate Condition Branches (ARCH6190)

هذا المحتوى غير متوفر بلغتك بعد.

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.