Class: RuboCop::Cop::Sevencop::RSpecMemoizedHelperBlockDelimiter

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector
Includes:
ConfigurableEnforcedStyle, RangeHelp
Defined in:
lib/rubocop/cop/sevencop/rspec_memoized_helper_block_delimiter.rb

Overview

Use do-end block delimiter on RSpec memoized helper.

Since these helpers define methods, they should be written in the same style as ‘def`.

Examples:

# bad
let(:foo) { 'bar' }

# good
let(:foo) do
  'bar'
end

# bad
subject(:foo) { 'bar' }

# good
subject(:foo) do
  'bar'
end

Constant Summary collapse

MSG =
'Use do-end block delimiter on RSpec memoized helper.'

Instance Method Summary collapse

Instance Method Details

#on_block(node) ⇒ void

This method returns an undefined value.

Parameters:

  • node (RuboCop::AST::BlockNode)


36
37
38
39
40
41
42
43
44
45
46
# File 'lib/rubocop/cop/sevencop/rspec_memoized_helper_block_delimiter.rb', line 36

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

  add_offense(
    node.location.begin.with(
      end_pos: node.location.end.end_pos
    )
  ) do |corrector|
    autocorrect(corrector, node)
  end
end