Class: RuboCop::Cop::SidekiqPro::BatchCallbackMethod
- Defined in:
- lib/rubocop/cop/sidekiq_pro/batch_callback_method.rb
Overview
Checks that batch callback methods are named correctly.
Sidekiq Pro batch callbacks require specific method names:
:completecallback requireson_completemethod:successcallback requireson_successmethod:deathcallback requireson_deathmethod
Constant Summary collapse
- CALLBACK_METHODS =
{ complete: :on_complete, success: :on_success, death: :on_death }.freeze
- MSG =
'Batch callback method should be named `%<expected>s`, not `%<actual>s`.'
Instance Method Summary collapse
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_def(node) ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/rubocop/cop/sidekiq_pro/batch_callback_method.rb', line 40 def on_def(node) return unless potential_callback_method?(node) method_name = node.method_name expected_name = expected_method_name_for(method_name) return unless expected_name add_offense(node.loc.name, message: format(MSG, expected: expected_name, actual: method_name)) end |