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

Safe auto-correction of Naming/BlockForwarding and Style/ArgumentsForwarding generates a syntax error (Ruby 3.2) #12361

Closed
tagliala opened this issue Nov 5, 2023 · 1 comment · Fixed by #12362
Labels

Comments

@tagliala
Copy link
Contributor

tagliala commented Nov 5, 2023

Hi, apologies if this is a duplicate

I've found an error when trying to correct Naming/BlockForwarding and Style/ArgumentsForwarding at the same time

Example file:

def some_method(form, **options, &block)
  render 'template', form: form, **options, &block
end

Example config:

AllCops:
  TargetRubyVersion: 3.2

Expected behavior

Generates a valid file

Actual behavior

def some_method(form, **, &)
  render(('template', form: form, **, &))
end
options_and_block.rb:13:21: F: Lint/Syntax: unexpected token tLABEL
(Using Ruby 3.1 parser; configure using TargetRubyVersion parameter, under AllCops)
  render((template, form: form, **, &))

Steps to reproduce the problem

  1. Create a file containing like the one in the example

  2. Run bundle exec rubocop options_and_block.rb --only Style/ArgumentsForwarding,Naming/BlockForwarding -a, targeting

  3. Check the output file

RuboCop version

1.57.2 (and main)

bundle exec rubocop -V
1.57.2 (using Parser 3.2.2.4, rubocop-ast 1.30.0, running on ruby 3.2.2) [x86_64-darwin22]
$ cat .rubocop.yml 
AllCops:
  NewCops: enable
  TargetRubyVersion: 3.2
@koic koic added the bug label Nov 5, 2023
koic added a commit to koic/rubocop that referenced this issue Nov 5, 2023
…warding`

Fixes rubocop#12361.

Fix an incorrect autocorrect for `Naming/BlockForwarding` and `Style/ArgumentsForwarding`
when autocorrection conflicts for anonymous arguments.
bbatsov pushed a commit that referenced this issue Nov 5, 2023
Fixes #12361.

Fix an incorrect autocorrect for `Naming/BlockForwarding` and `Style/ArgumentsForwarding`
when autocorrection conflicts for anonymous arguments.
@tagliala
Copy link
Contributor Author

tagliala commented Nov 5, 2023

Thanks!

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

Successfully merging a pull request may close this issue.

2 participants