Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow braced numeric block calls in Style/MethodCallWithArgsParentheses #9854

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1 @@
* [#9854](https://github.com/rubocop/rubocop/pull/9854): Allow braced numeric blocks in `omit_parentheses` style of `Style/MethodCallWithArgsParentheses`. ([@gsamokovarov][])
Expand Up @@ -116,7 +116,8 @@ def call_with_ambiguous_arguments?(node)
end

def call_with_braced_block?(node)
(node.send_type? || node.super_type?) && node.block_node && node.block_node.braces?
(node.send_type? || node.super_type?) &&
((node.parent&.block_type? || node.parent&.numblock_type?) && node.parent&.braces?)
end

def call_as_argument_or_chain?(node)
Expand Down
Expand Up @@ -404,6 +404,14 @@ def method_missing(name, ...)
end
end

context 'numbered parameters in 2.7', :ruby27 do
it 'accepts parens for braced numeric block calls' do
expect_no_offenses(<<~RUBY)
numblock.call(:arg) { _1 }
RUBY
end
end

it 'register an offense for parens in method call without args' do
trailing_whitespace = ' '

Expand Down