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

Bad auto correct Style/ArgumentsForwarding in class_eval #12630

Closed
znz opened this issue Jan 18, 2024 · 1 comment
Closed

Bad auto correct Style/ArgumentsForwarding in class_eval #12630

znz opened this issue Jan 18, 2024 · 1 comment

Comments

@znz
Copy link
Contributor

znz commented Jan 18, 2024

Auto correct Style/ArgumentsForwarding makes invalid code in class_eval.


Expected behavior

It does not change or keep valid.

Actual behavior

It becomes invalid code.

Steps to reproduce the problem

% docker run --rm -it ruby:3.1 /bin/bash
root@987347fd5d79:/# gem i rubocop
Fetching rubocop-ast-1.30.0.gem
Fetching ruby-progressbar-1.13.0.gem
Fetching ast-2.4.2.gem
Fetching parser-3.3.0.4.gem
Fetching unicode-display_width-2.5.0.gem
Fetching rainbow-3.1.1.gem
Fetching parallel-1.24.0.gem
Fetching rubocop-1.60.1.gem
Fetching regexp_parser-2.9.0.gem
Fetching language_server-protocol-3.17.0.3.gem
Successfully installed unicode-display_width-2.5.0
Successfully installed ruby-progressbar-1.13.0
Successfully installed ast-2.4.2
Successfully installed parser-3.3.0.4
Successfully installed rubocop-ast-1.30.0
Successfully installed regexp_parser-2.9.0
Successfully installed rainbow-3.1.1
Successfully installed parallel-1.24.0
Successfully installed language_server-protocol-3.17.0.3
Successfully installed rubocop-1.60.1
10 gems installed
root@987347fd5d79:/# cat > .rubocop.yml
AllCops:
  TargetRubyVersion: '3.1'
  NewCops: enable
root@987347fd5d79:/# cat > b.rb
C.class_eval do
  def foo(a=false, &block)
    bar(a, 1, &block)
  end
end
root@987347fd5d79:/# rubocop --only Style/ArgumentsForwarding -a b.rb
Inspecting 1 file
C

Offenses:

.rb:2:11: C: [Corrected] Style/ArgumentsForwarding: Use shorthand syntax ... for arguments forwarding.
  def foo(a=false, &block)
          ^^^^^^^^^^^^^^^
.rb:3:12: C: [Corrected] Style/ArgumentsForwarding: Use shorthand syntax ... for arguments forwarding.
    bar(a, 1, &block)
           ^^^^^^^^^

1 file inspected, 2 offenses detected, 2 offenses corrected
root@987347fd5d79:/# cat b.rb
C.class_eval do
  def foo(...)
    bar(a, ...)
  end
end

RuboCop version

root@987347fd5d79:/# rubocop -V
1.60.1 (using Parser 3.3.0.4, rubocop-ast 1.30.0, running on ruby 3.1.4) [aarch64-linux]
@koic
Copy link
Member

koic commented Jan 18, 2024

This issue is a dup with #12618 (comment) and will be resolved in #12628. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants