rubocop-performance 1.13.3 → 1.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/config/default.yml +1 -1
  3. data/lib/rubocop/cop/mixin/regexp_metacharacter.rb +2 -2
  4. data/lib/rubocop/cop/performance/ancestors_include.rb +1 -2
  5. data/lib/rubocop/cop/performance/array_semi_infinite_range_slice.rb +1 -1
  6. data/lib/rubocop/cop/performance/big_decimal_with_numeric_argument.rb +1 -1
  7. data/lib/rubocop/cop/performance/block_given_with_explicit_block.rb +1 -1
  8. data/lib/rubocop/cop/performance/caller.rb +1 -2
  9. data/lib/rubocop/cop/performance/case_when_splat.rb +2 -2
  10. data/lib/rubocop/cop/performance/casecmp.rb +10 -12
  11. data/lib/rubocop/cop/performance/chain_array_allocation.rb +1 -1
  12. data/lib/rubocop/cop/performance/collection_literal_in_loop.rb +2 -2
  13. data/lib/rubocop/cop/performance/compare_with_block.rb +1 -1
  14. data/lib/rubocop/cop/performance/concurrent_monotonic_time.rb +1 -1
  15. data/lib/rubocop/cop/performance/constant_regexp.rb +1 -1
  16. data/lib/rubocop/cop/performance/count.rb +1 -1
  17. data/lib/rubocop/cop/performance/delete_prefix.rb +3 -0
  18. data/lib/rubocop/cop/performance/delete_suffix.rb +3 -0
  19. data/lib/rubocop/cop/performance/detect.rb +1 -1
  20. data/lib/rubocop/cop/performance/double_start_end_with.rb +1 -1
  21. data/lib/rubocop/cop/performance/end_with.rb +1 -1
  22. data/lib/rubocop/cop/performance/flat_map.rb +1 -1
  23. data/lib/rubocop/cop/performance/inefficient_hash_search.rb +1 -1
  24. data/lib/rubocop/cop/performance/io_readlines.rb +1 -1
  25. data/lib/rubocop/cop/performance/method_object_as_block.rb +1 -1
  26. data/lib/rubocop/cop/performance/open_struct.rb +1 -1
  27. data/lib/rubocop/cop/performance/range_include.rb +2 -2
  28. data/lib/rubocop/cop/performance/redundant_block_call.rb +1 -1
  29. data/lib/rubocop/cop/performance/redundant_equality_comparison_block.rb +4 -1
  30. data/lib/rubocop/cop/performance/redundant_match.rb +1 -1
  31. data/lib/rubocop/cop/performance/redundant_merge.rb +1 -2
  32. data/lib/rubocop/cop/performance/redundant_sort_block.rb +1 -2
  33. data/lib/rubocop/cop/performance/redundant_split_regexp_argument.rb +1 -1
  34. data/lib/rubocop/cop/performance/redundant_string_chars.rb +1 -1
  35. data/lib/rubocop/cop/performance/reverse_each.rb +1 -2
  36. data/lib/rubocop/cop/performance/reverse_first.rb +1 -1
  37. data/lib/rubocop/cop/performance/size.rb +1 -2
  38. data/lib/rubocop/cop/performance/sort_reverse.rb +1 -1
  39. data/lib/rubocop/cop/performance/squeeze.rb +1 -1
  40. data/lib/rubocop/cop/performance/start_with.rb +1 -1
  41. data/lib/rubocop/cop/performance/string_identifier_argument.rb +2 -2
  42. data/lib/rubocop/cop/performance/string_include.rb +2 -3
  43. data/lib/rubocop/cop/performance/string_replacement.rb +1 -2
  44. data/lib/rubocop/cop/performance/sum.rb +1 -1
  45. data/lib/rubocop/cop/performance/times_map.rb +1 -1
  46. data/lib/rubocop/cop/performance/uri_default_parser.rb +1 -2
  47. data/lib/rubocop/performance/version.rb +1 -1
  48. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cc8de809f0aa167f08fd75ed2f7047fabc37b06b12a0c59e4647530b18fb6d99
