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
- #new_thread?(node) ⇒ Object
- #on_send(node) ⇒ Object (also: #on_csend)
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?, "(call (const {nil? cbase} :Thread) {:new :fork :start} ...)\n" |
#on_send(node) ⇒ Object Also known as: on_csend
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 |