rubocop 1.84.2 → 1.88.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 (313) hide show
  1. checksums.yaml +4 -4
  2. data/config/default.yml +180 -86
  3. data/config/obsoletion.yml +26 -1
  4. data/lib/rubocop/cache_config.rb +1 -1
  5. data/lib/rubocop/cli/command/auto_generate_config.rb +34 -2
  6. data/lib/rubocop/cli/command/list_enabled_cops_for.rb +40 -0
  7. data/lib/rubocop/cli/command/mcp.rb +19 -0
  8. data/lib/rubocop/cli/command/show_cops.rb +2 -2
  9. data/lib/rubocop/cli/command/show_docs_url.rb +4 -8
  10. data/lib/rubocop/cli/command/suggest_extensions.rb +1 -1
  11. data/lib/rubocop/cli.rb +9 -7
  12. data/lib/rubocop/comment_config.rb +12 -15
  13. data/lib/rubocop/config.rb +14 -10
  14. data/lib/rubocop/config_finder.rb +1 -1
  15. data/lib/rubocop/config_loader.rb +17 -2
  16. data/lib/rubocop/config_loader_resolver.rb +13 -4
  17. data/lib/rubocop/config_obsoletion/extracted_cop.rb +4 -2
  18. data/lib/rubocop/config_store.rb +2 -2
  19. data/lib/rubocop/config_validator.rb +1 -1
  20. data/lib/rubocop/cop/autocorrect_logic.rb +2 -1
  21. data/lib/rubocop/cop/base.rb +25 -4
  22. data/lib/rubocop/cop/bundler/gem_comment.rb +2 -2
  23. data/lib/rubocop/cop/correctors/condition_corrector.rb +1 -1
  24. data/lib/rubocop/cop/correctors/multiline_literal_brace_corrector.rb +1 -5
  25. data/lib/rubocop/cop/correctors/parentheses_corrector.rb +33 -2
  26. data/lib/rubocop/cop/correctors/percent_literal_corrector.rb +2 -2
  27. data/lib/rubocop/cop/correctors.rb +28 -0
  28. data/lib/rubocop/cop/documentation.rb +2 -3
  29. data/lib/rubocop/cop/exclude_limit.rb +31 -5
  30. data/lib/rubocop/cop/gemspec/duplicated_assignment.rb +2 -2
  31. data/lib/rubocop/cop/gemspec/require_mfa.rb +5 -5
  32. data/lib/rubocop/cop/gemspec/ruby_version_globals_usage.rb +3 -3
  33. data/lib/rubocop/cop/internal_affairs/itblock_handler.rb +69 -0
  34. data/lib/rubocop/cop/internal_affairs/location_line_equality_comparison.rb +1 -0
  35. data/lib/rubocop/cop/internal_affairs/redundant_let_rubocop_config_new.rb +5 -3
  36. data/lib/rubocop/cop/internal_affairs.rb +1 -0
  37. data/lib/rubocop/cop/layout/argument_alignment.rb +2 -2
  38. data/lib/rubocop/cop/layout/array_alignment.rb +1 -1
  39. data/lib/rubocop/cop/layout/begin_end_alignment.rb +1 -1
  40. data/lib/rubocop/cop/layout/block_alignment.rb +41 -4
  41. data/lib/rubocop/cop/layout/class_structure.rb +1 -1
  42. data/lib/rubocop/cop/layout/dot_position.rb +1 -1
  43. data/lib/rubocop/cop/layout/empty_line_after_guard_clause.rb +23 -7
  44. data/lib/rubocop/cop/layout/empty_line_between_defs.rb +1 -1
  45. data/lib/rubocop/cop/layout/empty_lines_around_attribute_accessor.rb +1 -0
  46. data/lib/rubocop/cop/layout/empty_lines_around_block_body.rb +12 -2
  47. data/lib/rubocop/cop/layout/empty_lines_around_class_body.rb +16 -2
  48. data/lib/rubocop/cop/layout/empty_lines_around_module_body.rb +16 -2
  49. data/lib/rubocop/cop/layout/end_alignment.rb +8 -5
  50. data/lib/rubocop/cop/layout/first_hash_element_indentation.rb +7 -1
  51. data/lib/rubocop/cop/layout/hash_alignment.rb +1 -1
  52. data/lib/rubocop/cop/layout/indentation_width.rb +12 -0
  53. data/lib/rubocop/cop/layout/line_length.rb +5 -3
  54. data/lib/rubocop/cop/layout/multiline_assignment_layout.rb +9 -2
  55. data/lib/rubocop/cop/layout/multiline_method_call_brace_layout.rb +1 -1
  56. data/lib/rubocop/cop/layout/multiline_method_call_indentation.rb +53 -3
  57. data/lib/rubocop/cop/layout/parameter_alignment.rb +1 -1
  58. data/lib/rubocop/cop/layout/redundant_line_break.rb +3 -1
  59. data/lib/rubocop/cop/layout/space_around_block_parameters.rb +1 -1
  60. data/lib/rubocop/cop/layout/space_around_keyword.rb +3 -1
  61. data/lib/rubocop/cop/layout/space_before_brackets.rb +1 -1
  62. data/lib/rubocop/cop/layout/space_in_lambda_literal.rb +1 -0
  63. data/lib/rubocop/cop/lint/ambiguous_assignment.rb +1 -11
  64. data/lib/rubocop/cop/lint/ambiguous_block_association.rb +1 -1
  65. data/lib/rubocop/cop/lint/ambiguous_operator_precedence.rb +1 -10
  66. data/lib/rubocop/cop/lint/circular_argument_reference.rb +1 -3
  67. data/lib/rubocop/cop/lint/constant_overwritten_in_rescue.rb +1 -1
  68. data/lib/rubocop/cop/lint/constant_reassignment.rb +93 -11
  69. data/lib/rubocop/cop/lint/constant_resolution.rb +6 -6
  70. data/lib/rubocop/cop/lint/data_define_override.rb +63 -0
  71. data/lib/rubocop/cop/lint/debugger.rb +0 -1
  72. data/lib/rubocop/cop/lint/deprecated_constants.rb +2 -8
  73. data/lib/rubocop/cop/lint/duplicate_methods.rb +55 -8
  74. data/lib/rubocop/cop/lint/empty_block.rb +4 -4
  75. data/lib/rubocop/cop/lint/empty_conditional_body.rb +6 -1
  76. data/lib/rubocop/cop/lint/empty_in_pattern.rb +8 -1
  77. data/lib/rubocop/cop/lint/empty_when.rb +8 -1
  78. data/lib/rubocop/cop/lint/ensure_return.rb +19 -1
  79. data/lib/rubocop/cop/lint/erb_new_arguments.rb +4 -2
  80. data/lib/rubocop/cop/lint/float_comparison.rb +1 -0
  81. data/lib/rubocop/cop/lint/incompatible_io_select_with_fiber_scheduler.rb +5 -1
  82. data/lib/rubocop/cop/lint/interpolation_check.rb +25 -5
  83. data/lib/rubocop/cop/lint/lambda_without_literal_block.rb +1 -1
  84. data/lib/rubocop/cop/lint/literal_assignment_in_condition.rb +11 -1
  85. data/lib/rubocop/cop/lint/literal_in_interpolation.rb +8 -11
  86. data/lib/rubocop/cop/lint/missing_cop_enable_directive.rb +5 -5
  87. data/lib/rubocop/cop/lint/multiple_comparison.rb +2 -2
  88. data/lib/rubocop/cop/lint/next_without_accumulator.rb +2 -0
  89. data/lib/rubocop/cop/lint/no_return_in_begin_end_blocks.rb +16 -0
  90. data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +4 -2
  91. data/lib/rubocop/cop/lint/non_local_exit_from_iterator.rb +1 -1
  92. data/lib/rubocop/cop/lint/number_conversion.rb +19 -10
  93. data/lib/rubocop/cop/lint/numbered_parameter_assignment.rb +1 -1
  94. data/lib/rubocop/cop/lint/numeric_operation_with_constant_result.rb +3 -0
  95. data/lib/rubocop/cop/lint/ordered_magic_comments.rb +7 -7
  96. data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +3 -13
  97. data/lib/rubocop/cop/lint/raise_exception.rb +1 -1
  98. data/lib/rubocop/cop/lint/rand_one.rb +1 -1
  99. data/lib/rubocop/cop/lint/redundant_cop_disable_directive.rb +4 -1
  100. data/lib/rubocop/cop/lint/redundant_cop_enable_directive.rb +6 -12
  101. data/lib/rubocop/cop/lint/redundant_dir_glob_sort.rb +15 -4
  102. data/lib/rubocop/cop/lint/redundant_safe_navigation.rb +36 -12
  103. data/lib/rubocop/cop/lint/redundant_splat_expansion.rb +4 -0
  104. data/lib/rubocop/cop/lint/redundant_type_conversion.rb +10 -3
  105. data/lib/rubocop/cop/lint/redundant_with_index.rb +1 -1
  106. data/lib/rubocop/cop/lint/redundant_with_object.rb +5 -0
  107. data/lib/rubocop/cop/lint/refinement_import_methods.rb +8 -1
  108. data/lib/rubocop/cop/lint/regexp_as_condition.rb +9 -1
  109. data/lib/rubocop/cop/lint/require_parentheses.rb +13 -4
  110. data/lib/rubocop/cop/lint/require_range_parentheses.rb +2 -1
  111. data/lib/rubocop/cop/lint/require_relative_self_path.rb +7 -5
  112. data/lib/rubocop/cop/lint/rescue_type.rb +1 -1
  113. data/lib/rubocop/cop/lint/safe_navigation_chain.rb +18 -0
  114. data/lib/rubocop/cop/lint/safe_navigation_consistency.rb +7 -1
  115. data/lib/rubocop/cop/lint/safe_navigation_with_empty.rb +1 -1
  116. data/lib/rubocop/cop/lint/script_permission.rb +5 -1
  117. data/lib/rubocop/cop/lint/self_assignment.rb +24 -1
  118. data/lib/rubocop/cop/lint/send_with_mixin_argument.rb +1 -1
  119. data/lib/rubocop/cop/lint/shadowed_exception.rb +1 -1
  120. data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +14 -0
  121. data/lib/rubocop/cop/lint/shared_mutable_default.rb +3 -1
  122. data/lib/rubocop/cop/lint/suppressed_exception_in_number_conversion.rb +12 -0
  123. data/lib/rubocop/cop/lint/symbol_conversion.rb +21 -4
  124. data/lib/rubocop/cop/lint/syntax.rb +25 -1
  125. data/lib/rubocop/cop/lint/to_enum_arguments.rb +28 -1
  126. data/lib/rubocop/cop/lint/top_level_return_with_argument.rb +1 -1
  127. data/lib/rubocop/cop/lint/trailing_comma_in_attribute_declaration.rb +5 -1
  128. data/lib/rubocop/cop/lint/unescaped_bracket_in_regexp.rb +4 -2
  129. data/lib/rubocop/cop/lint/unmodified_reduce_accumulator.rb +1 -0
  130. data/lib/rubocop/cop/lint/unreachable_code.rb +2 -2
  131. data/lib/rubocop/cop/lint/unreachable_pattern_branch.rb +113 -0
  132. data/lib/rubocop/cop/lint/unused_method_argument.rb +10 -0
  133. data/lib/rubocop/cop/lint/useless_assignment.rb +14 -14
  134. data/lib/rubocop/cop/lint/useless_constant_scoping.rb +4 -4
  135. data/lib/rubocop/cop/lint/useless_default_value_argument.rb +2 -0
  136. data/lib/rubocop/cop/lint/useless_ruby2_keywords.rb +8 -4
  137. data/lib/rubocop/cop/lint/useless_setter_call.rb +4 -1
  138. data/lib/rubocop/cop/lint/useless_times.rb +22 -1
  139. data/lib/rubocop/cop/lint/utils/nil_receiver_checker.rb +35 -9
  140. data/lib/rubocop/cop/lint/void.rb +32 -12
  141. data/lib/rubocop/cop/metrics/block_length.rb +1 -1
  142. data/lib/rubocop/cop/metrics/block_nesting.rb +23 -0
  143. data/lib/rubocop/cop/metrics/collection_literal_length.rb +1 -1
  144. data/lib/rubocop/cop/metrics/method_length.rb +1 -1
  145. data/lib/rubocop/cop/metrics/utils/iterating_block.rb +1 -1
  146. data/lib/rubocop/cop/migration/department_name.rb +12 -1
  147. data/lib/rubocop/cop/mixin/check_line_breakable.rb +1 -1
  148. data/lib/rubocop/cop/mixin/check_single_line_suitability.rb +2 -2
  149. data/lib/rubocop/cop/mixin/configurable_max.rb +6 -5
  150. data/lib/rubocop/cop/mixin/hash_transform_method/autocorrection.rb +63 -0
  151. data/lib/rubocop/cop/mixin/hash_transform_method.rb +10 -60
  152. data/lib/rubocop/cop/mixin/project_index_help.rb +48 -0
  153. data/lib/rubocop/cop/mixin.rb +86 -0
  154. data/lib/rubocop/cop/naming/binary_operator_parameter_name.rb +1 -1
  155. data/lib/rubocop/cop/naming/block_parameter_name.rb +1 -1
  156. data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +1 -1
  157. data/lib/rubocop/cop/naming/predicate_method.rb +2 -2
  158. data/lib/rubocop/cop/naming/predicate_prefix.rb +1 -1
  159. data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +1 -1
  160. data/lib/rubocop/cop/offense.rb +8 -0
  161. data/lib/rubocop/cop/registry.rb +62 -38
  162. data/lib/rubocop/cop/security/eval.rb +15 -2
  163. data/lib/rubocop/cop/security/io_methods.rb +1 -1
  164. data/lib/rubocop/cop/style/access_modifier_declarations.rb +14 -2
  165. data/lib/rubocop/cop/style/accessor_grouping.rb +4 -2
  166. data/lib/rubocop/cop/style/alias.rb +15 -3
  167. data/lib/rubocop/cop/style/and_or.rb +2 -1
  168. data/lib/rubocop/cop/style/arguments_forwarding.rb +25 -7
  169. data/lib/rubocop/cop/style/array_first_last.rb +12 -1
  170. data/lib/rubocop/cop/style/array_intersect.rb +4 -0
  171. data/lib/rubocop/cop/style/array_intersect_with_single_element.rb +3 -0
  172. data/lib/rubocop/cop/style/array_join.rb +4 -2
  173. data/lib/rubocop/cop/style/ascii_comments.rb +6 -3
  174. data/lib/rubocop/cop/style/attr.rb +5 -2
  175. data/lib/rubocop/cop/style/bare_percent_literals.rb +3 -1
  176. data/lib/rubocop/cop/style/begin_block.rb +3 -1
  177. data/lib/rubocop/cop/style/block_delimiters.rb +37 -31
  178. data/lib/rubocop/cop/style/case_equality.rb +18 -2
  179. data/lib/rubocop/cop/style/character_literal.rb +2 -2
  180. data/lib/rubocop/cop/style/class_and_module_children.rb +18 -2
  181. data/lib/rubocop/cop/style/class_equality_comparison.rb +21 -13
  182. data/lib/rubocop/cop/style/class_methods_definitions.rb +11 -5
  183. data/lib/rubocop/cop/style/collection_compact.rb +36 -16
  184. data/lib/rubocop/cop/style/colon_method_call.rb +16 -7
  185. data/lib/rubocop/cop/style/combinable_loops.rb +5 -0
  186. data/lib/rubocop/cop/style/comparable_clamp.rb +12 -1
  187. data/lib/rubocop/cop/style/concat_array_literals.rb +7 -1
  188. data/lib/rubocop/cop/style/conditional_assignment.rb +6 -5
  189. data/lib/rubocop/cop/style/constant_visibility.rb +4 -1
  190. data/lib/rubocop/cop/style/copyright.rb +22 -11
  191. data/lib/rubocop/cop/style/date_time.rb +4 -4
  192. data/lib/rubocop/cop/style/dig_chain.rb +5 -0
  193. data/lib/rubocop/cop/style/disable_cops_within_source_code_directive.rb +1 -1
  194. data/lib/rubocop/cop/style/document_dynamic_eval_definition.rb +6 -1
  195. data/lib/rubocop/cop/style/each_for_simple_loop.rb +1 -1
  196. data/lib/rubocop/cop/style/each_with_object.rb +2 -0
  197. data/lib/rubocop/cop/style/empty_block_parameter.rb +1 -1
  198. data/lib/rubocop/cop/style/empty_class_definition.rb +43 -20
  199. data/lib/rubocop/cop/style/empty_lambda_parameter.rb +1 -1
  200. data/lib/rubocop/cop/style/encoding.rb +7 -1
  201. data/lib/rubocop/cop/style/end_block.rb +3 -1
  202. data/lib/rubocop/cop/style/endless_method.rb +8 -3
  203. data/lib/rubocop/cop/style/fetch_env_var.rb +1 -1
  204. data/lib/rubocop/cop/style/file_open.rb +84 -0
  205. data/lib/rubocop/cop/style/file_write.rb +21 -16
  206. data/lib/rubocop/cop/style/for.rb +3 -0
  207. data/lib/rubocop/cop/style/format_string.rb +4 -3
  208. data/lib/rubocop/cop/style/format_string_token.rb +29 -2
  209. data/lib/rubocop/cop/style/global_vars.rb +5 -2
  210. data/lib/rubocop/cop/style/guard_clause.rb +9 -6
  211. data/lib/rubocop/cop/style/hash_as_last_array_item.rb +21 -5
  212. data/lib/rubocop/cop/style/hash_conversion.rb +1 -1
  213. data/lib/rubocop/cop/style/hash_lookup_method.rb +19 -7
  214. data/lib/rubocop/cop/style/hash_slice.rb +16 -0
  215. data/lib/rubocop/cop/style/hash_transform_keys.rb +17 -7
  216. data/lib/rubocop/cop/style/hash_transform_values.rb +17 -7
  217. data/lib/rubocop/cop/style/if_inside_else.rb +16 -7
  218. data/lib/rubocop/cop/style/if_unless_modifier.rb +15 -4
  219. data/lib/rubocop/cop/style/if_with_semicolon.rb +7 -5
  220. data/lib/rubocop/cop/style/inline_comment.rb +4 -1
  221. data/lib/rubocop/cop/style/ip_addresses.rb +1 -2
  222. data/lib/rubocop/cop/style/magic_comment_format.rb +3 -3
  223. data/lib/rubocop/cop/style/map_join.rb +123 -0
  224. data/lib/rubocop/cop/style/method_call_with_args_parentheses/require_parentheses.rb +5 -3
  225. data/lib/rubocop/cop/style/min_max_comparison.rb +1 -1
  226. data/lib/rubocop/cop/style/module_member_existence_check.rb +7 -14
  227. data/lib/rubocop/cop/style/multiline_if_then.rb +3 -1
  228. data/lib/rubocop/cop/style/mutable_constant.rb +106 -12
  229. data/lib/rubocop/cop/style/nil_comparison.rb +2 -3
  230. data/lib/rubocop/cop/style/nil_lambda.rb +1 -1
  231. data/lib/rubocop/cop/style/non_nil_check.rb +5 -11
  232. data/lib/rubocop/cop/style/not.rb +2 -0
  233. data/lib/rubocop/cop/style/numeric_literals.rb +3 -2
  234. data/lib/rubocop/cop/style/one_class_per_file.rb +115 -0
  235. data/lib/rubocop/cop/style/one_line_conditional.rb +4 -3
  236. data/lib/rubocop/cop/style/parallel_assignment.rb +12 -1
  237. data/lib/rubocop/cop/style/partition_instead_of_double_select.rb +270 -0
  238. data/lib/rubocop/cop/style/percent_literal_delimiters.rb +2 -0
  239. data/lib/rubocop/cop/style/predicate_with_kind.rb +84 -0
  240. data/lib/rubocop/cop/style/proc.rb +3 -2
  241. data/lib/rubocop/cop/style/raise_args.rb +1 -1
  242. data/lib/rubocop/cop/style/reduce_to_hash.rb +200 -0
  243. data/lib/rubocop/cop/style/redundant_array_constructor.rb +2 -2
  244. data/lib/rubocop/cop/style/redundant_begin.rb +3 -3
  245. data/lib/rubocop/cop/style/redundant_constant_base.rb +5 -5
  246. data/lib/rubocop/cop/style/redundant_each.rb +3 -3
  247. data/lib/rubocop/cop/style/redundant_fetch_block.rb +1 -1
  248. data/lib/rubocop/cop/style/redundant_format.rb +1 -0
  249. data/lib/rubocop/cop/style/redundant_interpolation_unfreeze.rb +26 -10
  250. data/lib/rubocop/cop/style/redundant_line_continuation.rb +16 -0
  251. data/lib/rubocop/cop/style/redundant_min_max_by.rb +93 -0
  252. data/lib/rubocop/cop/style/redundant_parentheses.rb +25 -22
  253. data/lib/rubocop/cop/style/redundant_percent_q.rb +4 -1
  254. data/lib/rubocop/cop/style/redundant_regexp_constructor.rb +2 -2
  255. data/lib/rubocop/cop/style/redundant_return.rb +3 -1
  256. data/lib/rubocop/cop/style/redundant_self.rb +2 -2
  257. data/lib/rubocop/cop/style/redundant_self_assignment_branch.rb +0 -5
  258. data/lib/rubocop/cop/style/redundant_struct_keyword_init.rb +114 -0
  259. data/lib/rubocop/cop/style/regexp_literal.rb +31 -2
  260. data/lib/rubocop/cop/style/rescue_modifier.rb +3 -3
  261. data/lib/rubocop/cop/style/safe_navigation.rb +7 -7
  262. data/lib/rubocop/cop/style/select_by_kind.rb +158 -0
  263. data/lib/rubocop/cop/style/select_by_range.rb +197 -0
  264. data/lib/rubocop/cop/style/select_by_regexp.rb +51 -21
  265. data/lib/rubocop/cop/style/self_assignment.rb +1 -1
  266. data/lib/rubocop/cop/style/semicolon.rb +18 -1
  267. data/lib/rubocop/cop/style/single_line_block_params.rb +2 -2
  268. data/lib/rubocop/cop/style/single_line_do_end_block.rb +1 -1
  269. data/lib/rubocop/cop/style/single_line_methods.rb +3 -1
  270. data/lib/rubocop/cop/style/sole_nested_conditional.rb +4 -2
  271. data/lib/rubocop/cop/style/special_global_vars.rb +6 -1
  272. data/lib/rubocop/cop/style/struct_inheritance.rb +13 -0
  273. data/lib/rubocop/cop/style/symbol_proc.rb +7 -6
  274. data/lib/rubocop/cop/style/tally_method.rb +181 -0
  275. data/lib/rubocop/cop/style/top_level_method_definition.rb +2 -2
  276. data/lib/rubocop/cop/style/trailing_comma_in_block_args.rb +1 -1
  277. data/lib/rubocop/cop/style/trailing_method_end_statement.rb +1 -0
  278. data/lib/rubocop/cop/style/unless_logical_operators.rb +3 -3
  279. data/lib/rubocop/cop/style/while_until_do.rb +7 -0
  280. data/lib/rubocop/cop/style/while_until_modifier.rb +16 -0
  281. data/lib/rubocop/cop/style/word_array.rb +1 -0
  282. data/lib/rubocop/cop/style/yoda_condition.rb +1 -1
  283. data/lib/rubocop/cop/style/yoda_expression.rb +1 -1
  284. data/lib/rubocop/cop/style/zero_length_predicate.rb +6 -3
  285. data/lib/rubocop/cop/team.rb +86 -35
  286. data/lib/rubocop/cop/variable_force/branch.rb +2 -2
  287. data/lib/rubocop/directive_comment.rb +2 -1
  288. data/lib/rubocop/file_patterns.rb +9 -1
  289. data/lib/rubocop/formatter/disabled_config_formatter.rb +19 -9
  290. data/lib/rubocop/formatter/formatter_set.rb +1 -1
  291. data/lib/rubocop/formatter/junit_formatter.rb +1 -1
  292. data/lib/rubocop/formatter/simple_text_formatter.rb +0 -2
  293. data/lib/rubocop/formatter/worst_offenders_formatter.rb +1 -1
  294. data/lib/rubocop/formatter.rb +22 -21
  295. data/lib/rubocop/lsp/diagnostic.rb +1 -0
  296. data/lib/rubocop/lsp/routes.rb +10 -3
  297. data/lib/rubocop/lsp/runtime.rb +1 -2
  298. data/lib/rubocop/mcp/server.rb +200 -0
  299. data/lib/rubocop/options.rb +35 -4
  300. data/lib/rubocop/path_util.rb +14 -2
  301. data/lib/rubocop/plugin/loader.rb +1 -1
  302. data/lib/rubocop/project_index_loader.rb +66 -0
  303. data/lib/rubocop/result_cache.rb +22 -10
  304. data/lib/rubocop/rspec/cop_helper.rb +8 -0
  305. data/lib/rubocop/rspec/shared_contexts.rb +32 -2
  306. data/lib/rubocop/runner.rb +124 -53
  307. data/lib/rubocop/server/cache.rb +5 -7
  308. data/lib/rubocop/server/core.rb +8 -0
  309. data/lib/rubocop/target_finder.rb +14 -7
  310. data/lib/rubocop/target_ruby.rb +18 -12
  311. data/lib/rubocop/version.rb +21 -3
  312. data/lib/rubocop.rb +22 -96
  313. metadata +27 -5
data/config/default.yml CHANGED
@@ -3,20 +3,16 @@
3
3
  AllCops:
4
4
  RubyInterpreters:
5
5
  - ruby
6
- - macruby
7
6
  - rake
8
7
  - jruby
9
- - rbx
10
8
  # Include common Ruby source files.
11
9
  Include:
12
10
  - '**/*.rb'
13
11
  - '**/*.arb'
14
12
  - '**/*.axlsx'
15
13
  - '**/*.builder'
16
- - '**/*.fcgi'
17
14
  - '**/*.gemfile'
18
15
  - '**/*.gemspec'
19
- - '**/*.god'
20
16
  - '**/*.jb'
21
17
  - '**/*.jbuilder'
22
18
  - '**/*.mspec'
@@ -25,15 +21,12 @@ AllCops:
25
21
  - '**/*.podspec'
26
22
  - '**/*.rabl'
27
23
  - '**/*.rake'
28
- - '**/*.rbuild'
29
24
  - '**/*.rbw'
30
- - '**/*.rbx'
31
25
  - '**/*.ru'
32
26
  - '**/*.ruby'
33
27
  - '**/*.schema'
34
28
  - '**/*.spec'
35
29
  - '**/*.thor'
36
- - '**/*.watchr'
37
30
  - '**/.irbrc'
