rubocop 1.78.0 → 1.79.0

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.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/config/default.yml +32 -19
  4. data/lib/rubocop/cop/internal_affairs/node_type_group.rb +3 -2
  5. data/lib/rubocop/cop/internal_affairs/useless_restrict_on_send.rb +1 -1
  6. data/lib/rubocop/cop/layout/empty_lines_after_module_inclusion.rb +99 -0
  7. data/lib/rubocop/cop/layout/space_around_keyword.rb +6 -1
  8. data/lib/rubocop/cop/layout/space_around_operators.rb +8 -0
  9. data/lib/rubocop/cop/lint/numeric_operation_with_constant_result.rb +1 -0
  10. data/lib/rubocop/cop/lint/redundant_safe_navigation.rb +101 -2
  11. data/lib/rubocop/cop/lint/require_range_parentheses.rb +1 -1
  12. data/lib/rubocop/cop/lint/rescue_type.rb +1 -1
  13. data/lib/rubocop/cop/lint/useless_numeric_operation.rb +1 -0
  14. data/lib/rubocop/cop/lint/utils/nil_receiver_checker.rb +121 -0
  15. data/lib/rubocop/cop/naming/method_name.rb +15 -1
  16. data/lib/rubocop/cop/naming/predicate_method.rb +4 -1
  17. data/lib/rubocop/cop/style/access_modifier_declarations.rb +1 -1
  18. data/lib/rubocop/cop/style/accessor_grouping.rb +13 -1
  19. data/lib/rubocop/cop/style/array_intersect.rb +51 -23
  20. data/lib/rubocop/cop/style/block_delimiters.rb +1 -1
  21. data/lib/rubocop/cop/style/conditional_assignment.rb +1 -1
  22. data/lib/rubocop/cop/style/dig_chain.rb +1 -1
  23. data/lib/rubocop/cop/style/exponential_notation.rb +1 -0
  24. data/lib/rubocop/cop/style/inverse_methods.rb +1 -1
  25. data/lib/rubocop/cop/style/it_assignment.rb +69 -12
  26. data/lib/rubocop/cop/style/it_block_parameter.rb +2 -0
  27. data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +2 -4
  28. data/lib/rubocop/cop/style/parallel_assignment.rb +3 -0
  29. data/lib/rubocop/cop/style/redundant_freeze.rb +1 -1
  30. data/lib/rubocop/cop/style/redundant_line_continuation.rb +1 -1
  31. data/lib/rubocop/cop/style/redundant_parentheses.rb +1 -0
  32. data/lib/rubocop/cop/style/single_line_methods.rb +3 -3
  33. data/lib/rubocop/cop/style/sole_nested_conditional.rb +30 -1
  34. data/lib/rubocop/cop/style/stabby_lambda_parentheses.rb +1 -1
  35. data/lib/rubocop/cop/variable_force.rb +16 -7
  36. data/lib/rubocop/cops_documentation_generator.rb +1 -0
  37. data/lib/rubocop/formatter/markdown_formatter.rb +1 -0
  38. data/lib/rubocop/formatter/pacman_formatter.rb +1 -0
  39. data/lib/rubocop/version.rb +1 -1
  40. data/lib/rubocop.rb +2 -0
  41. metadata +22 -6
@@ -296,7 +296,7 @@ module RuboCop
296
296
  variable_table.accessible_variables.each { |variable| variable.reference!(node) }
297
297
  end
298
298
 
299
- # Mark all assignments which are referenced in the same loop
299
+ # Mark last assignments which are referenced in the same loop
300
300
  # as referenced by ignoring AST order since they would be referenced
301
301
  # in next iteration.
302
302
  def mark_assignments_as_referenced_in_loop(node)
@@ -308,13 +308,12 @@ module RuboCop
308
308
  # would be skipped here.
309
309
  next unless variable
310
310
 
311
- variable.assignments.each do |assignment|
312
- next if assignment_nodes_in_loop.none? do |assignment_node|
313
- assignment_node.equal?(assignment.node)
314
- end
315
-
316
- assignment.reference!(node)
311
+ loop_assignments = variable.assignments.select do |assignment|
312
+ assignment_nodes_in_loop.include?(assignment.node)
317
313
  end
314
+ next unless loop_assignments.any?
315
+
316
+ reference_assignments(loop_assignments, node)
318
317
  end
319
318
  end
320
319
 
@@ -354,6 +353,16 @@ module RuboCop
354
353
  end
355
354
  end
356
355
 
356
+ def reference_assignments(loop_assignments, node)
357
+ # If inside a case statement, mark all as referenced.
358
+ # Otherwise, mark only the last assignment as referenced.
359
+ if loop_assignments.first.node.each_ancestor(:case, :case_match).any?
360
+ loop_assignments.each { |assignment| assignment.reference!(node) }
361
+ else
362
+ loop_assignments.last&.reference!(node)
363
+ end
364
+ end
365
+
357
366
  def scanned_node?(node)
358
367
  scanned_nodes.include?(node)
359
368
  end
@@ -7,6 +7,7 @@ require 'yard'
7
7
  # @api private
8
8
  class CopsDocumentationGenerator # rubocop:disable Metrics/ClassLength
9
9
  include ::RuboCop::Cop::Documentation
10
+
10
11
  CopData = Struct.new(
11
12
  :cop, :description, :example_objects, :safety_objects, :see_objects, :config, keyword_init: true
12
13
  )
@@ -6,6 +6,7 @@ module RuboCop
6
6
  class MarkdownFormatter < BaseFormatter
7
7
  include TextUtil
8
8
  include PathUtil
9
+
9
10
  attr_reader :files, :summary
10
11
 
