rubocop-performance 1.5.0 → 1.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2aa98e8177fd7ce04a6689bc8e25d5aa282feac4515b77eaa0971552d3436591
4
- data.tar.gz: a3f2e4ae23b70b9a30418b9e207f05c626c9f998254d22f70cec3ab5018acfe9
3
+ metadata.gz: 55bbd229a457fd01ff1b22b43e644f5399dd97160ae6e4b853ce83bd6ea32359
4
+ data.tar.gz: 7106cb02fec6940d7d59672b84add493689910ea1046bdc69b93d7db6edbeeb3
5
5
  SHA512:
6
- metadata.gz: 19e52e2ff3845ed2b85574d5ec4b675492e7d92ef3713c879f3524800ab29446f278e1dd0f0a4fe82a92c3d746fce9cd352122bba478671c8bccc0a4fe10c993
7
- data.tar.gz: 9b4657c5085913cc35d502431ae040f164b1844e0e995814bb3b23694ec157c765a385b5b69b0ee70fd0a14dfa7c2152ad715fbde9c21d4f7d6c40dce9f4ab06
6
+ metadata.gz: b2840baf60f0906f80aa7a310bee2ac0591eb8763ff938334498d47f52df17782efbdcea0c50479a587a3d5b04f00bb2510c7779577b92a4caa6221944b55d85
7
+ data.tar.gz: e89228cca25aefdceb216c530e928732d062f47971587e50403a79e67220904ff2b9e3601fbb997f529f1bd5b5fda066e727a4e2428026a44723edb959a3f066
@@ -51,7 +51,7 @@ module RuboCop
51
51
  caller_arg = node.receiver.first_argument
52
52
  n = caller_arg ? int_value(caller_arg) : 1
53
53
 
54
- if node.method_name == :[]
54
+ if node.method?(:[])
55
55
  m = int_value(node.first_argument)
56
56
  n += m
57
57
  format(MSG_BRACE, n: n, m: m, method: method_name)
@@ -9,8 +9,11 @@ module RuboCop
9
9
  # @example
10
10
  # # bad
11
11
  # 'abc'.match?(/bc\Z/)
12
+ # /bc\Z/.match?('abc')
12
13
  # 'abc' =~ /bc\Z/
14
+ # /bc\Z/ =~ 'abc'
13
15
  # 'abc'.match(/bc\Z/)
16
+ # /bc\Z/.match('abc')
14
17
  #
15
18
  # # good
16
19
  # 'abc'.end_with?('bc')
@@ -21,7 +24,8 @@ module RuboCop
21
24
 
22
25
  def_node_matcher :redundant_regex?, <<-PATTERN
23
26
  {(send $!nil? {:match :=~ :match?} (regexp (str $#literal_at_end?) (regopt)))
24
- (send (regexp (str $#literal_at_end?) (regopt)) {:match :=~} $_)}
27
+ (send (regexp (str $#literal_at_end?) (regopt)) {:match :match?} $_)
28
+ (match-with-lvasgn (regexp (str $#literal_at_end?) (regopt)) $_)}
25
29
  PATTERN
26
30
 
27
31
  def literal_at_end?(regex_str)
@@ -36,6 +40,7 @@ module RuboCop
36
40
 
37
41
  add_offense(node)
38
42
  end
43
+ alias on_match_with_lvasgn on_send
39
44
 
40
45
  def autocorrect(node)
41
46
  redundant_regex?(node) do |receiver, regex_str|
@@ -128,7 +128,7 @@ module RuboCop
128
128
  end
129
129
 
130
130
  def indent_width
131
- @config.for_cop('IndentationWidth')['Width'] || 2
131
+ @config.for_cop('Layout/IndentationWidth')['Width'] || 2
132
132
  end
133
133
 
134
134
  def max_key_value_pairs
@@ -60,7 +60,7 @@ module RuboCop
60
60
 
61
61
  _, constant = *node.receiver
62
62
 
63
- constant == :Array || node.method_name == :to_a
63
+ constant == :Array || node.method?(:to_a)
64
64
  end
65
65
 
66
66
  def hash?(node)
@@ -69,7 +69,7 @@ module RuboCop
69
69
 
70
70
  _, constant = *node.receiver
71
71
 
72
- constant == :Hash || node.method_name == :to_h
72
+ constant == :Hash || node.method?(:to_h)
73
73
  end
74
74
  end
75
75
  end
@@ -9,8 +9,11 @@ module RuboCop
9
9
  # @example
10
10
  # # bad
11
11
  # 'abc'.match?(/\Aab/)
12
+ # /\Aab/.match?('abc')
12
13
  # 'abc' =~ /\Aab/
14
+ # /\Aab/ =~ 'abc'
13
15
  # 'abc'.match(/\Aab/)
16
+ # /\Aab/.match('abc')
14
17
  #
15
18
  # # good
16
19
  # 'abc'.start_with?('ab')
@@ -21,7 +24,8 @@ module RuboCop
21
24
 
22
25
  def_node_matcher :redundant_regex?, <<-PATTERN
23
26
  {(send $!nil? {:match :=~ :match?} (regexp (str $#literal_at_start?) (regopt)))
24
- (send (regexp (str $#literal_at_start?) (regopt)) {:match :=~} $_)}
27
+ (send (regexp (str $#literal_at_start?) (regopt)) {:match :match?} $_)
28
+ (match-with-lvasgn (regexp (str $#literal_at_start?) (regopt)) $_)}
25
29
  PATTERN
26
30
 
27
31
  def literal_at_start?(regex_str)
@@ -39,6 +43,7 @@ module RuboCop
39
43
 
40
44
  add_offense(node)
41
45
  end
46
+ alias on_match_with_lvasgn on_send
42
47
 
43
48
  def autocorrect(node)
44
49
  redundant_regex?(node) do |receiver, regex_str|
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Performance
5
5
  module Version
6
- STRING = '1.5.0'
6
+ STRING = '1.5.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.5.0
4
+ version: 1.5.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: 2019-10-01 00:00:00.000000000 Z
13
+ date: 2019-11-13 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rubocop
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
107
  - !ruby/object:Gem::Version
108
108
  version: '0'
109
109
  requirements: []
110
- rubygems_version: 3.0.6
110
+ rubygems_version: 3.0.3
111
111
  signing_key:
112
112
  specification_version: 4
113
113
  summary: Automatic performance checking tool for Ruby code.