Skip to content

Commit

Permalink
Suppress RuboCop offenses
Browse files Browse the repository at this point in the history
Follow up rubocop/rubocop#10717,
rubocop/rubocop#10715, and
suppresses the following offenses:

```console
Offenses:

lib/rubocop/cop/performance/chain_array_allocation.rb:50:69: C:
[Correctable] Layout/LineContinuationSpacing: Use one space in front of
backslash.
        MSG = 'Use unchained `%<method>s` and `%<second_method>s!` '\
                                                                    ^
lib/rubocop/cop/performance/chain_array_allocation.rb:51:78: C:
[Correctable] Layout/LineContinuationSpacing: Use one space in front of
backslash.
              '(followed by `return array` if required) instead of chaining '\

                                                                             ^
lib/rubocop/cop/performance/collection_literal_in_loop.rb:35:70: C:
[Correctable] Layout/LineContinuationSpacing: Use one space in front of backslash.
        MSG = 'Avoid immutable %<literal_class>s literals in loops. '\
                                                                     ^
lib/rubocop/cop/performance/inefficient_hash_search.rb:61:56: C:
[Correctable] Layout/LineContinuationSpacing: Use one space in front of
backslash.
                "#{autocorrect_hash_expression(node)}."\
                                                       ^
lib/rubocop/cop/performance/inefficient_hash_search.rb:71:59: C:
[Correctable] Layout/LineContinuationSpacing: Use one space in front of
backslash.
          "Use `##{autocorrect_method(node)}` instead of "\
                                                          ^
spec/rubocop/cop/performance/constant_regexp_spec.rb:61:84: C:
[Correctable] Layout/LineContinuationSpacing: Use one space in front of
backslash.
  it 'does not register an offense when regexp contains interpolated constant and '\
                                                                                   ^
spec/rubocop/cop/performance/redundant_match_spec.rb:89:7: C:
Layout/LineContinuationLeadingSpace: Move leading spaces to the end of
previous line.
     ' surrounding method' do
      ^

115 files inspected, 7 offenses detected, 6 offenses autocorrectable
RuboCop failed!
```
  • Loading branch information
koic committed Jun 23, 2022
1 parent c1f2f6b commit bb804c8
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 11 deletions.
4 changes: 2 additions & 2 deletions lib/rubocop/cop/performance/chain_array_allocation.rb
Expand Up @@ -47,8 +47,8 @@ class ChainArrayAllocation < Base

RETURNS_NEW_ARRAY = (ALWAYS_RETURNS_NEW_ARRAY + RETURNS_NEW_ARRAY_WHEN_NO_BLOCK).freeze

MSG = 'Use unchained `%<method>s` and `%<second_method>s!` '\
'(followed by `return array` if required) instead of chaining '\
MSG = 'Use unchained `%<method>s` and `%<second_method>s!` ' \
'(followed by `return array` if required) instead of chaining ' \
'`%<method>s...%<second_method>s`.'

def_node_matcher :chain_array_allocation?, <<~PATTERN
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/performance/collection_literal_in_loop.rb
Expand Up @@ -32,7 +32,7 @@ module Performance
# end
#
class CollectionLiteralInLoop < Base
MSG = 'Avoid immutable %<literal_class>s literals in loops. '\
MSG = 'Avoid immutable %<literal_class>s literals in loops. ' \
'It is better to extract it into a local variable or a constant.'

POST_CONDITION_LOOP_TYPES = %i[while_post until_post].freeze
Expand Down
6 changes: 2 additions & 4 deletions lib/rubocop/cop/performance/inefficient_hash_search.rb
Expand Up @@ -58,8 +58,7 @@ def on_send(node)
# `key?`/`value?` method.
corrector.replace(
node.loc.expression,
"#{autocorrect_hash_expression(node)}."\
"#{autocorrect_method(node)}(#{autocorrect_argument(node)})"
"#{autocorrect_hash_expression(node)}.#{autocorrect_method(node)}(#{autocorrect_argument(node)})"
)
end
end
Expand All @@ -68,8 +67,7 @@ def on_send(node)
private

def message(node)
"Use `##{autocorrect_method(node)}` instead of "\
"`##{current_method(node)}.include?`."
"Use `##{autocorrect_method(node)}` instead of `##{current_method(node)}.include?`."
end

def autocorrect_method(node)
Expand Down
3 changes: 1 addition & 2 deletions spec/rubocop/cop/performance/constant_regexp_spec.rb
Expand Up @@ -58,8 +58,7 @@
RUBY
end

it 'does not register an offense when regexp contains interpolated constant and '\
'and interpolated non constant' do
it 'does not register an offense when regexp contains interpolated constant and and interpolated non constant' do
expect_no_offenses(<<~RUBY)
str.match?(/\#{CONST}\#{do_something(1)}/)
RUBY
Expand Down
3 changes: 1 addition & 2 deletions spec/rubocop/cop/performance/redundant_match_spec.rb
Expand Up @@ -85,8 +85,7 @@ def method(str)
RUBY
end

it 'does not register an error when return value of .match is returned from' \
' surrounding method' do
it 'does not register an error when return value of .match is returned from surrounding method' do
expect_no_offenses(<<~RUBY)
def method(str)
str.match(/regex/)
Expand Down

0 comments on commit bb804c8

Please sign in to comment.