module RuboCop::Cop::MultilineElementLineBreaks
Common functionality for checking for a line break before each element in a multi-line collection.
Private Instance Methods
all_on_same_line?(nodes)
click to toggle source
# File lib/rubocop/cop/mixin/multiline_element_line_breaks.rb, line 26 def all_on_same_line?(nodes) return true if nodes.empty? nodes.first.first_line == nodes.last.last_line end
check_line_breaks(_node, children)
click to toggle source
# File lib/rubocop/cop/mixin/multiline_element_line_breaks.rb, line 13 def check_line_breaks(_node, children) return if all_on_same_line?(children) last_seen_line = -1 children.each do |child| if last_seen_line >= child.first_line add_offense(child) else last_seen_line = child.last_line end end end