Class: RuboCop::Cop::Sidekiq::SelfSchedulingJob
- Includes:
- ClassNameHelper
- Defined in:
- lib/rubocop/cop/sidekiq/self_scheduling_job.rb
Overview
Checks for jobs that reschedule themselves.
Constant Summary collapse
- MSG =
'Avoid self-scheduling jobs. Use Sidekiq Cron or scheduler 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
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rubocop/cop/sidekiq/self_scheduling_job.rb', line 19 def on_def(node) return unless node.method?(:perform) return unless in_sidekiq_job?(node) class_node = node.each_ancestor(:class).first class_name = class_name(class_node) node.each_descendant(:send) do |send| next unless PerformMethods.all.include?(send.method_name) next unless self_receiver?(send.receiver, class_name) add_offense(send) end end |