Pattern: Missing use of next
to skip iteration
Issue: -
Use next
to skip iteration instead of a condition at the end.
# bad
[1, 2].each do |a|
if a == 1
puts a
end
end
# good
[1, 2].each do |a|
next unless a == 1
puts a
end
Attribute | Value |
---|---|
EnforcedStyle | skip_modifier_ifs |
MinBodyLength | 3 |
SupportedStyles | skip_modifier_ifs, always |