4
- data.tar.gz: df849a7c117eb44d8851969031cda6d5927e2f271ad41bc3689212bad6b9e2e1
3
+ metadata.gz: f4747d4148deec2021e930aac92abe205f8aeb8492c19e8a465d1e4282184d04
4
+ data.tar.gz: 82b9caa126eee0699cae6f46b784fa3fdd8f619c4df0dc2b4c083e6ef5c328b3
5
5
  SHA512:
6
- metadata.gz: 24c72e01dfa6cfe35b3c93e1c83d63aaa0362dff7bc4ed234b8b6f8c1a434927a945b077273ec84c95be86d70e050f28e18dad27ffc9c72350f49c7ff3477b4a
7
- data.tar.gz: 3340644f87ea108d8f7022756ff5cdf442b0d2951cd9ea351bb0a4012c2d0721dc921b1402e8b5f952899015b51c402cdbcab5e785d764f4655aa068c71be6b3
6
+ metadata.gz: bd64acd6e513565e8f607046bf9598bf0aadb166dc7bf17fab8633e0ed9722af8e4f984468d5f08eb398c7b4f4121537c01ad52e5c24b7226bef3bd8f2c0f6f7
7
+ data.tar.gz: 017c74d0dadf085c59e0f479dc5359d8c8fb71427d3e217392c349e51219a99933a0ebdd6426ece0aaca2149ee5b6d39a279f1cae8c9e9c4ff75f17d99fe22cd
data/config/default.yml CHANGED
@@ -247,7 +247,7 @@ Performance/RedundantSortBlock:
247
247
  VersionAdded: '1.7'
248
248
 
249
249
  Performance/RedundantSplitRegexpArgument:
250
- Description: 'This cop identifies places where `split` argument can be replaced from a deterministic regexp to a string.'
250
+ Description: 'Identifies places where `split` argument can be replaced from a deterministic regexp to a string.'
251
251
  Enabled: pending
252
252
  VersionAdded: '1.10'
253
253
 
@@ -54,9 +54,9 @@ module RuboCop
54
54
 
55
55
  def drop_start_metacharacter(regexp_string)
56
56
  if regexp_string.start_with?('\\A')
57
- regexp_string[2..-1] # drop `\A` anchor
57
+ regexp_string[2..] # drop `\A` anchor
58
58
  else
59
- regexp_string[1..-1] # drop `^` anchor
59
+ regexp_string[1..] # drop `^` anchor
60
60
  end
61
61
  end
62
62
 
@@ -3,8 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Performance
6
- # This cop is used to identify usages of `ancestors.include?` and
7
- # change them to use `<=` instead.
6
+ # Identifies usages of `ancestors.include?` and change them to use `<=` instead.
8
7
  #
9
8
  # @safety
10
9
  # This cop is unsafe because it can't tell whether the receiver is a class or an object.
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Performance
6
- # This cop identifies places where slicing arrays with semi-infinite ranges
6
+ # Identifies places where slicing arrays with semi-infinite ranges
7
7
  # can be replaced by `Array#take` and `Array#drop`.
8
8
  # This cop was created due to a mistake in microbenchmark and hence is disabled by default.
9
9
  # Refer https://github.com/rubocop/rubocop-performance/pull/175#issuecomment-731892717
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Performance
6
- # This cop identifies places where numeric argument to BigDecimal should be
6
+ # Identifies places where numeric argument to BigDecimal should be
7
7
  # converted to string. Initializing from String is faster
8
8
  # than from Numeric for BigDecimal.
9
9
  #
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Performance
6
- # This cop identifies unnecessary use of a `block_given?` where explicit check
6
+ # Identifies unnecessary use of a `block_given?` where explicit check
7
7
  # of block argument would suffice.
8
8
  #
9
9
  # @example
@@ -3,8 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Performance
6
- # This cop identifies places where `caller[n]`
7
- # can be replaced by `caller(n..n).first`.
6
+ # Identifies places where `caller[n]` can be replaced by `caller(n..n).first`.
8
7
  #
9
8
  # @example
10
9
  # # bad
@@ -18,7 +18,7 @@ module RuboCop
18
18
  # that is inside of the splat expansion.
19
19
  #
20
20
  # @safety
21
- # This cop is not unsafe auto-correction because it is not a guaranteed
21
+ # This cop is not unsafe autocorrection because it is not a guaranteed
22
22
  # performance improvement. If the data being processed by the `case` condition is
23
23
  # normalized in a manner that favors hitting a condition in the splat expansion,
