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

Infinite loop with Style/IfUnlessModifier #8006

Closed
zverok opened this issue May 21, 2020 · 2 comments
Closed

Infinite loop with Style/IfUnlessModifier #8006

zverok opened this issue May 21, 2020 · 2 comments
Labels

Comments

@zverok
Copy link
Contributor

zverok commented May 21, 2020

On Rubocop 0.84, with this statement:

    timespan = if params[:timespan] && POSSIBLE_TIMESPANS.include?(params[:timespan])
                 params[:timespan].to_sym
               end

and LineLength set to 100, rubocop -a falls into infinite loop:

app/controllers/customer_dashboard_controller.rb:67:16: C: [Corrected] Style/IfUnlessModifier: Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||.
    timespan = if params[:timespan] && POSSIBLE_TIMESPANS.include?(params[:timespan])
               ^^
app/controllers/customer_dashboard_controller.rb:67:17: C: [Corrected] Style/IfUnlessModifier: Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||.
    timespan = (if params[:timespan] && POSSIBLE_TIMESPANS.include?(params[:timespan])
                ^^
app/controllers/customer_dashboard_controller.rb:67:42: C: [Corrected] Style/IfUnlessModifier: Modifier form of if makes the line too long.
    timespan = (params[:timespan].to_sym if params[:timespan] && POSSIBLE_TIMESPANS.include?(params[:timespan]))
                                         ^^

Infinite loop detected in .../app/controllers/customer_dashboard_controller.rb.

(Yeah, I know code itself is horrible! Already rewritten it by hand, but still)

@JoeCohen
Copy link
Contributor

See #8025 for a similar bug report.

@dmytro-savochkin
Copy link

This should be closed due to #8435.

@koic koic closed this as completed Aug 3, 2020
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.

5 participants