rubocop 1.28.1 → 1.28.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rubocop/cop/layout/space_before_brackets.rb +7 -0
- data/lib/rubocop/cop/lint/ambiguous_block_association.rb +2 -1
- data/lib/rubocop/cop/style/block_delimiters.rb +5 -0
- data/lib/rubocop/cop/style/fetch_env_var.rb +13 -2
- data/lib/rubocop/cop/style/single_argument_dig.rb +1 -0
- data/lib/rubocop/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: 84de929227f41719d154ba01b986fa7b47302c666b6920b340271894cf56237a
|
4
|
+
data.tar.gz: 20a87b2853c7ddde2cdd8a6bb3c2495456926456e8bc49f601af5bc1bb212992
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b6e35bb4a8b77a1969f190bda4043d7a05efa77e896cb5327acbe47755a1d12b3345de012ad8c60c7b14bb0c42bd998da28d98045039103faedfe17a178b9db
|
7
|
+
data.tar.gz: a9ba88e530a520fe10607212eb29cbb74d8f84923eaec7bc726da783c6ea6f906f28ab3473b1af99bf6b65cd781ed30630169e826a1bb7f35e140c0a00bf1aa7
|
@@ -37,6 +37,7 @@ module RuboCop
|
|
37
37
|
receiver_end_pos = node.receiver.source_range.end_pos
|
38
38
|
selector_begin_pos = node.loc.selector.begin_pos
|
39
39
|
return if receiver_end_pos >= selector_begin_pos
|
40
|
+
return if dot_before_brackets?(node, receiver_end_pos, selector_begin_pos)
|
40
41
|
|
41
42
|
range_between(receiver_end_pos, selector_begin_pos)
|
42
43
|
elsif node.method?(:[]=)
|
@@ -44,6 +45,12 @@ module RuboCop
|
|
44
45
|
end
|
45
46
|
end
|
46
47
|
|
48
|
+
def dot_before_brackets?(node, receiver_end_pos, selector_begin_pos)
|
49
|
+
return false unless node.loc.respond_to?(:dot) && (dot = node.loc.dot)
|
50
|
+
|
51
|
+
dot.begin_pos == receiver_end_pos && dot.end_pos == selector_begin_pos
|
52
|
+
end
|
53
|
+
|
47
54
|
def offense_range_for_assignment(node, begin_pos)
|
48
55
|
end_pos = node.receiver.source_range.end_pos
|
49
56
|
|
@@ -44,7 +44,8 @@ module RuboCop
|
|
44
44
|
return unless node.arguments?
|
45
45
|
|
46
46
|
return unless ambiguous_block_association?(node)
|
47
|
-
return if node.parenthesized? || node.last_argument.lambda? ||
|
47
|
+
return if node.parenthesized? || node.last_argument.lambda? || node.last_argument.proc? ||
|
48
|
+
allowed_method?(node)
|
48
49
|
|
49
50
|
message = message(node)
|
50
51
|
|
@@ -288,11 +288,16 @@ module RuboCop
|
|
288
288
|
end
|
289
289
|
|
290
290
|
def end_of_chain(node)
|
291
|
+
return end_of_chain(node.block_node) if with_block?(node)
|
291
292
|
return node unless node.chained?
|
292
293
|
|
293
294
|
end_of_chain(node.parent)
|
294
295
|
end
|
295
296
|
|
297
|
+
def with_block?(node)
|
298
|
+
node.respond_to?(:block_node) && node.block_node
|
299
|
+
end
|
300
|
+
|
296
301
|
def get_blocks(node, &block)
|
297
302
|
case node.type
|
298
303
|
when :block
|
@@ -69,9 +69,20 @@ module RuboCop
|
|
69
69
|
# - Used as a flag (e.g., `if ENV['X']` or `!ENV['X']`) because
|
70
70
|
# it simply checks whether the variable is set.
|
71
71
|
# - Receiving a message with dot syntax, e.g. `ENV['X'].nil?`.
|
72
|
-
# - `ENV['key']`
|
72
|
+
# - `ENV['key']` assigned by logical AND/OR assignment.
|
73
73
|
def allowable_use?(node)
|
74
|
-
used_as_flag?(node) || message_chained_with_dot?(node) || node
|
74
|
+
used_as_flag?(node) || message_chained_with_dot?(node) || assigned?(node)
|
75
|
+
end
|
76
|
+
|
77
|
+
# The following are allowed cases:
|
78
|
+
#
|
79
|
+
# - `ENV['key']` is a receiver of `||=`, e.g. `ENV['X'] ||= y`.
|
80
|
+
# - `ENV['key']` is a receiver of `&&=`, e.g. `ENV['X'] &&= y`.
|
81
|
+
def assigned?(node)
|
82
|
+
return false unless (parent = node.parent)&.assignment?
|
83
|
+
|
84
|
+
lhs, _method, _rhs = *parent
|
85
|
+
node == lhs
|
75
86
|
end
|
76
87
|
end
|
77
88
|
end
|
data/lib/rubocop/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.28.
|
4
|
+
version: 1.28.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bozhidar Batsov
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2022-04-
|
13
|
+
date: 2022-04-25 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: parallel
|