38
31
  - '**/.pryrc'
39
32
  - '**/.simplecov'
@@ -43,7 +36,6 @@ AllCops:
43
36
  - '**/Brewfile'
44
37
  - '**/Buildfile'
45
38
  - '**/Capfile'
46
- - '**/Cheffile'
47
39
  - '**/Dangerfile'
48
40
  - '**/Deliverfile'
49
41
  - '**/Fastfile'
@@ -60,7 +52,6 @@ AllCops:
60
52
  - '**/Snapfile'
61
53
  - '**/Steepfile'
62
54
  - '**/Thorfile'
63
- - '**/Vagabondfile'
64
55
  - '**/Vagrantfile'
65
56
  Exclude:
66
57
  - 'node_modules/**/*'
@@ -113,11 +104,17 @@ AllCops:
113
104
  # When `NewCops` is `disable`, pending cops are disabled in bulk. Can be overridden by
114
105
  # the `--disable-pending-cops` command-line option.
115
106
  NewCops: pending
107
+ # When `true`, RuboCop builds a project index (a project-wide map of declarations and references)
108
+ # once per run and makes it available to cops that opt in.
109
+ # The project index is implemented by the optional `rubydex` gem; when `rubydex` is not installed,
110
+ # a warning is shown and the flag has no effect.
111
+ # The default `false` preserves RuboCop's traditional file-local analysis.
112
+ UseProjectIndex: false
116
113
  # Enables the result cache if `true`. Can be overridden by the `--cache` command
