rubocop 1.84.2 → 1.86.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.
Files changed (187) hide show
  1. checksums.yaml +4 -4
  2. data/config/default.yml +91 -15
  3. data/config/obsoletion.yml +5 -0
  4. data/lib/rubocop/cache_config.rb +1 -1
  5. data/lib/rubocop/cli/command/auto_generate_config.rb +1 -1
  6. data/lib/rubocop/cli/command/mcp.rb +19 -0
  7. data/lib/rubocop/cli/command/show_cops.rb +2 -2
  8. data/lib/rubocop/cli/command/show_docs_url.rb +1 -1
  9. data/lib/rubocop/cli.rb +6 -3
  10. data/lib/rubocop/config.rb +14 -10
  11. data/lib/rubocop/config_finder.rb +1 -1
  12. data/lib/rubocop/config_loader_resolver.rb +2 -1
  13. data/lib/rubocop/config_obsoletion/extracted_cop.rb +4 -2
  14. data/lib/rubocop/config_store.rb +1 -1
  15. data/lib/rubocop/config_validator.rb +1 -1
  16. data/lib/rubocop/cop/correctors/condition_corrector.rb +1 -1
  17. data/lib/rubocop/cop/correctors/percent_literal_corrector.rb +2 -2
  18. data/lib/rubocop/cop/documentation.rb +2 -3
  19. data/lib/rubocop/cop/gemspec/require_mfa.rb +1 -1
  20. data/lib/rubocop/cop/internal_affairs/itblock_handler.rb +69 -0
  21. data/lib/rubocop/cop/internal_affairs.rb +1 -0
  22. data/lib/rubocop/cop/layout/argument_alignment.rb +2 -2
  23. data/lib/rubocop/cop/layout/array_alignment.rb +1 -1
  24. data/lib/rubocop/cop/layout/dot_position.rb +1 -1
  25. data/lib/rubocop/cop/layout/empty_line_after_guard_clause.rb +9 -2
  26. data/lib/rubocop/cop/layout/empty_line_between_defs.rb +1 -1
  27. data/lib/rubocop/cop/layout/empty_lines_around_attribute_accessor.rb +1 -0
  28. data/lib/rubocop/cop/layout/empty_lines_around_block_body.rb +12 -2
  29. data/lib/rubocop/cop/layout/empty_lines_around_class_body.rb +16 -2
  30. data/lib/rubocop/cop/layout/empty_lines_around_module_body.rb +16 -2
  31. data/lib/rubocop/cop/layout/end_alignment.rb +6 -3
  32. data/lib/rubocop/cop/layout/first_hash_element_indentation.rb +7 -1
  33. data/lib/rubocop/cop/layout/hash_alignment.rb +1 -1
  34. data/lib/rubocop/cop/layout/indentation_width.rb +1 -1
  35. data/lib/rubocop/cop/layout/line_length.rb +5 -3
  36. data/lib/rubocop/cop/layout/multiline_assignment_layout.rb +9 -2
  37. data/lib/rubocop/cop/layout/multiline_method_call_indentation.rb +28 -3
  38. data/lib/rubocop/cop/layout/parameter_alignment.rb +1 -1
  39. data/lib/rubocop/cop/layout/redundant_line_break.rb +1 -1
  40. data/lib/rubocop/cop/layout/space_around_block_parameters.rb +1 -1
  41. data/lib/rubocop/cop/layout/space_around_keyword.rb +3 -1
  42. data/lib/rubocop/cop/layout/space_in_lambda_literal.rb +1 -0
  43. data/lib/rubocop/cop/lint/constant_reassignment.rb +59 -9
  44. data/lib/rubocop/cop/lint/constant_resolution.rb +1 -1
  45. data/lib/rubocop/cop/lint/data_define_override.rb +63 -0
  46. data/lib/rubocop/cop/lint/duplicate_methods.rb +55 -8
  47. data/lib/rubocop/cop/lint/empty_block.rb +1 -1
  48. data/lib/rubocop/cop/lint/empty_conditional_body.rb +6 -1
  49. data/lib/rubocop/cop/lint/empty_in_pattern.rb +8 -1
  50. data/lib/rubocop/cop/lint/empty_when.rb +8 -1
  51. data/lib/rubocop/cop/lint/interpolation_check.rb +7 -2
  52. data/lib/rubocop/cop/lint/next_without_accumulator.rb +2 -0
  53. data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +3 -1
  54. data/lib/rubocop/cop/lint/number_conversion.rb +1 -1
  55. data/lib/rubocop/cop/lint/redundant_cop_enable_directive.rb +0 -9
  56. data/lib/rubocop/cop/lint/redundant_safe_navigation.rb +23 -6
  57. data/lib/rubocop/cop/lint/safe_navigation_chain.rb +17 -0
  58. data/lib/rubocop/cop/lint/safe_navigation_consistency.rb +7 -1
  59. data/lib/rubocop/cop/lint/syntax.rb +25 -1
  60. data/lib/rubocop/cop/lint/trailing_comma_in_attribute_declaration.rb +1 -0
  61. data/lib/rubocop/cop/lint/unmodified_reduce_accumulator.rb +1 -0
  62. data/lib/rubocop/cop/lint/unreachable_pattern_branch.rb +113 -0
  63. data/lib/rubocop/cop/lint/unused_method_argument.rb +10 -0
  64. data/lib/rubocop/cop/lint/useless_assignment.rb +1 -1
  65. data/lib/rubocop/cop/lint/useless_constant_scoping.rb +4 -4
  66. data/lib/rubocop/cop/lint/useless_default_value_argument.rb +2 -0
  67. data/lib/rubocop/cop/lint/utils/nil_receiver_checker.rb +22 -7
  68. data/lib/rubocop/cop/lint/void.rb +32 -12
  69. data/lib/rubocop/cop/metrics/block_nesting.rb +23 -0
  70. data/lib/rubocop/cop/migration/department_name.rb +12 -1
  71. data/lib/rubocop/cop/mixin/check_line_breakable.rb +1 -1
  72. data/lib/rubocop/cop/mixin/check_single_line_suitability.rb +2 -2
  73. data/lib/rubocop/cop/mixin/hash_transform_method/autocorrection.rb +63 -0
  74. data/lib/rubocop/cop/mixin/hash_transform_method.rb +10 -60
  75. data/lib/rubocop/cop/naming/block_parameter_name.rb +1 -1
  76. data/lib/rubocop/cop/registry.rb +20 -13
  77. data/lib/rubocop/cop/security/eval.rb +15 -2
  78. data/lib/rubocop/cop/style/access_modifier_declarations.rb +14 -2
  79. data/lib/rubocop/cop/style/accessor_grouping.rb +4 -2
  80. data/lib/rubocop/cop/style/alias.rb +4 -1
  81. data/lib/rubocop/cop/style/and_or.rb +1 -0
  82. data/lib/rubocop/cop/style/arguments_forwarding.rb +25 -7
  83. data/lib/rubocop/cop/style/array_join.rb +4 -2
  84. data/lib/rubocop/cop/style/ascii_comments.rb +6 -3
  85. data/lib/rubocop/cop/style/attr.rb +5 -2
  86. data/lib/rubocop/cop/style/bare_percent_literals.rb +3 -1
  87. data/lib/rubocop/cop/style/begin_block.rb +3 -1
  88. data/lib/rubocop/cop/style/block_delimiters.rb +25 -33
  89. data/lib/rubocop/cop/style/case_equality.rb +4 -0
  90. data/lib/rubocop/cop/style/class_and_module_children.rb +10 -2
  91. data/lib/rubocop/cop/style/collection_compact.rb +36 -16
  92. data/lib/rubocop/cop/style/colon_method_call.rb +3 -1
  93. data/lib/rubocop/cop/style/concat_array_literals.rb +2 -0
  94. data/lib/rubocop/cop/style/conditional_assignment.rb +0 -4
  95. data/lib/rubocop/cop/style/copyright.rb +1 -1
  96. data/lib/rubocop/cop/style/each_for_simple_loop.rb +1 -1
  97. data/lib/rubocop/cop/style/each_with_object.rb +2 -0
  98. data/lib/rubocop/cop/style/empty_block_parameter.rb +1 -1
  99. data/lib/rubocop/cop/style/empty_class_definition.rb +43 -20
  100. data/lib/rubocop/cop/style/empty_lambda_parameter.rb +1 -1
  101. data/lib/rubocop/cop/style/encoding.rb +7 -1
  102. data/lib/rubocop/cop/style/end_block.rb +3 -1
  103. data/lib/rubocop/cop/style/endless_method.rb +8 -3
  104. data/lib/rubocop/cop/style/file_open.rb +84 -0
  105. data/lib/rubocop/cop/style/for.rb +3 -0
  106. data/lib/rubocop/cop/style/format_string_token.rb +29 -2
  107. data/lib/rubocop/cop/style/global_vars.rb +5 -2
  108. data/lib/rubocop/cop/style/guard_clause.rb +9 -6
  109. data/lib/rubocop/cop/style/hash_as_last_array_item.rb +21 -5
  110. data/lib/rubocop/cop/style/hash_lookup_method.rb +7 -0
  111. data/lib/rubocop/cop/style/hash_transform_keys.rb +17 -7
  112. data/lib/rubocop/cop/style/hash_transform_values.rb +17 -7
  113. data/lib/rubocop/cop/style/if_inside_else.rb +1 -5
  114. data/lib/rubocop/cop/style/if_unless_modifier.rb +14 -3
  115. data/lib/rubocop/cop/style/if_with_semicolon.rb +7 -5
  116. data/lib/rubocop/cop/style/inline_comment.rb +4 -1
  117. data/lib/rubocop/cop/style/ip_addresses.rb +1 -2
  118. data/lib/rubocop/cop/style/magic_comment_format.rb +2 -2
  119. data/lib/rubocop/cop/style/map_join.rb +123 -0
  120. data/lib/rubocop/cop/style/method_call_with_args_parentheses/require_parentheses.rb +5 -3
  121. data/lib/rubocop/cop/style/module_member_existence_check.rb +1 -11
  122. data/lib/rubocop/cop/style/multiline_if_then.rb +3 -1
  123. data/lib/rubocop/cop/style/mutable_constant.rb +1 -1
  124. data/lib/rubocop/cop/style/nil_comparison.rb +2 -3
  125. data/lib/rubocop/cop/style/nil_lambda.rb +1 -1
  126. data/lib/rubocop/cop/style/non_nil_check.rb +5 -11
  127. data/lib/rubocop/cop/style/not.rb +2 -0
  128. data/lib/rubocop/cop/style/numeric_literals.rb +3 -2
  129. data/lib/rubocop/cop/style/one_class_per_file.rb +115 -0
  130. data/lib/rubocop/cop/style/one_line_conditional.rb +4 -3
  131. data/lib/rubocop/cop/style/parallel_assignment.rb +4 -0
  132. data/lib/rubocop/cop/style/partition_instead_of_double_select.rb +270 -0
  133. data/lib/rubocop/cop/style/percent_literal_delimiters.rb +2 -0
  134. data/lib/rubocop/cop/style/predicate_with_kind.rb +84 -0
  135. data/lib/rubocop/cop/style/proc.rb +3 -2
  136. data/lib/rubocop/cop/style/raise_args.rb +1 -1
  137. data/lib/rubocop/cop/style/reduce_to_hash.rb +184 -0
  138. data/lib/rubocop/cop/style/redundant_begin.rb +3 -3
  139. data/lib/rubocop/cop/style/redundant_each.rb +3 -3
  140. data/lib/rubocop/cop/style/redundant_fetch_block.rb +1 -1
  141. data/lib/rubocop/cop/style/redundant_interpolation_unfreeze.rb +26 -10
  142. data/lib/rubocop/cop/style/redundant_line_continuation.rb +16 -0
  143. data/lib/rubocop/cop/style/redundant_min_max_by.rb +93 -0
  144. data/lib/rubocop/cop/style/redundant_parentheses.rb +25 -22
  145. data/lib/rubocop/cop/style/redundant_percent_q.rb +4 -1
  146. data/lib/rubocop/cop/style/redundant_return.rb +3 -1
  147. data/lib/rubocop/cop/style/redundant_self_assignment_branch.rb +0 -5
  148. data/lib/rubocop/cop/style/redundant_struct_keyword_init.rb +114 -0
  149. data/lib/rubocop/cop/style/safe_navigation.rb +7 -7
  150. data/lib/rubocop/cop/style/select_by_kind.rb +158 -0
  151. data/lib/rubocop/cop/style/select_by_range.rb +197 -0
  152. data/lib/rubocop/cop/style/select_by_regexp.rb +51 -21
  153. data/lib/rubocop/cop/style/semicolon.rb +2 -0
  154. data/lib/rubocop/cop/style/single_line_block_params.rb +2 -2
  155. data/lib/rubocop/cop/style/single_line_do_end_block.rb +1 -1
  156. data/lib/rubocop/cop/style/single_line_methods.rb +3 -1
  157. data/lib/rubocop/cop/style/special_global_vars.rb +6 -1
  158. data/lib/rubocop/cop/style/symbol_proc.rb +4 -3
  159. data/lib/rubocop/cop/style/tally_method.rb +181 -0
  160. data/lib/rubocop/cop/style/trailing_comma_in_block_args.rb +1 -1
  161. data/lib/rubocop/cop/style/trailing_method_end_statement.rb +1 -0
  162. data/lib/rubocop/cop/style/yoda_expression.rb +1 -1
  163. data/lib/rubocop/cop/variable_force/branch.rb +2 -2
  164. data/lib/rubocop/directive_comment.rb +2 -1
  165. data/lib/rubocop/formatter/disabled_config_formatter.rb +1 -1
  166. data/lib/rubocop/formatter/formatter_set.rb +1 -1
  167. data/lib/rubocop/formatter/junit_formatter.rb +1 -1
  168. data/lib/rubocop/formatter/simple_text_formatter.rb +0 -2
  169. data/lib/rubocop/formatter/worst_offenders_formatter.rb +1 -1
  170. data/lib/rubocop/formatter.rb +22 -21
  171. data/lib/rubocop/lsp/diagnostic.rb +1 -0
  172. data/lib/rubocop/lsp/routes.rb +10 -3
  173. data/lib/rubocop/mcp/server.rb +200 -0
  174. data/lib/rubocop/options.rb +10 -1
  175. data/lib/rubocop/path_util.rb +14 -2
  176. data/lib/rubocop/plugin/loader.rb +1 -1
  177. data/lib/rubocop/result_cache.rb +22 -10
  178. data/lib/rubocop/rspec/cop_helper.rb +8 -0
  179. data/lib/rubocop/rspec/shared_contexts.rb +11 -2
  180. data/lib/rubocop/runner.rb +8 -3
  181. data/lib/rubocop/server/cache.rb +5 -7
  182. data/lib/rubocop/server/core.rb +2 -0
  183. data/lib/rubocop/target_finder.rb +1 -1
  184. data/lib/rubocop/target_ruby.rb +18 -12
  185. data/lib/rubocop/version.rb +2 -2
  186. data/lib/rubocop.rb +14 -0
  187. metadata +22 -5
