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 caused by Layout/ArgumentAlignment, Layout/ClosingParenthesisIndentation, Layout/MultilineMethodCallIndentation -> Layout/ArgumentAlignment, Layout/ClosingParenthesisIndentation, Layout/FirstArgumentIndentation #9641

Closed
fran-worley opened this issue Mar 26, 2021 · 0 comments
Assignees
Labels

Comments

@fran-worley
Copy link

@fran-worley fran-worley commented Mar 26, 2021

Since updating to v1.11 from v1.10 I have encountered issues running rubocop -A.

Whilst I can and should look at simplifying the code in question, I thought I'd post here anyway as an example of code that breaks rubocop so you can avoid it impacting others.


Expected behavior

Rubocop when run with -A would run and successfully and correct any violations.

Actual behavior

It attempts a number of corrections to the offending line of code:

...path_to_file/present_collection.rb:110:9: C: [Corrected] Layout/MultilineMethodCallIndentation: Align query with Sequel.|( on line 109.
        query,
        ^^^^^
...path_to_file/present_collection.rb:110:15: C: [Corrected] Layout/FirstArgumentIndentation: Indent the first argument one step more than the start of the previous line.
              query,
              ^^^^^
...path_to_file/present_collection.rb:111:9: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
        Sequel.&({ qualified_column(:pin) => true }, Sequel.~(qualified_column(:status_id) => Task::CLOSED_STATUS_ID))
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...path_to_file/present_collection.rb:111:15: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
              Sequel.&({ qualified_column(:pin) => true }, Sequel.~(qualified_column(:status_id) => Task::CLOSED_STATUS_ID))
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...path_to_file/present_collection.rb:112:7: C: [Corrected] Layout/ClosingParenthesisIndentation: Indent ) to column 12 (not 6)
      )
      ^
...path_to_file/present_collection.rb:112:13: C: [Corrected] Layout/ClosingParenthesisIndentation: Indent ) to column 6 (not 12)
            )

before failing with the following error:
Infinite loop detected in /[...path_to_file]/present_collection.rb and caused by Layout/ArgumentAlignment, Layout/ClosingParenthesisIndentation, Layout/MultilineMethodCallIndentation -> Layout/ArgumentAlignment, Layout/ClosingParenthesisIndentation, Layout/FirstArgumentIndentation

Steps to reproduce the problem

# .rubocop.yml

Layout/ParameterAlignment:
  EnforcedStyle: with_fixed_indentation

The offending code is as follows:

class Task
  CLOSED_STATUS_ID = 1

  def my_method(params)
    if params[:include_pinned]
      query = Sequel.|(
        query,
        Sequel.&({ qualified_column(:pin) => true }, Sequel.~(qualified_column(:status_id) => Task::CLOSED_STATUS_ID))
      )
    end
  end
end

RuboCop version

$ [bundle exec] rubocop -V
1.12.0 (using Parser 3.0.0.0, rubocop-ast 1.4.1, running on ruby 2.6.6 x86_64-darwin19)
  - rubocop-performance 1.10.2
@dvandersluis dvandersluis self-assigned this Mar 26, 2021
dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Mar 26, 2021
…ring on method calls that look like operators.

`right_hand_side` was not correctly calculating when the send node looks like an operator but has a receiver (ie. `foo.&`). This was leading to an autocorrection loop with `Layout/ArgumentAlignment`, `Layout/ClosingParenthesisIndentation` and `Layout/FirstArgumentIndentation`.
dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Mar 26, 2021
…ring on method calls that look like operators.

`right_hand_side` was not correctly calculating when the send node looks like an operator but has a receiver (ie. `foo.&`). This was leading to an autocorrection loop with `Layout/ArgumentAlignment`, `Layout/ClosingParenthesisIndentation` and `Layout/FirstArgumentIndentation`.
dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Mar 26, 2021
…ring on method calls that look like operators.

`right_hand_side` was not correctly calculating when the send node looks like an operator but has a receiver (ie. `foo.&`). This was leading to an autocorrection loop with `Layout/ArgumentAlignment`, `Layout/ClosingParenthesisIndentation` and `Layout/FirstArgumentIndentation`.
dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Mar 26, 2021
…ring on method calls that look like operators.

`right_hand_side` was not correctly calculating when the send node looks like an operator but has a receiver (ie. `foo.&`). This was leading to an autocorrection loop with `Layout/ArgumentAlignment`, `Layout/ClosingParenthesisIndentation` and `Layout/FirstArgumentIndentation`.
dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Mar 26, 2021
…ring on method calls that look like operators.

`right_hand_side` was not correctly calculating when the send node looks like an operator but has a receiver (ie. `foo.&`). This was leading to an autocorrection loop with `Layout/ArgumentAlignment`, `Layout/ClosingParenthesisIndentation` and `Layout/FirstArgumentIndentation`.
@koic koic closed this in #9642 Mar 27, 2021
koic added a commit that referenced this issue Mar 27, 2021
[Fix #9641] Fix `Layout/MultilineMethodCallIndentation` triggering on method calls that look like operators
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants