Class: RuboCop::Cop::Sevencop::RSpecEmptyLineAfterLet

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector
Defined in:
lib/rubocop/cop/sevencop/rspec_empty_line_after_let.rb

Overview

Insert empty line after ‘let`.

Since ‘let` defines a method, it should be written in the same style as `def`.

Examples:

# bad
context 'with something' do
  let(:foo) do
    'foo'
  end
  let(:bar) do
    'bar'
  end
end

# good
context 'with something' do
  let(:foo) do
    'foo'
  end

  let(:bar) do
    'bar'
  end
end

# good
context 'with something' do
  let(:foo) do
    'foo'
  end
end

Constant Summary collapse

MSG =
'Insert empty line after `let`.'

Instance Method Summary collapse

Instance Method Details

#on_block(node) ⇒ void

This method returns an undefined value.

Parameters:

  • node (RuboCop::AST::BlockNode)


45
46
47
48
49
50
51
# File 'lib/rubocop/cop/sevencop/rspec_empty_line_after_let.rb', line 45

def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler
  return unless bad?(node)

  add_offense(node) do |corrector|
    corrector.insert_after(node.location.end, "\n")
  end
end