@@ -27,6 +27,7 @@ module RuboCop
27
27
  # there's parallel execution and the cache is shared.
28
28
  def self.cleanup(config_store, verbose, cache_root_override = nil)
29
29
  return if inhibit_cleanup # OPTIMIZE: For faster testing
30
+ return unless config_store.for_pwd.for_all_cops['MaxFilesInCache']
30
31
 
31
32
  rubocop_cache_dir = cache_root(config_store, cache_root_override)
32
33
  return unless File.exist?(rubocop_cache_dir)
@@ -85,15 +86,23 @@ module RuboCop
85
86
  end
86
87
 
87
88
  def self.cache_root(config_store, cache_root_override = nil)
88
- CacheConfig.root_dir do
89
+ return @cache_root if @cache_root && !cache_root_override
90
+
91
+ result = CacheConfig.root_dir do
89
92
  cache_root_override || config_store.for_pwd.for_all_cops['CacheRootDirectory']
90
93
  end
94
+ @cache_root = result unless cache_root_override
95
+ result
91
96
  end
92
97
 
93
98
  def self.allow_symlinks_in_cache_location?(config_store)
94
99
  config_store.for_pwd.for_all_cops['AllowSymlinksInCacheRootDirectory']
95
100
  end
96
101
 
102
+ def self.reset_config_cache
103
+ @cache_root = nil
104
+ end
105
+
97
106
  attr_reader :path
