Skip to content

Files

Latest commit

 

History

History
69 lines (49 loc) · 1.13 KB

Lint-BlockAlignment.md

File metadata and controls

69 lines (49 loc) · 1.13 KB

Pattern: Misaligned end in block

Issue: -

Description

This rule checks whether the end keywords are aligned properly for do..end blocks.

Three modes are supported through the EnforcedStyleAlignWith configuration parameter:

start_of_block : the end shall be aligned with the start of the line where the do appeared.

start_of_line : the end shall be aligned with the start of the line where the expression started.

either (which is the default) : the end is allowed to be in either location.

Examples

# bad

foo.bar
   .each do
     baz
       end
# EnforcedStyleAlignWith: either (default)

# good

variable = lambda do |i|
  i
end
# EnforcedStyleAlignWith: start_of_block

# good

foo.bar
  .each do
     baz
   end
# EnforcedStyleAlignWith: start_of_line

# good

foo.bar
  .each do
     baz
end

Default configuration

Attribute Value
EnforcedStyleAlignWith either
SupportedStylesAlignWith either, start_of_block, start_of_line

Further Reading