Pattern: Misaligned end
in block
Issue: -
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.
# 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
Attribute | Value |
---|---|
EnforcedStyleAlignWith | either |
SupportedStylesAlignWith | either, start_of_block, start_of_line |