class RuboCop::Cop::Layout::FirstArrayElementLineBreak
}]
:b => :c
[:a, {
# good
@example AllowMultilineFinalElement: true
}]
:b => :c
:a, {
[
# good
}]
:b => :c
[ :a, {
# bad
@example AllowMultilineFinalElement: false (default)
[:a, :b]
# good
:b]
:a,
[
# good
:b]
[ :a,
# bad
@example
multi-line array.
Checks for a line break before the first element in a
def assignment_on_same_line?(node)
def assignment_on_same_line?(node) source = node.source_range.source_line[0...node.loc.column] /\s*=\s*$/.match?(source) end
def ignore_last_element?
def ignore_last_element? !!cop_config['AllowMultilineFinalElement'] end
def on_array(node)
def on_array(node) return if !node.loc.begin && !assignment_on_same_line?(node) check_children_line_break(node, node.children, ignore_last: ignore_last_element?) end