Class: RuboCop::Cop::RSpec::EmptyLineAfterHook

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector
Includes:
EmptyLineSeparation
Defined in:
lib/rubocop/cop/rspec/empty_line_after_hook.rb

Overview

Checks if there is an empty line after hook blocks.

Examples:

# bad
before { do_something }
it { does_something }

# bad
after { do_something }
it { does_something }

# bad
around { |test| test.run }
it { does_something }

# good
before { do_something }

it { does_something }

# good
after { do_something }

it { does_something }

# good
around { |test| test.run }

it { does_something }

Constant Summary collapse

MSG =
'Add an empty line after `%<hook>s`.'

Instance Method Summary collapse

Methods included from EmptyLineSeparation

#last_child?, #missing_separating_line, #missing_separating_line_offense, #offending_loc

Methods included from FinalEndLocation

#final_end_location

Methods inherited from Base

inherited, #on_new_investigation

Methods included from RSpec::Language::NodePattern

#block_pattern, #send_pattern

Instance Method Details

#on_block(node) ⇒ Object


42
43
44
45
46
47
48
# File 'lib/rubocop/cop/rspec/empty_line_after_hook.rb', line 42

def on_block(node)
  return unless hook?(node)

  missing_separating_line_offense(node) do |method|
    format(MSG, hook: method)
  end
end