A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/rubocop/rubocop/issues/14307 below:

Fix Style/MethodCallWithArgsParentheses with guarded return and anonymous forwards · Issue #14307 · rubocop/rubocop · GitHub

I'm seeing an issue where you'll get a RuboCop issue when using a guard to return early with bare double splats. I'm guessing this will happen with bare/named single splats, double splats, and block arguments too.

Expected behavior

I would expect the following to be valid and require parenthesis in this case because, without them, you'll get a syntax error:

def demo(value, **)
  record = find_by_name value

  return create(name: value, **) unless record

  record
end

The reason is that create(name: value, **) requires parentheses in this case. Otherwise, it's a syntax error.

Actual behavior

Here's what actually happens:

demo.rb:20:24: C: [Correctable] Style/MethodCallWithArgsParentheses: Omit parentheses for method calls with arguments. (https://rubystyle.guide#method-invocation-parens)
          return create(name: value, **) unless record
                       ^^^^^^^^^^^^^^^^^
Steps to reproduce the problem

You can recreate the above using the following configuration:

Style/MethodCallWithArgsParentheses:
  Enabled: true
  EnforcedStyle: omit_parentheses
  AllowParenthesesInChaining: true
  AllowParenthesesInMultilineCall: true
  IgnoreMacros: false
RuboCop version
1.76.2 (using Parser 3.3.8.0, Prism 1.4.0, rubocop-ast 1.45.1, analyzing as Ruby 3.4, running on ruby 3.4.4) [arm64-darwin24.5.0]
  - rubocop-sequel 0.3.8
  - rubocop-capybara 2.22.1
  - rubocop-disable_syntax 0.2.0
  - rubocop-packaging 0.6.0
  - rubocop-performance 1.25.0
  - rubocop-thread_safety 0.7.2
  - rubocop-rake 0.7.1
  - rubocop-rspec 3.6.0

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4