Class: Rubocop::Cop::Style::EmptyLineBetweenDefs
- Defined in:
- lib/rubocop/cop/style/empty_line_between_defs.rb
Overview
This cop checks whether method definitions are separated by empty lines.
Constant Summary collapse
- MSG =
'Use empty lines between defs.'
Instance Attribute Summary
Attributes inherited from Cop
#autocorrect, #corrections, #debug, #disabled_lines, #offences
Instance Method Summary collapse
Methods inherited from Cop
#add_offence, all, #autocorrect_action, cop_name, cop_type, #do_autocorrect, #ignore_node, inherited, #initialize, lint?, #name, rails?, style?
Constructor Details
This class inherits a constructor from Rubocop::Cop::Cop
Instance Method Details
#on_def(node) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/rubocop/cop/style/empty_line_between_defs.rb', line 11 def on_def(node) def_start = node.loc.keyword.line def_end = node.loc.end.line if @prev_def_end && (def_start - @prev_def_end) == 1 add_offence(:convention, node.loc.keyword, MSG) end @prev_def_end = def_end end |