Why this matters
Flatter code is easier to reason about and maintain.
Validate and return early to reduce nesting and improve readability.
Flatter code is easier to reason about and maintain.
Side-by-side examples engineers can pattern-match during review.
if (req != null) { if (req.isValid()) { process(req); } }if (req == null || !req.isValid()) return error("invalid");
process(req);deeply nested ifsguard clauses then main pathFrom 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.