Layout/DotPosition
auto correct failed with Infinite loop detected, also selects heredocs?
#10150
Labels
Layout/DotPosition
auto correct failed with Infinite loop detected, also selects heredocs?
#10150
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:
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
The text was updated successfully, but these errors were encountered: