Why this matters
Improves readability and testability.
Move long conditional expressions to well-named predicate methods.
Improves readability and testability.
Side-by-side examples engineers can pattern-match during review.
if a.present? && b.nil? && user.admin? && Time.zone.now.monday?if eligible_for_discount?(user)
...
end
private
def eligible_for_discount?(user)
a.present? && b.nil? && user.admin? && Time.zone.now.monday?
endlong inline conditionpredicate method encapsulates logicFrom the same buckets as this rule.
Check if loops use equality operators (== or !=) in termination conditions. These can lead to infinite loops if the condition is never met exactly. Instead, use relational operators like < or > for safer loop termination.