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: e1c6a984e751fe1b9c6c438ef37aa5e12475f1b8 (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 blacklists keyword arguments usage in Sidekiq workers
    class AvoidKeywordArgumentsInSidekiqWorkers < RuboCop::Cop::Cop
      MSG = "Do not use keyword arguments in Sidekiq workers. " \
        "For details, check https://github.com/mperham/sidekiq/issues/2372".freeze
      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, location: :expression)
          end
        end
      end
    end
  end
end