rubocop 1.79.1 → 1.79.2

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: dc8a905ea4a217b5c7a43390a0777107217ce2a1a14b325e5367a4dbafb6cf1d
4
- data.tar.gz: 01e471a4471ee7ac1151db63ace049693be1a8008955722b1028843034c00e82
3
+ metadata.gz: f846b1bf660549b8197375e32c8219bff1e42888b925976bd3514cd9b32c1d3b
4
+ data.tar.gz: 4e862ade4bbe0c24c7734427695733316c893b5278f9868aa88c44255d03461c
5
5
  SHA512:
6
- metadata.gz: 21c054eb2cb142bbf75ed66598252f114e1b759d4a699f6319f804ed761cdf68b51ad75a96c02475b5bafdf5341198684c3764aadd4ccdf256d0509bf207ea0c
7
- data.tar.gz: 11c7240440560b7ec024b469634ce3621a0e10363083f5ce2a8bd8d8af9ff5e5c1814a87d320297109534e0c7654c20837f9d4963e9c322e24595d907042f285
6
+ metadata.gz: 05ff2343d4ddcdd26cf94325a5b9026fb7468f456b5714da5108030c39fb0fcfb7218848596d07b04817052af53bc225e66b1f81c53f18adb780c2b4bd417012
7
+ data.tar.gz: 9c2ce30fbd9467d85bed0aa581beaa225f3e5b032f0e7a5b09130c8eb2918b25e452f3704a9774e8199c1b9e1ccb1b7d10e558a710c7a73d9f9bd86940475ebf
@@ -83,6 +83,8 @@ module RuboCop
83
83
  end
84
84
 
85
85
  def allowed_method?(node)
86
+ node = node.body if node.respond_to?(:modifier_form?) && node.modifier_form?
87
+
86
88
  return false unless node.send_type?
87
89
 
88
90
  MODULE_INCLUSION_METHODS.include?(node.method_name)
@@ -62,40 +62,19 @@ module RuboCop
62
62
  node.receiver && node.receiver.loc.last_line != node.loc.selector&.line
63
63
  end
64
64
 
65
- def empty_lines(node)
66
- lines = processed_lines(node)
67
- lines.select! { |code, _| code.empty? }
68
- lines.map { |_, line| line }
69
- end
70
-
71
- def extra_lines(node)
72
- empty_lines(node).each do |line|
73
- range = source_range(processed_source.buffer, line, 0)
74
- yield(range)
75
- end
76
- end
77
-
78
- def processed_lines(node)
79
- line_numbers(node).each_with_object([]) do |num, array|
80
- array << [processed_source.lines[num - 1], num]
65
+ def extra_lines(node, &block)
66
+ node.arguments.each do |arg|
67
+ empty_range_for_starting_point(arg.source_range.begin, &block)
81
68
  end
82
- end
83
69
 
84
- def line_numbers(node)
85
- inner_lines = []
86
- line_nums = node.arguments.each_with_object([]) do |arg_node, lines|
87
- lines << outer_lines(arg_node)
88
- inner_lines << inner_lines(arg_node) if arg_node.multiline?
89
- end
90
- line_nums.flatten.uniq - inner_lines.flatten - outer_lines(node)
70
+ empty_range_for_starting_point(node.loc.end.begin, &block) if node.loc.end
91
71
  end
92
72
 
93
- def inner_lines(node)
94
- [node.first_line + 1, node.last_line - 1]
95
- end
73
+ def empty_range_for_starting_point(start)
74
+ range = range_with_surrounding_space(start, whitespace: true, side: :left)
75
+ return unless range.last_line - range.first_line > 1
96
76
 
97
- def outer_lines(node)
98
- [node.first_line - 1, node.last_line + 1]
77
+ yield range.source_buffer.line_range(range.last_line - 1).adjust(end_pos: 1)
99
78
  end
100
79
  end
101
80
  end
