Skip to content

Commit

Permalink
Suppress Layout/LineEndStringConcatenationIndentation warn
Browse files Browse the repository at this point in the history
  • Loading branch information
richardstewart0213 committed Jun 23, 2021
1 parent 61d6761 commit 6df6a97
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 29 deletions.
12 changes: 4 additions & 8 deletions lib/rubocop/cop/performance/case_when_splat.rb
Expand Up @@ -58,10 +58,8 @@ class CaseWhenSplat < Base
include RangeHelp
extend AutoCorrector

MSG = 'Reordering `when` conditions with a splat to the end ' \
'of the `when` branches can improve performance.'
ARRAY_MSG = 'Pass the contents of array literals ' \
'directly to `when` conditions.'
MSG = 'Reordering `when` conditions with a splat to the end of the `when` branches can improve performance.'
ARRAY_MSG = 'Pass the contents of array literals directly to `when` conditions.'

def on_case(case_node)
when_conditions = case_node.when_branches.flat_map(&:conditions)
Expand Down Expand Up @@ -134,13 +132,11 @@ def when_branch_range(when_node)
end

def new_condition_with_then(node, new_condition)
"\n#{indent_for(node)}when " \
"#{new_condition} then #{node.body.source}"
"\n#{indent_for(node)}when #{new_condition} then #{node.body.source}"
end

def new_branch_without_then(node, new_condition)
"\n#{indent_for(node)}when #{new_condition}" \
"\n#{indent_for(node.body)}#{node.body.source}"
"\n#{indent_for(node)}when #{new_condition}\n#{indent_for(node.body)}#{node.body.source}"
end

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

POST_CONDITION_LOOP_TYPES = %i[while_post until_post].freeze
LOOP_TYPES = (POST_CONDITION_LOOP_TYPES + %i[while until for]).freeze
Expand Down
12 changes: 4 additions & 8 deletions lib/rubocop/cop/performance/detect.rb
Expand Up @@ -31,14 +31,10 @@ class Detect < Base

CANDIDATE_METHODS = Set[:select, :find_all, :filter].freeze

MSG = 'Use `%<prefer>s` instead of ' \
'`%<first_method>s.%<second_method>s`.'
REVERSE_MSG = 'Use `reverse.%<prefer>s` instead of ' \
'`%<first_method>s.%<second_method>s`.'
INDEX_MSG = 'Use `%<prefer>s` instead of ' \
'`%<first_method>s[%<index>i]`.'
INDEX_REVERSE_MSG = 'Use `reverse.%<prefer>s` instead of ' \
'`%<first_method>s[%<index>i]`.'
MSG = 'Use `%<prefer>s` instead of `%<first_method>s.%<second_method>s`.'
REVERSE_MSG = 'Use `reverse.%<prefer>s` instead of `%<first_method>s.%<second_method>s`.'
INDEX_MSG = 'Use `%<prefer>s` instead of `%<first_method>s[%<index>i]`.'
INDEX_REVERSE_MSG = 'Use `reverse.%<prefer>s` instead of `%<first_method>s[%<index>i]`.'
RESTRICT_ON_SEND = %i[first last []].freeze

def_node_matcher :detect_candidate?, <<~PATTERN
Expand Down
3 changes: 1 addition & 2 deletions lib/rubocop/cop/performance/regexp_match.rb
Expand Up @@ -78,8 +78,7 @@ class RegexpMatch < Base
# Constants are included in this list because it is unlikely that
# someone will store `nil` as a constant and then use it for comparison
TYPES_IMPLEMENTING_MATCH = %i[const regexp str sym].freeze
MSG = 'Use `match?` instead of `%<current>s` when `MatchData` ' \
'is not used.'
MSG = 'Use `match?` instead of `%<current>s` when `MatchData` is not used.'

def_node_matcher :match_method?, <<~PATTERN
{
Expand Down
10 changes: 4 additions & 6 deletions spec/rubocop/cop/performance/case_when_splat_spec.rb
Expand Up @@ -192,8 +192,7 @@
end

context 'autocorrect' do
it 'corrects a single when with splat expansion followed by ' \
'another value' do
it 'corrects a single when with splat expansion followed by another value' do
source = <<~RUBY
case foo
when *Foo, Bar, Baz
Expand All @@ -209,8 +208,7 @@
RUBY
end

it 'corrects a when with splat expansion followed by another value ' \
'when there are multiple whens' do
it 'corrects a when with splat expansion followed by another value when there are multiple whens' do
source = <<~RUBY
case foo
when *Foo, Bar
Expand All @@ -230,8 +228,8 @@
RUBY
end

it 'corrects a when with multiple out of order splat expansions ' \
'followed by other values when there are multiple whens' do
it 'corrects a when with multiple out of order splat expansions followed by other values ' \
'when there are multiple whens' do
source = <<~RUBY
case foo
when *Foo, Bar, *Baz, Qux
Expand Down
3 changes: 1 addition & 2 deletions spec/rubocop/cop/performance/flat_map_spec.rb
Expand Up @@ -35,8 +35,7 @@
RUBY
end

it "does not register an offense when calling #{method}...#{flatten} " \
'with a number greater than 1' do
it "does not register an offense when calling #{method}...#{flatten} with a number greater than 1" do
expect_no_offenses("[1, 2, 3, 4].#{method} { |e| [e, e] }.#{flatten}(3)")
end

Expand Down
3 changes: 1 addition & 2 deletions tasks/cops_documentation.rake
Expand Up @@ -25,8 +25,7 @@ task verify_cops_documentation: :generate_cops_documentation do
# Output diff before raising error
sh('GIT_PAGER=cat git diff docs')

warn 'The docs directory is out of sync. ' \
'Run `rake generate_cops_documentation` and commit the results.'
warn 'The docs directory is out of sync. Run `rake generate_cops_documentation` and commit the results.'
exit!
end
end
Expand Down

0 comments on commit 6df6a97

Please sign in to comment.