11
12
  def initialize(output, options = {})
@@ -9,6 +9,7 @@ module RuboCop
9
9
  # https://github.com/go-labs/rspec_pacman_formatter
10
10
  class PacmanFormatter < ClangStyleFormatter
11
11
  include TextUtil
12
+
12
13
  attr_accessor :progress_line
13
14
 
14
15
  FALLBACK_TERMINAL_WIDTH = 80
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  # This module holds the RuboCop version information.
5
5
  module Version
6
- STRING = '1.78.0'
6
+ STRING = '1.79.0'
7
7
 
8
8
  MSG = '%<version>s (using %<parser_version>s, ' \
9
9
  'rubocop-ast %<rubocop_ast_version>s, ' \
data/lib/rubocop.rb CHANGED
@@ -211,6 +211,7 @@ require_relative 'rubocop/cop/layout/empty_line_after_guard_clause'
211
211
  require_relative 'rubocop/cop/layout/empty_line_after_magic_comment'
212
212
  require_relative 'rubocop/cop/layout/empty_line_after_multiline_condition'
213
213
  require_relative 'rubocop/cop/layout/empty_line_between_defs'
214
+ require_relative 'rubocop/cop/layout/empty_lines_after_module_inclusion'
214
215
  require_relative 'rubocop/cop/layout/empty_lines_around_access_modifier'
215
216
  require_relative 'rubocop/cop/layout/empty_lines_around_arguments'
216
217
  require_relative 'rubocop/cop/layout/empty_lines_around_attribute_accessor'
@@ -290,6 +291,7 @@ require_relative 'rubocop/cop/layout/space_inside_string_interpolation'
290
291
  require_relative 'rubocop/cop/layout/trailing_empty_lines'
291
292
  require_relative 'rubocop/cop/layout/trailing_whitespace'
292
293
 
294
+ require_relative 'rubocop/cop/lint/utils/nil_receiver_checker'
293
295
  require_relative 'rubocop/cop/lint/ambiguous_assignment'
294
296
  require_relative 'rubocop/cop/lint/ambiguous_block_association'
295
297
  require_relative 'rubocop/cop/lint/ambiguous_operator'
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.78.0
4
+ version: 1.79.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bozhidar Batsov
@@ -9,7 +9,7 @@ authors:
9
9
  - Yuji Nakayama
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2025-07-08 00:00:00.000000000 Z
12
+ date: 2025-07-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
@@ -127,7 +127,7 @@ dependencies:
127
127
  requirements:
128
128
  - - ">="
129
129
  - !ruby/object:Gem::Version
130
- version: 1.45.1
130
+ version: 1.46.0
131
131
  - - "<"
132
132
  - !ruby/object:Gem::Version
133
133
  version: '2.0'
@@ -137,7 +137,7 @@ dependencies:
137
137
  requirements:
138
138
  - - ">="
139
139
  - !ruby/object:Gem::Version
140
- version: 1.45.1
140
+ version: 1.46.0
141
141
  - - "<"
142
142
  - !ruby/object:Gem::Version
143
143
  version: '2.0'
@@ -155,6 +155,20 @@ dependencies:
155
155
  - - "~>"
156
156
  - !ruby/object:Gem::Version
157
157
  version: '1.7'
158
+ - !ruby/object:Gem::Dependency
159
+ name: tsort
160
+ requirement: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - ">="
163
+ - !ruby/object:Gem::Version
164
+ version: 0.2.0
165
+ type: :runtime
166
+ prerelease: false
167
+ version_requirements: !ruby/object:Gem::Requirement
168
+ requirements:
169
+ - - ">="
170
+ - !ruby/object:Gem::Version
171
+ version: 0.2.0
158
172
  - !ruby/object:Gem::Dependency
159
173
  name: unicode-display_width
160
174
  requirement: !ruby/object:Gem::Requirement
@@ -342,6 +356,7 @@ files:
342
356
  - lib/rubocop/cop/layout/empty_line_after_multiline_condition.rb
343
357
  - lib/rubocop/cop/layout/empty_line_between_defs.rb
344
358
  - lib/rubocop/cop/layout/empty_lines.rb
359
+ - lib/rubocop/cop/layout/empty_lines_after_module_inclusion.rb
345
360
  - lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb
346
361
  - lib/rubocop/cop/layout/empty_lines_around_arguments.rb
347
362
  - lib/rubocop/cop/layout/empty_lines_around_attribute_accessor.rb
@@ -572,6 +587,7 @@ files:
572
587
  - lib/rubocop/cop/lint/useless_ruby2_keywords.rb
573
588
  - lib/rubocop/cop/lint/useless_setter_call.rb
574
589
  - lib/rubocop/cop/lint/useless_times.rb
590
+ - lib/rubocop/cop/lint/utils/nil_receiver_checker.rb
575
591
  - lib/rubocop/cop/lint/void.rb
576
592
  - lib/rubocop/cop/message_annotator.rb
577
593
  - lib/rubocop/cop/metrics/abc_size.rb
@@ -1088,9 +1104,9 @@ licenses:
1088
1104
  - MIT
1089
1105
  metadata:
1090
1106
  homepage_uri: https://rubocop.org/
1091
- changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.78.0
1107
+ changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.79.0
1092
1108
  source_code_uri: https://github.com/rubocop/rubocop/
1093
- documentation_uri: https://docs.rubocop.org/rubocop/1.78/
1109
+ documentation_uri: https://docs.rubocop.org/rubocop/1.79/
1094
1110
  bug_tracker_uri: https://github.com/rubocop/rubocop/issues
1095
1111
  rubygems_mfa_required: 'true'
1096
1112
  rdoc_options: []