Class: Rubocop::Cop::Style::Proc
- Defined in:
- lib/rubocop/cop/style/proc.rb
Overview
This cops checks for uses of Proc.new where Kernel#proc would be more appropriate.
Constant Summary collapse
- MSG =
'Use proc instead of Proc.new.'
- TARGET =
s(:send, s(:const, nil, :Proc), :new)
Instance Attribute Summary
Attributes inherited from Cop
#autocorrect, #corrections, #debug, #disabled_lines, #offences
Instance Method Summary collapse
Methods inherited from Cop
#add_offence, all, #autocorrect_action, cop_name, cop_type, #do_autocorrect, #ignore_node, inherited, #initialize, lint?, #name, rails?, style?
Constructor Details
This class inherits a constructor from Rubocop::Cop::Cop
Instance Method Details
#on_block(node) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rubocop/cop/style/proc.rb', line 13 def on_block(node) # We're looking for # (block # (send # (const nil :Proc) :new) # ...) block_method, = *node if block_method == TARGET add_offence(:convention, block_method.loc.expression, MSG) end end |