@@ -71,7 +71,7 @@ module RuboCop
71
71
  KIND = 'class'
72
72
 
73
73
  def on_class(node)
74
- first_line = node.parent_class.first_line if node.parent_class
74
+ first_line = node.parent_class.last_line if node.parent_class
75
75
 
76
76
  check(node, node.body, adjusted_first_line: first_line)
77
77
  end
@@ -56,12 +56,10 @@ module RuboCop
56
56
 
57
57
  def on_send(node)
58
58
  return unless (to_h_node, map_node = map_to_h(node))
59
+ return if to_h_node.block_literal?
59
60
 
60
61
  message = format(MSG, method: map_node.loc.selector.source, dot: to_h_node.loc.dot.source)
61
62
  add_offense(map_node.loc.selector, message: message) do |corrector|
62
- # If the `to_h` call already has a block, do not autocorrect.
63
- next if to_h_node.block_literal?
64
-
65
63
  autocorrect(corrector, to_h_node, map_node)
66
64
  end
67
65
  end
@@ -40,12 +40,10 @@ module RuboCop
40
40
 
41
41
  def on_send(node)
42
42
  return unless (to_set_node, map_node = map_to_set?(node))
43
+ return if to_set_node.block_literal?
43
44
 
44
45
  message = format(MSG, method: map_node.loc.selector.source)
45
46
  add_offense(map_node.loc.selector, message: message) do |corrector|
46
- # If the `to_set` call already has a block, do not autocorrect.
47
- next if to_set_node.block_literal?
48
-
49
47
  autocorrect(corrector, to_set_node, map_node)
50
48
  end
51
49
  end
@@ -149,7 +149,7 @@ module RuboCop
149
149
  return offense(begin_node, message)
150
150
  end
151
151
 
152
- check_send(begin_node, node) if node.call_type?
152
+ check_send(begin_node, node) if call_node?(node)
153
153
  end
154
154
 
155
155
  # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
@@ -219,7 +219,13 @@ module RuboCop
219
219
  !!config.for_enabled_cop('Style/ParenthesesAroundCondition')['AllowInMultilineConditions']
220
220
  end
221
221
 
222
+ def call_node?(node)
223
+ node.call_type? || (node.any_block_type? && !node.lambda_or_proc?)
224
+ end
225
+
222
226
  def check_send(begin_node, node)
227
+ node = node.send_node if node.any_block_type?
228
+
223
229
  return check_unary(begin_node, node) if node.unary_operation?
224
230
 
225
231
  return unless method_call_with_redundant_parentheses?(node)
@@ -259,6 +259,8 @@ module RuboCop
259
259
  end
260
260
 
261
261
  def dotless_operator_call?(method_call)
262
+ method_call = method_call.parent while method_call.parent.send_type?
263
+
262
264
  return false if method_call.loc.dot
263
265
 
264
266
  method_call.method?(:[]) || method_call.method?(:[]=) || method_call.operator_method?
@@ -71,6 +71,8 @@ module RuboCop
71
71
  end
72
72
  end
73
73
 
74
+ BRANCH_NODES = %i[if case case_match rescue].freeze
75
+
74
76
  def variable_table
75
77
  @variable_table ||= VariableTable.new(self)
76
78
  end
@@ -353,15 +355,17 @@ module RuboCop
353
355
  end
354
356
  end
355
357
 
356
- def reference_assignments(loop_assignments, node)
358
+ def reference_assignments(loop_assignments, loop_node)
359
+ node = loop_assignments.first.node
360
+
357
361
  # If inside a branching statement, mark all as referenced.
358
362
  # Otherwise, mark only the last assignment as referenced.
359
363
  # Note that `rescue` must be considered as branching because of
360
364
  # the `retry` keyword.
