lib/rubocop/cop/lint/format_parameter_mismatch.rb in rubocop-0.52.1 vs lib/rubocop/cop/lint/format_parameter_mismatch.rb in rubocop-0.53.0
- old
+ new
@@ -18,12 +18,12 @@
# # good
#
# format('A value: %s and another: %i', a_value, another)
class FormatParameterMismatch < Cop
# http://rubular.com/r/CvpbxkcTzy
- MSG = "Number of arguments (%i) to `%s` doesn't match the number of " \
- 'fields (%i).'.freeze
+ MSG = "Number of arguments (%<arg_num>i) to `%<method>s` doesn't " \
+ 'match the number of fields (%<field_num>i).'.freeze
FIELD_REGEX =
/(%(([\s#+-0\*]*)(\d*)?(\.\d+)?[bBdiouxXeEfgGaAcps]|%))/
NAMED_FIELD_REGEX = /%\{[_a-zA-Z][_a-zA-Z]+\}/
KERNEL = 'Kernel'.freeze
SHOVEL = '<<'.freeze
@@ -167,10 +167,11 @@
def message(node)
num_args_for_format, num_expected_fields = count_matches(node)
method_name = node.method?(:%) ? 'String#%' : node.method_name
- format(MSG, num_args_for_format, method_name, num_expected_fields)
+ format(MSG, arg_num: num_args_for_format, method: method_name,
+ field_num: num_expected_fields)
end
end
end
end
end