rubocop-performance 1.4.0 → 1.4.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7ae023c81bdf2e4816ffa5bed9a98fc10bcaec5e6e37c89f51eb9fb11fa452f
|
4
|
+
data.tar.gz: 01bc8929e0c9ab2d80933c13c35dbcc713a04574ff51002ff2f7182e05045917
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05da6b08dea1f6b8f16aa077bbfaa021b9586efb6895452f6af465fa03f695740370d8eb126d467c79565c204a2d76125fd0ce6137b9e18bb3dbe47d6c9ed44d
|
7
|
+
data.tar.gz: b0c11d70c9677b6e7e8796523b602a7dfe8ed308dfe124b26a4935193eee4293f5147cdd198b2a277841ccea131dde686c0be965811659cb030b16e3a0841b68
|
@@ -177,25 +177,42 @@ module RuboCop
|
|
177
177
|
scope_root = scope_root(match_node)
|
178
178
|
body = scope_root ? scope_body(scope_root) : match_node.ancestors.last
|
179
179
|
|
180
|
-
|
181
|
-
match_node.parent.modifier_form?
|
180
|
+
range = range_to_search_for_last_matches(match_node, body, scope_root)
|
182
181
|
|
183
|
-
|
182
|
+
find_last_match(body, range, scope_root)
|
183
|
+
end
|
184
184
|
|
185
|
+
def range_to_search_for_last_matches(match_node, body, scope_root)
|
186
|
+
expression = if modifier_form?(match_node)
|
187
|
+
match_node.parent.if_branch.loc.expression
|
188
|
+
else
|
189
|
+
match_node.loc.expression
|
190
|
+
end
|
191
|
+
|
192
|
+
match_node_pos = expression.begin_pos
|
185
193
|
next_match_pos = next_match_pos(body, match_node_pos, scope_root)
|
186
|
-
range = match_node_pos..next_match_pos
|
187
194
|
|
188
|
-
|
195
|
+
match_node_pos..next_match_pos
|
189
196
|
end
|
190
197
|
|
191
198
|
def next_match_pos(body, match_node_pos, scope_root)
|
192
199
|
node = search_match_nodes(body).find do |match|
|
193
|
-
|
194
|
-
|
200
|
+
begin_pos = if modifier_form?(match)
|
201
|
+
match.parent.if_branch.loc.expression.begin_pos
|
202
|
+
else
|
203
|
+
match.loc.expression.begin_pos
|
204
|
+
end
|
205
|
+
|
206
|
+
begin_pos > match_node_pos && scope_root(match) == scope_root
|
195
207
|
end
|
208
|
+
|
196
209
|
node ? node.loc.expression.begin_pos : Float::INFINITY
|
197
210
|
end
|
198
211
|
|
212
|
+
def modifier_form?(match_node)
|
213
|
+
match_node.parent.if_type? && match_node.parent.modifier_form?
|
214
|
+
end
|
215
|
+
|
199
216
|
def find_last_match(body, range, scope_root)
|
200
217
|
last_matches(body).find do |ref|
|
201
218
|
ref_pos = ref.loc.expression.begin_pos
|
@@ -1,13 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module RuboCop
|
4
|
-
# RuboCop included the performance cops directly before version 1.0.0.
|
5
|
-
# We can remove them to avoid warnings about redefining constants.
|
6
|
-
module Cop
|
7
|
-
remove_const('Performance') if const_defined?('Performance')
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
3
|
require_relative 'performance/caller'
|
12
4
|
require_relative 'performance/case_when_splat'
|
13
5
|
require_relative 'performance/casecmp'
|
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.
|
4
|
+
version: 1.4.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-
|
13
|
+
date: 2019-07-29 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rubocop
|