98
107
 
99
108
  def initialize(file, team, options, config_store, cache_root_override = nil)
@@ -196,6 +205,17 @@ module RuboCop
196
205
  end
197
206
  end
198
207
 
208
+ # Return a hash of the options given at invocation, minus the ones that have
209
+ # no effect on which offenses and disabled line ranges are found, and thus
210
+ # don't affect caching.
211
+ def relevant_options_digest(options)
212
+ @relevant_options_digest ||= {}
213
+ @relevant_options_digest[options] ||= begin
214
+ options = options.reject { |key, _| NON_CHANGING.include?(key) }
215
+ options.to_s.gsub(/[^a-z]+/i, '_')
216
+ end
217
+ end
218
+
199
219
  private
200
220
 
201
221
  def digest(path)
@@ -227,20 +247,12 @@ module RuboCop
227
247
  end
228
248
  end
229
249
 
230
- # Return a hash of the options given at invocation, minus the ones that have
231
- # no effect on which offenses and disabled line ranges are found, and thus
232
- # don't affect caching.
233
- def relevant_options_digest(options)
234
- options = options.reject { |key, _| NON_CHANGING.include?(key) }
235
- options.to_s.gsub(/[^a-z]+/i, '_')
236
- end
237
-
238
250
  # We combine team and options into a single "context" checksum to avoid