117
114
  # line option.
118
115
  UseCache: true
119
116
  # Threshold for how many files can be stored in the result cache before some
120
- # of the files are automatically removed.
117
+ # of the files are automatically removed. Set to false to disable cache pruning.
121
118
  MaxFilesInCache: 20000
122
119
  # The cache will be stored in "rubocop_cache" under this directory. If
123
120
  # CacheRootDirectory is ~ (nil), which it is by default, the root will be
@@ -203,12 +200,12 @@ Bundler/GemComment:
203
200
  Description: 'Add a comment describing each gem.'
204
201
  Enabled: false
205
202
  VersionAdded: '0.59'
206
- VersionChanged: '0.85'
203
+ VersionChanged: '1.88'
207
204
  Include:
208
205
  - '**/*.gemfile'
209
206
  - '**/Gemfile'
210
207
  - '**/gems.rb'
211
- IgnoredGems: []
208
+ AllowedGems: []
212
209
  OnlyFor: []
213
210
 
214
211
  Bundler/GemFilename:
@@ -375,7 +372,7 @@ Gemspec/RubyVersionGlobalsUsage:
375
372
  Include:
376
373
  - '**/*.gemspec'
377
374
 
378
- #################### Layout ###########################
375
+ #################### Layout ################################
379
376
 
380
377
  Layout/AccessModifierIndentation:
381
378
  Description: Checks indentation of private/protected visibility modifiers.
@@ -493,7 +490,7 @@ Layout/BlockEndNewline:
493
490
  VersionAdded: '0.49'
494
491
 
495
492
  Layout/CaseIndentation:
496
- Description: 'Indentation of when in a case/(when|in)/[else/]end.'
493
+ Description: 'Checks how the `when` and `in` clauses of a `case` expression are indented.'
497
494
  StyleGuide: '#indent-when-to-case'
498
495
  Enabled: true
499
496
  VersionAdded: '0.49'
@@ -538,15 +535,22 @@ Layout/ClosingParenthesisIndentation:
538
535
  Description: 'Checks the indentation of hanging closing parentheses.'
539
536
  Enabled: true
540
537
  VersionAdded: '0.49'
538
+ VersionChanged: '1.86'
539
+ # By default the indentation width from `Layout/IndentationWidth` is used,
540
+ # but it can be overridden by setting this parameter.
541
+ IndentationWidth: ~
541
542
 
542
543
  Layout/CommentIndentation:
543
- Description: 'Indentation of comments.'
544
+ Description: 'Checks the indentation of comments.'
544
545
  Enabled: true
546
+ VersionAdded: '0.49'
547
+ VersionChanged: '1.86'
545
548
  # When true, allows comments to have extra indentation if that aligns them
546
549
  # with a comment on the preceding line.
547
550
  AllowForAlignment: false
548
- VersionAdded: '0.49'
549
- VersionChanged: '1.24'
551
+ # By default the indentation width from `Layout/IndentationWidth` is used,
552
+ # but it can be overridden by setting this parameter.
553
+ IndentationWidth: ~
550
554
 
551
555
  Layout/ConditionPosition:
552
556
  Description: >-
@@ -908,9 +912,9 @@ Layout/HashAlignment:
908
912
  Align the elements of a hash literal if they span more than
909
913
  one line.
910
914
  Enabled: true
911
- AllowMultipleStyles: true
912
915
  VersionAdded: '0.49'
913
916
  VersionChanged: '1.16'
917
+ AllowMultipleStyles: true
914
918
  # Alignment of entries using hash rocket as separator. Valid values are:
915
919
  #
916
920
  # key - left alignment of keys
@@ -985,8 +989,8 @@ Layout/HeredocArgumentClosingParenthesis:
985
989
  Description: >-
986
990
  Checks for the placement of the closing parenthesis in a
987
991
  method call that passes a HEREDOC string as an argument.
988
- Enabled: false
989
992
  StyleGuide: '#heredoc-argument-closing-parentheses'
993
+ Enabled: false
990
994
  VersionAdded: '0.68'
991
995
 
992
996
  Layout/HeredocIndentation:
@@ -1422,6 +1426,7 @@ Layout/SpaceBeforeBlockBraces:
1422
1426
  before it.
1423
1427
  Enabled: true
1424
1428
  VersionAdded: '0.49'
1429
+ VersionChanged: '0.52'
1425
1430
  EnforcedStyle: space
1426
1431
  SupportedStyles:
1427
1432
  - space
@@ -1430,7 +1435,6 @@ Layout/SpaceBeforeBlockBraces:
1430
1435
  SupportedStylesForEmptyBraces:
1431
1436
  - space
1432
1437
  - no_space
1433
- VersionChanged: '0.52'
1434
1438
 
1435
1439
  Layout/SpaceBeforeBrackets:
1436
1440
  Description: 'Checks for receiver with a space before the opening brackets.'
@@ -1705,6 +1709,7 @@ Lint/ConstantReassignment:
1705
1709
  Description: 'Checks for constant reassignments.'
1706
1710
  Enabled: pending
1707
1711
  VersionAdded: '1.70'
1712
+ VersionChanged: '1.87'
1708
1713
 
1709
1714
  Lint/ConstantResolution:
1710
1715
  Description: 'Checks that constants are fully qualified with `::`.'
@@ -1720,6 +1725,11 @@ Lint/CopDirectiveSyntax:
1720
1725
  Enabled: pending
1721
1726
  VersionAdded: '1.72'
1722
1727
 
1728
+ Lint/DataDefineOverride:
1729
+ Description: 'Disallow overriding the `Data` built-in methods via `Data.define`.'
1730
+ Enabled: pending
1731
+ VersionAdded: '1.85'
1732
+
1723
1733
  Lint/Debugger:
1724
1734
  Description: 'Checks for debugger calls.'
1725
1735
  Enabled: true
@@ -1917,9 +1927,9 @@ Lint/EmptyConditionalBody:
1917
1927
  Description: 'Checks for the presence of `if`, `elsif` and `unless` branches without a body.'
1918
1928
  Enabled: true
1919
1929
  AutoCorrect: contextual
1920
- AllowComments: true
1921
1930
  VersionAdded: '0.89'
1922
1931
  VersionChanged: '1.73'
1932
+ AllowComments: true
1923
1933
 
1924
1934
  Lint/EmptyEnsure:
1925
1935
  Description: 'Checks for empty ensure block.'
@@ -1955,9 +1965,9 @@ Lint/EmptyInterpolation:
1955
1965
  Lint/EmptyWhen:
1956
1966
  Description: 'Checks for `when` branches with empty bodies.'
1957
1967
  Enabled: true
1958
- AllowComments: true
1959
1968
  VersionAdded: '0.45'
1960
1969
  VersionChanged: '0.83'
1970
+ AllowComments: true
1961
1971
 
1962
1972
  Lint/EnsureReturn:
1963
1973
  Description: 'Do not use return in an ensure block.'
@@ -1991,7 +2001,7 @@ Lint/FloatOutOfRange:
1991
2001
  VersionAdded: '0.36'
1992
2002
 
1993
2003
  Lint/FormatParameterMismatch:
1994
- Description: 'The number of parameters to format/sprint must match the fields.'
2004
+ Description: 'Checks for a mismatch between the format fields and the arguments to `format`/`sprintf`/`%`.'
1995
2005
  Enabled: true
1996
2006
  VersionAdded: '0.33'
1997
2007
 
@@ -2011,14 +2021,14 @@ Lint/HeredocMethodCallPosition:
2011
2021
  Description: >-
2012
2022
  Checks for the ordering of a method call where
2013
2023
  the receiver of the call is a HEREDOC.
2014
- Enabled: false
2015
2024
  StyleGuide: '#heredoc-method-calls'
2025
+ Enabled: false
2016
2026
  VersionAdded: '0.68'
2017
2027
 
2018
2028
  Lint/IdentityComparison:
2019
2029
  Description: 'Prefer `equal?` over `==` when comparing `object_id`.'
2020
- Enabled: true
2021
2030
  StyleGuide: '#identity-comparison'
2031
+ Enabled: true
2022
2032
  VersionAdded: '0.91'
2023
2033
 
2024
2034
  Lint/ImplicitStringConcatenation:
@@ -2104,6 +2114,7 @@ Lint/MissingCopEnableDirective:
2104
2114
  Description: 'Checks for a `# rubocop:enable` after `# rubocop:disable`.'
2105
2115
  Enabled: true
2106
2116
  VersionAdded: '0.52'
2117
+ VersionChanged: '1.88'
2107
2118
  # Maximum number of consecutive lines the cop can be disabled for.
2108
2119
  # 0 allows only single-line disables
2109
2120
  # 1 would mean the maximum allowed is the following:
@@ -2111,16 +2122,16 @@ Lint/MissingCopEnableDirective:
2111
2122
  # a = 1
2112
2123
  # # rubocop:enable SomeCop
2113
2124
  # .inf for any size
2114
- MaximumRangeSize: .inf
2125
+ MaxRangeSize: .inf
2115
2126
 
2116
2127
  Lint/MissingSuper:
2117
2128
  Description: >-
2118
2129
  Checks for the presence of constructors and lifecycle callbacks
2119
2130
  without calls to `super`.
2120
2131
  Enabled: true
2121
- AllowedParentClasses: []
2122
2132
  VersionAdded: '0.89'
2123
2133
  VersionChanged: '1.4'
2134
+ AllowedParentClasses: []
2124
2135
 
2125
2136
  Lint/MixedCaseRange:
2126
2137
  Description: 'Checks for mixed-case character ranges since they include likely unintended characters.'
@@ -2186,11 +2197,11 @@ Lint/NumberConversion:
2186
2197
  Description: 'Checks unsafe usage of number conversion methods.'
2187
2198
  Enabled: false
2188
2199
  VersionAdded: '0.53'
2189
- VersionChanged: '1.1'
2200
+ VersionChanged: '1.88'
2190
2201
  SafeAutoCorrect: false
2191
2202
  AllowedMethods: []
2192
2203
  AllowedPatterns: []
2193
- IgnoredClasses:
2204
+ AllowedClasses:
2194
2205
  - Time
2195
2206
  - DateTime
2196
2207
 
@@ -2340,13 +2351,16 @@ Lint/RedundantWithIndex:
2340
2351
  Lint/RedundantWithObject:
2341
2352
  Description: 'Checks for redundant `with_object`.'
2342
2353
  Enabled: true
2354
+ SafeAutoCorrect: false
2343
2355
  VersionAdded: '0.51'
2356
+ VersionChanged: '1.88'
2344
2357
 
2345
2358
  Lint/RefinementImportMethods:
2346
2359
  Description: 'Use `Refinement#import_methods` when using `include` or `prepend` in `refine` block.'
2347
2360
  Enabled: pending
2348
2361
  SafeAutoCorrect: false
2349
2362
  VersionAdded: '1.27'
2363
+ VersionChanged: '1.88'
2350
2364
 
2351
2365
  Lint/RegexpAsCondition:
2352
2366
  Description: >-
@@ -2409,8 +2423,9 @@ Lint/SafeNavigationConsistency:
2409
2423
  consistent and appropriate safe navigation, without excess or deficiency,
2410
2424
  is used for all method calls on the same object.
2411
2425
  Enabled: true
2426
+ SafeAutoCorrect: false
2412
2427
  VersionAdded: '0.55'
2413
- VersionChanged: '0.77'
2428
+ VersionChanged: '1.85'
2414
2429
  AllowedMethods:
2415
2430
  - present?
2416
2431
  - blank?
@@ -2477,10 +2492,10 @@ Lint/SuppressedException:
2477
2492
  Description: "Don't suppress exceptions."
2478
2493
  StyleGuide: '#dont-hide-exceptions'
2479
2494
  Enabled: true
2480
- AllowComments: true
2481
- AllowNil: true
2482
2495
  VersionAdded: '0.9'
2483
2496
  VersionChanged: '1.12'
2497
+ AllowComments: true
2498
+ AllowNil: true
2484
2499
 
2485
2500
  Lint/SuppressedExceptionInNumberConversion:
2486
2501
  Description: 'Checks for cases where exceptions unrelated to the numeric constructors may be unintentionally swallowed.'
@@ -2573,7 +2588,7 @@ Lint/UnmodifiedReduceAccumulator:
2573
2588
  VersionChanged: '1.5'
2574
2589
 
2575
2590
  Lint/UnreachableCode:
2576
- Description: 'Unreachable code.'
2591
+ Description: 'Checks for unreachable code.'
2577
2592
  Enabled: true
2578
2593
  VersionAdded: '0.9'
2579
2594
 
@@ -2587,6 +2602,11 @@ Lint/UnreachableLoop:
2587
2602
  # eg. `exactly(2).times`
2588
2603
  - !ruby/regexp /(exactly|at_least|at_most)\(\d+\)\.times/
2589
2604
 
2605
+ Lint/UnreachablePatternBranch:
2606
+ Description: 'Checks for unreachable `in` pattern branches after an unconditional catch-all pattern.'
2607
+ Enabled: pending
2608
+ VersionAdded: '1.85'
2609
+
2590
2610
  Lint/UnusedBlockArgument:
2591
2611
  Description: 'Checks for unused block arguments.'
2592
2612
  StyleGuide: '#underscore-unused-vars'
@@ -2713,7 +2733,7 @@ Lint/UselessTimes:
2713
2733
  VersionChanged: '1.61'
2714
2734
 
2715
2735
  Lint/Void:
2716
- Description: 'Possible use of operator/literal/variable in void context.'
2736
+ Description: 'Checks for operators, literals, lambdas, and procs used in void context.'
2717
2737
  Enabled: true
2718
2738
  AutoCorrect: contextual
2719
2739
  VersionAdded: '0.9'
@@ -2723,9 +2743,7 @@ Lint/Void:
2723
2743
  #################### Metrics ###############################
2724
2744
 
2725
2745
  Metrics/AbcSize:
2726
- Description: >-
2727
- A calculated magnitude based on number of assignments,
2728
- branches, and conditions.
2746
+ Description: 'Checks that the ABC size of methods is not higher than the configured maximum.'
2729
2747
  References:
2730
2748
  - https://wiki.c2.com/?AbcMetric
2731
2749
  - https://en.wikipedia.org/wiki/ABC_Software_Metric
@@ -2778,13 +2796,12 @@ Metrics/CollectionLiteralLength:
2778
2796
  Description: 'Checks for `Array` or `Hash` literals with many entries.'
2779
2797
  Enabled: pending
2780
2798
  VersionAdded: '1.47'
2781
- LengthThreshold: 250
2799
+ VersionChanged: '1.88'
2800
+ Max: 250
2782
2801
 
2783
2802
  # Avoid complex methods.
2784
2803
  Metrics/CyclomaticComplexity:
2785
- Description: >-
2786
- A complexity metric that is strongly correlated to the number
2787
- of test cases needed to validate a method.
2804
+ Description: 'Checks that the cyclomatic complexity of methods is not higher than the configured maximum.'
2788
2805
  Enabled: true
2789
2806
  VersionAdded: '0.25'
2790
2807
  VersionChanged: '0.81'
@@ -2824,9 +2841,7 @@ Metrics/ParameterLists:
2824
2841
  MaxOptionalParameters: 3
2825
2842
 
2826
2843
  Metrics/PerceivedComplexity:
2827
- Description: >-
2828
- A complexity metric geared towards measuring complexity for a
2829
- human reader.
2844
+ Description: 'Checks that the perceived complexity of methods is not higher than the configured maximum.'
2830
2845
  Enabled: true
2831
2846
  VersionAdded: '0.25'
2832
2847
  VersionChanged: '0.81'
@@ -2834,16 +2849,14 @@ Metrics/PerceivedComplexity:
2834
2849
  AllowedPatterns: []
2835
2850
  Max: 8
2836
2851
 
2837
- ################## Migration #############################
2852
+ #################### Migration #############################
2838
2853
 
2839
2854
  Migration/DepartmentName:
2840
- Description: >-
2841
- Check that cop names in rubocop:disable (etc) comments are
2842
- given with department name.
2855
+ Description: 'Checks that cop names in `rubocop:disable` (etc.) comments are given with a department name.'
2843
2856
  Enabled: true
2844
2857
  VersionAdded: '0.75'
2845
2858
 
2846
- #################### Naming ##############################
2859
+ #################### Naming ################################
2847
2860
 
2848
2861
  Naming/AccessorMethodName:
2849
2862
  Description: Checks the naming of accessor methods for get_/set_.
@@ -2860,7 +2873,7 @@ Naming/AsciiIdentifiers:
2860
2873
  AsciiConstants: true
2861
2874
 
2862
2875
  Naming/BinaryOperatorParameterName:
2863
- Description: 'When defining binary operators, name the argument other.'
2876
+ Description: 'Checks that the sole parameter of binary operator methods is named `other`.'
2864
2877
  StyleGuide: '#other-arg'
2865
2878
  Enabled: true
2866
2879
  VersionAdded: '0.50'
@@ -3030,7 +3043,10 @@ Naming/InclusiveLanguage:
3030
3043
  - block
3031
3044
  slave:
3032
3045
  WholeWord: true
3033
- Suggestions: ['replica', 'secondary', 'follower']
3046
+ Suggestions:
3047
+ - replica
3048
+ - secondary
3049
+ - follower
3034
3050
 
3035
3051
  Naming/MemoizedInstanceVariableName:
3036
3052
  Description: >-
@@ -3117,7 +3133,7 @@ Naming/PredicateMethod:
3117
3133
  - nonzero?
3118
3134
 
3119
3135
  Naming/PredicatePrefix:
3120
- Description: 'Predicate method names should not be prefixed and end with a `?`.'
3136
+ Description: 'Checks that predicate method names end with a question mark and do not start with a forbidden prefix.'
3121
3137
  StyleGuide: '#bool-methods-qmark'
3122
3138
  Enabled: true
3123
3139
  VersionAdded: '0.50'
@@ -3199,14 +3215,14 @@ Naming/VariableNumber:
3199
3215
  #################### Security ##############################
3200
3216
 
3201
3217
  Security/CompoundHash:
3202
- Description: 'When overwriting Object#hash to combine values, prefer delegating to Array#hash over writing a custom implementation.'
3218
+ Description: 'Checks for `hash` implementations that combine values manually instead of delegating to `Array#hash`.'
3203
3219
  Enabled: pending
3204
3220
  Safe: false
3205
3221
  VersionAdded: '1.28'
3206
3222
  VersionChanged: '1.51'
3207
3223
 
3208
3224
  Security/Eval:
3209
- Description: 'The use of eval represents a serious security risk.'
3225
+ Description: 'Checks for the use of `Kernel#eval` and `Binding#eval` with dynamic arguments.'
3210
3226
  Enabled: true
3211
3227
  VersionAdded: '0.47'
3212
3228
 
@@ -3242,7 +3258,7 @@ Security/MarshalLoad:
3242
3258
  VersionAdded: '0.47'
3243
3259
 
3244
3260
  Security/Open:
3245
- Description: 'The use of `Kernel#open` and `URI.open` represent a serious security risk.'
3261
+ Description: 'Checks for the use of `Kernel#open` and `URI.open` with dynamic data.'
3246
3262
  Enabled: true
3247
3263
  VersionAdded: '0.53'
3248
3264
  VersionChanged: '1.0'
@@ -3258,7 +3274,7 @@ Security/YAMLLoad:
3258
3274
  VersionAdded: '0.47'
3259
3275
  SafeAutoCorrect: false
3260
3276
 
3261
- #################### Style ###############################
3277
+ #################### Style #################################
3262
3278
 
3263
3279
  Style/AccessModifierDeclarations:
3264
3280
  Description: 'Checks style of how access modifiers are used.'
@@ -3320,6 +3336,8 @@ Style/ArgumentsForwarding:
3320
3336
  Description: 'Use arguments forwarding.'
3321
3337
  StyleGuide: '#arguments-forwarding'
3322
3338
  Enabled: pending
3339
+ VersionAdded: '1.1'
3340
+ VersionChanged: '1.58'
3323
3341
  AllowOnlyRestArgument: true
3324
3342
  UseAnonymousForwarding: true
3325
3343
  RedundantRestArgumentNames:
@@ -3333,8 +3351,6 @@ Style/ArgumentsForwarding:
3333
3351
  - blk
3334
3352
  - block
3335
3353
  - proc
3336
- VersionAdded: '1.1'
3337
- VersionChanged: '1.58'
3338
3354
 
3339
3355
  Style/ArrayCoercion:
3340
3356
  Description: >-
@@ -3685,7 +3701,7 @@ Style/CollectionCompact:
3685
3701
 
3686
3702
  # Align with the style guide.
3687
3703
  Style/CollectionMethods:
3688
- Description: 'Preferred collection methods.'
3704
+ Description: 'Enforces the use of consistent method names from the `Enumerable` module.'
3689
3705
  StyleGuide: '#map-find-select-reduce-include-size'
3690
3706
  Enabled: false
3691
3707
  VersionAdded: '0.9'
@@ -3787,11 +3803,11 @@ Style/CommentedKeyword:
3787
3803
 
3788
3804
  Style/ComparableBetween:
3789
3805
  Description: 'Enforces the use of `Comparable#between?` instead of logical comparison.'
3806
+ StyleGuide: '#ranges-or-between'
3790
3807
  Enabled: pending
3791
3808
  Safe: false
3792
3809
  VersionAdded: '1.74'
3793
3810
  VersionChanged: '1.75'
3794
- StyleGuide: '#ranges-or-between'
3795
3811
 
3796
3812
  Style/ComparableClamp:
3797
3813
  Description: 'Enforces the use of `Comparable#clamp` instead of comparison by minimum and maximum.'
@@ -3982,10 +3998,13 @@ Style/EmptyClassDefinition:
3982
3998
  Description: 'Enforces consistent style for empty class definitions.'
3983
3999
  Enabled: pending
3984
4000
  VersionAdded: '1.84'
3985
- EnforcedStyle: class_definition
4001
+ VersionChanged: '1.86'
4002
+ EnforcedStyle: class_keyword
3986
4003
  SupportedStyles:
3987
- - class_definition
4004
+ - class_keyword
3988
4005
  - class_new
4006
+ - class_definition # Deprecated.
4007
+ AllowedParentClasses: []
3989
4008
 
3990
4009
  Style/EmptyElse:
3991
4010
  Description: 'Avoid empty else-clauses.'
@@ -4109,7 +4128,7 @@ Style/ExplicitBlockArgument:
4109
4128
  VersionChanged: '1.8'
4110
4129
 
4111
4130
  Style/ExponentialNotation:
4112
- Description: 'When using exponential notation, favor a mantissa between 1 (inclusive) and 10 (exclusive).'
4131
+ Description: 'Enforces consistency in the use of exponential (scientific) notation.'
4113
4132
  StyleGuide: '#exponential-notation'
