Class: Rubocop::Cop::NewLambdaLiteral

Inherits:
Cop
  • Object
show all
Defined in:
lib/rubocop/cop/new_lambda_literal.rb

Constant Summary collapse

MSG =
'Use the new lambda literal syntax ->(params) {...}.'
TARGET =
s(:send, nil, :lambda)

Instance Attribute Summary

Attributes inherited from Cop

#debug, #disabled_lines, #offences

Instance Method Summary collapse

Methods inherited from Cop

#add_offence, cop_name, #has_report?, inherited, #initialize, #inspect, #name, #on_comment

Constructor Details

This class inherits a constructor from Rubocop::Cop::Cop

Instance Method Details

#on_send(node) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/rubocop/cop/new_lambda_literal.rb', line 10

def on_send(node)
  if node == TARGET && node.loc.selector.source != '->'
    add_offence(:convention, node.loc.line, MSG)
  end

  super
end