239
251
  # making file names that are too long for some filesystems to handle.
240
252
  # This context is for anything that's not (1) the RuboCop executable
241
253
  # checksum or (2) the inspected file checksum.
242
254
  def context_checksum(team, options)
243
- keys = [team.external_dependency_checksum, relevant_options_digest(options)]
255
+ keys = [team.external_dependency_checksum, self.class.relevant_options_digest(options)]
244
256
  Digest::SHA1.hexdigest(keys.join)
245
257
  end
246
258
  end
@@ -6,6 +6,12 @@ require 'tempfile'
6
6
  module CopHelper
7
7
  extend RSpec::SharedContext
8
8
 
9
+ @integrated_plugins = false
10
+
11
+ class << self
12
+ attr_accessor :integrated_plugins
13
+ end
14
+
9
15
  let(:ruby_version) do
10
16
  # The minimum version Prism can parse is 3.3.
11
17
  ENV['PARSER_ENGINE'] == 'parser_prism' ? 3.3 : RuboCop::TargetRuby::DEFAULT_VERSION
@@ -18,11 +24,13 @@ module CopHelper
18
24
 
19
25
  before(:all) do
20
26
  next if ENV['RUBOCOP_CORE_DEVELOPMENT']
27
+ next if CopHelper.integrated_plugins
21
28
 
22
29
  plugins = Gem.loaded_specs.filter_map do |feature_name, feature_specification|
23
30
  feature_name if feature_specification.metadata['default_lint_roller_plugin']
24
31
  end
25
32
  RuboCop::Plugin.integrate_plugins(RuboCop::Config.new, plugins)
33
+ CopHelper.integrated_plugins = true
26
34
  end
27
35
 
28
36
  def inspect_source(source, file = nil)
@@ -2,8 +2,12 @@
2
2
 
3
3
  require 'tmpdir'
4
4
 
5
+ # Reset cached PathUtil.pwd before each example so that tests using Dir.chdir
6
+ # or stubbing Dir.pwd get a fresh value.
7
+ RSpec.configure { |c| c.before { RuboCop::PathUtil.reset_pwd } }
8
+
5
9
  RSpec.shared_context 'isolated environment' do # rubocop:disable Metrics/BlockLength
6
- around do |example|
10
+ around do |example| # rubocop:disable Metrics/BlockLength
7
11
  Dir.mktmpdir do |tmpdir|
8
12
  original_home = Dir.home
9
13
  original_xdg_config_home = ENV.fetch('XDG_CONFIG_HOME', nil)
@@ -26,11 +30,16 @@ RSpec.shared_context 'isolated environment' do # rubocop:disable Metrics/BlockLe
26
30
  begin
27
31
  FileUtils.mkdir_p(working_dir)
28
32
 
29
- Dir.chdir(working_dir) { example.run }
33
+ Dir.chdir(working_dir) do
34
+ RuboCop::PathUtil.reset_pwd
35
+ RuboCop::ResultCache.reset_config_cache
36
+ example.run
37
+ end
30
38
  ensure
31
39
  ENV['HOME'] = original_home
32
40
  ENV['XDG_CONFIG_HOME'] = original_xdg_config_home
33
41
 
42
+ RuboCop::ResultCache.reset_config_cache
34
43
  RuboCop::ConfigLoader.clear_options # This also resets RuboCop::FileFinder.root_level
35
44
  end
36
45
  end
@@ -194,7 +194,7 @@ module RuboCop
194
194
 
195
195
  if real_run_needed
196
196
  offenses = yield
197
- save_in_cache(cache, offenses)
197
+ save_in_cache(cache, offenses) unless Cop::Registry.global.warnings?(file)
198
198
  end
199
199
 
200
200
  offenses
@@ -350,7 +350,9 @@ module RuboCop
350
350
 
351
351
  def inspect_file(processed_source, team = mobilize_team(processed_source))
352
352
  extracted_ruby_sources = extract_ruby_sources(processed_source)
353
- offenses = extracted_ruby_sources.flat_map do |extracted_ruby_source|
353
+ offenses = []
354
+
355
+ extracted_ruby_sources.each do |extracted_ruby_source|
354
356
  report = team.investigate(
355
357
  extracted_ruby_source[:processed_source],
356
358
  offset: extracted_ruby_source[:offset],
@@ -358,8 +360,11 @@ module RuboCop
358
360
  )
359
361
  @errors.concat(team.errors)
360
362
  @warnings.concat(team.warnings)
361
- report.offenses
363
+ offenses.concat(report.offenses)
364
+
365
+ break if team.updated_source_file?
362
366
  end
367
+
363
368
  [offenses, team.updated_source_file?]
364
369
  end
365
370
 
@@ -114,13 +114,11 @@ module RuboCop
114
114
  end
115
115
 
116
116
  def acquire_lock
117
- lock_file = File.open(lock_path, File::CREAT)
118
- # flock returns 0 if successful, and false if not.
119
- flock_result = lock_file.flock(File::LOCK_EX | File::LOCK_NB)
120
- yield flock_result != false
121
- ensure
122
- lock_file.flock(File::LOCK_UN)
123
- lock_file.close
117
+ File.open(lock_path, File::CREAT) do |lock_file|
118
+ # flock returns 0 if successful, and false if not.
119
+ flock_result = lock_file.flock(File::LOCK_EX | File::LOCK_NB)
120
+ yield flock_result != false
121
+ end
124
122
  end
125
123
 
126
124
  def write_port_and_token_files(port:, token:)
@@ -45,6 +45,8 @@ module RuboCop
45
45
  write_port_and_token_files
46
46
 
47
47
  pid = fork do
48
+ # NOTE: As of Ruby 4.0.0, ZJIT is still under development, while YJIT is production-ready,
49
+ # so support for ZJIT is deferred.
48
50
  if defined?(RubyVM::YJIT.enable)
49
51
  RubyVM::YJIT.enable
50
52
  end
@@ -38,7 +38,7 @@ module RuboCop
38
38
  # @param base_dir Root directory under which to search for
39
39
  # ruby source files
40
40
  # @return [Array] Array of filenames
41
- def target_files_in_dir(base_dir = Dir.pwd)
41
+ def target_files_in_dir(base_dir = PathUtil.pwd)
42
42
  # Support Windows: Backslashes from command-line -> forward slashes
