Method: RuboCop::Cop::Style::Lambda#on_block

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

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

[View source]

64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/rubocop/cop/style/lambda.rb', line 64

def on_block(node)
  return unless node.lambda?

  selector = node.send_node.source

  return unless offending_selector?(node, selector)

  add_offense(node.send_node, message: message(node, selector)) do |corrector|
    if node.send_node.lambda_literal?
      LambdaLiteralToMethodCorrector.new(node).call(corrector)
    else
      autocorrect_method_to_literal(corrector, node)
    end
  end
end