4114
4133
  Enabled: true
4115
4134
  VersionAdded: '0.82'
@@ -4126,8 +4145,9 @@ Style/FetchEnvVar:
4126
4145
  - https://rubystyle.guide/#hash-fetch-defaults
4127
4146
  Enabled: pending
4128
4147
  VersionAdded: '1.28'
4148
+ VersionChanged: '1.88'
4129
4149
  # Environment variables to be excluded from the inspection.
4130
- AllowedVars: []
4150
+ AllowedVariables: []
4131
4151
  # When `true`, autocorrects `ENV["key"]` to `ENV.fetch("key", nil)`.
4132
4152
  # When `false`, autocorrects `ENV["key"]` to `ENV.fetch("key")`.
4133
4153
  DefaultToNil: true
@@ -4145,6 +4165,12 @@ Style/FileNull:
4145
4165
  SafeAutoCorrect: false
4146
4166
  VersionAdded: '1.69'
4147
4167
 
4168
+ Style/FileOpen:
4169
+ Description: 'Checks for `File.open` without a block, which can leak file descriptors.'
4170
+ Enabled: pending
4171
+ Safe: false
4172
+ VersionAdded: '1.85'
4173
+
4148
4174
  Style/FileRead:
4149
4175
  Description: 'Favor `File.(bin)read` convenience methods.'
4150
4176
  StyleGuide: '#file-read'
@@ -4206,6 +4232,8 @@ Style/FormatString:
4206
4232
  Style/FormatStringToken:
4207
4233
  Description: 'Use a consistent style for format string tokens.'
4208
4234
  Enabled: true
4235
+ VersionAdded: '0.49'
4236
+ VersionChanged: '1.74'
4209
4237
  EnforcedStyle: annotated
4210
4238
  SupportedStyles:
4211
4239
  # Prefer tokens which contain a sprintf like type annotation like
@@ -4224,8 +4252,6 @@ Style/FormatStringToken:
4224
4252
  # only register offenses for strings given to `printf`, `sprintf`,
4225
4253
  # format` and `%` methods. Other strings are not considered.
4226
4254
  Mode: aggressive
4227
- VersionAdded: '0.49'
4228
- VersionChanged: '1.74'
4229
4255
  AllowedMethods: []
4230
4256
  AllowedPatterns: []
4231
4257
 
@@ -4419,9 +4445,9 @@ Style/IdenticalConditionalBranches:
4419
4445
  Style/IfInsideElse:
4420
4446
  Description: 'Finds if nodes inside else, which can be converted to elsif.'
4421
4447
  Enabled: true
4422
- AllowIfModifier: false
4423
4448
  VersionAdded: '0.36'
4424
4449
  VersionChanged: '1.3'
4450
+ AllowIfModifier: false
4425
4451
 
4426
4452
  Style/IfUnlessModifier:
4427
4453
  Description: >-
@@ -4552,14 +4578,14 @@ Style/ItAssignment:
4552
4578
  Style/ItBlockParameter:
4553
4579
  Description: 'Checks for blocks with one argument where `it` block parameter can be used.'
4554
4580
  Enabled: pending
4581
+ VersionAdded: '1.75'
4582
+ VersionChanged: '1.76'
4555
4583
  EnforcedStyle: allow_single_line
4556
4584
  SupportedStyles:
4557
4585
  - allow_single_line
4558
4586
  - only_numbered_parameters
4559
4587
  - always
4560
4588
  - disallow
4561
- VersionAdded: '1.75'
4562
- VersionChanged: '1.76'
4563
4589
 
4564
4590
  Style/KeywordArgumentsMerging:
4565
4591
  Description: >-
@@ -4642,6 +4668,12 @@ Style/MapIntoArray:
4642
4668
  VersionChanged: '1.67'
4643
4669
  Safe: false
4644
4670
 
4671
+ Style/MapJoin:
4672
+ Description: 'Checks for redundant `map(&:to_s)` before `join`.'
4673
+ Enabled: pending
4674
+ Safe: false
4675
+ VersionAdded: '1.85'
4676
+
4645
4677
  Style/MapToHash:
4646
4678
  Description: 'Prefer `to_h` with a block over `map.to_h`.'
4647
4679
  Enabled: pending
@@ -4678,10 +4710,10 @@ Style/MethodCallWithoutArgsParentheses:
4678
4710
  Description: 'Do not use parentheses for method calls with no arguments.'
4679
4711
  StyleGuide: '#method-invocation-parens'
4680
4712
  Enabled: true
4681
- AllowedMethods: []
4682
- AllowedPatterns: []
4683
4713
  VersionAdded: '0.47'
4684
4714
  VersionChanged: '0.55'
4715
+ AllowedMethods: []
4716
+ AllowedPatterns: []
4685
4717
 
4686
4718
  Style/MethodCalledOnDoEndBlock:
4687
4719
  Description: 'Avoid chaining a method call on a do...end block.'
@@ -4779,7 +4811,6 @@ Style/ModuleMemberExistenceCheck:
4779
4811
  Description: 'Checks for usage of `Module` methods returning arrays that can be replaced with equivalent predicates.'
4780
4812
  Enabled: pending
4781
4813
  VersionAdded: '1.82'
4782
- AllowedMethods: []
4783
4814
 
4784
4815
  Style/MultilineBlockChain:
4785
4816
  Description: 'Avoid multi-line chains of blocks.'
@@ -4788,7 +4819,7 @@ Style/MultilineBlockChain:
4788
4819
  VersionAdded: '0.13'
4789
4820
 
4790
4821
  Style/MultilineIfModifier:
4791
- Description: 'Only use if/unless modifiers on single line statements.'
4822
+ Description: 'Checks for uses of `if`/`unless` modifiers with multiline bodies.'
4792
4823
  StyleGuide: '#no-multiline-if-modifiers'
4793
4824
  Enabled: true
4794
4825
  VersionAdded: '0.45'
@@ -4851,7 +4882,7 @@ Style/MutableConstant:
4851
4882
  Description: 'Do not assign mutable objects to constants.'
4852
4883
  Enabled: true
4853
4884
  VersionAdded: '0.34'
4854
- VersionChanged: '1.8'
4885
+ VersionChanged: '1.88'
4855
4886
  SafeAutoCorrect: false
4856
4887
  EnforcedStyle: literals
4857
4888
  SupportedStyles:
@@ -4863,6 +4894,9 @@ Style/MutableConstant:
4863
4894
  # no harm in freezing an already frozen object.
4864
4895
  - literals
4865
4896
  - strict
4897
+ # When `true`, recursively check and freeze mutable literals nested inside
4898
+ # arrays and hashes (e.g. `[{a: []}]` becomes `[{a: [].freeze}.freeze].freeze`).
4899
+ Recursive: false
4866
4900
 
4867
4901
  Style/NegatedIf:
4868
4902
  Description: >-
@@ -5091,15 +5125,25 @@ Style/ObjectThen:
5091
5125
  - then
5092
5126
  - yield_self
5093
5127
 
5128
+ Style/OneClassPerFile:
5129
+ Description: 'Checks that each source file defines at most one top-level class or module.'
5130
+ Enabled: pending
5131
+ VersionAdded: '1.85'
5132
+ VersionChanged: '1.86'
5133
+ AllowedClasses: []
5134
+ Exclude:
5135
+ - 'spec/**/*'
5136
+ - 'test/**/*'
5137
+
5094
5138
  Style/OneLineConditional:
5095
5139
  Description: >-
5096
5140
  Favor the ternary operator (?:) or multi-line constructs over
5097
5141
  single-line if/then/else/end constructs.
5098
5142
  StyleGuide: '#ternary-operator'
5099
5143
  Enabled: true
5100
- AlwaysCorrectToMultiline: false
5101
5144
  VersionAdded: '0.9'
5102
5145
  VersionChanged: '0.90'
5146
+ AlwaysCorrectToMultiline: false
5103
5147
 
5104
5148
  Style/OpenStructUse:
5105
5149
  Description: >-
@@ -5179,11 +5223,20 @@ Style/ParenthesesAroundCondition:
5179
5223
  AllowSafeAssignment: true
5180
5224
  AllowInMultilineConditions: false
5181
5225
 
5226
+ Style/PartitionInsteadOfDoubleSelect:
5227
+ Description: >-
5228
+ Checks for consecutive `select`/`filter`/`find_all` and `reject` calls
5229
+ on the same receiver with the same block body.
5230
+ Enabled: pending
5231
+ Safe: false
5232
+ VersionAdded: '1.85'
5233
+
5182
5234
  Style/PercentLiteralDelimiters:
