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
bug

Comments

@zverok
Copy link
Contributor

@zverok 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

@JoeCohen JoeCohen commented May 24, 2020

See #8025 for a similar bug report.

tejasbubane added a commit to tejasbubane/rubocop that referenced this issue May 24, 2020
tejasbubane added a commit to tejasbubane/rubocop that referenced this issue May 24, 2020
tejasbubane added a commit to tejasbubane/rubocop that referenced this issue May 25, 2020
tejasbubane added a commit to tejasbubane/rubocop that referenced this issue May 25, 2020
tejasbubane added a commit to tejasbubane/rubocop that referenced this issue May 31, 2020
tejasbubane added a commit to tejasbubane/rubocop that referenced this issue May 31, 2020
tejasbubane added a commit to tejasbubane/rubocop that referenced this issue May 31, 2020
@dmytro-savochkin
Copy link

@dmytro-savochkin dmytro-savochkin commented Aug 3, 2020

This should be closed due to #8435.

@koic koic closed this Aug 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

5 participants
You can’t perform that action at this time.