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

Layout/DotPosition auto correct failed with Infinite loop detected, also selects heredocs? #10150

Closed
ahjmorton opened this issue Oct 1, 2021 · 2 comments

Comments

@ahjmorton
Copy link

ahjmorton commented Oct 1, 2021

Expected behavior

When trying to auto correct a Rubocop error with Layout/DotPosition I would expect it to be fixed as it's a correctable problem. In addition I'm not sure heredocs allow the dot to be on the next line.

Actual behavior

It selects the heredocs as errors.
When running the autocorrect it corrects two cases then fails with "infinite loop detected".

Command / stack trace below:

Projects/service [dependabot/bundler/rubocop-1.22.0] » bundle exec rubocop --debug -A For /Users/andrewmorton/Projects/service: configuration from /Users/andrewmorton/Projects/service/.rubocop.yml Inheriting configuration from /Users/andrewmorton/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/gc_ruboconfig-2.28.0/rubocop.yml configuration from /Users/andrewmorton/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-rspec-2.5.0/config/default.yml configuration from /Users/andrewmorton/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-rspec-2.5.0/config/default.yml Default configuration from /Users/andrewmorton/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.22.0/config/default.yml configuration from /Users/andrewmorton/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-performance-1.11.5/config/default.yml configuration from /Users/andrewmorton/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-performance-1.11.5/config/default.yml Inspecting 322 files ... Skipping scan of 321 other files ... Scanning /Users/andrewmorton/Projects/abacus/.pryrc /Users/andrewmorton/.cache/rubocop_cache/6dd46ebe8c7a02683e489e4c8aa0c910f8413621/a787bfe2a02a843b5735436d51733fbf12391c24/a200cfa1c5b604bf3920cede30a3a7f1f36e80c5 .Scanning /Users/andrewmorton/Projects/service/app/business_logic/reprocess_dropped_messages.rb C

Offenses:

