Class: RuboCop::Cop::StatsD::SplatArguments

Inherits:
RuboCop::Cop show all
Defined in:
lib/statsd/instrument/rubocop/splat_arguments.rb

Overview

This Rubocop will check for using splat arguments (*args) in StatsD metric calls. To run this rule on your codebase, invoke Rubocop this way:

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

This cop will not autocorrect offenses.

Constant Summary collapse

MSG =
'Do not use splat arguments in StatsD metric calls'
STATSD_METRIC_METHODS =
%i{increment gauge measure set histogram distribution key_value}

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/statsd/instrument/rubocop/splat_arguments.rb', line 19

def on_send(node)
  if node.receiver&.type == :const && node.receiver&.const_name == "StatsD"
    if STATSD_METRIC_METHODS.include?(node.method_name)
      check_for_splat_arguments(node)
    end
  end
end