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 #8025

Closed
JoeCohen opened this issue May 24, 2020 · 0 comments · Fixed by #8435
Closed

Infinite loop with Style/IfUnlessModifier #8025

JoeCohen opened this issue May 24, 2020 · 0 comments · Fixed by #8435

Comments

@JoeCohen
Copy link
Contributor

Use the template below when reporting bugs. Please, make sure that
you're running the latest stable RuboCop and that the problem you're reporting
hasn't been reported (and potentially fixed) already.

Before filing the ticket you should replace all text above the horizontal
rule with your own words.


Note: This may be the same bug as #8006

Expected behavior

Either autocorrect or ignore this bit of code:

      merge = if ver.respond_to?(:merge_source_id)
                get_version_merge_link(obj, ver)
              end

Actual behavior

$ rubocop -f html -o rubocop.html --only Style/IfUnlessModifier -a
Infinite loop detected in /vagrant/mushroom-observer/app/helpers/version_helper.rb.
/home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/lib/rubocop/runner.rb:292:in check_for_infinite_loop' /home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/lib/rubocop/runner.rb:275:in block in iterate_until_no_changes'
/home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/lib/rubocop/runner.rb:274:in loop' /home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/lib/rubocop/runner.rb:274:in iterate_until_no_changes'
/home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/lib/rubocop/runner.rb:245:in do_inspection_loop' /home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/lib/rubocop/runner.rb:124:in block in file_offenses'
/home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/lib/rubocop/runner.rb:148:in file_offense_cache' /home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/lib/rubocop/runner.rb:122:in file_offenses'
/home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/lib/rubocop/runner.rb:113:in process_file' /home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/lib/rubocop/runner.rb:92:in block in each_inspected_file'
/home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/lib/rubocop/runner.rb:91:in each' /home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/lib/rubocop/runner.rb:91:in reduce'
/home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/lib/rubocop/runner.rb:91:in each_inspected_file' /home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/lib/rubocop/runner.rb:78:in inspect_files'
/home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/lib/rubocop/runner.rb:39:in run' /home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/lib/rubocop/cli/command/execute_runner.rb:21:in execute_runner'
/home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/lib/rubocop/cli/command/execute_runner.rb:13:in run' /home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/lib/rubocop/cli/command.rb:10:in run'
/home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/lib/rubocop/cli/environment.rb:17:in run' /home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/lib/rubocop/cli.rb:65:in run_command'
/home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/lib/rubocop/cli.rb:72:in execute_runners' /home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/lib/rubocop/cli.rb:41:in run'
/home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/exe/rubocop:13:in block in <top (required)>' /home/vagrant/.rvm/rubies/ruby-2.6.6/lib/ruby/2.6.0/benchmark.rb:308:in realtime'
/home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/exe/rubocop:12:in <top (required)>' /home/vagrant/.rvm/gems/ruby-2.6.6/bin/rubocop:23:in load'
/home/vagrant/.rvm/gems/ruby-2.6.6/bin/rubocop:23:in <main>' /home/vagrant/.rvm/gems/ruby-2.6.6/bin/ruby_executable_hooks:24:in eval'
/home/vagrant/.rvm/gems/ruby-2.6.6/bin/ruby_executable_hooks:24:in <main>' VM:/vagrant/mushroom-observer $ rubocop -f html -o rubocop.html --only Style/IfUnlessModifier -a app/helpers/version_helper.rb Infinite loop detected in /vagrant/mushroom-observer/app/helpers/version_helper.rb. /home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/lib/rubocop/runner.rb:292:in check_for_infinite_loop'
/home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/lib/rubocop/runner.rb:275:in block in iterate_until_no_changes' /home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/lib/rubocop/runner.rb:274:in loop'
/home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/lib/rubocop/runner.rb:274:in iterate_until_no_changes' /home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/lib/rubocop/runner.rb:245:in do_inspection_loop'
/home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/lib/rubocop/runner.rb:124:in block in file_offenses' /home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/lib/rubocop/runner.rb:148:in file_offense_cache'
/home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/lib/rubocop/runner.rb:122:in file_offenses' /home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/lib/rubocop/runner.rb:113:in process_file'
/home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/lib/rubocop/runner.rb:92:in block in each_inspected_file' /home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/lib/rubocop/runner.rb:91:in each'
/home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/lib/rubocop/runner.rb:91:in reduce' /home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/lib/rubocop/runner.rb:91:in each_inspected_file'
/home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/lib/rubocop/runner.rb:78:in inspect_files' /home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/lib/rubocop/runner.rb:39:in run'
/home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/lib/rubocop/cli/command/execute_runner.rb:21:in execute_runner' /home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/lib/rubocop/cli/command/execute_runner.rb:13:in run'
/home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/lib/rubocop/cli/command.rb:10:in run' /home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/lib/rubocop/cli/environment.rb:17:in run'
/home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/lib/rubocop/cli.rb:65:in run_command' /home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/lib/rubocop/cli.rb:72:in execute_runners'
/home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/lib/rubocop/cli.rb:41:in run' /home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/exe/rubocop:13:in block in <top (required)>'
/home/vagrant/.rvm/rubies/ruby-2.6.6/lib/ruby/2.6.0/benchmark.rb:308:in realtime' /home/vagrant/.rvm/gems/ruby-2.6.6/gems/rubocop-0.83.0/exe/rubocop:12:in <top (required)>'
/home/vagrant/.rvm/gems/ruby-2.6.6/bin/rubocop:23:in load' /home/vagrant/.rvm/gems/ruby-2.6.6/bin/rubocop:23:in

'
/home/vagrant/.rvm/gems/ruby-2.6.6/bin/ruby_executable_hooks:24:in eval' /home/vagrant/.rvm/gems/ruby-2.6.6/bin/ruby_executable_hooks:24:in '

Steps to reproduce the problem

The problem can be reproduced by running

$ rubocop -f html -o rubocop.html --only Style/IfUnlessModifier -a

on a file containing

      merge = if ver.respond_to?(:merge_source_id)
                get_version_merge_link(obj, ver)
              end

RuboCop version

Include the output of rubocop -V or bundle exec rubocop -V if using Bundler. Here's an example:

$ rubocop -V
0.83.0 (using Parser 2.7.1.2, running on ruby 2.6.6 x86_64-linux)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants