Skip to content

Commit

Permalink
Bump RuboCop Performance to 1.10
Browse files Browse the repository at this point in the history
This PR bumps RuboCop Performance to 1.10 and suppresses the new
`Performance/RedundantSplitRegexpArgument` cop's offenses.

```console
% bundle exec rubocop
(snip)

Offenses:

lib/rubocop/cop/mixin/preferred_delimiters.rb:18:42: C: [Corrected]
Performance/RedundantSplitRegexpArgument: Use string as argument instead
of regexp.
        preferred_delimiters[type].split(//)
                                         ^^
lib/rubocop/cop/mixin/preferred_delimiters.rb:18:42: C: [Corrected]
Style/StringLiterals: Prefer single-quoted strings when you don't need
string interpolation or special symbols.
        preferred_delimiters[type].split("")
                                         ^^
lib/rubocop/cop/style/command_literal.rb:168:58: C: [Corrected]
Performance/RedundantSplitRegexpArgument: Use string as argument instead
of regexp.
          (command_delimiter || default_delimiter).split(//)
                                                         ^^
lib/rubocop/cop/style/command_literal.rb:168:58: C: [Corrected]
Style/StringLiterals: Prefer single-quoted strings when you don't need
string interpolation or special symbols.
          (command_delimiter || default_delimiter).split("")
                                                         ^^
lib/rubocop/cop/style/regexp_literal.rb:153:49: C: [Corrected]
Performance/RedundantSplitRegexpArgument: Use string as argument instead
of regexp.
            ['PreferredDelimiters']['%r'].split(//)
                                                ^^
lib/rubocop/cop/style/regexp_literal.rb:153:49: C: [Corrected]
Style/StringLiterals: Prefer single-quoted strings when you don't need
string interpolation or special symbols.
            ['PreferredDelimiters']['%r'].split("")
                                                ^^
spec/support/alignment_examples.rb:11:26: C: [Corrected]
Performance/RedundantSplitRegexpArgument: Use string as argument instead
of regexp.
  annotated_source.split(/\n\n/).each do |chunk|
                         ^^^^^^

1265 files inspected, 7 offenses detected, 7 offenses corrected
```
  • Loading branch information
koic committed Feb 28, 2021
1 parent 2a727f9 commit 3790bb7
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ else
end
gem 'rake', '~> 13.0'
gem 'rspec', '~> 3.7'
gem 'rubocop-performance', '~> 1.9.0'
gem 'rubocop-performance', '~> 1.10.0'
gem 'rubocop-rspec', '~> 2.2.0'
# Workaround for cc-test-reporter with SimpleCov 0.18.
# Stop upgrading SimpleCov until the following issue will be resolved.
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/mixin/preferred_delimiters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def initialize(type, config, preferred_delimiters)
end

def delimiters
preferred_delimiters[type].split(//)
preferred_delimiters[type].split('')
end

private
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/style/command_literal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def backtick_literal?(node)
end

def preferred_delimiter
(command_delimiter || default_delimiter).split(//)
(command_delimiter || default_delimiter).split('')
end

def command_delimiter
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/style/regexp_literal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def slash_literal?(node)

def preferred_delimiters
config.for_cop('Style/PercentLiteralDelimiters') \
['PreferredDelimiters']['%r'].split(//)
['PreferredDelimiters']['%r'].split('')
end

def correct_delimiters(node, corrector)
Expand Down
2 changes: 1 addition & 1 deletion spec/support/alignment_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
else
{ 'Enabled' => false }
end
annotated_source.split(/\n\n/).each do |chunk|
annotated_source.split("\n\n").each do |chunk|
chunk << "\n" unless chunk.end_with?("\n")
source = chunk.lines.reject { |line| /^ *\^/.match?(line) }.join
name = source.gsub(/\n(?=[a-z ])/, ' <newline> ').gsub(/\s+/, ' ')
Expand Down

0 comments on commit 3790bb7

Please sign in to comment.