rubocop-performance 1.14.0 → 1.14.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f4747d4148deec2021e930aac92abe205f8aeb8492c19e8a465d1e4282184d04
4
- data.tar.gz: 82b9caa126eee0699cae6f46b784fa3fdd8f619c4df0dc2b4c083e6ef5c328b3
3
+ metadata.gz: 7716dc36d8facd9d8604d89d117f85db5fed60efcad66ad8354d673492800140
4
+ data.tar.gz: 59f4dd4e4df5afef36700a8951e8e91e18567ba978506d9aa02884abafc6d639
5
5
  SHA512:
6
- metadata.gz: bd64acd6e513565e8f607046bf9598bf0aadb166dc7bf17fab8633e0ed9722af8e4f984468d5f08eb398c7b4f4121537c01ad52e5c24b7226bef3bd8f2c0f6f7
7
- data.tar.gz: 017c74d0dadf085c59e0f479dc5359d8c8fb71427d3e217392c349e51219a99933a0ebdd6426ece0aaca2149ee5b6d39a279f1cae8c9e9c4ff75f17d99fe22cd
6
+ metadata.gz: 748977ac053ddab36afda43c709eee6424957a81ce18daf1048cf42399226e0d2d67f9964ba544594a03862d5650eff369a34b407d49892d72957ab3acf2ca11
7
+ data.tar.gz: 9a785cd79f0e781643720fd19e2454d6b1cac890c215d5a44762e4173d69e9f6ec6adc57fe43646dba7b3e48bf86663842f595f54db1f51c7e251af75113ecee
data/config/default.yml CHANGED
@@ -160,7 +160,7 @@ Performance/FlatMap:
160
160
  Description: >-
161
161
  Use `Enumerable#flat_map`
162
162
  instead of `Enumerable#map...Array#flatten(1)`
163
- or `Enumberable#collect..Array#flatten(1)`.
163
+ or `Enumerable#collect..Array#flatten(1)`.
164
164
  Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerablemaparrayflatten-vs-enumerableflat_map-code'
165
165
  Enabled: true
166
166
  VersionAdded: '0.30'
@@ -47,13 +47,13 @@ module RuboCop
47
47
 
48
48
  RETURNS_NEW_ARRAY = (ALWAYS_RETURNS_NEW_ARRAY + RETURNS_NEW_ARRAY_WHEN_NO_BLOCK).freeze
49
49
 
50
- MSG = 'Use unchained `%<method>s` and `%<second_method>s!` '\
51
- '(followed by `return array` if required) instead of chaining '\
50
+ MSG = 'Use unchained `%<method>s` and `%<second_method>s!` ' \
51
+ '(followed by `return array` if required) instead of chaining ' \
52
52
  '`%<method>s...%<second_method>s`.'
53
53
 
54
54
  def_node_matcher :chain_array_allocation?, <<~PATTERN
55
55
  (send {
56
- (send _ $%RETURN_NEW_ARRAY_WHEN_ARGS {int lvar ivar cvar gvar})
56
+ (send _ $%RETURN_NEW_ARRAY_WHEN_ARGS {int lvar ivar cvar gvar send})
57
57
  (block (send _ $%ALWAYS_RETURNS_NEW_ARRAY) ...)
58
58
  (send _ $%RETURNS_NEW_ARRAY ...)
59
59
  } $%HAS_MUTATION_ALTERNATIVE ...)
@@ -32,7 +32,7 @@ module RuboCop
32
32
  # end
33
33
  #
34
34
  class CollectionLiteralInLoop < Base
35
- MSG = 'Avoid immutable %<literal_class>s literals in loops. '\
35
+ MSG = 'Avoid immutable %<literal_class>s literals in loops. ' \
36
36
  'It is better to extract it into a local variable or a constant.'
37
37
 
38
38
  POST_CONDITION_LOOP_TYPES = %i[while_post until_post].freeze
@@ -58,8 +58,7 @@ module RuboCop
58
58
  # `key?`/`value?` method.
59
59
  corrector.replace(
60
60
  node.loc.expression,
61
- "#{autocorrect_hash_expression(node)}."\
62
- "#{autocorrect_method(node)}(#{autocorrect_argument(node)})"
61
+ "#{autocorrect_hash_expression(node)}.#{autocorrect_method(node)}(#{autocorrect_argument(node)})"
63
62
  )
64
63
  end
65
64
  end
@@ -68,8 +67,7 @@ module RuboCop
68
67
  private
69
68
 
70
69
  def message(node)
71
- "Use `##{autocorrect_method(node)}` instead of "\
72
- "`##{current_method(node)}.include?`."
70
+ "Use `##{autocorrect_method(node)}` instead of `##{current_method(node)}.include?`."
73
71
  end
74
72
 
75
73
  def autocorrect_method(node)
@@ -83,7 +83,7 @@ module RuboCop
83
83
  end
84
84
 
85
85
  def invoke_method_after_map_compact_on_same_line?(compact_node, chained_method)
86
- compact_node.loc.selector.line == chained_method.loc.selector.line
86
+ compact_node.loc.selector.line == chained_method.loc.last_line
87
87
  end
88
88
 
89
89
  def compact_method_with_final_newline_range(compact_method_range)
@@ -74,6 +74,9 @@ module RuboCop
74
74
  # end
75
75
  class RegexpMatch < Base
76
76
  extend AutoCorrector
77
+ extend TargetRubyVersion
78
+
79
+ minimum_target_ruby_version 2.4
77
80
 
78
81
  # Constants are included in this list because it is unlikely that
79
82
  # someone will store `nil` as a constant and then use it for comparison
@@ -38,7 +38,7 @@ module RuboCop
38
38
  remove_class_variable remove_method undef_method class_variable_get class_variable_set
39
39
  deprecate_constant module_function private private_constant protected public public_constant
40
40
  remove_const ruby2_keywords
41
- define_singleton_method instance_variable_defined instance_variable_get instance_variable_set
41
+ define_singleton_method instance_variable_defined? instance_variable_get instance_variable_set
42
42
  method public_method public_send remove_instance_variable respond_to? send singleton_method
43
43
  __send__
44
44
  ].freeze
@@ -7,7 +7,7 @@ module RuboCop
7
7
  # in some Enumerable object can be replaced by `Enumerable#sum` method.
8
8
  #
9
9
  # @safety
10
- # Auto-corrections are unproblematic wherever an initial value is provided explicitly:
10
+ # Autocorrections are unproblematic wherever an initial value is provided explicitly:
11
11
  #
12
12
  # [source,ruby]
13
13
  # ----
@@ -43,7 +43,7 @@ module RuboCop
43
43
  #
44
44
  # @example OnlySumOrWithInitialValue: false (default)
45
45
  # # bad
46
- # [1, 2, 3].inject(:+) # Auto-corrections for cases without initial value are unsafe
46
+ # [1, 2, 3].inject(:+) # Autocorrections for cases without initial value are unsafe
47
47
  # [1, 2, 3].inject(&:+) # and will only be performed when using the `-A` option.
48
48
  # [1, 2, 3].reduce { |acc, elem| acc + elem } # They can be prohibited completely using `SafeAutoCorrect: true`.
49
49
  # [1, 2, 3].reduce(10, :+)
@@ -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.14.0'
7
+ STRING = '1.14.3'
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.14.0
4
+ version: 1.14.3
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-05-24 00:00:00.000000000 Z
13
+ date: 2022-07-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rubocop