Class: RuboCop::Cop::StatsD::MetaprogrammingPositionalArguments
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::StatsD::MetaprogrammingPositionalArguments
- Includes:
- RuboCop::Cop::StatsD
- Defined in:
- lib/statsd/instrument/rubocop/metaprogramming_positional_arguments.rb
Overview
This Rubocop will check for using the metaprogramming macros for positional
argument usage, which is deprecated. These macros include statsd_count_if
,
statsd_measure
, etc.
Use the following Rubocop invocation to check your project's codebase:
rubocop --only StatsD/MetaprogrammingPositionalArguments
-r `bundle show statsd-instrument`/lib/statsd/instrument/rubocop.rb
This cop will not autocorrect the offenses it finds, but generally the fixes are easy to fix
Constant Summary collapse
- MSG =
"Use keyword arguments for StatsD metaprogramming macros"
Constants included from RuboCop::Cop::StatsD
METAPROGRAMMING_METHODS, METRIC_METHODS, SINGLETON_CONFIGURATION_METHODS
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/statsd/instrument/rubocop/metaprogramming_positional_arguments.rb', line 24 def on_send(node) if (node) arguments = node.arguments.dup arguments.shift # method arguments.shift # metric arguments.pop if arguments.last&.type == :block_pass case arguments.length when 0 when 1 add_offense(node) if arguments.first.type != :hash else add_offense(node) end end end |