Welcome to mirror list, hosted at ThFree Co, Russian Federation.

avoid_keyword_arguments_in_sidekiq_workers.rb « cop « rubocop - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 78e405cf0cc49a11ad3099b0ff4678a40f5c9d29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# frozen_string_literal: true

module RuboCop
  module Cop
    # Cop that denylists keyword arguments usage in Sidekiq workers
    class AvoidKeywordArgumentsInSidekiqWorkers < RuboCop::Cop::Base
      MSG = "Do not use keyword arguments in Sidekiq workers. " \
        "For details, check https://github.com/mperham/sidekiq/issues/2372"
      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
            add_offense(node)
          end
        end
      end
    end
  end
end