You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would expect Style/MethodDefParentheses to not throw errors when forwarding splats (single and double). This is similar in nature to this issue opened last year when anonymous block support was added to Ruby.
Actual behavior
You'll get the following errors when using splat forwarding:
/Users/bkuhlmann/Engineering/Misc/snippet:16:13: C: [Correctable] Style/MethodDefParentheses: Use def without parentheses. (https://rubystyle.guide#method-parens)
def single(*)
^^^
/Users/bkuhlmann/Engineering/Misc/snippet:20:13: C: [Correctable] Style/MethodDefParentheses: Use def without parentheses. (https://rubystyle.guide#method-parens)
def double(**)
^^^^
Steps to reproduce the problem
Start by configuring Rubocop to use the following configuration:
Save the above and run as rubocop snippet.rb and notice you get the same errors as reported above. If you were to remove the parentheses -- as RuboCop suggests -- then you'd get the following syntax error:
syntax error, unexpected `super', expecting ';' or '\n'
15 module Demo
> 16 def single *
> 18 end
23 end
/Users/bkuhlmann/Engineering/Misc/snippet:17: syntax error, unexpected `super', expecting ';' or '\n' (SyntaxError)
super
^~~~~
…ous rest and keyword rest args
Fixesrubocop#11361
This PR fixes a false positive for `Style/MethodDefParentheses` when using `EnforcedStyle: require_no_parentheses`
and Ruby 3.2's anonymous rest and keyword rest arguments.
…ous rest and keyword rest args
Fixesrubocop#11361
This PR fixes a false positive for `Style/MethodDefParentheses` when using `EnforcedStyle: require_no_parentheses`
and Ruby 3.2's anonymous rest and keyword rest arguments.
Expected behavior
I would expect
Style/MethodDefParentheses
to not throw errors when forwarding splats (single and double). This is similar in nature to this issue opened last year when anonymous block support was added to Ruby.Actual behavior
You'll get the following errors when using splat forwarding:
Steps to reproduce the problem
Start by configuring Rubocop to use the following configuration:
Next, use the following code as an example:
Save the above and run as
rubocop snippet.rb
and notice you get the same errors as reported above. If you were to remove the parentheses -- as RuboCop suggests -- then you'd get the following syntax error:RuboCop version
The text was updated successfully, but these errors were encountered: