rubocop-performance 1.15.2 → 1.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/lib/rubocop/cop/performance/chain_array_allocation.rb +1 -1
- data/lib/rubocop/cop/performance/detect.rb +6 -3
- data/lib/rubocop/cop/performance/redundant_merge.rb +2 -5
- data/lib/rubocop/cop/performance/string_include.rb +9 -9
- data/lib/rubocop/performance/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b0361feae763e4c8cbea3bd0160a1e4b0646b2e3b3246fb8dd55a5f21a53acd
|
4
|
+
data.tar.gz: 152d09678555d309441fb809f60b07b69b04289b3949bf1eaca3e9b70b3afe13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f08bd2f25c0e0e537bf8fa5378e701d6b6b6794a45fe534229e73a0dd4bd623dd415965966655a802cc8e93a3776880d99c89245947aae090ba2c49f0bb183f
|
7
|
+
data.tar.gz: 34f697ee70070d32d17b3684712cec5628e71cbdb393722fec3bb0dbc541cf65af92a762907dbbb0c5e6c3023f8dd4738e06a131a5a28014749dac440e15bc92
|
data/LICENSE.txt
CHANGED
@@ -33,7 +33,7 @@ module RuboCop
|
|
33
33
|
RETURNS_NEW_ARRAY_WHEN_NO_BLOCK = %i[zip product].to_set.freeze
|
34
34
|
|
35
35
|
# These methods ALWAYS return a new array
|
36
|
-
# after they're called it's safe to mutate the
|
36
|
+
# after they're called it's safe to mutate the resulting array
|
37
37
|
ALWAYS_RETURNS_NEW_ARRAY = %i[* + - collect compact drop
|
38
38
|
drop_while flatten map reject
|
39
39
|
reverse rotate select shuffle sort
|
@@ -8,9 +8,12 @@ module RuboCop
|
|
8
8
|
# `detect` instead.
|
9
9
|
#
|
10
10
|
# @safety
|
11
|
-
# This cop is unsafe because is
|
12
|
-
#
|
13
|
-
#
|
11
|
+
# This cop is unsafe because is assumes the class implements the
|
12
|
+
# `Enumerable` interface, but can't reliably detect this. This creates
|
13
|
+
# known compatibility issues with `Hash`, `ActiveRecord` and other
|
14
|
+
# frameworks. `Hash` and `ActiveRecord` do not implement a `detect`
|
15
|
+
# method and `find` has its own meaning. Correcting `Hash` and
|
16
|
+
# `ActiveRecord` methods with this cop should be considered unsafe.
|
14
17
|
#
|
15
18
|
# @example
|
16
19
|
# # bad
|
@@ -28,6 +28,7 @@ module RuboCop
|
|
28
28
|
# hash[:a] = 1
|
29
29
|
# hash[:b] = 2
|
30
30
|
class RedundantMerge < Base
|
31
|
+
include Alignment
|
31
32
|
extend AutoCorrector
|
32
33
|
|
33
34
|
AREF_ASGN = '%<receiver>s[%<key>s] = %<value>s'
|
@@ -129,7 +130,7 @@ module RuboCop
|
|
129
130
|
end
|
130
131
|
|
131
132
|
def rewrite_with_modifier(node, parent, new_source)
|
132
|
-
indent = ' ' *
|
133
|
+
indent = ' ' * configured_indentation_width
|
133
134
|
padding = "\n#{indent + leading_spaces(node)}"
|
134
135
|
new_source.gsub!(/\n/, padding)
|
135
136
|
|
@@ -144,10 +145,6 @@ module RuboCop
|
|
144
145
|
node.source_range.source_line[/\A\s*/]
|
145
146
|
end
|
146
147
|
|
147
|
-
def indent_width
|
148
|
-
@config.for_cop('Layout/IndentationWidth')['Width'] || 2
|
149
|
-
end
|
150
|
-
|
151
148
|
def max_key_value_pairs
|
152
149
|
Integer(cop_config['MaxKeyValuePairs'] || 2)
|
153
150
|
end
|
@@ -6,19 +6,19 @@ module RuboCop
|
|
6
6
|
# Identifies unnecessary use of a regex where `String#include?` would suffice.
|
7
7
|
#
|
8
8
|
# @safety
|
9
|
-
# This cop's offenses are not safe to autocorrect if a receiver is nil.
|
9
|
+
# This cop's offenses are not safe to autocorrect if a receiver is nil or a Symbol.
|
10
10
|
#
|
11
11
|
# @example
|
12
12
|
# # bad
|
13
|
-
#
|
14
|
-
# /ab/.match?(
|
15
|
-
#
|
16
|
-
# /ab/ =~
|
17
|
-
#
|
18
|
-
# /ab/.match(
|
13
|
+
# str.match?(/ab/)
|
14
|
+
# /ab/.match?(str)
|
15
|
+
# str =~ /ab/
|
16
|
+
# /ab/ =~ str
|
17
|
+
# str.match(/ab/)
|
18
|
+
# /ab/.match(str)
|
19
19
|
#
|
20
20
|
# # good
|
21
|
-
#
|
21
|
+
# str.include?('ab')
|
22
22
|
class StringInclude < Base
|
23
23
|
extend AutoCorrector
|
24
24
|
|
@@ -27,7 +27,7 @@ module RuboCop
|
|
27
27
|
|
28
28
|
def_node_matcher :redundant_regex?, <<~PATTERN
|
29
29
|
{(send $!nil? {:match :=~ :!~ :match?} (regexp (str $#literal?) (regopt)))
|
30
|
-
(send (regexp (str $#literal?) (regopt)) {:match :match?} $
|
30
|
+
(send (regexp (str $#literal?) (regopt)) {:match :match?} $_)
|
31
31
|
(match-with-lvasgn (regexp (str $#literal?) (regopt)) $_)}
|
32
32
|
PATTERN
|
33
33
|
|
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.
|
4
|
+
version: 1.16.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:
|
13
|
+
date: 2023-02-06 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.
|
126
|
+
documentation_uri: https://docs.rubocop.org/rubocop-performance/1.16/
|
127
127
|
bug_tracker_uri: https://github.com/rubocop/rubocop-performance/issues
|
128
128
|
rubygems_mfa_required: 'true'
|
129
129
|
post_install_message:
|
@@ -141,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
141
|
- !ruby/object:Gem::Version
|
142
142
|
version: '0'
|
143
143
|
requirements: []
|
144
|
-
rubygems_version: 3.
|
144
|
+
rubygems_version: 3.3.26
|
145
145
|
signing_key:
|
146
146
|
specification_version: 4
|
147
147
|
summary: Automatic performance checking tool for Ruby code.
|