361
- if loop_assignments.first.node.each_ancestor(:if, :rescue, :case, :case_match).any?
362
- loop_assignments.each { |assignment| assignment.reference!(node) }
365
+ if node.each_ancestor(*BRANCH_NODES).any? || node.parent.each_descendant(*BRANCH_NODES).any?
366
+ loop_assignments.each { |assignment| assignment.reference!(loop_node) }
363
367
  else
364
- loop_assignments.last&.reference!(node)
368
+ loop_assignments.last&.reference!(loop_node)
365
369
  end
366
370
  end
367
371
 
@@ -198,20 +198,22 @@ module RuboCop
198
198
  end
199
199
 
200
200
  def rubocop_extra_features
201
- lib_root = File.join(File.dirname(__FILE__), '..')
202
- exe_root = File.join(lib_root, '..', 'exe')
201
+ @rubocop_extra_features ||= begin
202
+ lib_root = File.join(File.dirname(__FILE__), '..')
203
+ exe_root = File.join(lib_root, '..', 'exe')
203
204
 
204
- # Make sure to use an absolute path to prevent errors on Windows
205
- # when traversing the relative paths with symlinks.
206
- exe_root = File.absolute_path(exe_root)
205
+ # Make sure to use an absolute path to prevent errors on Windows
206
+ # when traversing the relative paths with symlinks.
207
+ exe_root = File.absolute_path(exe_root)
207
208
 
208
- # These are all the files we have `require`d plus everything in the
209
- # exe directory. A change to any of them could affect the cop output
210
- # so we include them in the cache hash.
211
- source_files = $LOADED_FEATURES + Find.find(exe_root).to_a
212
- source_files -= ResultCache.rubocop_required_features # Rely on gem versions
209
+ # These are all the files we have `require`d plus everything in the
210
+ # exe directory. A change to any of them could affect the cop output
211
+ # so we include them in the cache hash.
212
+ source_files = $LOADED_FEATURES + Find.find(exe_root).to_a
213
+ source_files -= ResultCache.rubocop_required_features # Rely on gem versions
213
214
 
214
- source_files
215
+ source_files
216
+ end
215
217
  end
216
218
 
217
219
  # Return a hash of the options given at invocation, minus the ones that have
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  # This module holds the RuboCop version information.
5
5
  module Version
6
- STRING = '1.79.1'
6
+ STRING = '1.79.2'
7
7
 
8
8
  MSG = '%<version>s (using %<parser_version>s, ' \
9
9
  'rubocop-ast %<rubocop_ast_version>s, ' \
metadata CHANGED
@@ -1,16 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.79.1
4
+ version: 1.79.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bozhidar Batsov
8
8
  - Jonas Arvidsson
9
9
  - Yuji Nakayama
10
- autorequire:
11
10
  bindir: exe
12
11
  cert_chain: []
13
- date: 2025-07-31 00:00:00.000000000 Z
12
+ date: 2025-08-05 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: json
@@ -1091,12 +1090,11 @@ licenses:
1091
1090
  - MIT
1092
1091
  metadata:
1093
1092
  homepage_uri: https://rubocop.org/
1094
- changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.79.1
1093
+ changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.79.2
1095
1094
  source_code_uri: https://github.com/rubocop/rubocop/
1096
1095
  documentation_uri: https://docs.rubocop.org/rubocop/1.79/
1097
1096
  bug_tracker_uri: https://github.com/rubocop/rubocop/issues
1098
1097
  rubygems_mfa_required: 'true'
1099
- post_install_message:
1100
1098
  rdoc_options: []
1101
1099
  require_paths:
1102
1100
  - lib
@@ -1111,8 +1109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1111
1109
  - !ruby/object:Gem::Version
1112
1110
  version: '0'
1113
1111
  requirements: []
1114
- rubygems_version: 3.3.7
1115
- signing_key:
1112
+ rubygems_version: 3.6.2
1116
1113
  specification_version: 4
1117
1114
  summary: Automatic Ruby code style checking tool.
1118
1115
  test_files: []