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 Layout/DotPosition with EnforcedStyle: trailing #10208

Closed
sue445 opened this issue Oct 23, 2021 · 1 comment
Closed

Comments

@sue445
Copy link
Contributor

sue445 commented Oct 23, 2021

Infinite loop detected in Layout/DotPosition with EnforcedStyle: trailing

Example code

Gemfile

# frozen_string_literal: true

source 'https://rubygems.org'

git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }

gem 'rubocop', '1.22.2'

.rubocop.yml

AllCops:
  NewCops: disable

Layout/DotPosition:
  EnforcedStyle: trailing

bug_report.rb

array.
  map {}.uniq

Expected behavior

auto corrected with no error.

Actual behavior

bundle exec rubocop --only Layout/DotPosition --debug
$ bundle exec rubocop --only Layout/DotPosition --debug
For /Users/sue445/workspace/github.com/sue445/20211023_rubocop_bug_report: configuration from /Users/sue445/workspace/github.com/sue445/20211023_rubocop_bug_report/.rubocop.yml
Default configuration from /Users/sue445/workspace/github.com/sue445/20211023_rubocop_bug_report/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.2/config/default.yml
Use parallel by default.
Running parallel inspection
Inspecting 2 files
Scanning /Users/sue445/workspace/github.com/sue445/20211023_rubocop_bug_report/Gemfile
Loading cache from /Users/sue445/.cache/rubocop_cache/7f0eee2f0b87c119e94624d01ad756c759477948/8c90a000d1999bcca87cf483d4740a636a6afc04/ffbe561692eebdbe99f29673aa6c1d017ca91772
.Scanning /Users/sue445/workspace/github.com/sue445/20211023_rubocop_bug_report/bug_report.rb
Loading cache from /Users/sue445/.cache/rubocop_cache/7f0eee2f0b87c119e94624d01ad756c759477948/8c90a000d1999bcca87cf483d4740a636a6afc04/9ce767ae58d712a1e2d4fe9bcaf78522e1d6bf91
C

Offenses:

bug_report.rb:2:9: C: [Correctable] Layout/DotPosition: Place the . on the previous line, together with the method call receiver.
  map {}.uniq
        ^

2 files inspected, 1 offense detected, 1 offense auto-correctable
Finished in 0.3527680000006512 seconds
bundle exec rubocop --only Layout/DotPosition --debug --auto-correct
$ bundle exec rubocop --only Layout/DotPosition --debug --auto-correct
For /Users/sue445/workspace/github.com/sue445/20211023_rubocop_bug_report: configuration from /Users/sue445/workspace/github.com/sue445/20211023_rubocop_bug_report/.rubocop.yml
Default configuration from /Users/sue445/workspace/github.com/sue445/20211023_rubocop_bug_report/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.2/config/default.yml
Inspecting 2 files
Scanning /Users/sue445/workspace/github.com/sue445/20211023_rubocop_bug_report/Gemfile
.Scanning /Users/sue445/workspace/github.com/sue445/20211023_rubocop_bug_report/bug_report.rb
C

Offenses:

bug_report.rb:2:9: C: [Corrected] Layout/DotPosition: Place the . on the previous line, together with the method call receiver.
  map {}.uniq
        ^

