rubocop-performance 1.7.0 → 1.7.1
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/config/default.yml +3 -0
- data/lib/rubocop/cop/performance/ancestors_include.rb +3 -1
- data/lib/rubocop/cop/performance/big_decimal_with_numeric_argument.rb +12 -5
- data/lib/rubocop/cop/performance/string_include.rb +2 -0
- 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: 34605a937c1a3e040428bee06e322220659c105b6e835423d9e0e73869fd83ee
|
4
|
+
data.tar.gz: e3fa0103bd2518cec45334bc162e144963eef9e3d09ab9fd6bd7b2d35b654e84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5fe72ab5a0370aa8e0cc434080a27a38d8979084c53c50cd18e8cbc0896572ddc9d011130d56283f9d588268253ec0e2e44fc32b81483e1458689c60c17e835b
|
7
|
+
data.tar.gz: a60d627b0d1ded2fb6103a78fb4414fc1e1f1ff13ab9f4e82c399289c9a40c3c6e0385ee2509074175bd724755f768dd4625bb9791af993032a1f840a0533ef6
|
data/config/default.yml
CHANGED
@@ -4,6 +4,7 @@ Performance/AncestorsInclude:
|
|
4
4
|
Description: 'Use `A <= B` instead of `A.ancestors.include?(B)`.'
|
5
5
|
Reference: 'https://github.com/JuanitoFatas/fast-ruby#ancestorsinclude-vs--code'
|
6
6
|
Enabled: 'pending'
|
7
|
+
Safe: false
|
7
8
|
VersionAdded: '1.7'
|
8
9
|
|
9
10
|
Performance/BigDecimalWithNumericArgument:
|
@@ -247,6 +248,8 @@ Performance/StartWith:
|
|
247
248
|
Performance/StringInclude:
|
248
249
|
Description: 'Use `String#include?` instead of a regex match with literal-only pattern.'
|
249
250
|
Enabled: 'pending'
|
251
|
+
AutoCorrect: false
|
252
|
+
SafeAutoCorrect: false
|
250
253
|
VersionAdded: '1.7'
|
251
254
|
|
252
255
|
Performance/StringReplacement:
|
@@ -35,7 +35,9 @@ module RuboCop
|
|
35
35
|
def autocorrect(node)
|
36
36
|
ancestors_include_candidate?(node) do |subclass, superclass|
|
37
37
|
lambda do |corrector|
|
38
|
-
|
38
|
+
subclass_source = subclass ? subclass.source : 'self'
|
39
|
+
|
40
|
+
corrector.replace(node, "#{subclass_source} <= #{superclass.source}")
|
39
41
|
end
|
40
42
|
end
|
41
43
|
end
|
@@ -8,14 +8,13 @@ module RuboCop
|
|
8
8
|
# than from Numeric for BigDecimal.
|
9
9
|
#
|
10
10
|
# @example
|
11
|
-
#
|
12
11
|
# # bad
|
13
|
-
#
|
14
|
-
#
|
12
|
+
# BigDecimal(1, 2)
|
13
|
+
# BigDecimal(1.2, 3, exception: true)
|
15
14
|
#
|
16
15
|
# # good
|
17
|
-
#
|
18
|
-
#
|
16
|
+
# BigDecimal('1', 2)
|
17
|
+
# BigDecimal('1.2', 3, exception: true)
|
19
18
|
#
|
20
19
|
class BigDecimalWithNumericArgument < Cop
|
21
20
|
MSG = 'Convert numeric argument to string before passing to `BigDecimal`.'
|
@@ -26,6 +25,8 @@ module RuboCop
|
|
26
25
|
|
27
26
|
def on_send(node)
|
28
27
|
big_decimal_with_numeric_argument?(node) do |numeric|
|
28
|
+
next if numeric.float_type? && specifies_precision?(node)
|
29
|
+
|
29
30
|
add_offense(node, location: numeric.source_range)
|
30
31
|
end
|
31
32
|
end
|
@@ -37,6 +38,12 @@ module RuboCop
|
|
37
38
|
end
|
38
39
|
end
|
39
40
|
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def specifies_precision?(node)
|
45
|
+
node.arguments.size > 1 && !node.arguments[1].hash_type?
|
46
|
+
end
|
40
47
|
end
|
41
48
|
end
|
42
49
|
end
|
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.7.
|
4
|
+
version: 1.7.1
|
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: 2020-07-
|
13
|
+
date: 2020-07-17 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rubocop
|