Class: RuboCop::Cop::Salsify::DelayedJobSelfEnqueue
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Salsify::DelayedJobSelfEnqueue
- Defined in:
- lib/rubocop/cop/salsify/delayed_job_self_enqueue.rb
Overview
Detects ‘Delayed::Job.enqueue(self, …)`.
Re-enqueuing ‘self` serializes the entire object including memoized ActiveRecord instances. If any of those records are deleted before the job is next executed, deserialization will raise `Delayed::DeserializationError`. Create a fresh instance with only the primitive arguments instead.
Constant Summary collapse
- MSG =
'Do not pass `self` to `Delayed::Job.enqueue`. ' \ 'Create a new job instance to avoid serializing memoized AR objects.'
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
34 35 36 37 38 |
# File 'lib/rubocop/cop/salsify/delayed_job_self_enqueue.rb', line 34 def on_send(node) return unless enqueue_self?(node) add_offense(node, message: MSG) end |