rubocop 1.44.0 → 1.44.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: ad37375bb32d669c2c9ac877f9a8522829c76495e41bffb9796663807dfbcf2d
4
- data.tar.gz: 8efe81401a312e4e7f438509aa1dfa7929d505d8797863dc55c97212573fbfda
3
+ metadata.gz: 3f6f58220d287e215fa9baaa9c274e89b128c0e42222595caa432132d27de274
4
+ data.tar.gz: e3c547bef6b2803f80ba22013eae4cff56f6fb572aca19a886bb2fb52e8ba665
5
5
  SHA512:
6
- metadata.gz: 7ece75066f9a765556559a906b11feef8d68bd6fe72a160c378bd10f59c5aab66d2e1b034a0932a7cc6aeab09275e1758e3680fbb0e05e79567deefd975e94bf
7
- data.tar.gz: b1ed9f275eb702308fb17406da11b13ae79ed7453ba4145c857e5192004469c0c6ec07bab8030f6de0831bcebfb19dda4a9a484ea830d237de6c2154f571b03b
6
+ metadata.gz: f9d29df635f00839a5da2cee59c55d4a279129529e3f0b130b7ad8602058fa11e733562a8e253dfa03b45e716c406e425d6c1f28fbd5a4a0b06436404058aa91
7
+ data.tar.gz: 4a80236cfa9402004dddf72346b395e944840da07525658de1a42ce5bbef7a030be86c38af798e6cf977b75b2c6153ecd7f33b9d91ab3cec1d631b68d21a4568
@@ -157,7 +157,7 @@ module RuboCop
157
157
  def all_elements_aligned?(elements)
158
158
  elements.flat_map do |e|
159
159
  if e.hash_type?
160
- e.each_pair.map { |pair| pair.loc.column }
160
+ e.each_child_node.map { |child| child.loc.column }
161
161
  else
162
162
  e.loc.column
163
163
  end
@@ -38,6 +38,10 @@ module RuboCop
38
38
  'a whitespace to the right of the `%<operator>s` if it ' \
39
39
  'should be %<possible>s.'
40
40
 
41
+ def self.autocorrect_incompatible_with
42
+ [Naming::BlockForwarding]
43
+ end
44
+
41
45
  def on_new_investigation
42
46
  processed_source.diagnostics.each do |diagnostic|
43
47
  next unless diagnostic.reason == :ambiguous_prefix
@@ -80,6 +80,7 @@ module RuboCop
80
80
  num_of_format_args, num_of_expected_fields = count_matches(node)
81
81
 
82
82
  return false if num_of_format_args == :unknown
83
+ return false if num_of_expected_fields.zero? && node.child_nodes.first.dstr_type?
83
84
 
84
85
  matched_arguments_count?(num_of_expected_fields, num_of_format_args)
85
86
  end
@@ -8,27 +8,25 @@ module RuboCop
8
8
  #
9
9
  # @example
10
10
  # # bad
11
+ # <<-SQL
12
+ # bar
13
+ # SQL
14
+ # .strip_indent
11
15
  #
12
- # <<-SQL
13
- # bar
14
- # SQL
15
- # .strip_indent
16
- #
17
- # <<-SQL
18
- # bar
19
- # SQL
20
- # .strip_indent
21
- # .trim
16
+ # <<-SQL
17
+ # bar
18
+ # SQL
19
+ # .strip_indent
20
+ # .trim
22
21
  #
23
22
  # # good
23
+ # <<~SQL
24
+ # bar
25
+ # SQL
24
26
  #
25
- # <<~SQL
26
- # bar
27
- # SQL
28
- #
29
- # <<~SQL.trim
30
- # bar
31
- # SQL
27
+ # <<~SQL.trim
28
+ # bar
29
+ # SQL
32
30
  #
33
31
  class HeredocMethodCallPosition < Base
34
32
  include RangeHelp
@@ -8,6 +8,7 @@ module RuboCop
8
8
  # Replace numbered captures with non-capturing groupings or
9
9
  # named captures.
10
10
  #
11
+ # @example
11
12
  # # bad
12
13
  # /(?<foo>FOO)(BAR)/
13
14
  #
@@ -128,6 +128,8 @@ module RuboCop
128
128
  end
129
129
 
130
130
  def check_nonmutating(node)
131
+ return unless node.respond_to?(:method_name)
132
+
131
133
  method_name = node.method_name
132
134
  return unless NONMUTATING_METHODS.include?(method_name)
133
135
 
@@ -47,6 +47,10 @@ module RuboCop
47
47
 
48
48
  MSG = 'Use %<style>s block forwarding.'
49
49
 
50
+ def self.autocorrect_incompatible_with
51
+ [Lint::AmbiguousOperator]
52
+ end
53
+
50
54
  def on_def(node)
51
55
  return if node.arguments.empty?
52
56
 
@@ -68,7 +68,7 @@ module RuboCop
68
68
  replaced_node = ternary_replacement(node)
69
69
 
70
70
  return replaced_node unless node.parent
71
- return "(#{replaced_node})" if %i[and or].include?(node.parent.type)
71
+ return "(#{replaced_node})" if node.parent.operator_keyword?
72
72
  return "(#{replaced_node})" if node.parent.send_type? && node.parent.operator_method?
73
73
 
74
74
  replaced_node
@@ -172,7 +172,9 @@ module RuboCop
172
172
  end
173
173
 
174
174
  def modifier_statement?(node)
175
- node && %i[if while until].include?(node.type) && node.modifier_form?
175
+ return false unless node
176
+
177
+ node.basic_conditional? && node.modifier_form?
176
178
  end
177
179
 
178
180
  # An internal class for correcting parallel assignment
@@ -42,7 +42,7 @@ module RuboCop
42
42
 
43
43
  if rhs.send_type?
44
44
  check_send_node(node, rhs, var_name, var_type)
45
- elsif %i[and or].include?(rhs.type)
45
+ elsif rhs.operator_keyword?
46
46
  check_boolean_node(node, rhs, var_name, var_type)
47
47
  end
48
48
  end
@@ -76,7 +76,7 @@ module RuboCop
76
76
 
77
77
  if rhs.send_type?
78
78
  autocorrect_send_node(corrector, node, rhs)
79
- elsif %i[and or].include?(rhs.type)
79
+ elsif rhs.operator_keyword?
80
80
  autocorrect_boolean_node(corrector, node, rhs)
81
81
  end
82
82
  end
@@ -97,8 +97,10 @@ module RuboCop
97
97
  scope_stack.reverse_each do |scope|
98
98
  variable = scope.variables[name]
99
99
  return variable if variable
100
+
100
101
  # Only block scope allows referencing outer scope variables.
101
- return nil unless scope.node.block_type?
102
+ node = scope.node
103
+ return nil unless node.block_type? || node.numblock_type?
102
104
  end
103
105
 
104
106
  nil
@@ -6,7 +6,7 @@ module RuboCop
6
6
  #
7
7
  # This mixin makes it easier to specify strict offense expectations
8
8
  # in a declarative and visual fashion. Just type out the code that
9
- # should generate a offense, annotate code by writing '^'s
9
+ # should generate an offense, annotate code by writing '^'s
10
10
  # underneath each character that should be highlighted, and follow
11
11
  # the carets with a string (separated by a space) that is the
12
12
  # message of the offense. You can include multiple offenses in
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  # This module holds the RuboCop version information.
5
5
  module Version
6
- STRING = '1.44.0'
6
+ STRING = '1.44.1'
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.44.0
4
+ version: 1.44.1
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: 2023-01-23 00:00:00.000000000 Z
13
+ date: 2023-01-25 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: json