Class: RuboCop::Cop::Sidekiq::HugeJobArguments

Inherits:
Base
  • Object
show all
Defined in:
lib/rubocop/cop/sidekiq/huge_job_arguments.rb

Overview

Checks for potentially huge arguments passed to Sidekiq jobs.

Examples:

# bad
MyJob.perform_async(users.pluck(:id, :name, :email))
MyJob.perform_async([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])

# good
MyJob.perform_async(user_ids)

Constant Summary collapse

MSG =
'Avoid passing large arguments to Sidekiq jobs. Pass IDs and load records in the job instead.'
DEFAULT_MAX_ARRAY_SIZE =
10
DEFAULT_MAX_HASH_SIZE =
10
DEFAULT_MAX_PLUCK_COLUMNS =
3

Instance Method Summary collapse

Methods included from Sidekiq::Language

#active_job_class?, #perform_call?, #sidekiq_include?, #sidekiq_options_call?

Instance Method Details

#on_send(node) ⇒ Object Also known as: on_csend



23
24
25
26
27
28
29
# File 'lib/rubocop/cop/sidekiq/huge_job_arguments.rb', line 23

def on_send(node)
  perform_call?(node) do
    node.arguments.each do |arg|
      check_argument(arg)
    end
  end
end