Skip to content

Commit

Permalink
Merge pull request #6765 from gsamokovarov/omit-parentheses-kwargs
Browse files Browse the repository at this point in the history
Allow parens for optional keyword value calls in Style/MethodCallWithArgsParentheses
  • Loading branch information
koic authored Feb 17, 2019
2 parents 3ec2faa + 4f1449b commit 508b051
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

### Bug fixes

* [#6765](https://github.com/rubocop-hq/rubocop/pull/6765): Fix false positives in keyword arguments for `Style/MethodCallWithArgsParentheses` `omit_parentheses`. ([@gsamokovarov]][])
* [#6763](https://github.com/rubocop-hq/rubocop/pull/6763): Fix false positives in range literals for `Style/MethodCallWithArgsParentheses` `omit_parentheses`. ([@gsamokovarov]][])
* [#6748](https://github.com/rubocop-hq/rubocop/issues/6748): Fix `Style/RaiseArgs` auto-correction breaking in contexts that require parentheses. ([@drenmi][])

Expand Down
3 changes: 2 additions & 1 deletion lib/rubocop/cop/style/method_call_with_args_parentheses.rb
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,8 @@ def call_in_logical_operators?(node)
end

def call_in_optional_arguments?(node)
node.parent && node.parent.optarg_type?
node.parent &&
(node.parent.optarg_type? || node.parent.kwoptarg_type?)
end

def call_with_ambiguous_arguments?(node)
Expand Down
12 changes: 12 additions & 0 deletions spec/rubocop/cop/style/method_call_with_args_parentheses_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,18 @@ def seatle_style arg = default(42)
RUBY
end

it 'accepts parens in default keyword argument value calls' do
expect_no_offenses(<<-RUBY.strip_indent)
def regular(arg: default(42))
nil
end
def seatle_style arg: default(42)
nil
end
RUBY
end

it 'accepts parens in method args' do
expect_no_offenses('top.test 1, 2, foo: bar(3)')
end
Expand Down

0 comments on commit 508b051

Please # to comment.