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 false positive for heredocs with trailing style #10140

Closed
luizkowalski opened this issue Sep 29, 2021 · 0 comments · Fixed by #10141
Closed

Layout/DotPosition false positive for heredocs with trailing style #10140

luizkowalski opened this issue Sep 29, 2021 · 0 comments · Fixed by #10141
Assignees
Labels

Comments

@luizkowalski
Copy link

luizkowalski commented Sep 29, 2021

I have a method like this

def generate_balance_history
    Rails.cache.fetch("balance_result_for_#{@organization.id}", expires_in: 5.minutes) do
      sql = <<~SQL.squish
        SELECT DISTINCT (value_date::DATE),
        ....

I just updated rubocop to 1.22.0 and now I get this error when I try to run rubocop -A to autofix the issues

app/controllers/admin/transactions_controller.rb:25:19: C: [Corrected] Layout/DotPosition: Place the . on the previous line, together with the method call receiver.
      sql = <<~SQL.squish
                  ^

39 files inspected, 1 offense detected, 1 offense corrected
Infinite loop detected in /Users/luizkowalski/rails_dev/abi-prototype/app/controllers/admin/transactions_controller.rb and caused by Layout/DotPosition
/Users/luizkowalski/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.0/lib/rubocop/runner.rb:298:in `check_for_infinite_loop'
/Users/luizkowalski/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.0/lib/rubocop/runner.rb:281:in `block in iterate_until_no_changes'

this is the full trace running with debug:

app/controllers/admin/transactions_controller.rb:25:19: C: [Corrected] Layout/DotPosition: Place the . on the previous line, together with the method call receiver.
      sql = <<~SQL.squish
                  ^

39 files inspected, 1 offense detected, 1 offense corrected
Infinite loop detected in /Users/luizkowalski/rails_dev/abi-prototype/app/controllers/admin/transactions_controller.rb and caused by Layout/DotPosition
/Users/luizkowalski/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.0/lib/rubocop/runner.rb:298:in `check_for_infinite_loop'
/Users/luizkowalski/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.0/lib/rubocop/runner.rb:281:in `block in iterate_until_no_changes'
/Users/luizkowalski/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.0/lib/rubocop/runner.rb:280:in `loop'
/Users/luizkowalski/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.0/lib/rubocop/runner.rb:280:in `iterate_until_no_changes'
/Users/luizkowalski/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.0/lib/rubocop/runner.rb:249:in `do_inspection_loop'
/Users/luizkowalski/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.0/lib/rubocop/runner.rb:130:in `block in file_offenses'
/Users/luizkowalski/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.0/lib/rubocop/runner.rb:155:in `file_offense_cache'
/Users/luizkowalski/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.0/lib/rubocop/runner.rb:129:in `file_offenses'
/Users/luizkowalski/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.0/lib/rubocop/runner.rb:120:in `process_file'
/Users/luizkowalski/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.0/lib/rubocop/runner.rb:101:in `block in each_inspected_file'
/Users/luizkowalski/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.0/lib/rubocop/runner.rb:100:in `each'
/Users/luizkowalski/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.0/lib/rubocop/runner.rb:100:in `reduce'
/Users/luizkowalski/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.0/lib/rubocop/runner.rb:100:in `each_inspected_file'
/Users/luizkowalski/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.0/lib/rubocop/runner.rb:86:in `inspect_files'
/Users/luizkowalski/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.0/lib/rubocop/runner.rb:47:in `run'
/Users/luizkowalski/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.0/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
/Users/luizkowalski/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.0/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
/Users/luizkowalski/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.0/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
/Users/luizkowalski/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.0/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
/Users/luizkowalski/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.0/lib/rubocop/cli/command.rb:11:in `run'
/Users/luizkowalski/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.0/lib/rubocop/cli/environment.rb:18:in `run'
/Users/luizkowalski/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.0/lib/rubocop/cli.rb:71:in `run_command'
/Users/luizkowalski/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.0/lib/rubocop/cli.rb:78:in `execute_runners'
/Users/luizkowalski/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.0/lib/rubocop/cli.rb:47:in `run'
/Users/luizkowalski/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.0/exe/rubocop:12:in `block in <top (required)>'
/Users/luizkowalski/.rbenv/versions/3.0.2/lib/ruby/3.0.0/benchmark.rb:308:in `realtime'
/Users/luizkowalski/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.0/exe/rubocop:12:in `<top (required)>'
/Users/luizkowalski/.rbenv/versions/3.0.2/bin/rubocop:25:in `load'
/Users/luizkowalski/.rbenv/versions/3.0.2/bin/rubocop:25:in `<top (required)>'
/Users/luizkowalski/.rbenv/versions/3.0.2/lib/ruby/site_ruby/3.0.0/bundler/cli/exec.rb:58:in `load'
/Users/luizkowalski/.rbenv/versions/3.0.2/lib/ruby/site_ruby/3.0.0/bundler/cli/exec.rb:58:in `kernel_load'
/Users/luizkowalski/.rbenv/versions/3.0.2/lib/ruby/site_ruby/3.0.0/bundler/cli/exec.rb:23:in `run'
/Users/luizkowalski/.rbenv/versions/3.0.2/lib/ruby/site_ruby/3.0.0/bundler/cli.rb:478:in `exec'
/Users/luizkowalski/.rbenv/versions/3.0.2/lib/ruby/site_ruby/3.0.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/Users/luizkowalski/.rbenv/versions/3.0.2/lib/ruby/site_ruby/3.0.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/Users/luizkowalski/.rbenv/versions/3.0.2/lib/ruby/site_ruby/3.0.0/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/Users/luizkowalski/.rbenv/versions/3.0.2/lib/ruby/site_ruby/3.0.0/bundler/cli.rb:31:in `dispatch'
/Users/luizkowalski/.rbenv/versions/3.0.2/lib/ruby/site_ruby/3.0.0/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/Users/luizkowalski/.rbenv/versions/3.0.2/lib/ruby/site_ruby/3.0.0/bundler/cli.rb:25:in `start'
/Users/luizkowalski/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bundler-2.2.28/exe/bundle:49:in `block in <top (required)>'
/Users/luizkowalski/.rbenv/versions/3.0.2/lib/ruby/site_ruby/3.0.0/bundler/friendly_errors.rb:128:in `with_friendly_errors'
/Users/luizkowalski/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bundler-2.2.28/exe/bundle:37:in `<top (required)>'
/Users/luizkowalski/.rbenv/versions/3.0.2/bin/bundle:23:in `load'
/Users/luizkowalski/.rbenv/versions/3.0.2/bin/bundle:23:in `<main>'

Steps to reproduce the problem

Most likely just try what I posted with HEREDOC

Version:

1.22.0 (using Parser 3.0.2.0, rubocop-ast 1.12.0, running on ruby 3.0.2 arm64-darwin20)
  - rubocop-minitest 0.15.1
  - rubocop-performance 1.11.5
  - rubocop-rails 2.12.2
@dvandersluis dvandersluis self-assigned this Sep 29, 2021
dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Sep 29, 2021
…a heredoc receives a method on the same line as the start sigil in `trailing` style.
@dvandersluis dvandersluis changed the title Rubocop breaks with infinite loop when using HEREDOCS Layout/DotPosition false positive for heredocs with trailing style Sep 29, 2021
koic added a commit that referenced this issue Sep 29, 2021
[Fix #10140] Fix false positive for `Layout/DotPosition` when a heredoc receives a method on the same line as the start sigil in `trailing` style
@koic koic pinned this issue Oct 1, 2021
mshibuya added a commit to railsadminteam/rails_admin that referenced this issue Oct 2, 2021
@koic koic unpinned this issue Oct 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants