Class: RuboCop::Cop::RSpec::ScatteredLet

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/cop/rspec/scattered_let.rb

Overview

Patches the upstream RSpec/ScatteredLet cop so that Sorbet sig declarations attached to let/let! blocks (Sorbet's RSpec mode) do not interrupt the consecutive-let chain.

Without this patch the upstream cop flags valid sig+let arrangements because the intervening sig block breaks the consecutive-sibling check. (The sig-aware MoveNode patch in lib/rubocop/gusto/move_node_patch.rb handles dragging the sig along during autocorrect.)

Examples:

# good (no longer flagged)
context "..." do
  sig { returns(Something) }
  let(:thing) { create(:something) }

  sig { returns(Other) }
  let(:other) { create(:other) }
end

Instance Method Summary collapse

Instance Method Details

#sig_block?(node) ⇒ Object



32
33
34
# File 'lib/rubocop/cop/rspec/scattered_let.rb', line 32

def_node_matcher :sig_block?, <<~PATTERN
  (block (send nil? :sig) _ _)
PATTERN