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(node) ⇒ Object



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

def correct(node)
  offense_style, range = node
  lambda do |corrector|
    case offense_style
    when :no_empty_lines
      corrector.remove(range)
    when :empty_lines
      corrector.insert_before(range, "\n")
    end
  end
end

.insert_before(node) ⇒ Object



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

def insert_before(node)
  ->(corrector) { corrector.insert_before(node.source_range, "\n") }
end