-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Description
The new Lint/SplatKeywordArguments cop, added in 0.56.0 (#5871), warns in several cases that are seemingly outside the intent of the new Ruby 2.6.0 warning message it claims to emulate.
The pertinent test code in ruby core is located here:
The only cases in which the new ruby 2.6 warning is expected are when a double-splat arg is passed to a method that has one or more positional args, but no double-splatted keyword arg.
Line 524, which calls a method defined with a single positional arg, and line 527, which calls a method defined with a single positional arg with a default value, are examples where the warning is expected.
Lines 530 and 533 which call methods defined with double-splatted and single-splatted arguments, respectively, are not expected to generate the warning.
It's not entirely clear that rubocop is able to replicate this warning correctly since it would need to examine both the calling arguments (to look for double-splatted hashes) AND the definition of the method being called (to determine whether that hash would be assigned to a positional method argument).
Expected behavior
options = { opt1: 1, opt2: 2 }
def method1(kw_args); end
def method2(**kw_args); end
method1(**options) # This will warn in ruby 2.6 and currently warns in rubocop.
method2(**options) # This does not warn in ruby 2.6 and should not warn in rubocop.Actual behavior
Call to method2 warns.
RuboCop version
$ rubocop -V
0.56.0 (using Parser 2.5.1.0, running on ruby 2.5.1 x86_64-darwin17)