Class: RuboCop::Cop::Sidekiq::JobDependency

Inherits:
Base
  • Object
show all
Defined in:
lib/rubocop/cop/sidekiq/job_dependency.rb

Overview

Checks for implicit job dependencies (enqueuing other jobs inside jobs).

Examples:

# bad
def perform
  SecondJob.perform_async
end

Constant Summary collapse

MSG =
'Avoid implicit job dependencies. Use Sidekiq Batches instead.'

Instance Method Summary collapse

Methods included from Sidekiq::Language

#active_job_class?, #perform_call?, #sidekiq_include?, #sidekiq_options_call?

Instance Method Details

#on_def(node) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/rubocop/cop/sidekiq/job_dependency.rb', line 17

def on_def(node)
  return unless node.method?(:perform)
  return unless in_sidekiq_job?(node)

  node.each_descendant(:send) do |send|
    next unless perform_call?(send)

    add_offense(send)
  end
end