-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Description
Example code:
class Foo
def bar(*args, &block)
hello(*args, &block)
world(*args)
end
end
Expected behavior
Output code should be working code after autofix.
Actual behavior
$ bundle exec rubocop -a test.rb`
...
test.rb:3:13: C: [Corrected] Style/ArgumentsForwarding: Use shorthand syntax ... for arguments forwarding.
def bar(*args, &block)
^^^^^^^^^^^^^
test.rb:4:12: C: [Corrected] Style/ArgumentsForwarding: Use shorthand syntax ... for arguments forwarding.
puts(*args, &block)
^^^^^^^^^^^^^
Result
class Foo
class << self
def bar(...)
puts(...)
puts(*args)
end
end
end
This is broken since args
is not defined anymore.
Please note it happens when running on 3.2.0 with TargetRubyVersion: 2.7
.
If I run it on 3.2.0 with TargetRubyVersion: 3.2
, output is:
class Foo
class << self
def bar(*, &block)
puts(*, &block)
puts(*)
end
end
end
And this is not working on ruby 2.7
Steps to reproduce the problem
Gemfile
source 'https://rubygems.org'
gem 'rubocop', '1.56.0'
Gemfile.lock
GEM
remote: https://rubygems.org/
specs:
ast (2.4.2)
base64 (0.1.1)
json (2.6.3)
language_server-protocol (3.17.0.3)
parallel (1.23.0)
parser (3.2.2.3)
ast (~> 2.4.1)
racc
racc (1.7.1)
rainbow (3.1.1)
regexp_parser (2.8.1)
rexml (3.2.6)
rubocop (1.56.0)
base64 (~> 0.1.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.2.2.3)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.28.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.29.0)
parser (>= 3.2.1.0)
ruby-progressbar (1.13.0)
unicode-display_width (2.4.2)
PLATFORMS
arm64-darwin-22
DEPENDENCIES
rubocop (= 1.56.0)
BUNDLED WITH
2.4.12
.rubocop.yml
AllCops:
TargetRubyVersion: 2.7
Style/ArgumentsForwarding:
Enabled: true
$ ruby --version
ruby 2.7.8p225 (2023-03-30 revision 1f4d455848) [arm64-darwin22]
$ bundle exec rubocop -V
1.56.0 (using Parser 3.2.2.3, rubocop-ast 1.29.0, running on ruby 2.7.8) [arm64-darwin22]
$ cat .tool-versions
ruby 2.7.8
Metadata
Metadata
Assignees
Labels
No labels