Class: RuboCop::Cop::ThreadSafety::NewThread
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::ThreadSafety::NewThread
- Defined in:
- lib/rubocop/cop/thread_safety/new_thread.rb
Overview
Avoid starting new threads.
Let a framework like Sidekiq handle the threads.
Constant Summary collapse
- MSG =
'Avoid starting new threads.'
- RESTRICT_ON_SEND =
%i[new fork start].freeze
Instance Method Summary collapse
Instance Method Details
#new_thread?(node) ⇒ Object
18 19 20 |
# File 'lib/rubocop/cop/thread_safety/new_thread.rb', line 18 def_node_matcher :new_thread?, <<~MATCHER (send (const {nil? cbase} :Thread) {:new :fork :start} ...) MATCHER |
#on_send(node) ⇒ Object
22 23 24 |
# File 'lib/rubocop/cop/thread_safety/new_thread.rb', line 22 def on_send(node) new_thread?(node) { add_offense(node) } end |