Skip to content

Commit

Permalink
Suppress Lint/RequireRangeParentheses offense
Browse files Browse the repository at this point in the history
Follow up #10792.

This commit suppresses the following `Lint/RequireRangeParentheses` offense.

```console
% bundle exec rubocop
(snip)

Offenses:

lib/rubocop/cop/mixin/percent_array.rb:101:13: W:
Lint/RequireRangeParentheses: Wrap the endless range literal
node.children[0].location.expression.end_pos... to avoid precedence
ambiguity.
            node.children[0].location.expression.end_pos... ...
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1 file inspected, 1 offense detected
```
  • Loading branch information
koic committed Jul 7, 2022
1 parent 5a9cd67 commit 4868b0e
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/rubocop/cop/mixin/percent_array.rb
Expand Up @@ -98,8 +98,7 @@ def build_bracketed_array_with_appropriate_whitespace(elements:, node:)
def whitespace_between(node)
if node.children.length >= 2
node.source[
node.children[0].location.expression.end_pos...
node.children[1].location.expression.begin_pos
node.children[0].loc.expression.end_pos...node.children[1].loc.expression.begin_pos
]
else
' '
Expand All @@ -112,7 +111,7 @@ def whitespace_between(node)
# @param [RuboCop::AST::ArrayNode] node
# @return [String]
def whitespace_leading(node)
node.source[node.location.begin.end_pos...node.children[0].location.expression.begin_pos]
node.source[node.loc.begin.end_pos...node.children[0].loc.expression.begin_pos]
end

# Provides trailing whitespace for building a bracketed array.
Expand All @@ -121,7 +120,7 @@ def whitespace_leading(node)
# @param [RuboCop::AST::ArrayNode] node
# @return [String]
def whitespace_trailing(node)
node.source[node.children[-1].location.expression.end_pos...node.location.end.begin_pos]
node.source[node.children[-1].loc.expression.end_pos...node.loc.end.begin_pos]
end
end
end
Expand Down

0 comments on commit 4868b0e

Please sign in to comment.