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

Lint/RedundantSplatExpansion altering code in unsafe manner #9507

Closed
iHiD opened this issue Feb 11, 2021 · 1 comment · Fixed by #9508
Closed

Lint/RedundantSplatExpansion altering code in unsafe manner #9507

iHiD opened this issue Feb 11, 2021 · 1 comment · Fixed by #9508
Labels

Comments

@iHiD
Copy link

iHiD commented Feb 11, 2021

Hello. Thanks for your work on Rubocop.

I have an issue where Lint/RedundantSplatExpansion is incorrectly changing code.

# Example 1
# This is (correctly) left unchanged:
method = :some_method
args = Array.new(args, 'a')
res = send(method, *args)

# Example 2
# This is the same code with the variable inlined
method = :some_method
res = send(method, *Array.new(args, 'a'))

# Rubocop incorrectly changes Example 2 to:
method = :some_method
res = Array.new(args, 'a')

I can reproduce by pasting that code block into a file and seeing it change as it's linted.

RuboCop version

➜ bundle exec rubocop -V
1.7.0 (using Parser 2.7.2.0, rubocop-ast 1.4.0, running on ruby 2.6.6 x86_64-darwin19)
  - rubocop-minitest 0.10.2
  - rubocop-performance 1.9.2
  - rubocop-rails 2.9.1
@koic koic added the bug label Feb 11, 2021
koic added a commit to koic/rubocop that referenced this issue Feb 11, 2021
…platExpansion`

Fixes rubocop#9507.

This PR fixes an incorrect auto-correct for `Lint/RedundantSplatExpansion`
when expanding `Array.new` call on method argument
bbatsov pushed a commit that referenced this issue Feb 11, 2021
…ansion`

Fixes #9507.

This PR fixes an incorrect auto-correct for `Lint/RedundantSplatExpansion`
when expanding `Array.new` call on method argument
@iHiD
Copy link
Author

iHiD commented Feb 11, 2021

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