5183
5235
  Description: 'Use `%`-literal delimiters consistently.'
5184
5236
  StyleGuide: '#percent-literal-braces'
5185
5237
  Enabled: true
5186
5238
  VersionAdded: '0.19'
5239
+ VersionChanged: '0.48'
5187
5240
  # Specify the default preferred delimiter for all types with the 'default' key
5188
5241
  # Override individual delimiters (even with default specified) by specifying
5189
5242
  # an individual key
@@ -5194,7 +5247,6 @@ Style/PercentLiteralDelimiters:
5194
5247
  '%r': '{}'
5195
5248
  '%w': '[]'
5196
5249
  '%W': '[]'
5197
- VersionChanged: '0.48'
5198
5250
 
5199
5251
  Style/PercentQLiterals:
5200
5252
  Description: 'Checks if uses of %Q/%q match the configured preference.'
@@ -5211,6 +5263,12 @@ Style/PerlBackrefs:
5211
5263
  Enabled: true
5212
5264
  VersionAdded: '0.13'
5213
5265
 
5266
+ Style/PredicateWithKind:
5267
+ Description: 'Prefer `any?(Klass)` to `any? { |x| x.is_a?(Klass) }`.'
5268
+ Enabled: pending
5269
+ SafeAutoCorrect: false
5270
+ VersionAdded: '1.85'
5271
+
5214
5272
  Style/PreferredHashMethods:
5215
5273
  Description: 'Checks use of `has_key?` and `has_value?` Hash methods.'
5216
5274
  StyleGuide: '#hash-key'
@@ -5261,6 +5319,12 @@ Style/RandomWithOffset:
5261
5319
  Enabled: true
5262
5320
  VersionAdded: '0.52'
5263
5321
 
5322
+ Style/ReduceToHash:
5323
+ Description: 'Use `to_h { ... }` instead of `each_with_object`, `inject`, or `reduce` to build a hash.'
5324
+ Enabled: pending
5325
+ Safe: false
5326
+ VersionAdded: '1.85'
5327
+
5264
5328
  Style/RedundantArgument:
5265
5329
  Description: 'Checks for a redundant argument passed to certain methods.'
5266
5330
  Enabled: pending
@@ -5409,9 +5473,9 @@ Style/RedundantInitialize:
5409
5473
  Enabled: pending
5410
5474
  AutoCorrect: contextual
5411
5475
  Safe: false
5412
- AllowComments: true
5413
5476
  VersionAdded: '1.27'
5414
5477
  VersionChanged: '1.61'
5478
+ AllowComments: true
5415
5479
 
5416
5480
  Style/RedundantInterpolation:
5417
5481
  Description: 'Checks for strings that are just an interpolated expression.'
@@ -5430,6 +5494,11 @@ Style/RedundantLineContinuation:
5430
5494
  Enabled: pending
5431
5495
  VersionAdded: '1.49'
5432
5496
 
5497
+ Style/RedundantMinMaxBy:
5498
+ Description: 'Identifies places where `max_by`/`min_by` can be replaced by `max`/`min`.'
5499
+ Enabled: pending
5500
+ VersionAdded: '1.85'
5501
+
5433
5502
  Style/RedundantParentheses:
5434
5503
  Description: "Checks for parentheses that seem not to serve any purpose."
5435
5504
  Enabled: true
@@ -5507,6 +5576,13 @@ Style/RedundantStringEscape:
5507
5576
  Enabled: pending
5508
5577
  VersionAdded: '1.37'
5509
5578
 
5579
+ Style/RedundantStructKeywordInit:
5580
+ Description: 'Checks for redundant `keyword_init` option for `Struct.new`.'
5581
+ Enabled: false
5582
+ SafeAutoCorrect: false
5583
+ VersionAdded: '1.85'
5584
+ VersionChanged: '1.86'
5585
+
5510
5586
  Style/RegexpLiteral:
5511
5587
  Description: 'Use / or %r around regular expressions.'
5512
5588
  StyleGuide: '#percent-r'
@@ -5563,10 +5639,10 @@ Style/ReturnNilInPredicateMethodDefinition:
5563
5639
  StyleGuide: '#bool-methods-qmark'
5564
5640
  Enabled: pending
5565
5641
  SafeAutoCorrect: false
5566
- AllowedMethods: []
5567
- AllowedPatterns: []
5568
5642
  VersionAdded: '1.53'
5569
5643
  VersionChanged: '1.67'
5644
+ AllowedMethods: []
5645
+ AllowedPatterns: []
5570
5646
 
5571
5647
  Style/ReverseFind:
5572
5648
  Description: 'Use `array.rfind` instead of `array.reverse.find`.'
@@ -5613,8 +5689,20 @@ Style/Sample:
5613
5689
  Enabled: true
5614
5690
  VersionAdded: '0.30'
5615
5691
 
5692
+ Style/SelectByKind:
5693
+ Description: 'Prefer grep/grep_v to select/reject/find/detect with a kind check.'
5694
+ Enabled: pending
5695
+ SafeAutoCorrect: false
5696
+ VersionAdded: '1.85'
5697
+
5698
+ Style/SelectByRange:
5699
+ Description: 'Prefer grep/grep_v to select/reject/find/detect with a range check.'
5700
+ Enabled: pending
5701
+ SafeAutoCorrect: false
5702
+ VersionAdded: '1.85'
5703
+
5616
5704
  Style/SelectByRegexp:
5617
- Description: 'Prefer grep/grep_v to select/reject with a regexp match.'
5705
+ Description: 'Prefer grep/grep_v to select/reject/find/detect with a regexp match.'
5618
5706
  Enabled: pending
5619
5707
  SafeAutoCorrect: false
5620
5708
  VersionAdded: '1.22'
@@ -5873,6 +5961,12 @@ Style/SymbolProc:
5873
5961
  AllowedPatterns: []
5874
5962
  AllowComments: false
5875
5963
 
5964
+ Style/TallyMethod:
5965
+ Description: 'Prefer `Enumerable#tally` over manual counting patterns.'
5966
+ Enabled: pending
5967
+ Safe: false
5968
+ VersionAdded: '1.85'
5969
+
5876
5970
  Style/TernaryParentheses:
5877
5971
  Description: 'Checks for use of parentheses around ternary conditions.'
5878
5972
  Enabled: true
@@ -5897,12 +5991,12 @@ Style/TrailingBodyOnClass:
5897
5991
  VersionAdded: '0.53'
5898
5992
 
5899
5993
  Style/TrailingBodyOnMethodDefinition:
5900
- Description: 'Method body goes below definition.'
5994
+ Description: 'Checks for trailing code after the method definition.'
5901
5995
  Enabled: true
5902
5996
  VersionAdded: '0.52'
5903
5997
 
5904
5998
  Style/TrailingBodyOnModule:
5905
- Description: 'Module body goes below module statement.'
5999
+ Description: 'Checks for trailing code after the module definition.'
5906
6000
  Enabled: true
5907
6001
  VersionAdded: '0.53'
5908
6002
 
@@ -5975,10 +6069,10 @@ Style/TrailingUnderscoreVariable:
5975
6069
  Description: >-
5976
6070
  Checks for the usage of unneeded trailing underscores at the
5977
6071
  end of parallel variable assignment.
5978
- AllowNamedUnderscoreVariables: true
5979
6072
  Enabled: true
5980
6073
  VersionAdded: '0.31'
5981
6074
  VersionChanged: '0.35'
6075
+ AllowNamedUnderscoreVariables: true
5982
6076
 
5983
6077
  # `TrivialAccessors` requires exact name matches and doesn't allow
5984
6078
  # predicated methods by default.
@@ -6111,6 +6205,9 @@ Style/YodaCondition:
6111
6205
  References:
6112
6206
  - 'https://en.wikipedia.org/wiki/Yoda_conditions'
6113
6207
  Enabled: true
6208
+ Safe: false
6209
+ VersionAdded: '0.49'
6210
+ VersionChanged: '0.75'
6114
6211
  EnforcedStyle: forbid_for_all_comparison_operators
6115
6212
  SupportedStyles:
6116
6213
  # check all comparison operators
@@ -6121,9 +6218,6 @@ Style/YodaCondition:
6121
6218
  - require_for_all_comparison_operators
6122
6219
  # enforce yoda only for equality operators: `!=` and `==`
6123
6220
  - require_for_equality_operators_only
6124
- Safe: false
6125
- VersionAdded: '0.49'
6126
- VersionChanged: '0.75'
6127
6221
 
6128
6222
  Style/YodaExpression:
6129
6223
  Description: 'Forbid the use of yoda expressions.'