Skip to content

Files

Latest commit

 

History

History
85 lines (67 loc) · 991 Bytes

Style-EmptyElse.md

File metadata and controls

85 lines (67 loc) · 991 Bytes

Pattern: Empty else clause

Issue: -

Description

Checks for empty else clauses, possibly including comments and/or an explicit nil depending on the enforced style.

SupportedStyles:

Examples

# good for all styles

if condition
  statement
else
  statement
end

# good for all styles
if condition
  statement
end
# empty - warn only on empty else

# bad
if condition
  statement
else
end

# good
if condition
  statement
else
  nil
end
# nil - warn on else with nil in it

# bad
if condition
  statement
else
  nil
end

# good
if condition
  statement
else
end
# both - warn on empty else and else with nil in it

# bad
if condition
  statement
else
  nil
end

# bad
if condition
  statement
else
end

Default configuration

Attribute Value
EnforcedStyle both
SupportedStyles empty, nil, both

Further Reading