Class: RuboCop::Cop::ThreadSafety::NewThread

Inherits:
RuboCop::Cop show all
Defined in:
lib/rubocop/cop/thread_safety/new_thread.rb

Overview

Avoid starting new threads.

Let a framework like Sidekiq handle the threads.

Examples:

# bad
Thread.new { do_work }

Constant Summary collapse

MSG =
'Avoid starting new threads.'

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object



20
21
22
23
24
# File 'lib/rubocop/cop/thread_safety/new_thread.rb', line 20

def on_send(node)
  return unless new_thread?(node)

  add_offense(node, message: MSG)
end