Sha256: 4022b4fc93d8179acd453f4591a0b922c94c1319a55ff67246a8bcc6038e9d07

Contents?: true

Size: 885 Bytes

Versions: 12

Compression:

Stored size: 885 Bytes

Contents

# frozen-string-literal: true

require_relative '../rubocop' unless defined?(RuboCop::Cop::StatsD)

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.rb \
      #      --only StatsD/SplatArguments
      #
      # This cop will not autocorrect offenses.
      class SplatArguments < Cop
        include RuboCop::Cop::StatsD

        MSG = 'Do not use splat arguments in StatsD metric calls'

        def on_send(node)
          if metric_method?(node)
            if node.arguments.any? { |arg| arg.type == :splat }
              add_offense(node)
            end
          end
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
statsd-instrument-3.0.2 lib/statsd/instrument/rubocop/splat_arguments.rb
statsd-instrument-3.0.1 lib/statsd/instrument/rubocop/splat_arguments.rb
statsd-instrument-3.0.0 lib/statsd/instrument/rubocop/splat_arguments.rb
statsd-instrument-3.0.0.pre2 lib/statsd/instrument/rubocop/splat_arguments.rb
statsd-instrument-2.9.2 lib/statsd/instrument/rubocop/splat_arguments.rb
statsd-instrument-3.0.0.pre1 lib/statsd/instrument/rubocop/splat_arguments.rb
statsd-instrument-2.9.1 lib/statsd/instrument/rubocop/splat_arguments.rb
statsd-instrument-2.9.0 lib/statsd/instrument/rubocop/splat_arguments.rb
statsd-instrument-2.8.0 lib/statsd/instrument/rubocop/splat_arguments.rb
statsd-instrument-2.7.1 lib/statsd/instrument/rubocop/splat_arguments.rb
statsd-instrument-2.7.0 lib/statsd/instrument/rubocop/splat_arguments.rb
statsd-instrument-2.6.0 lib/statsd/instrument/rubocop/splat_arguments.rb