diff --git a/lib/rubocop/cop/style/method_call_with_args_parentheses.rb b/lib/rubocop/cop/style/method_call_with_args_parentheses.rb index 2012a4c831f..580fc0a557f 100644 --- a/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +++ b/lib/rubocop/cop/style/method_call_with_args_parentheses.rb @@ -237,6 +237,7 @@ def call_in_literals?(node) node.parent && (node.parent.pair_type? || node.parent.array_type? || + splat?(node.parent) || ternary_if?(node.parent)) end diff --git a/spec/rubocop/cop/style/method_call_with_args_parentheses_spec.rb b/spec/rubocop/cop/style/method_call_with_args_parentheses_spec.rb index b3ba35a4fcd..0834f53d757 100644 --- a/spec/rubocop/cop/style/method_call_with_args_parentheses_spec.rb +++ b/spec/rubocop/cop/style/method_call_with_args_parentheses_spec.rb @@ -414,6 +414,19 @@ def foo RUBY end + it 'accepts parens in splat calls' do + expect_no_offenses(<<-RUBY) + foo(*bar(args)) + foo(**quux(args)) + RUBY + end + + it 'accepts parens in block passing calls' do + expect_no_offenses(<<-RUBY) + foo(&method(:args)) + RUBY + end + it 'auto-corrects single-line calls' do original = <<-RUBY.strip_indent top.test(1, 2, foo: bar(3))