Module: RuboCop::Cop::MultilineElementLineBreaks
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Included In:
| |
Defined in: | lib/rubocop/cop/mixin/multiline_element_line_breaks.rb |
Overview
Common functionality for checking for a line break before each element in a multi-line collection.
Instance Method Summary
Instance Method Details
#all_on_same_line?(nodes, ignore_last: false) ⇒ Boolean
(private)
# File 'lib/rubocop/cop/mixin/multiline_element_line_breaks.rb', line 23
def all_on_same_line?(nodes, ignore_last: false) return true if nodes.empty? return same_line?(nodes.first, nodes.last) if ignore_last nodes.first.first_line == nodes.last.last_line end
#check_line_breaks(_node, children, ignore_last: false) (private)
[ GitHub ]# File 'lib/rubocop/cop/mixin/multiline_element_line_breaks.rb', line 10
def check_line_breaks(_node, children, ignore_last: false) return if all_on_same_line?(children, ignore_last: ignore_last) last_seen_line = -1 children.each do |child| if last_seen_line >= child.first_line add_offense(child) { |corrector| EmptyLineCorrector.insert_before(corrector, child) } else last_seen_line = child.last_line end end end