Class: RuboCop::Cop::Sidekiq::QueueSpecified
- Defined in:
- lib/rubocop/cop/sidekiq/queue_specified.rb
Overview
Checks that Sidekiq jobs have an explicit queue specified.
Without an explicit queue, jobs go to the default queue.
Specifying queues helps with job organization and prioritization.
Constant Summary collapse
- MSG =
'Specify a queue for this Sidekiq job using `sidekiq_options queue: :queue_name`.'
Instance Method Summary collapse
- #on_class(node) ⇒ Object
- #sidekiq_include?(node) ⇒ Object
- #sidekiq_options_with_queue?(node) ⇒ Object
Methods included from Sidekiq::Language
#active_job_class?, #perform_call?, #sidekiq_options_call?
Instance Method Details
#on_class(node) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/rubocop/cop/sidekiq/queue_specified.rb', line 36 def on_class(node) return unless sidekiq_job_class?(node) return if queue_option?(node) include_node = find_sidekiq_include(node) add_offense(include_node) if include_node end |
#sidekiq_include?(node) ⇒ Object
27 28 29 |
# File 'lib/rubocop/cop/sidekiq/queue_specified.rb', line 27 def_node_matcher :sidekiq_include?, "(send nil? :include (const (const {nil? cbase} :Sidekiq) {:Job :Worker}))\n" |
#sidekiq_options_with_queue?(node) ⇒ Object
32 33 34 |
# File 'lib/rubocop/cop/sidekiq/queue_specified.rb', line 32 def_node_matcher :sidekiq_options_with_queue?, "(send nil? :sidekiq_options (hash <(pair (sym :queue) _) ...>))\n" |