Method: RuboCop::Cop::Style::MultilineBlockChain#on_block

Defined in:
lib/rubocop/cop/style/multiline_block_chain.rb

#on_block(node) ⇒ Object Also known as: on_numblock, on_itblock



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/rubocop/cop/style/multiline_block_chain.rb', line 30

def on_block(node)
  node.send_node.each_node(:call) do |send_node|
    receiver = send_node.receiver

    next unless receiver&.any_block_type? && receiver.multiline?

    range = range_between(receiver.loc.end.begin_pos, node.send_node.source_range.end_pos)

    add_offense(range)

    # Done. If there are more blocks in the chain, they will be
    # found by subsequent calls to on_block.
    break
  end
end