Why this matters
A `case` statement without an `else` clause may not handle all possible cases, leading to unexpected behavior. Always include an `else` clause or explicitly document why it is unnecessary.
Check if every `case` statement includes an `else` clause. If an `else` clause is missing, ensure that a comment explicitly states why it is unnecessary.
A `case` statement without an `else` clause may not handle all possible cases, leading to unexpected behavior. Always include an `else` clause or explicitly document why it is unnecessary.
Side-by-side examples engineers can pattern-match during review.
case param
when 1
do_something()
when 2
do_something_else()
endcase param
when 1
do_something()
when 2
do_something_else()
else
handle_error('error_message')
endcase param
when 1
do_something()
when 2
do_something_else()
endcase param
when 1
do_something()
when 2
do_something_else()
else
handle_error('error_message')
endFrom 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.