24
24
  # it is possible that moving the splat condition to the end will use more memory,
@@ -168,7 +168,7 @@ module RuboCop
168
168
 
169
169
  def needs_reorder?(when_node)
170
170
  following_branches =
171
- when_node.parent.when_branches[(when_node.branch_index + 1)..-1]
171
+ when_node.parent.when_branches[(when_node.branch_index + 1)..]
172
172
 
173
173
  following_branches.any? do |when_branch|
174
174
  when_branch.conditions.any? do |condition|
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Performance
6
- # This cop identifies places where a case-insensitive string comparison
6
+ # Identifies places where a case-insensitive string comparison
7
7
  # can better be implemented using `casecmp`.
8
8
  #
9
9
  # @safety
@@ -54,11 +54,11 @@ module RuboCop
54
54
  return unless (parts = take_method_apart(node))
55
55
 
56
56
  _receiver, method, arg, variable = parts
57
- good_method = build_good_method(arg, variable)
57
+ good_method = build_good_method(method, arg, variable)
58
58
 
59
59
  message = format(MSG, good: good_method, bad: node.source)
60
60
  add_offense(node, message: message) do |corrector|
61
- correction(corrector, node, method, arg, variable)
61
+ autocorrect(corrector, node, good_method)
62
62
  end
63
63
  end
64
64
 
@@ -81,22 +81,20 @@ module RuboCop
81
81
  [receiver, method, arg, variable]
82
82
  end
83
83
 
84
- def correction(corrector, node, method, arg, variable)
85
- corrector.insert_before(node.loc.expression, '!') if method == :!=
86
-
87
- replacement = build_good_method(arg, variable)
88
-
89
- corrector.replace(node.loc.expression, replacement)
84
+ def autocorrect(corrector, node, replacement)
85
+ corrector.replace(node, replacement)
90
86
  end
91
87
 
92
- def build_good_method(arg, variable)
88
+ def build_good_method(method, arg, variable)
89
+ bang = method == :!= ? '!' : ''
90
+
93
91
  # We want resulting call to be parenthesized
94
92
  # if arg already includes one or more sets of parens, don't add more
95
93
  # or if method call already used parens, again, don't add more
96
94
  if arg.send_type? || !parentheses?(arg)
97
- "#{variable.source}.casecmp(#{arg.source}).zero?"
95
+ "#{bang}#{variable.source}.casecmp(#{arg.source}).zero?"
98
96
  else
99
- "#{variable.source}.casecmp#{arg.source}.zero?"
97
+ "#{bang}#{variable.source}.casecmp#{arg.source}.zero?"
100
98
  end
101
99
  end
102
100
  end
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Performance
6
- # This cop is used to identify usages of `array.compact.flatten.map { |x| x.downcase }`.
6
+ # Identifies usages of `array.compact.flatten.map { |x| x.downcase }`.
7
7
  # Each of these methods (`compact`, `flatten`, `map`) will generate a new intermediate array
8
8
  # that is promptly thrown away. Instead it is faster to mutate when we know it's safe.
9
9
  #
@@ -5,8 +5,8 @@ require 'set'
5
5
  module RuboCop
6
6
  module Cop
7
7
  module Performance
8
- # This cop identifies places where Array and Hash literals are used
9
- # within loops. It is better to extract them into a local variable or constant
8
+ # Identifies places where Array and Hash literals are used within loops.
9
+ # It is better to extract them into a local variable or constant
10
10
  # to avoid unnecessary allocations on each iteration.
11
11
  #
12
12
  # You can set the minimum number of elements to consider
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Performance
6
- # This cop identifies places where `sort { |a, b| a.foo <=> b.foo }`
6
+ # Identifies places where `sort { |a, b| a.foo <=> b.foo }`
7
7
  # can be replaced by `sort_by(&:foo)`.
8
8
  # This cop also checks `max` and `min` methods.
9
9
  #
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Performance
6
- # This cop identifies places where `Concurrent.monotonic_time`
6
+ # Identifies places where `Concurrent.monotonic_time`
7
7
  # can be replaced by `Process.clock_gettime(Process::CLOCK_MONOTONIC)`.
8
8
  #
