Class: RuboCop::Cop::Netlify::SidekiqKeywordArguments

Inherits:
RuboCop::Cop
  • Object
show all
Defined in:
lib/rubocop/cop/netlify/sidekiq_keyword_arguments.rb

Overview

This cop checks the usage of keyword arguments in Sidekiq workers.

Examples:

# bad
def perform(user_id, name:)

# good
def perform(user_id, name)

Constant Summary collapse

MSG =
"Avoid keyword arguments in workers"
OBSERVED_METHOD =
:perform

Instance Method Summary collapse

Instance Method Details

#on_def(node) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/rubocop/cop/netlify/sidekiq_keyword_arguments.rb', line 18

def on_def(node)
  return if node.method_name != OBSERVED_METHOD

  node.arguments.each do |argument|
    if keyword_argument?(argument)
      add_offense(node, location: :expression)
      break
    end
  end
end