Class: RuboCop::Cop::SidekiqPro::NestedBatchWithoutParent
- Defined in:
- lib/rubocop/cop/sidekiq_pro/nested_batch_without_parent.rb
Overview
Checks that nested batches have proper parent relationship.
When creating nested batches inside a batch.jobs block, the child batch should reference the parent for proper tracking.
Constant Summary collapse
- MSG =
'Nested batch should reference parent batch for proper tracking.'
Instance Method Summary collapse
- #on_block(node) ⇒ Object (also: #on_numblock)
Methods inherited from Base
#batch_description_set?, #batch_jobs_block?, #batch_new?, #batch_on_callback?
Methods included from Sidekiq::Language
#active_job_class?, #perform_call?, #sidekiq_include?, #sidekiq_options_call?
Instance Method Details
#on_block(node) ⇒ Object Also known as: on_numblock
44 45 46 47 48 49 50 |
# File 'lib/rubocop/cop/sidekiq_pro/nested_batch_without_parent.rb', line 44 def on_block(node) return unless batch_jobs_block?(node) node.body&.each_descendant(:send) do |send_node| add_offense(send_node) if batch_new?(send_node) && send_node.arguments.empty? end end |