9
9
  # @example
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Performance
6
- # This cop finds regular expressions with dynamic components that are all constants.
6
+ # Finds regular expressions with dynamic components that are all constants.
7
7
  #
8
8
  # Ruby allocates a new Regexp object every time it executes a code containing such
9
9
  # a regular expression. It is more efficient to extract it into a constant,
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Performance
6
- # This cop is used to identify usages of `count` on an `Enumerable` that
6
+ # Identifies usages of `count` on an `Enumerable` that
7
7
  # follow calls to `select`, `find_all`, `filter` or `reject`. Querying logic can instead be
8
8
  # passed to the `count` call.
9
9
  #
@@ -49,6 +49,9 @@ module RuboCop
49
49
  class DeletePrefix < Base
50
50
  include RegexpMetacharacter
51
51
  extend AutoCorrector
52
+ extend TargetRubyVersion
53
+
54
+ minimum_target_ruby_version 2.5
52
55
 
53
56
  MSG = 'Use `%<prefer>s` instead of `%<current>s`.'
54
57
  RESTRICT_ON_SEND = %i[gsub gsub! sub sub!].freeze
@@ -49,6 +49,9 @@ module RuboCop
49
49
  class DeleteSuffix < Base
50
50
  include RegexpMetacharacter
51
51
  extend AutoCorrector
52
+ extend TargetRubyVersion
53
+
54
+ minimum_target_ruby_version 2.5
52
55
 
53
56
  MSG = 'Use `%<prefer>s` instead of `%<current>s`.'
54
57
  RESTRICT_ON_SEND = %i[gsub gsub! sub sub!].freeze
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Performance
6
- # This cop is used to identify usages of `first`, `last`, `[0]` or `[-1]`
6
+ # Identifies usages of `first`, `last`, `[0]` or `[-1]`
7
7
  # chained to `select`, `find_all` or `filter` and change them to use
8
8
  # `detect` instead.
9
9
  #
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Performance
6
- # This cop checks for double `#start_with?` or `#end_with?` calls
6
+ # Checks for double `#start_with?` or `#end_with?` calls
7
7
  # separated by `||`. In some cases such calls can be replaced
8
8
  # with an single `#start_with?`/`#end_with?` call.
9
9
  #
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Performance
6
- # This cop identifies unnecessary use of a regex where `String#end_with?` would suffice.
6
+ # Identifies unnecessary use of a regex where `String#end_with?` would suffice.
7
7
  #
8
8
  # This cop has `SafeMultiline` configuration option that `true` by default because
9
9
  # `end$` is unsafe as it will behave incompatible with `end_with?`
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Performance
6
- # This cop is used to identify usages of `map { ... }.flatten` and
6
+ # Identifies usages of `map { ... }.flatten` and
7
7
  # change them to use `flat_map { ... }` instead.
8
8
  #
9
9
  # @example
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Performance
6
- # This cop checks for inefficient searching of keys and values within
6
+ # Checks for inefficient searching of keys and values within
7
7
  # hashes.
8
8
  #
9
9
  # `Hash#keys.include?` is less efficient than `Hash#key?` because
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Performance
6
- # This cop identifies places where inefficient `readlines` method
6
+ # Identifies places where inefficient `readlines` method
7
7
  # can be replaced by `each_line` to avoid fully loading file content into memory.
8
8
  #
9
9
  # @example
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Performance
6
- # This cop identifies places where methods are converted to blocks, with the
6
+ # Identifies places where methods are converted to blocks, with the
7
7
  # use of `&method`, and passed as arguments to method calls.
8
8
  # It is faster to replace those with explicit blocks, calling those methods inside.
9
9
  #
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Performance
6
- # This cop checks for `OpenStruct.new` calls.
6
+ # Checks for `OpenStruct.new` calls.
7
7
  # Instantiation of an `OpenStruct` invalidates
8
8
  # Ruby global method cache as it causes dynamic method
9
9
  # definition during program runtime.
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Performance
6
- # This cop identifies uses of `Range#include?` and `Range#member?`, which iterates over each
6
+ # Identifies uses of `Range#include?` and `Range#member?`, which iterates over each
7
7
  # item in a `Range` to see if a specified item is there. In contrast,
8
8
  # `Range#cover?` simply compares the target item with the beginning and
9
9
  # end points of the `Range`. In a great majority of cases, this is what
@@ -11,7 +11,7 @@ module RuboCop
11
11
  #
12
12
  # @safety
13
13
  # This cop is unsafe because `Range#include?` (or `Range#member?`) and `Range#cover?`
14
- # are not equivalent behaviour.
14
+ # are not equivalent behavior.
15
15
  #
16
16
  # @example
17
17
  # # bad
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Performance
6
- # This cop identifies the use of a `&block` parameter and `block.call`
6
+ # Identifies the use of a `&block` parameter and `block.call`
7
7
  # where `yield` would do just as well.
8
8
  #
9
9
  # @example
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Performance
6
- # This cop checks for uses `Enumerable#all?`, `Enumerable#any?`, `Enumerable#one?`,
6
+ # Checks for uses `Enumerable#all?`, `Enumerable#any?`, `Enumerable#one?`,
7
7
  # and `Enumerable#none?` are compared with `===` or similar methods in block.
8
8
  #
9
9
  # By default, `Object#===` behaves the same as `Object#==`, but this
@@ -25,6 +25,9 @@ module RuboCop
25
25
  #
26
26
  class RedundantEqualityComparisonBlock < Base
27
27
  extend AutoCorrector
28
+ extend TargetRubyVersion
29
+
30
+ minimum_target_ruby_version 2.5
28
31
 
29
32
  MSG = 'Use `%<prefer>s` instead of block.'
30
33
 
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Performance
6
- # This cop identifies the use of `Regexp#match` or `String#match`, which
6
+ # Identifies the use of `Regexp#match` or `String#match`, which
7
7
  # returns `#<MatchData>`/`nil`. The return value of `=~` is an integral
8
8
  # index/`nil` and is more performant.
9
9
  #
@@ -3,8 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Performance
6
- # This cop identifies places where `Hash#merge!` can be replaced by
7
- # `Hash#[]=`.
6
+ # Identifies places where `Hash#merge!` can be replaced by `Hash#[]=`.
8
7
  # You can set the maximum number of key-value pairs to consider
9
8
  # an offense with `MaxKeyValuePairs`.
10
9
  #
@@ -3,8 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Performance
6
- # This cop identifies places where `sort { |a, b| a <=> b }`
7
- # can be replaced with `sort`.
6
+ # Identifies places where `sort { |a, b| a <=> b }` can be replaced with `sort`.
8
7
  #
9
8
  # @example
10
9
  # # bad
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Performance
6
- # This cop identifies places where `split` argument can be replaced from
6
+ # Identifies places where `split` argument can be replaced from
7
7
  # a deterministic regexp to a string.
8
8
  #
9
9
  # @example
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Performance
6
- # This cop checks for redundant `String#chars`.
6
+ # Checks for redundant `String#chars`.
7
7
  #
8
8
  # @example
9
9
  # # bad
@@ -3,8 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Performance
6
- # This cop is used to identify usages of `reverse.each` and
7
- # change them to use `reverse_each` instead.
6
+ # Identifies usages of `reverse.each` and change them to use `reverse_each` instead.
8
7
  #
9
8
  # If the return value is used, it will not be detected because the result will be different.
10
9
  #
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Performance
6
- # This cop identifies places where `reverse.first(n)` and `reverse.first`
6
+ # Identifies places where `reverse.first(n)` and `reverse.first`
7
7
  # can be replaced by `last(n).reverse` and `last`.
8
8
  #
9
9
  # @example
@@ -3,8 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Performance
6
- # This cop is used to identify usages of `count` on an
7
- # `Array` and `Hash` and change them to `size`.
6
+ # Identifies usages of `count` on an `Array` and `Hash` and change them to `size`.
8
7
  #
9
8
  # @example
10
9
  # # bad
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Performance
6
- # This cop identifies places where `sort { |a, b| b <=> a }`
6
+ # Identifies places where `sort { |a, b| b <=> a }`
7
7
  # can be replaced by a faster `sort.reverse`.
8
8
  #
9
9
  # @example
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Performance
6
- # This cop identifies places where `gsub(/a+/, 'a')` and `gsub!(/a+/, 'a')`
6
+ # Identifies places where `gsub(/a+/, 'a')` and `gsub!(/a+/, 'a')`
7
7
  # can be replaced by `squeeze('a')` and `squeeze!('a')`.
8
8
  #
9
9
  # The `squeeze('a')` method is faster than `gsub(/a+/, 'a')`.
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Performance
6
- # This cop identifies unnecessary use of a regex where `String#start_with?` would suffice.
6
+ # Identifies unnecessary use of a regex where `String#start_with?` would suffice.
7
7
  #
8
8
  # This cop has `SafeMultiline` configuration option that `true` by default because
9
9
  # `^start` is unsafe as it will behave incompatible with `start_with?`
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Performance
6
- # This cop identifies places where string identifier argument can be replaced
6
+ # Identifies places where string identifier argument can be replaced
7
7
  # by symbol identifier argument.
8
8
  # It prevents the redundancy of the internal string-to-symbol conversion.
9
9
  #
@@ -46,7 +46,7 @@ module RuboCop
46
46
  def on_send(node)
47
47
  return unless (first_argument = node.first_argument)
48
48
  return unless first_argument.str_type?
49
- return if first_argument.value.include?(' ')
49
+ return if first_argument.value.include?(' ') || first_argument.value.include?('::')
50
50
 
51
51
  replacement = first_argument.value.to_sym.inspect
52
52
 
@@ -3,11 +3,10 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Performance
6
- # This cop identifies unnecessary use of a regex where
7
- # `String#include?` would suffice.
6
+ # Identifies unnecessary use of a regex where `String#include?` would suffice.
8
7
  #
9
8
  # @safety
10
- # This cop's offenses are not safe to auto-correct if a receiver is nil.
9
+ # This cop's offenses are not safe to autocorrect if a receiver is nil.
11
10
  #
12
11
  # @example
13
12
  # # bad
@@ -3,8 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Performance
6
- # This cop identifies places where `gsub` can be replaced by
7
- # `tr` or `delete`.
6
+ # Identifies places where `gsub` can be replaced by `tr` or `delete`.
8
7
  #
9
8
  # @example
10
9
  # # bad
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Performance
6
- # This cop identifies places where custom code finding the sum of elements
6
+ # Identifies places where custom code finding the sum of elements
7
7
  # in some Enumerable object can be replaced by `Enumerable#sum` method.
8
8
  #
9
9
  # @safety
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Performance
6
- # This cop checks for .times.map calls.
6
+ # Checks for .times.map calls.
7
7
  # In most cases such calls can be replaced
8
8
  # with an explicit array creation.
9
9
  #
@@ -3,8 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Performance
6
- # This cop identifies places where `URI::Parser.new`
7
- # can be replaced by `URI::DEFAULT_PARSER`.
6
+ # Identifies places where `URI::Parser.new` can be replaced by `URI::DEFAULT_PARSER`.
8
7
  #
9
8
  # @example
10
9
  # # bad
@@ -4,7 +4,7 @@ module RuboCop
4
4
  module Performance
5
5
  # This module holds the RuboCop Performance version information.
6
6
  module Version
7
- STRING = '1.13.3'
7
+ STRING = '1.14.0'
8
8
 
9
9
  def self.document_version
10
10
  STRING.match('\d+\.\d+').to_s
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-performance
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.13.3
4
+ version: 1.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bozhidar Batsov
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2022-03-05 00:00:00.000000000 Z
13
+ date: 2022-05-24 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rubocop
@@ -123,7 +123,7 @@ metadata:
123
123
  homepage_uri: https://docs.rubocop.org/rubocop-performance/
124
124
  changelog_uri: https://github.com/rubocop/rubocop-performance/blob/master/CHANGELOG.md
125
125
  source_code_uri: https://github.com/rubocop/rubocop-performance/
126
- documentation_uri: https://docs.rubocop.org/rubocop-performance/1.13/
126
+ documentation_uri: https://docs.rubocop.org/rubocop-performance/1.14/
127
127
  bug_tracker_uri: https://github.com/rubocop/rubocop-performance/issues
128
128
  rubygems_mfa_required: 'true'
129
129
  post_install_message:
@@ -134,7 +134,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
134
134
  requirements:
135
135
  - - ">="
136
136
  - !ruby/object:Gem::Version
137
- version: 2.5.0
137
+ version: 2.6.0
138
138
  required_rubygems_version: !ruby/object:Gem::Requirement
139
139
  requirements:
140
140
  - - ">="