Class: RuboCop::Cop::Betterment::DirectDelayedEnqueue
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Betterment::DirectDelayedEnqueue
- Defined in:
- lib/rubocop/cop/betterment/direct_delayed_enqueue.rb
Constant Summary collapse
- DELAY_MESSAGE =
'Please use Active Job instead of using `Object#delay`'
- ENQUEUE_MESSAGE =
'Please use Active Job instead of using `Delayed::Job.enqueue`'
Instance Method Summary collapse
Instance Method Details
#enqueue?(node) ⇒ Object
11 12 13 |
# File 'lib/rubocop/cop/betterment/direct_delayed_enqueue.rb', line 11 def_node_matcher :enqueue?, <<-PATTERN (send (const (const nil? :Delayed) :Job) :enqueue ...) PATTERN |
#on_send(node) ⇒ Object
15 16 17 18 |
# File 'lib/rubocop/cop/betterment/direct_delayed_enqueue.rb', line 15 def on_send(node) add_offense(node, message: DELAY_MESSAGE) if node.method?(:delay) add_offense(node, message: ENQUEUE_MESSAGE) if enqueue?(node) end |