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 with trailing style still fails autocorrect with heredoc arguments #10165

Closed
tsugimoto opened this issue Oct 5, 2021 · 1 comment · Fixed by #10168
Closed
Assignees
Labels

Comments

@tsugimoto
Copy link
Contributor

#10140 is not fully resolved when heredocs are passed as method arguments, like below code.

foo(<<END).split
  text
END

Expected behavior

Should not mark offenses, should not autocorrect, and complete without errors.

Actual behavior

Offense is marked, autocorrect is attempted and errors with Infinite loop detected backtrace.

Steps to reproduce the problem

rubocop.yml

AllCops:
  NewCops: enable

Layout/DotPosition:
  EnforcedStyle: trailing

a.rb

# frozen_string_literal: true

foo(<<END).split
  text
END
$ rubocop --auto-correct --only Layout/DotPosition
Inspecting 1 file
C

Offenses:

a.rb:3:11: C: [Corrected] Layout/DotPosition: Place the . on the previous line, together with the method call receiver.
foo(<<END).split
          ^

0 files inspected, 1 offense detected, 1 offense corrected
Infinite loop detected in /Users/tsugimoto/Desktop/rb/a.rb and caused by Layout/DotPosition
/Users/tsugimoto/.anyenv/envs/rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.22.1/lib/rubocop/runner.rb:298:in `check_for_infinite_loop'
/Users/tsugimoto/.anyenv/envs/rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.22.1/lib/rubocop/runner.rb:281:in `block in iterate_until_no_changes'
/Users/tsugimoto/.anyenv/envs/rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.22.1/lib/rubocop/runner.rb:280:in `loop'
/Users/tsugimoto/.anyenv/envs/rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.22.1/lib/rubocop/runner.rb:280:in `iterate_until_no_changes'
/Users/tsugimoto/.anyenv/envs/rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.22.1/lib/rubocop/runner.rb:249:in `do_inspection_loop'
/Users/tsugimoto/.anyenv/envs/rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.22.1/lib/rubocop/runner.rb:130:in `block in file_offenses'
/Users/tsugimoto/.anyenv/envs/rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.22.1/lib/rubocop/runner.rb:155:in `file_offense_cache'
/Users/tsugimoto/.anyenv/envs/rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.22.1/lib/rubocop/runner.rb:129:in `file_offenses'
/Users/tsugimoto/.anyenv/envs/rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.22.1/lib/rubocop/runner.rb:120:in `process_file'
/Users/tsugimoto/.anyenv/envs/rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.22.1/lib/rubocop/runner.rb:101:in `block in each_inspected_file'
/Users/tsugimoto/.anyenv/envs/rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.22.1/lib/rubocop/runner.rb:100:in `each'
/Users/tsugimoto/.anyenv/envs/rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.22.1/lib/rubocop/runner.rb:100:in `reduce'
/Users/tsugimoto/.anyenv/envs/rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.22.1/lib/rubocop/runner.rb:100:in `each_inspected_file'
/Users/tsugimoto/.anyenv/envs/rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.22.1/lib/rubocop/runner.rb:86:in `inspect_files'
/Users/tsugimoto/.anyenv/envs/rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.22.1/lib/rubocop/runner.rb:47:in `run'
/Users/tsugimoto/.anyenv/envs/rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.22.1/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
/Users/tsugimoto/.anyenv/envs/rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.22.1/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
/Users/tsugimoto/.anyenv/envs/rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.22.1/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
/Users/tsugimoto/.anyenv/envs/rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.22.1/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
/Users/tsugimoto/.anyenv/envs/rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.22.1/lib/rubocop/cli/command.rb:11:in `run'
/Users/tsugimoto/.anyenv/envs/rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.22.1/lib/rubocop/cli/environment.rb:18:in `run'
/Users/tsugimoto/.anyenv/envs/rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.22.1/lib/rubocop/cli.rb:71:in `run_command'
/Users/tsugimoto/.anyenv/envs/rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.22.1/lib/rubocop/cli.rb:78:in `execute_runners'
/Users/tsugimoto/.anyenv/envs/rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.22.1/lib/rubocop/cli.rb:47:in `run'
/Users/tsugimoto/.anyenv/envs/rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.22.1/exe/rubocop:12:in `block in <top (required)>'
/Users/tsugimoto/.anyenv/envs/rbenv/versions/2.7.3/lib/ruby/2.7.0/benchmark.rb:308:in `realtime'
/Users/tsugimoto/.anyenv/envs/rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.22.1/exe/rubocop:12:in `<top (required)>'
/Users/tsugimoto/.anyenv/envs/rbenv/versions/2.7.3/bin/rubocop:23:in `load'
/Users/tsugimoto/.anyenv/envs/rbenv/versions/2.7.3/bin/rubocop:23:in `<main>'
$ 

RuboCop version

$ rubocop -V
1.22.1 (using Parser 3.0.2.0, rubocop-ast 1.12.0, running on ruby 2.7.3 x86_64-darwin20)
$ 
@koic koic added the bug label Oct 5, 2021
@dvandersluis dvandersluis self-assigned this Oct 5, 2021
@dvandersluis
Copy link
Member

I'll take another look, thanks for the report.

dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Oct 5, 2021
… selector and receiver are on the same line.
dvandersluis added a commit that referenced this issue Oct 6, 2021
[Fix #10165] Fix `Layout/DotPosition` false positives when the selector and receiver are on the same line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants