class RuboCop::Cop::Layout::FirstArrayElementLineBreak
This cop checks for a line break before the first element in a multi-line array.
@example
# bad [ :a, :b] # good [ :a, :b]
Constants
- MSG
Public Instance Methods
on_array(node)
click to toggle source
# File lib/rubocop/cop/layout/first_array_element_line_break.rb, line 26 def on_array(node) return if !node.loc.begin && !assignment_on_same_line?(node) check_children_line_break(node, node.children) end
Private Instance Methods
assignment_on_same_line?(node)
click to toggle source
# File lib/rubocop/cop/layout/first_array_element_line_break.rb, line 34 def assignment_on_same_line?(node) source = node.source_range.source_line[0...node.loc.column] source =~ /\s*\=\s*$/ end