2021-02-11 21:09:00 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-05-11 21:09:40 +00:00
|
|
|
module RuboCop
|
|
|
|
module Cop
|
|
|
|
# Cop that blacklists keyword arguments usage in Sidekiq workers
|
2022-09-14 15:12:56 +00:00
|
|
|
class AvoidKeywordArgumentsInSidekiqWorkers < RuboCop::Cop::Base
|
2020-05-11 21:09:40 +00:00
|
|
|
MSG = "Do not use keyword arguments in Sidekiq workers. " \
|
2021-03-26 03:09:21 +00:00
|
|
|
"For details, check https://github.com/mperham/sidekiq/issues/2372"
|
2020-05-11 21:09:40 +00:00
|
|
|
OBSERVED_METHOD = :perform
|
|
|
|
|
|
|
|
def on_def(node)
|
|
|
|
return if node.method_name != OBSERVED_METHOD
|
|
|
|
|
|
|
|
node.arguments.each do |argument|
|
|
|
|
if argument.type == :kwarg || argument.type == :kwoptarg
|
2022-09-14 15:12:56 +00:00
|
|
|
add_offense(node)
|
2020-05-11 21:09:40 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|