Class: RuboCop::Cop::RSpec::EmptyLineAfterSubject

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

Overview

Checks if there is an empty line after subject block.

Examples:

# bad
subject(:obj) { described_class }
let(:foo) { bar }

# good
subject(:obj) { described_class }

let(:foo) { bar }

Constant Summary collapse

MSG =
'Add an empty line after `%<subject>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


23
24
25
26
27
28
29
# File 'lib/rubocop/cop/rspec/empty_line_after_subject.rb', line 23

def on_block(node)
  return unless subject?(node) && !in_spec_block?(node)

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