1 file inspected, 1 offense detected, 1 offense corrected
Infinite loop detected in /Users/sue445/workspace/github.com/sue445/20211023_rubocop_bug_report/bug_report.rb and caused by Layout/DotPosition
/Users/sue445/workspace/github.com/sue445/20211023_rubocop_bug_report/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.2/lib/rubocop/runner.rb:298:in `check_for_infinite_loop'
/Users/sue445/workspace/github.com/sue445/20211023_rubocop_bug_report/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.2/lib/rubocop/runner.rb:281:in `block in iterate_until_no_changes'
/Users/sue445/workspace/github.com/sue445/20211023_rubocop_bug_report/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.2/lib/rubocop/runner.rb:280:in `loop'
/Users/sue445/workspace/github.com/sue445/20211023_rubocop_bug_report/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.2/lib/rubocop/runner.rb:280:in `iterate_until_no_changes'
/Users/sue445/workspace/github.com/sue445/20211023_rubocop_bug_report/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.2/lib/rubocop/runner.rb:249:in `do_inspection_loop'
/Users/sue445/workspace/github.com/sue445/20211023_rubocop_bug_report/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.2/lib/rubocop/runner.rb:130:in `block in file_offenses'
/Users/sue445/workspace/github.com/sue445/20211023_rubocop_bug_report/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.2/lib/rubocop/runner.rb:155:in `file_offense_cache'
/Users/sue445/workspace/github.com/sue445/20211023_rubocop_bug_report/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.2/lib/rubocop/runner.rb:129:in `file_offenses'
/Users/sue445/workspace/github.com/sue445/20211023_rubocop_bug_report/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.2/lib/rubocop/runner.rb:120:in `process_file'
/Users/sue445/workspace/github.com/sue445/20211023_rubocop_bug_report/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.2/lib/rubocop/runner.rb:101:in `block in each_inspected_file'
/Users/sue445/workspace/github.com/sue445/20211023_rubocop_bug_report/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.2/lib/rubocop/runner.rb:100:in `each'
/Users/sue445/workspace/github.com/sue445/20211023_rubocop_bug_report/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.2/lib/rubocop/runner.rb:100:in `reduce'
/Users/sue445/workspace/github.com/sue445/20211023_rubocop_bug_report/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.2/lib/rubocop/runner.rb:100:in `each_inspected_file'
/Users/sue445/workspace/github.com/sue445/20211023_rubocop_bug_report/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.2/lib/rubocop/runner.rb:86:in `inspect_files'
/Users/sue445/workspace/github.com/sue445/20211023_rubocop_bug_report/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.2/lib/rubocop/runner.rb:47:in `run'
/Users/sue445/workspace/github.com/sue445/20211023_rubocop_bug_report/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.2/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
/Users/sue445/workspace/github.com/sue445/20211023_rubocop_bug_report/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.2/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
/Users/sue445/workspace/github.com/sue445/20211023_rubocop_bug_report/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.2/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
/Users/sue445/workspace/github.com/sue445/20211023_rubocop_bug_report/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.2/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
/Users/sue445/workspace/github.com/sue445/20211023_rubocop_bug_report/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.2/lib/rubocop/cli/command.rb:11:in `run'
/Users/sue445/workspace/github.com/sue445/20211023_rubocop_bug_report/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.2/lib/rubocop/cli/environment.rb:18:in `run'
/Users/sue445/workspace/github.com/sue445/20211023_rubocop_bug_report/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.2/lib/rubocop/cli.rb:71:in `run_command'
/Users/sue445/workspace/github.com/sue445/20211023_rubocop_bug_report/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.2/lib/rubocop/cli.rb:78:in `execute_runners'
/Users/sue445/workspace/github.com/sue445/20211023_rubocop_bug_report/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.2/lib/rubocop/cli.rb:47:in `run'
/Users/sue445/workspace/github.com/sue445/20211023_rubocop_bug_report/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.2/exe/rubocop:12:in `block in <top (required)>'
/Users/sue445/.rbenv/versions/3.0.2/lib/ruby/3.0.0/benchmark.rb:308:in `realtime'
/Users/sue445/workspace/github.com/sue445/20211023_rubocop_bug_report/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.2/exe/rubocop:12:in `<top (required)>'
/Users/sue445/workspace/github.com/sue445/20211023_rubocop_bug_report/vendor/bundle/ruby/3.0.0/bin/rubocop:23:in `load'
/Users/sue445/workspace/github.com/sue445/20211023_rubocop_bug_report/vendor/bundle/ruby/3.0.0/bin/rubocop:23:in `<top (required)>'
/Users/sue445/.rbenv/versions/3.0.2/lib/ruby/3.0.0/bundler/cli/exec.rb:63:in `load'
/Users/sue445/.rbenv/versions/3.0.2/lib/ruby/3.0.0/bundler/cli/exec.rb:63:in `kernel_load'
/Users/sue445/.rbenv/versions/3.0.2/lib/ruby/3.0.0/bundler/cli/exec.rb:28:in `run'
/Users/sue445/.rbenv/versions/3.0.2/lib/ruby/3.0.0/bundler/cli.rb:474:in `exec'
/Users/sue445/.rbenv/versions/3.0.2/lib/ruby/3.0.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/Users/sue445/.rbenv/versions/3.0.2/lib/ruby/3.0.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/Users/sue445/.rbenv/versions/3.0.2/lib/ruby/3.0.0/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/Users/sue445/.rbenv/versions/3.0.2/lib/ruby/3.0.0/bundler/cli.rb:30:in `dispatch'
/Users/sue445/.rbenv/versions/3.0.2/lib/ruby/3.0.0/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/Users/sue445/.rbenv/versions/3.0.2/lib/ruby/3.0.0/bundler/cli.rb:24:in `start'
/Users/sue445/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bundler-2.2.22/libexec/bundle:49:in `block in <top (required)>'
/Users/sue445/.rbenv/versions/3.0.2/lib/ruby/3.0.0/bundler/friendly_errors.rb:128:in `with_friendly_errors'
/Users/sue445/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bundler-2.2.22/libexec/bundle:37:in `<top (required)>'
/Users/sue445/.rbenv/versions/3.0.2/bin/bundle:23:in `load'
/Users/sue445/.rbenv/versions/3.0.2/bin/bundle:23:in `<main>'
Finished in 0.2694740000006277 seconds

If I don't use EnforcedStyle: trailing, no error will occur

Steps to reproduce the problem

  1. Save the example code at the beginning to local
  2. Run bundle exec rubocop --only Layout/DotPosition --debug --auto-correct

RuboCop version

$ bundle exec rubocop -V
1.22.2 (using Parser 3.0.2.0, rubocop-ast 1.12.0, running on ruby 3.0.2 x86_64-darwin20)

1.22.1 is no problem

@koic
Copy link
Member

koic commented Oct 23, 2021

This issue resolved by #10207 and it will be fixed in the next release. Thank you.

@koic koic closed this as completed Oct 23, 2021
ivgiuliani added a commit to gocardless/bucket-store that referenced this issue Oct 26, 2021
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

3 participants