app/business_logic/reprocess_dropped_messages.rb:12:40: C: [Corrected] Layout/DotPosition: Place the . on the previous line, together with the method call receiver. (https://rubystyle.guide#consistent-multi-line-chains)
LONG_STRING_AS_A_HEREDOC = <<~SQL.squish.strip_heredoc.freeze
^
app/business_logic/reprocess_dropped_messages.rb:35:41: C: [Corrected] Layout/DotPosition: Place the . on the previous line, together with the method call receiver. (https://rubystyle.guide#consistent-multi-line-chains)
ANOTHER_LONG_STRING_AS_A_HEREDOC = <<~SQL.squish.strip_heredoc.freeze
^

50 files inspected, 2 offenses detected, 2 offenses corrected
Infinite loop detected in /Users/andrewmorton/Projects/abacus/app/business_logic/reprocess_dropped_messages.rb and caused by Layout/DotPosition
/Users/andrewmorton/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.22.0/lib/rubocop/runner.rb:298:in check_for_infinite_loop' /Users/andrewmorton/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.22.0/lib/rubocop/runner.rb:281:in block in iterate_until_no_changes'
/Users/andrewmorton/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.22.0/lib/rubocop/runner.rb:280:in loop' /Users/andrewmorton/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.22.0/lib/rubocop/runner.rb:280:in iterate_until_no_changes'
/Users/andrewmorton/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.22.0/lib/rubocop/runner.rb:249:in do_inspection_loop' /Users/andrewmorton/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.22.0/lib/rubocop/runner.rb:130:in block in file_offenses'
/Users/andrewmorton/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.22.0/lib/rubocop/runner.rb:155:in file_offense_cache' /Users/andrewmorton/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.22.0/lib/rubocop/runner.rb:129:in file_offenses'
/Users/andrewmorton/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.22.0/lib/rubocop/runner.rb:120:in process_file' /Users/andrewmorton/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.22.0/lib/rubocop/runner.rb:101:in block in each_inspected_file'
/Users/andrewmorton/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.22.0/lib/rubocop/runner.rb:100:in each' /Users/andrewmorton/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.22.0/lib/rubocop/runner.rb:100:in reduce'
/Users/andrewmorton/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.22.0/lib/rubocop/runner.rb:100:in each_inspected_file' /Users/andrewmorton/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.22.0/lib/rubocop/runner.rb:86:in inspect_files'
/Users/andrewmorton/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.22.0/lib/rubocop/runner.rb:47:in run' /Users/andrewmorton/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.22.0/lib/rubocop/cli/command/execute_runner.rb:26:in block in execute_runner'
/Users/andrewmorton/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.22.0/lib/rubocop/cli/command/execute_runner.rb:52:in with_redirect' /Users/andrewmorton/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.22.0/lib/rubocop/cli/command/execute_runner.rb:25:in execute_runner'
/Users/andrewmorton/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.22.0/lib/rubocop/cli/command/execute_runner.rb:17:in run' /Users/andrewmorton/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.22.0/lib/rubocop/cli/command.rb:11:in run'
/Users/andrewmorton/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.22.0/lib/rubocop/cli/environment.rb:18:in run' /Users/andrewmorton/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.22.0/lib/rubocop/cli.rb:71:in run_command'
/Users/andrewmorton/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.22.0/lib/rubocop/cli.rb:78:in execute_runners' /Users/andrewmorton/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.22.0/lib/rubocop/cli.rb:47:in run'
/Users/andrewmorton/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.22.0/exe/rubocop:12:in block in <top (required)>' /Users/andrewmorton/.rbenv/versions/2.7.2/lib/ruby/2.7.0/benchmark.rb:308:in realtime'
/Users/andrewmorton/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.22.0/exe/rubocop:12:in <top (required)>' /Users/andrewmorton/.rbenv/versions/2.7.2/bin/rubocop:23:in load'
/Users/andrewmorton/.rbenv/versions/2.7.2/bin/rubocop:23:in <top (required)>' /Users/andrewmorton/.rbenv/versions/2.7.2/lib/ruby/2.7.0/bundler/cli/exec.rb:63:in load'
/Users/andrewmorton/.rbenv/versions/2.7.2/lib/ruby/2.7.0/bundler/cli/exec.rb:63:in kernel_load' /Users/andrewmorton/.rbenv/versions/2.7.2/lib/ruby/2.7.0/bundler/cli/exec.rb:28:in run'
/Users/andrewmorton/.rbenv/versions/2.7.2/lib/ruby/2.7.0/bundler/cli.rb:476:in exec' /Users/andrewmorton/.rbenv/versions/2.7.2/lib/ruby/2.7.0/bundler/vendor/thor/lib/thor/command.rb:27:in run'
/Users/andrewmorton/.rbenv/versions/2.7.2/lib/ruby/2.7.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in invoke_command' /Users/andrewmorton/.rbenv/versions/2.7.2/lib/ruby/2.7.0/bundler/vendor/thor/lib/thor.rb:399:in dispatch'
/Users/andrewmorton/.rbenv/versions/2.7.2/lib/ruby/2.7.0/bundler/cli.rb:30:in dispatch' /Users/andrewmorton/.rbenv/versions/2.7.2/lib/ruby/2.7.0/bundler/vendor/thor/lib/thor/base.rb:476:in start'
/Users/andrewmorton/.rbenv/versions/2.7.2/lib/ruby/2.7.0/bundler/cli.rb:24:in start' /Users/andrewmorton/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/libexec/bundle:46:in block in <top (required)>'
/Users/andrewmorton/.rbenv/versions/2.7.2/lib/ruby/2.7.0/bundler/friendly_errors.rb:123:in with_friendly_errors' /Users/andrewmorton/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/libexec/bundle:34:in <top (required)>'
/Users/andrewmorton/.rbenv/versions/2.7.2/bin/bundle:23:in load' /Users/andrewmorton/.rbenv/versions/2.7.2/bin/bundle:23:in

'
Finished in 0.7263179998844862 seconds

Steps to reproduce the problem

With this new rule enabled I have 12 offenses of the cop above detected across multiple files. The autocorrect appears to fail after correcting all the items in the first file.

RuboCop version

Projects/service [dependabot/bundler/rubocop-1.22.0] » bundle exec rubocop -V
1.22.0 (using Parser 3.0.2.0, rubocop-ast 1.12.0, running on ruby 2.7.2 x86_64-darwin20)
  - rubocop-performance 1.11.5
  - rubocop-rspec 2.5.0
@koic
Copy link
Member

koic commented Oct 1, 2021

This issue is a dup with #10140 and resolved by #10141. Thank you for your feedback!

@koic koic closed this as completed Oct 1, 2021
@koic koic added the duplicate label Oct 1, 2021
@koic
Copy link
Member

koic commented Oct 1, 2021

And I pinned the issue #10140 until the next new version will be released.

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

No branches or pull requests

2 participants