Class: RuboCop::Cop::Faker::DeprecatedArguments
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Faker::DeprecatedArguments
- Extended by:
- AutoCorrector
- Includes:
- RangeHelp
- Defined in:
- lib/rubocop/cop/faker/deprecated_arguments.rb
Overview
Checks that Faker arguments style is based on Faker 2. Use keyword arguments instead of positional arguments.
Constant Summary collapse
- MSG =
'Passing `%<arg>s` with the %<index>s argument of ' \ '`%<class_name>s.%<method_name>s` is deprecated. ' \ 'Use keyword argument like `%<class_name>s.%<method_name>s' \ '(%<keyword>s: %<arg>s)` instead.'
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/rubocop/cop/faker/deprecated_arguments.rb', line 25 def on_send(node) return unless node.receiver class_name = faker_class_name(node) return unless (methods = argument_keywords[class_name]) node = node.parent if unique_generator_method?(node) return unless (keywords = methods[node.method_name.to_s]) node.arguments.each_with_index do |argument, index| next if argument.hash_type? = ( keyword: keywords[index], arg: argument.source, class_name: class_name, index: index, method_name: node.method_name ) add_offense_for_arguments(node, argument, ) end end |