Skip to content

Commit

Permalink
Fix a build error
Browse files Browse the repository at this point in the history
This PR fixes the following build error.

```console
bundle exec rubocop
(snip)

Offenses:

lib/rubocop/cop/mixin/preceding_following_alignment.rb:96:9: W:
[Correctable] Lint/AmbiguousOperatorPrecedence: Wrap expressions with
varying precedence with parentheses to avoid ambiguity.
        range.source[-1] == '=' && line[range.last_column - 1] == '=' ||
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/rubocop/cop/mixin/preceding_following_alignment.rb:101:9: W:
[Correctable] Lint/AmbiguousOperatorPrecedence: Wrap expressions with
varying precedence with parentheses to avoid ambiguity.
        range.source == '<<' && line[range.last_column - 1] == '=' ||
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/rubocop/cop/mixin/preceding_following_alignment.rb:102:11: W:
[Correctable] Lint/AmbiguousOperatorPrecedence: Wrap expressions with
varying precedence with parentheses to avoid ambiguity.
          range.source[-1] == '=' && line[(range.last_column - 2)..(range.last_column - 1)] == '<<'
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/rubocop/cop/mixin/preceding_following_alignment.rb:102:101:
C: Layout/LineLength: Line is too long. [101/100]
          (range.source[-1] == '=' && line[(range.last_column - 2)..(range.last_column - 1)] == '<<')
                                                                                                    ^

1304 files inspected, 4 offenses detected, 3 offenses corrected
```

https://github.com/rubocop/rubocop/runs/3453863216
  • Loading branch information
koic committed Aug 29, 2021
1 parent 9db1c7d commit 2a49404
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/rubocop/cop/mixin/preceding_following_alignment.rb
Expand Up @@ -93,13 +93,15 @@ def aligned_char?(range, line)
end

def aligned_assignment?(range, line)
range.source[-1] == '=' && line[range.last_column - 1] == '=' ||
(range.source[-1] == '=' && line[range.last_column - 1] == '=') ||
aligned_with_append_operator?(range, line)
end

def aligned_with_append_operator?(range, line)
range.source == '<<' && line[range.last_column - 1] == '=' ||
range.source[-1] == '=' && line[(range.last_column - 2)..(range.last_column - 1)] == '<<'
last_column = range.last_column

(range.source == '<<' && line[last_column - 1] == '=') ||
(range.source[-1] == '=' && line[(last_column - 2)..(last_column - 1)] == '<<')
end

def aligned_identical?(range, line)
Expand Down

0 comments on commit 2a49404

Please sign in to comment.