Why this matters
Avoids crashes and clarifies control flow.
Guard early or use safe navigation when dereferencing possibly-nil data.
Avoids crashes and clarifies control flow.
Side-by-side examples engineers can pattern-match during review.
order.customer.name.downcasereturn unless order&.customer&.name
name = order.customer.name.downcaseobj.child.valuereturn unless obj&.child&.valueFrom 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.