From 4868b0e7bdb588eccd2ea6c1b775b35421946009 Mon Sep 17 00:00:00 2001 From: Koichi ITO Date: Fri, 8 Jul 2022 00:21:49 +0900 Subject: [PATCH] Suppress `Lint/RequireRangeParentheses` offense Follow up https://github.com/rubocop/rubocop/pull/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 ``` --- lib/rubocop/cop/mixin/percent_array.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/rubocop/cop/mixin/percent_array.rb b/lib/rubocop/cop/mixin/percent_array.rb index faed8fe4341..55877d266be 100644 --- a/lib/rubocop/cop/mixin/percent_array.rb +++ b/lib/rubocop/cop/mixin/percent_array.rb @@ -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 ' ' @@ -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. @@ -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