Class: RuboCop::Cop::StatsD::MeasureAsDistArgument

Inherits:
RuboCop::Cop
  • Object
show all
Includes:
RuboCop::Cop::StatsD
Defined in:
lib/statsd/instrument/rubocop/measure_as_dist_argument.rb

Overview

This Rubocop will check for specifying the as_dist: true keyword argument on StatsD.measure and statsd_measure. This argument is deprecated. Instead, you can use StatsD.distribution (or statsd_distribution) directly.

To run this cop on your codebase:

rubocop --require `bundle show statsd-instrument`/lib/statsd/instrument/rubocop.rb \
  --only StatsD/MeasureAsDistArgument

This cop will not autocorrect offenses.

Constant Summary collapse

MSG =
<<~MSG
  Do not use StatsD.measure(..., as_dist: true). This is deprecated.

  Use StatsD.distribution (or statsd_distribution) instead.
MSG

Constants included from RuboCop::Cop::StatsD

METAPROGRAMMING_METHODS, METRIC_METHODS, SINGLETON_CONFIGURATION_METHODS

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'lib/statsd/instrument/rubocop/measure_as_dist_argument.rb', line 27

def on_send(node)
  if metric_method?(node) && node.method_name == :measure
    add_offense(node) if has_keyword_argument?(node, :as_dist)
  end

  if metaprogramming_method?(node) && node.method_name == :statsd_measure
    add_offense(node) if has_keyword_argument?(node, :as_dist)
  end
end