From 09256644569fd381a46f67779d2318aaa5483bb4 Mon Sep 17 00:00:00 2001 From: Koichi ITO Date: Sat, 3 Jul 2021 23:34:38 +0900 Subject: [PATCH] Suppress RuboCop 1.8's new offense This PR suppresses and auto-corrects the following RuboCop 1.8's new offense. ```console % bundle exec rubocop -a (snip) Inspecting 3 files CCC Offenses: lib/rubocop/ast/node_pattern/compiler/sequence_subcompiler.rb:350:13: C: [Corrected] Layout/LineEndStringConcatenationIndentation: Indent the first part of a string concatenated with backslash. "#{@cur_child_var} || true)" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lib/rubocop/ast/node_pattern/parser.rb:55:13: C: [Corrected] Layout/LineEndStringConcatenationIndentation: Align parts of a string concatenated with backslash. "but got expression matching multiple elements: #{detail}" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ spec/rubocop/ast/node_pattern_spec.rb:948:9: C: [Corrected] Layout/LineEndStringConcatenationIndentation: Indent the first part of a string concatenated with backslash. '[!nil {($_ sym $_) (send ($_ $_) :object_id)}]}' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 files inspected, 3 offenses detected, 3 offenses corrected ``` --- lib/rubocop/ast/node_pattern/compiler/sequence_subcompiler.rb | 2 +- lib/rubocop/ast/node_pattern/parser.rb | 2 +- spec/rubocop/ast/node_pattern_spec.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/rubocop/ast/node_pattern/compiler/sequence_subcompiler.rb b/lib/rubocop/ast/node_pattern/compiler/sequence_subcompiler.rb index fffd9d342..124ef5a66 100644 --- a/lib/rubocop/ast/node_pattern/compiler/sequence_subcompiler.rb +++ b/lib/rubocop/ast/node_pattern/compiler/sequence_subcompiler.rb @@ -347,7 +347,7 @@ def use_index_from_end def compile_loop_advance(to = '+=1') # The `#{@cur_child_var} ||` is just to avoid unused variable warning "(#{@cur_child_var} = #{@seq_var}.children[#{@cur_index_var} #{to}]; " \ - "#{@cur_child_var} || true)" + "#{@cur_child_var} || true)" end def compile_loop(term) diff --git a/lib/rubocop/ast/node_pattern/parser.rb b/lib/rubocop/ast/node_pattern/parser.rb index db8f3d6c9..c1df451b7 100644 --- a/lib/rubocop/ast/node_pattern/parser.rb +++ b/lib/rubocop/ast/node_pattern/parser.rb @@ -52,7 +52,7 @@ def enforce_unary(node) detail = node.loc&.expression&.source || node.to_s raise NodePattern::Invalid, 'parse error, expected unary node pattern ' \ - "but got expression matching multiple elements: #{detail}" + "but got expression matching multiple elements: #{detail}" end # Overrides Racc::Parser's method: diff --git a/spec/rubocop/ast/node_pattern_spec.rb b/spec/rubocop/ast/node_pattern_spec.rb index a2a6638a3..af7181bef 100644 --- a/spec/rubocop/ast/node_pattern_spec.rb +++ b/spec/rubocop/ast/node_pattern_spec.rb @@ -945,7 +945,7 @@ def not_match_codes(*codes) context 'with complex nesting' do let(:pattern) do '{(send {$int $float} {$:inc $:dec}) ' \ - '[!nil {($_ sym $_) (send ($_ $_) :object_id)}]}' + '[!nil {($_ sym $_) (send ($_ $_) :object_id)}]}' end let(:ruby) { '10.object_id' } let(:captured_vals) { [:int, 10] }