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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b0057db5077a3ded345dc26bc31452317c972d8646102835fe6f6452d2c09a99
4
- data.tar.gz: 71a30cb395f16476d0e4150ef7de1e848a72a9df6c063d2fe63afa948328b56a
3
+ metadata.gz: 84de929227f41719d154ba01b986fa7b47302c666b6920b340271894cf56237a
4
+ data.tar.gz: 20a87b2853c7ddde2cdd8a6bb3c2495456926456e8bc49f601af5bc1bb212992
5
5
  SHA512:
6
- metadata.gz: 35b960489ce8a90ea9bee84376021229f5f66c3ff76bb331f4e6678012ec1052a1b489008a59769728fd0f1c6ad56056230bffe4fae6136076c1b5ca6a455c3f
7
- data.tar.gz: b43334414d5d99618a4102677e50c8d5bd3dd7a1657a2cdc626fb84dec220faa2a8d876df631416e4897f382140d4ee0d095d0fc4969255b3047a25fa9fd2fbc
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? || allowed_method?(node)
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']` is a receiver of `||=`, e.g. `ENV['X'] ||= y`.
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.parent&.or_asgn_type?
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
@@ -44,6 +44,7 @@ module RuboCop
44
44
 
45
45
  expression = single_argument_dig?(node)
46
46
  return unless expression
47
+ return if expression.forwarded_args_type?
47
48
 
48
49
  receiver = node.receiver.source
49
50
  argument = expression.source
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  # This module holds the RuboCop version information.
5
5
  module Version
6
- STRING = '1.28.1'
6
+ STRING = '1.28.2'
7
7
 
8
8
  MSG = '%<version>s (using Parser %<parser_version>s, '\
9
9
  'rubocop-ast %<rubocop_ast_version>s, ' \
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.1
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-21 00:00:00.000000000 Z
13
+ date: 2022-04-25 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: parallel