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 detected in this code snippet #3690

Closed
terryyin opened this issue Nov 1, 2016 · 4 comments · Fixed by #3731
Closed

Infinite loop detected in this code snippet #3690

terryyin opened this issue Nov 1, 2016 · 4 comments · Fixed by #3731

Comments

@terryyin
Copy link

terryyin commented Nov 1, 2016

def x
  a b {
    %(
-
    )
  }
end
@tejasbubane
Copy link
Contributor

I cannot reproduce this on rubocop 0.45.0, rather got this offense:

Offenses:

rubocop_bug_test.rb:3:8: C: Style/SpaceInsideBlockBraces: Space missing inside {.
  a b { ...


1 file inspected, 1 offense detected

@rrosenblum
Copy link
Contributor

rrosenblum commented Nov 17, 2016

@tejasbubane I was able to reproduce on RuboCop 0.45.0 running rubocop -a. The offense is registered when rubocop is run on the file. The infinite loop comes from the auto-correction.

Here is the stack trace

  work/rubocop/lib/rubocop/runner.rb:233:in `check_for_infinite_loop'
  work/rubocop/lib/rubocop/runner.rb:216:in `block in iterate_until_no_changes'
  work/rubocop/lib/rubocop/runner.rb:215:in `loop'
  work/rubocop/lib/rubocop/runner.rb:215:in `iterate_until_no_changes'
  work/rubocop/lib/rubocop/runner.rb:186:in `do_inspection_loop'
  work/rubocop/lib/rubocop/runner.rb:101:in `block in file_offenses'
  work/rubocop/lib/rubocop/runner.rb:111:in `file_offense_cache'
  work/rubocop/lib/rubocop/runner.rb:99:in `file_offenses'
  work/rubocop/lib/rubocop/runner.rb:90:in `process_file'
  work/rubocop/lib/rubocop/runner.rb:68:in `block in each_inspected_file'
  work/rubocop/lib/rubocop/runner.rb:65:in `each'
  work/rubocop/lib/rubocop/runner.rb:65:in `reduce'
  work/rubocop/lib/rubocop/runner.rb:65:in `each_inspected_file'
  work/rubocop/lib/rubocop/runner.rb:57:in `inspect_files'
  work/rubocop/lib/rubocop/runner.rb:36:in `run'
  work/rubocop/lib/rubocop/cli.rb:72:in `execute_runner'
  work/rubocop/lib/rubocop/cli.rb:27:in `run'

@rrosenblum
Copy link
Contributor

I was able to narrow this down to a single cop. Running rubocop -a --only Style/SpaceInsideBlockBraces will produce the infinite loop. I wasn't able to do much more digging than this yet. It looks like there might be some auto-correct tests missing from that cop.

@terryyin
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants