Class: RuboCop::Cop::StatsD::MetricValueKeywordArgument

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

Overview

This Rubocop will check for providing the value for a metric using a keyword argument, which is deprecated. Use the following Rubocop invocation to check your project's codebase:

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

This cop will not autocorrect offenses. Most of the time, these are easy to fix by providing the value as the second argument, rather than a keyword argument.

StatsD.increment('foo', value: 3) => StatsD.increment('foo', 3)

Constant Summary collapse

MSG =
<<~MSG
  Do not use the StatsD.metric('name', value: <value>, ...). The `value` keyword argument is deprecated.

  Use a positional argument instead: StatsD.metric('name', <value>, ...).
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



28
29
30
31
32
# File 'lib/statsd/instrument/rubocop/metric_value_keyword_argument.rb', line 28

def on_send(node)
  if metric_method?(node) && has_keyword_argument?(node, :value)
    add_offense(node)
  end
end