rubocop-performance 1.7.0 → 1.7.1

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: 5be372d62d20424e05201d4b78bb06bf19fc707d845d6b799599ba72958f72b7
4
- data.tar.gz: 87c59d78e37de238add70195fa26c95d31b23eb3065695f443a1694d3acf9145
3
+ metadata.gz: 34605a937c1a3e040428bee06e322220659c105b6e835423d9e0e73869fd83ee
4
+ data.tar.gz: e3fa0103bd2518cec45334bc162e144963eef9e3d09ab9fd6bd7b2d35b654e84
5
5
  SHA512:
6
- metadata.gz: d6caf119ca1a8b11d829ed555f3a0653a1087d3a3ee3be078460c9ecfb5a5fb236a7abf2c058f57647d4f74dffccc66aebcf4d330f5a6a5bd5deaa12a8fea480
7
- data.tar.gz: d8a6e634d4453300d24e5869bffa690457d07048b1e2978cc00dbc930c40e2dc80789a6faa95823e63414e5c579f8784cbe4f743607e2fd9598cf478aa1801ed
6
+ metadata.gz: 5fe72ab5a0370aa8e0cc434080a27a38d8979084c53c50cd18e8cbc0896572ddc9d011130d56283f9d588268253ec0e2e44fc32b81483e1458689c60c17e835b
7
+ data.tar.gz: a60d627b0d1ded2fb6103a78fb4414fc1e1f1ff13ab9f4e82c399289c9a40c3c6e0385ee2509074175bd724755f768dd4625bb9791af993032a1f840a0533ef6
@@ -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
- corrector.replace(node, "#{subclass.source} <= #{superclass.source}")
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
- # BigDecimal(1, 2)
14
- # BigDecimal(1.2, 3, exception: true)
12
+ # BigDecimal(1, 2)
13
+ # BigDecimal(1.2, 3, exception: true)
15
14
  #
16
15
  # # good
17
- # BigDecimal('1', 2)
18
- # BigDecimal('1.2', 3, exception: true)
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
@@ -6,6 +6,8 @@ module RuboCop
6
6
  # This cop identifies unnecessary use of a regex where
7
7
  # `String#include?` would suffice.
8
8
  #
9
+ # This cop's offenses are not safe to auto-correct if a receiver is nil.
10
+ #
9
11
  # @example
10
12
  # # bad
11
13
  # 'abc'.match?(/ab/)
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Performance
5
5
  module Version
6
- STRING = '1.7.0'
6
+ STRING = '1.7.1'
7
7
  end
8
8
  end
9
9
  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.0
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-07 00:00:00.000000000 Z
13
+ date: 2020-07-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rubocop