rubocop-performance 1.14.2 → 1.14.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/default.yml +1 -1
- data/lib/rubocop/cop/performance/chain_array_allocation.rb +3 -3
- data/lib/rubocop/cop/performance/collection_literal_in_loop.rb +1 -1
- data/lib/rubocop/cop/performance/inefficient_hash_search.rb +2 -4
- data/lib/rubocop/cop/performance/string_identifier_argument.rb +1 -1
- data/lib/rubocop/cop/performance/sum.rb +2 -2
- data/lib/rubocop/performance/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7716dc36d8facd9d8604d89d117f85db5fed60efcad66ad8354d673492800140
|
4
|
+
data.tar.gz: 59f4dd4e4df5afef36700a8951e8e91e18567ba978506d9aa02884abafc6d639
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 `
|
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)
|
@@ -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
|
-
#
|
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(:+) #
|
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, :+)
|
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.
|
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-
|
13
|
+
date: 2022-07-17 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rubocop
|