class RuboCop::Cop::Layout::MultilineArrayLineBreaks

Ensures that each item in a multi-line array starts on a separate line.

@example

# bad
[
  a, b,
  c
]

# good
[
  a,
  b,
  c
]

# good
[
  a,
  b,
  foo(
    bar
  )
]

@example AllowMultilineFinalElement: false (default)

# bad
[a, b, foo(
  bar
)]

@example AllowMultilineFinalElement: true

# good
[a, b, foo(
  bar
)]

Constants

MSG

Public Instance Methods

on_array(node) click to toggle source
# File lib/rubocop/cop/layout/multiline_array_line_breaks.rb, line 53
def on_array(node)
  check_line_breaks(node, node.children, ignore_last: ignore_last_element?)
end

Private Instance Methods

ignore_last_element?() click to toggle source
# File lib/rubocop/cop/layout/multiline_array_line_breaks.rb, line 59
def ignore_last_element?
  !!cop_config['AllowMultilineFinalElement']
end