Why this matters
Prevents NameError and makes control flow explicit.
Always initialize variables before use and avoid conditionally-defined locals.
Prevents NameError and makes control flow explicit.
Side-by-side examples engineers can pattern-match during review.
if cond
msg = compute
end
logger.info(msg)msg = nil
msg = compute if cond
logger.info(msg)x += 1 before xx = 0; x += 1From 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.