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

Repeated Conditional incorrectly reports in case there are local variable checks in different methods #1455

Open
hwo411 opened this issue Mar 4, 2019 · 2 comments
Labels

Comments

@hwo411
Copy link

hwo411 commented Mar 4, 2019

In case we have code like

class RepeatedConditionals
  def repeat_1
    switch = true # or some other code, e.g. `Service.call(...)`
    puts "Repeat 1!" if switch
  end

  def repeat_2
    switch = false # or some other code, e.g. `Service.call(...)`
    puts "Repeat 2!" if switch
  end

  def repeat_3
    switch = 123 # or some other code, e.g. `Service.call(...)`
    puts "Repeat 3!" if switch
  end
end

reek incorrectly reports Repeated Conditional

It shouldn't do this if all of the conditionals are local variables.

@troessner
Copy link
Owner

It shouldn't do this if all of the conditionals are local variables.

Fair point! That should be fairly easy to fix, thanks for the bug report.

@JuanVqz
Copy link
Contributor

JuanVqz commented Oct 11, 2023

@troessner I'd like to help on this one. I wonder how should we fix it. Can we scope the if and case per def method? will it break the attr_accessor scenario? Thanks for any help/guide/idea you can provide.

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.

3 participants