Class: RuboCop::Cop::EmptyLineCorrector

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/cop/correctors/empty_line_corrector.rb

Overview

This class does empty line auto-correction

Class Method Summary collapse

Class Method Details

.correct(corrector, node) ⇒ Object


8
9
10
11
12
13
14
15
16
17
# File 'lib/rubocop/cop/correctors/empty_line_corrector.rb', line 8

def correct(corrector, node)
  offense_style, range = node

  case offense_style
  when :no_empty_lines
    corrector.remove(range)
  when :empty_lines
    corrector.insert_before(range, "\n")
  end
end

.insert_before(corrector, node) ⇒ Object


19
20
21
# File 'lib/rubocop/cop/correctors/empty_line_corrector.rb', line 19

def insert_before(corrector, node)
  corrector.insert_before(node, "\n")
end