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/ShadowingOuterLocalVariable: a false positive case with case statement and block variable #10512

Closed
rickselby opened this issue Apr 8, 2022 · 1 comment · Fixed by #10513

Comments

@rickselby
Copy link
Contributor

Expected behavior

No offense with Lint/ShadowingOuterLocalVariable cop

Actual behavior

 W: Lint/ShadowingOuterLocalVariable: Shadowing outer local variable - item.
  array.each do |item|
                 ^^^^

Steps to reproduce the problem

def test(array)
  case array.length
  when 1
    item = array.first
    p item
  else
    array.each do |item|
      p item
    end
  end
end

RuboCop version

1.27.0 (using Parser 3.1.1.0, rubocop-ast 1.16.0, running on ruby 2.7.5 x86_64-linux)
  - rubocop-performance 1.13.3
  - rubocop-rake 0.6.0
  - rubocop-rspec 2.9.0

I thought #10479 would fix this one, but it didn't.

@ydah
Copy link
Member

ydah commented Apr 8, 2022

I've confirmed that it does reproduce. Sorry. I'll attempt to fix it.

ydah added a commit to ydah/rubocop that referenced this issue Jun 13, 2022
…lVariable` conditional statement and block variable
bbatsov pushed a commit that referenced this issue Aug 6, 2022
…le` conditional statement and block variable
WJWH pushed a commit to WJWH/rubocop that referenced this issue Aug 8, 2022
…lVariable` conditional statement and block variable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants