Class: RuboCop::Cop::Betterment::Timeout

Inherits:
RuboCop::Cop show all
Defined in:
lib/rubocop/cop/betterment/timeout.rb

Constant Summary collapse

MSG =
'Using Timeout.timeout without a custom exception can prevent rescue blocks from executing'.freeze

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/rubocop/cop/betterment/timeout.rb', line 7

def on_send(node)
  target_receiver = s(:const, nil, :Timeout)
  target_method = :timeout

  if node.receiver == target_receiver && node.method_name == target_method && node.arguments.one?
    add_offense(node, location: node.source_range)
  end
end