43
43
  base_dir = base_dir.gsub(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
44
44
  all_files = find_files(base_dir, File::FNM_DOTMATCH)
@@ -160,21 +160,18 @@ module RuboCop
160
160
  # The target ruby version may be found in a .ruby-version file.
161
161
  # @api private
162
162
  class RubyVersionFile < Source
163
- RUBY_VERSION_FILENAME = '.ruby-version'
164
- RUBY_VERSION_PATTERN = /\A(?:ruby-)?(?<version>\d+\.\d+)/.freeze
165
-
166
163
  def name
167
- "`#{RUBY_VERSION_FILENAME}`"
164
+ "`#{filename}`"
168
165
  end
169
166
 
170
167
  private
171
168
 
172
169
  def filename
173
- RUBY_VERSION_FILENAME
170
+ '.ruby-version'
174
171
  end
175
172
 
176
173
  def pattern
177
- RUBY_VERSION_PATTERN
174
+ /\A(?:ruby-)?(?<version>\d+\.\d+)/.freeze
178
175
  end
179
176
 
180
177
  def find_version
@@ -193,21 +190,29 @@ module RuboCop
193
190
  # starting with `ruby`.
194
191
  # @api private
195
192
  class ToolVersionsFile < RubyVersionFile
196
- TOOL_VERSIONS_FILENAME = '.tool-versions'
197
- TOOL_VERSIONS_PATTERN = /^(?:ruby )(?<version>\d+\.\d+)/.freeze
193
+ private
198
194
 
199
- def name
200
- "`#{TOOL_VERSIONS_FILENAME}`"
195
+ def filename
196
+ '.tool-versions'
201
197
  end
202
198
 
199
+ def pattern
200
+ /^(?:ruby )(?<version>\d+\.\d+)/.freeze
201
+ end
202
+ end
203
+
204
+ # The target ruby version may be found in a mise.toml file, in a line
205
+ # starting with `ruby = "`.
206
+ # @api private
207
+ class MiseTomlFile < RubyVersionFile
203
208
  private
204
209
 
205
210
  def filename
206
- TOOL_VERSIONS_FILENAME
211
+ 'mise.toml'
207
212
  end
208
213
 
209
214
  def pattern
210
- TOOL_VERSIONS_PATTERN
215
+ /^ruby = "(?<version>\d+\.\d+)/.freeze
211
216
  end
212
217
  end
213
218
 
@@ -275,6 +280,7 @@ module RuboCop
275
280
  RuboCopConfig,
276
281
  GemspecFile,
277
282
  RubyVersionFile,
283
+ MiseTomlFile,
278
284
  ToolVersionsFile,
279
285
  BundlerLockFile,
280
286
  Default
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  # This module holds the RuboCop version information.
5
5
  module Version
6
- STRING = '1.84.2'
6
+ STRING = '1.86.1'
7
7
 
8
8
  MSG = '%<version>s (using %<parser_version>s, ' \
9
9
  'rubocop-ast %<rubocop_ast_version>s, ' \
@@ -55,7 +55,7 @@ module RuboCop
55
55
 
56
56
  # @api private
57
57
  def self.parser_version(target_ruby_version)
58
- config_path = ConfigFinder.find_config_path(Dir.pwd)
58
+ config_path = ConfigFinder.find_config_path(PathUtil.pwd)
59
59
  yaml = Util.silence_warnings do
60
60
  ConfigLoader.load_yaml_configuration(config_path)
61
61
  end
data/lib/rubocop.rb CHANGED
@@ -309,6 +309,7 @@ require_relative 'rubocop/cop/lint/constant_overwritten_in_rescue'
309
309
  require_relative 'rubocop/cop/lint/constant_reassignment'
310
310
  require_relative 'rubocop/cop/lint/constant_resolution'
311
311
  require_relative 'rubocop/cop/lint/cop_directive_syntax'
312
+ require_relative 'rubocop/cop/lint/data_define_override'
312
313
  require_relative 'rubocop/cop/lint/debugger'
313
314
  require_relative 'rubocop/cop/lint/deprecated_class_methods'
314
315
  require_relative 'rubocop/cop/lint/deprecated_constants'
@@ -426,6 +427,7 @@ require_relative 'rubocop/cop/lint/unified_integer'
426
427
  require_relative 'rubocop/cop/lint/unmodified_reduce_accumulator'
427
428
  require_relative 'rubocop/cop/lint/unreachable_code'
428
429
  require_relative 'rubocop/cop/lint/unreachable_loop'
430
+ require_relative 'rubocop/cop/lint/unreachable_pattern_branch'
429
431
  require_relative 'rubocop/cop/lint/unused_block_argument'
430
432
  require_relative 'rubocop/cop/lint/unused_method_argument'
431
433
  require_relative 'rubocop/cop/lint/uri_escape_unescape'
@@ -561,6 +563,7 @@ require_relative 'rubocop/cop/style/exponential_notation'
561
563
  require_relative 'rubocop/cop/style/fetch_env_var'
562
564
  require_relative 'rubocop/cop/style/file_empty'
563
565
  require_relative 'rubocop/cop/style/file_null'
566
+ require_relative 'rubocop/cop/style/file_open'
564
567
  require_relative 'rubocop/cop/style/file_read'
565
568
  require_relative 'rubocop/cop/style/file_touch'
566
569
  require_relative 'rubocop/cop/style/file_write'
@@ -592,6 +595,7 @@ require_relative 'rubocop/cop/style/if_with_semicolon'
592
595
  require_relative 'rubocop/cop/style/implicit_runtime_error'
593
596
  require_relative 'rubocop/cop/style/in_pattern_then'
594
597
  require_relative 'rubocop/cop/style/infinite_loop'
598
+ require_relative 'rubocop/cop/style/reduce_to_hash'
595
599
  require_relative 'rubocop/cop/style/inverse_methods'
596
600
  require_relative 'rubocop/cop/style/inline_comment'
597
601
  require_relative 'rubocop/cop/style/invertible_unless_condition'
@@ -605,6 +609,7 @@ require_relative 'rubocop/cop/style/lambda_call'
605
609
  require_relative 'rubocop/cop/style/line_end_concatenation'
606
610
  require_relative 'rubocop/cop/style/magic_comment_format'
607
611
  require_relative 'rubocop/cop/style/map_into_array'
612
+ require_relative 'rubocop/cop/style/map_join'
608
613
  require_relative 'rubocop/cop/style/map_to_hash'
609
614
  require_relative 'rubocop/cop/style/map_to_set'
610
615
  require_relative 'rubocop/cop/style/method_call_without_args_parentheses'
@@ -613,8 +618,10 @@ require_relative 'rubocop/cop/style/min_max_comparison'
613
618
  require_relative 'rubocop/cop/style/module_member_existence_check'
614
619
  require_relative 'rubocop/cop/style/multiline_in_pattern_then'
615
620
  require_relative 'rubocop/cop/style/numbered_parameters'
621
+ require_relative 'rubocop/cop/style/one_class_per_file'
616
622
  require_relative 'rubocop/cop/style/open_struct_use'
617
623
  require_relative 'rubocop/cop/style/operator_method_call'
624
+ require_relative 'rubocop/cop/style/partition_instead_of_double_select'
618
625
  require_relative 'rubocop/cop/style/redundant_array_constructor'
619
626
  require_relative 'rubocop/cop/style/redundant_array_flatten'
620
627
  require_relative 'rubocop/cop/style/redundant_assignment'
@@ -630,10 +637,12 @@ require_relative 'rubocop/cop/style/redundant_heredoc_delimiter_quotes'
630
637
  require_relative 'rubocop/cop/style/redundant_initialize'
631
638
  require_relative 'rubocop/cop/style/redundant_interpolation_unfreeze'
632
639
  require_relative 'rubocop/cop/style/redundant_line_continuation'
640
+ require_relative 'rubocop/cop/style/redundant_min_max_by'
633
641
  require_relative 'rubocop/cop/style/redundant_regexp_argument'
634
642
  require_relative 'rubocop/cop/style/redundant_regexp_constructor'
635
643
  require_relative 'rubocop/cop/style/redundant_self_assignment'
636
644
  require_relative 'rubocop/cop/style/redundant_self_assignment_branch'
645
+ require_relative 'rubocop/cop/style/redundant_struct_keyword_init'
637
646
  require_relative 'rubocop/cop/style/require_order'
638
647
  require_relative 'rubocop/cop/style/reverse_find'
639
648
  require_relative 'rubocop/cop/style/safe_navigation_chain_length'
@@ -687,6 +696,7 @@ require_relative 'rubocop/cop/style/parentheses_around_condition'
687
696
  require_relative 'rubocop/cop/style/percent_literal_delimiters'
688
697
  require_relative 'rubocop/cop/style/percent_q_literals'
689
698
  require_relative 'rubocop/cop/style/perl_backrefs'
699
+ require_relative 'rubocop/cop/style/predicate_with_kind'
690
700
  require_relative 'rubocop/cop/style/preferred_hash_methods'
691
701
  require_relative 'rubocop/cop/style/proc'
692
702
  require_relative 'rubocop/cop/style/quoted_symbols'
@@ -716,6 +726,8 @@ require_relative 'rubocop/cop/style/return_nil'
716
726
  require_relative 'rubocop/cop/style/return_nil_in_predicate_method_definition'
717
727
  require_relative 'rubocop/cop/style/safe_navigation'
718
728
  require_relative 'rubocop/cop/style/sample'
729
+ require_relative 'rubocop/cop/style/select_by_kind'
730
+ require_relative 'rubocop/cop/style/select_by_range'
719
731
  require_relative 'rubocop/cop/style/select_by_regexp'
720
732
  require_relative 'rubocop/cop/style/self_assignment'
721
733
  require_relative 'rubocop/cop/style/semicolon'
@@ -743,6 +755,7 @@ require_relative 'rubocop/cop/style/swap_values'
743
755
  require_relative 'rubocop/cop/style/symbol_array'
744
756
  require_relative 'rubocop/cop/style/symbol_literal'
745
757
  require_relative 'rubocop/cop/style/symbol_proc'
758
+ require_relative 'rubocop/cop/style/tally_method'
746
759
  require_relative 'rubocop/cop/style/ternary_parentheses'
747
760
  require_relative 'rubocop/cop/style/top_level_method_definition'
748
761
  require_relative 'rubocop/cop/style/trailing_body_on_class'
@@ -811,6 +824,7 @@ require_relative 'rubocop/cli/command/auto_generate_config'
811
824
  require_relative 'rubocop/cli/command/execute_runner'
812
825
  require_relative 'rubocop/cli/command/init_dotfile'
813
826
  require_relative 'rubocop/cli/command/lsp'
827
+ require_relative 'rubocop/cli/command/mcp'
814
828
  require_relative 'rubocop/cli/command/show_cops'
815
829
  require_relative 'rubocop/cli/command/show_docs_url'
816
830
  require_relative 'rubocop/cli/command/suggest_extensions'
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.84.2
4
+ version: 1.86.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bozhidar Batsov
@@ -57,14 +57,14 @@ dependencies:
57
57
  name: parallel
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - "~>"
60
+ - - ">="
61
61
  - !ruby/object:Gem::Version
62
62
  version: '1.10'
63
63
  type: :runtime
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - "~>"
67
+ - - ">="
68
68
  - !ruby/object:Gem::Version
69
69
  version: '1.10'
70
70
  - !ruby/object:Gem::Dependency
@@ -208,6 +208,7 @@ files:
208
208
  - lib/rubocop/cli/command/execute_runner.rb
209
209
  - lib/rubocop/cli/command/init_dotfile.rb
210
210
  - lib/rubocop/cli/command/lsp.rb
211
+ - lib/rubocop/cli/command/mcp.rb
211
212
  - lib/rubocop/cli/command/show_cops.rb
212
213
  - lib/rubocop/cli/command/show_docs_url.rb
213
214
  - lib/rubocop/cli/command/suggest_extensions.rb
@@ -286,6 +287,7 @@ files:
286
287
  - lib/rubocop/cop/internal_affairs/example_description.rb
287
288
  - lib/rubocop/cop/internal_affairs/example_heredoc_delimiter.rb
288
289
  - lib/rubocop/cop/internal_affairs/inherit_deprecated_cop_class.rb
290
+ - lib/rubocop/cop/internal_affairs/itblock_handler.rb
289
291
  - lib/rubocop/cop/internal_affairs/lambda_or_proc.rb
290
292
  - lib/rubocop/cop/internal_affairs/location_exists.rb
291
293
  - lib/rubocop/cop/internal_affairs/location_expression.rb
@@ -439,6 +441,7 @@ files:
439
441
  - lib/rubocop/cop/lint/constant_reassignment.rb
440
442
  - lib/rubocop/cop/lint/constant_resolution.rb
441
443
  - lib/rubocop/cop/lint/cop_directive_syntax.rb
444
+ - lib/rubocop/cop/lint/data_define_override.rb
442
445
  - lib/rubocop/cop/lint/debugger.rb
443
446
  - lib/rubocop/cop/lint/deprecated_class_methods.rb
444
447
  - lib/rubocop/cop/lint/deprecated_constants.rb
@@ -556,6 +559,7 @@ files:
556
559
  - lib/rubocop/cop/lint/unmodified_reduce_accumulator.rb
557
560
  - lib/rubocop/cop/lint/unreachable_code.rb
558
561
  - lib/rubocop/cop/lint/unreachable_loop.rb
562
+ - lib/rubocop/cop/lint/unreachable_pattern_branch.rb
559
563
  - lib/rubocop/cop/lint/unused_block_argument.rb
560
564
  - lib/rubocop/cop/lint/unused_method_argument.rb
561
565
  - lib/rubocop/cop/lint/uri_escape_unescape.rb
@@ -630,6 +634,7 @@ files:
630
634
  - lib/rubocop/cop/mixin/hash_shorthand_syntax.rb
631
635
  - lib/rubocop/cop/mixin/hash_subset.rb
632
636
  - lib/rubocop/cop/mixin/hash_transform_method.rb
637
+ - lib/rubocop/cop/mixin/hash_transform_method/autocorrection.rb
633
638
  - lib/rubocop/cop/mixin/heredoc.rb
634
639
  - lib/rubocop/cop/mixin/integer_node.rb
635
640
  - lib/rubocop/cop/mixin/interpolation.rb
@@ -781,6 +786,7 @@ files:
781
786
  - lib/rubocop/cop/style/fetch_env_var.rb
782
787
  - lib/rubocop/cop/style/file_empty.rb
783
788
  - lib/rubocop/cop/style/file_null.rb
789
+ - lib/rubocop/cop/style/file_open.rb
784
790
  - lib/rubocop/cop/style/file_read.rb
785
791
  - lib/rubocop/cop/style/file_touch.rb
786
792
  - lib/rubocop/cop/style/file_write.rb
@@ -826,6 +832,7 @@ files:
826
832
  - lib/rubocop/cop/style/magic_comment_format.rb
827
833
  - lib/rubocop/cop/style/map_compact_with_conditional_block.rb
828
834
  - lib/rubocop/cop/style/map_into_array.rb
835
+ - lib/rubocop/cop/style/map_join.rb
829
836
  - lib/rubocop/cop/style/map_to_hash.rb
830
837
  - lib/rubocop/cop/style/map_to_set.rb
831
838
  - lib/rubocop/cop/style/method_call_with_args_parentheses.rb
@@ -872,6 +879,7 @@ files:
872
879
  - lib/rubocop/cop/style/numeric_literals.rb
873
880
  - lib/rubocop/cop/style/numeric_predicate.rb
874
881
  - lib/rubocop/cop/style/object_then.rb
882
+ - lib/rubocop/cop/style/one_class_per_file.rb
875
883
  - lib/rubocop/cop/style/one_line_conditional.rb
876
884
  - lib/rubocop/cop/style/open_struct_use.rb
877
885
  - lib/rubocop/cop/style/operator_method_call.rb
@@ -881,14 +889,17 @@ files:
881
889
  - lib/rubocop/cop/style/or_assignment.rb
882
890
  - lib/rubocop/cop/style/parallel_assignment.rb
883
891
  - lib/rubocop/cop/style/parentheses_around_condition.rb
892
+ - lib/rubocop/cop/style/partition_instead_of_double_select.rb
884
893
  - lib/rubocop/cop/style/percent_literal_delimiters.rb
885
894
  - lib/rubocop/cop/style/percent_q_literals.rb
886
895
  - lib/rubocop/cop/style/perl_backrefs.rb
896
+ - lib/rubocop/cop/style/predicate_with_kind.rb
887
897
  - lib/rubocop/cop/style/preferred_hash_methods.rb
888
898
  - lib/rubocop/cop/style/proc.rb
889
899
  - lib/rubocop/cop/style/quoted_symbols.rb
890
900
  - lib/rubocop/cop/style/raise_args.rb
891
901
  - lib/rubocop/cop/style/random_with_offset.rb
902
+ - lib/rubocop/cop/style/reduce_to_hash.rb
892
903
  - lib/rubocop/cop/style/redundant_argument.rb
893
904
  - lib/rubocop/cop/style/redundant_array_constructor.rb
894
905
  - lib/rubocop/cop/style/redundant_array_flatten.rb
@@ -912,6 +923,7 @@ files:
912
923
  - lib/rubocop/cop/style/redundant_interpolation.rb
913
924
  - lib/rubocop/cop/style/redundant_interpolation_unfreeze.rb
914
925
  - lib/rubocop/cop/style/redundant_line_continuation.rb
926
+ - lib/rubocop/cop/style/redundant_min_max_by.rb
915
927
  - lib/rubocop/cop/style/redundant_parentheses.rb
916
928
  - lib/rubocop/cop/style/redundant_percent_q.rb
917
929
  - lib/rubocop/cop/style/redundant_regexp_argument.rb
@@ -925,6 +937,7 @@ files:
925
937
  - lib/rubocop/cop/style/redundant_sort.rb
926
938
  - lib/rubocop/cop/style/redundant_sort_by.rb
927
939
  - lib/rubocop/cop/style/redundant_string_escape.rb
940
+ - lib/rubocop/cop/style/redundant_struct_keyword_init.rb
928
941
  - lib/rubocop/cop/style/regexp_literal.rb
929
942
  - lib/rubocop/cop/style/require_order.rb
930
943
  - lib/rubocop/cop/style/rescue_modifier.rb
@@ -935,6 +948,8 @@ files:
935
948
  - lib/rubocop/cop/style/safe_navigation.rb
936
949
  - lib/rubocop/cop/style/safe_navigation_chain_length.rb
937
950
  - lib/rubocop/cop/style/sample.rb
951
+ - lib/rubocop/cop/style/select_by_kind.rb
952
+ - lib/rubocop/cop/style/select_by_range.rb
938
953
  - lib/rubocop/cop/style/select_by_regexp.rb
939
954
  - lib/rubocop/cop/style/self_assignment.rb
940
955
  - lib/rubocop/cop/style/semicolon.rb
@@ -965,6 +980,7 @@ files:
965
980
  - lib/rubocop/cop/style/symbol_array.rb
966
981
  - lib/rubocop/cop/style/symbol_literal.rb
967
982
  - lib/rubocop/cop/style/symbol_proc.rb
983
+ - lib/rubocop/cop/style/tally_method.rb
968
984
  - lib/rubocop/cop/style/ternary_parentheses.rb
969
985
  - lib/rubocop/cop/style/top_level_method_definition.rb
970
986
  - lib/rubocop/cop/style/trailing_body_on_class.rb
@@ -1046,6 +1062,7 @@ files:
1046
1062
  - lib/rubocop/lsp/severity.rb
1047
1063
  - lib/rubocop/lsp/stdin_runner.rb
1048
1064
  - lib/rubocop/magic_comment.rb
1065
+ - lib/rubocop/mcp/server.rb
1049
1066
  - lib/rubocop/name_similarity.rb
1050
1067
  - lib/rubocop/options.rb
1051
1068
  - lib/rubocop/path_util.rb
@@ -1097,9 +1114,9 @@ licenses:
1097
1114
  - MIT
1098
1115
  metadata:
1099
1116
  homepage_uri: https://rubocop.org/
1100
- changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.84.2
1117
+ changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.86.1
1101
1118
  source_code_uri: https://github.com/rubocop/rubocop/
1102
- documentation_uri: https://docs.rubocop.org/rubocop/1.84/
1119
+ documentation_uri: https://docs.rubocop.org/rubocop/1.86/
1103
1120
  bug_tracker_uri: https://github.com/rubocop/rubocop/issues
1104
1121
  rubygems_mfa_required: 'true'
1105
1122
  rdoc_options: []