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

deprecate_track_redis_hll_event.rb « gitlab « cop « rubocop - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3e30f3aa4d022390e885a604679930751981598a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# frozen_string_literal: true

require 'rack/utils'

module RuboCop
  module Cop
    module Gitlab
      # This cop prevents from using deprecated `track_redis_hll_event` method.
      #
      # @example
      #
      # # bad
      #  track_redis_hll_event :show, name: 'p_analytics_valuestream'
      #
      # # good
      #   track_event :show, name: 'g_analytics_valuestream', destinations: [:redis_hll]
      class DeprecateTrackRedisHLLEvent < RuboCop::Cop::Cop
        MSG = '`track_redis_hll_event` is deprecated. Use `track_event` helper instead. ' \
              'See https://docs.gitlab.com/ee/development/service_ping/implement.html#add-new-events'

        def_node_matcher :track_redis_hll_event_used?, <<~PATTERN
          (send _ :track_redis_hll_event ...)
        PATTERN

        def on_send(node)
          return unless track_redis_hll_event_used?(node)

          add_offense(node, location: :selector)
        end
      end
    end
  end
end