Skip to content

Files

Latest commit

 

History

History
37 lines (27 loc) · 681 Bytes

Style-Next.md

File metadata and controls

37 lines (27 loc) · 681 Bytes

Pattern: Missing use of next to skip iteration

Issue: -

Description

Use next to skip iteration instead of a condition at the end.

Examples

# 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

Default configuration

Attribute Value
EnforcedStyle skip_modifier_ifs
MinBodyLength 3
SupportedStyles skip_modifier_ifs, always

Further Reading