Module: RuboCop::Cop::Style::EmptyLinesAroundBody

Includes:
ConfigurableEnforcedStyle
Included in:
EmptyLinesAroundClassBody, EmptyLinesAroundMethodBody, EmptyLinesAroundModuleBody
Defined in:
lib/rubocop/cop/mixin/empty_lines_around_body.rb

Overview

Common functionality for checking if presence/absence of empty lines around some kind of body matches the configuration.

Constant Summary collapse

MSG_EXTRA =
'Extra empty line detected at %s body %s.'
MSG_MISSING =
'Empty line missing at %s body %s.'

Instance Method Summary collapse

Methods included from ConfigurableEnforcedStyle

#alternative_style, #both_styles_detected, #correct_style_detected, #opposite_style_detected, #parameter_name, #style, #unrecognized_style_detected

Instance Method Details

#autocorrect(range) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/rubocop/cop/mixin/empty_lines_around_body.rb', line 14

def autocorrect(range)
  @corrections << lambda do |corrector|
    case style
    when :no_empty_lines then corrector.remove(range)
    when :empty_lines    then corrector.insert_before(range, "\n")
    end
  end
end