class RuboCop::Cop::Netlify::SidekiqKeywordArguments

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

@example

# bad
def perform(user_id, name:)

# good
def perform(user_id, name)

Constants

MSG
OBSERVED_METHOD

Public Instance Methods

on_def(node) click to toggle source
# 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

Private Instance Methods

keyword_argument?(argument) click to toggle source
# File lib/rubocop/cop/netlify/sidekiq_keyword_arguments.rb, line 31
def keyword_argument?(argument)
  argument.type == :kwarg || argument.type == :kwoptarg
end