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

Getting Lint/UselessAssignment offense when variable is used inside block #11496

Closed
alebian opened this issue Jan 24, 2023 · 1 comment
Closed

Comments

@alebian
Copy link

alebian commented Jan 24, 2023

Expected behavior

When using a variable inside a block I would not expect a Lint/UselessAssignment offense.

Actual behavior

When I use a variable inside a block I get a Lint/UselessAssignment offense.

Steps to reproduce the problem

array1 = [1, 2, 3, 4, 5, 6]
array2 = [6, 7, 8]
array1.select { array2.include?(_1) }

After running rubocop I get the next output:

Offenses:

test.rb:2:1: W: Lint/UselessAssignment: Useless assignment to variable - array2. Did you mean array1?
array2 = [6, 7, 8]

RuboCop version

1.44.0

@koic
Copy link
Member

koic commented Jan 24, 2023

This issue is a dup with #11485 and resolved by #11488.

@koic koic closed this as completed Jan 24, 2023
@koic koic added the duplicate label Jan 24, 2023
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