Class: RuboCop::Cop::SidekiqPro::BatchWithoutCallback
- Defined in:
- lib/rubocop/cop/sidekiq_pro/batch_without_callback.rb
Overview
Checks that batches have callbacks or descriptions for tracking.
Batches without callbacks or descriptions are difficult to track and monitor. Consider adding at least one callback or a description.
Constant Summary collapse
- MSG =
'Batch should have a callback or description for 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
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/rubocop/cop/sidekiq_pro/batch_without_callback.rb', line 38 def on_block(node) return unless batch_jobs_block?(node) batch_receiver = node.receiver return unless batch_receiver batch_var_name = extract_variable_name(batch_receiver) return unless batch_var_name add_offense(node.send_node) unless callback_or_description?(node, batch_var_name) end |