Sha256: cb0b1ec8c5da9a622830ef7b870a3567943d820e941de3cb0b3d23d8c93bdf05
Contents?: true
Size: 1.11 KB
Versions: 2
Compression:
Stored size: 1.11 KB
Contents
# frozen-string-literal: true module RuboCop module Cop module StatsD # 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. class SplatArguments < Cop MSG = 'Do not use splat arguments in StatsD metric calls' STATSD_METRIC_METHODS = %i{increment gauge measure set histogram distribution key_value} 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 private def check_for_splat_arguments(node) if node.arguments.any? { |arg| arg.type == :splat } add_offense(node) end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
statsd-instrument-2.5.1 | lib/statsd/instrument/rubocop/splat_arguments.rb |
statsd-instrument-2.5.0 | lib/statsd/instrument/rubocop/splat_arguments.rb |