rubocop 1.81.7 → 1.92.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 (621) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +1 -1
  3. data/README.md +2 -2
  4. data/config/default.yml +626 -111
  5. data/config/obsoletion.yml +39 -1
  6. data/exe/rubocop +1 -1
  7. data/lib/rubocop/cache_config.rb +29 -0
  8. data/lib/rubocop/cached_data.rb +50 -5
  9. data/lib/rubocop/changed_files.rb +134 -0
  10. data/lib/rubocop/cli/command/auto_generate_config.rb +34 -2
  11. data/lib/rubocop/cli/command/cop_names.rb +57 -0
  12. data/lib/rubocop/cli/command/execute_runner.rb +54 -3
  13. data/lib/rubocop/cli/command/explain.rb +34 -0
  14. data/lib/rubocop/cli/command/list_enabled_cops_for.rb +40 -0
  15. data/lib/rubocop/cli/command/lsp.rb +1 -1
  16. data/lib/rubocop/cli/command/mcp.rb +19 -0
  17. data/lib/rubocop/cli/command/show_cops.rb +8 -2
  18. data/lib/rubocop/cli/command/show_docs_url.rb +8 -10
  19. data/lib/rubocop/cli/command/suggest_extensions.rb +1 -1
  20. data/lib/rubocop/cli.rb +41 -14
  21. data/lib/rubocop/comment_config/directive_range.rb +34 -0
  22. data/lib/rubocop/comment_config/disable_next.rb +143 -0
  23. data/lib/rubocop/comment_config/push_pop.rb +55 -0
  24. data/lib/rubocop/comment_config.rb +97 -44
  25. data/lib/rubocop/config.rb +100 -15
  26. data/lib/rubocop/config_finder.rb +1 -1
  27. data/lib/rubocop/config_loader.rb +49 -27
  28. data/lib/rubocop/config_loader_resolver.rb +95 -20
  29. data/lib/rubocop/config_obsoletion/cop_rule.rb +2 -1
  30. data/lib/rubocop/config_obsoletion/extracted_cop.rb +4 -2
  31. data/lib/rubocop/config_obsoletion/removed_cop.rb +9 -1
  32. data/lib/rubocop/config_obsoletion.rb +1 -1
  33. data/lib/rubocop/config_store.rb +2 -2
  34. data/lib/rubocop/config_validator.rb +69 -7
  35. data/lib/rubocop/cop/autocorrect_logic.rb +24 -6
  36. data/lib/rubocop/cop/badge.rb +10 -2
  37. data/lib/rubocop/cop/base.rb +128 -35
  38. data/lib/rubocop/cop/bundler/gem_comment.rb +5 -4
  39. data/lib/rubocop/cop/bundler/gem_version.rb +28 -28
  40. data/lib/rubocop/cop/bundler/ordered_gems.rb +1 -10
  41. data/lib/rubocop/cop/bundler.rb +19 -0
  42. data/lib/rubocop/cop/commissioner.rb +13 -11
  43. data/lib/rubocop/cop/cop_documentation.rb +81 -0
  44. data/lib/rubocop/cop/cop_explanation.rb +140 -0
  45. data/lib/rubocop/cop/corrector.rb +4 -4
  46. data/lib/rubocop/cop/correctors/alignment_corrector.rb +87 -9
  47. data/lib/rubocop/cop/correctors/condition_corrector.rb +1 -1
  48. data/lib/rubocop/cop/correctors/each_to_for_corrector.rb +37 -7
  49. data/lib/rubocop/cop/correctors/empty_line_corrector.rb +1 -1
  50. data/lib/rubocop/cop/correctors/lambda_literal_to_method_corrector.rb +31 -4
  51. data/lib/rubocop/cop/correctors/multiline_literal_brace_corrector.rb +35 -5
  52. data/lib/rubocop/cop/correctors/ordered_gem_corrector.rb +8 -1
  53. data/lib/rubocop/cop/correctors/parentheses_corrector.rb +70 -2
  54. data/lib/rubocop/cop/correctors/percent_literal_corrector.rb +2 -2
  55. data/lib/rubocop/cop/correctors.rb +28 -0
  56. data/lib/rubocop/cop/documentation.rb +3 -4
  57. data/lib/rubocop/cop/exclude_limit.rb +31 -5
  58. data/lib/rubocop/cop/gemspec/dependency_version.rb +0 -6
  59. data/lib/rubocop/cop/gemspec/development_dependencies.rb +1 -1
  60. data/lib/rubocop/cop/gemspec/duplicated_assignment.rb +14 -4
  61. data/lib/rubocop/cop/gemspec/ordered_dependencies.rb +1 -8
  62. data/lib/rubocop/cop/gemspec/require_mfa.rb +9 -6
  63. data/lib/rubocop/cop/gemspec/ruby_version_globals_usage.rb +12 -7
  64. data/lib/rubocop/cop/gemspec.rb +22 -0
  65. data/lib/rubocop/cop/generator/registration_injector.rb +188 -0
  66. data/lib/rubocop/cop/generator.rb +5 -1
  67. data/lib/rubocop/cop/internal_affairs/example_heredoc_delimiter.rb +8 -8
  68. data/lib/rubocop/cop/internal_affairs/itblock_handler.rb +69 -0
  69. data/lib/rubocop/cop/internal_affairs/location_exists.rb +28 -2
  70. data/lib/rubocop/cop/internal_affairs/location_line_equality_comparison.rb +1 -0
  71. data/lib/rubocop/cop/internal_affairs/node_matcher_directive.rb +12 -16
  72. data/lib/rubocop/cop/internal_affairs/node_pattern_groups/ast_processor.rb +1 -1
  73. data/lib/rubocop/cop/internal_affairs/node_pattern_groups/ast_walker.rb +1 -2
  74. data/lib/rubocop/cop/internal_affairs/node_type_group.rb +0 -7
  75. data/lib/rubocop/cop/internal_affairs/on_send_without_on_csend.rb +1 -1
  76. data/lib/rubocop/cop/internal_affairs/redundant_context_config_parameter.rb +1 -7
  77. data/lib/rubocop/cop/internal_affairs/redundant_let_rubocop_config_new.rb +5 -3
  78. data/lib/rubocop/cop/internal_affairs/style_detected_api_use.rb +1 -7
  79. data/lib/rubocop/cop/internal_affairs/useless_message_assertion.rb +4 -4
  80. data/lib/rubocop/cop/internal_affairs.rb +1 -0
  81. data/lib/rubocop/cop/layout/argument_alignment.rb +9 -3
  82. data/lib/rubocop/cop/layout/array_alignment.rb +1 -1
  83. data/lib/rubocop/cop/layout/begin_end_alignment.rb +1 -1
  84. data/lib/rubocop/cop/layout/block_alignment.rb +84 -4
  85. data/lib/rubocop/cop/layout/case_indentation.rb +28 -10
  86. data/lib/rubocop/cop/layout/class_structure.rb +156 -41
  87. data/lib/rubocop/cop/layout/comment_indentation.rb +17 -7
  88. data/lib/rubocop/cop/layout/condition_position.rb +13 -3
  89. data/lib/rubocop/cop/layout/def_end_alignment.rb +4 -0
  90. data/lib/rubocop/cop/layout/dot_position.rb +26 -16
  91. data/lib/rubocop/cop/layout/else_alignment.rb +2 -14
  92. data/lib/rubocop/cop/layout/empty_comment.rb +8 -10
  93. data/lib/rubocop/cop/layout/empty_line_after_guard_clause.rb +25 -7
  94. data/lib/rubocop/cop/layout/empty_line_after_magic_comment.rb +63 -5
  95. data/lib/rubocop/cop/layout/empty_line_after_multiline_condition.rb +21 -8
  96. data/lib/rubocop/cop/layout/empty_line_between_defs.rb +15 -2
  97. data/lib/rubocop/cop/layout/empty_lines.rb +5 -2
  98. data/lib/rubocop/cop/layout/empty_lines_after_module_inclusion.rb +2 -2
  99. data/lib/rubocop/cop/layout/empty_lines_around_attribute_accessor.rb +2 -0
  100. data/lib/rubocop/cop/layout/empty_lines_around_block_body.rb +21 -5
  101. data/lib/rubocop/cop/layout/empty_lines_around_class_body.rb +16 -2
  102. data/lib/rubocop/cop/layout/empty_lines_around_exception_handling_keywords.rb +23 -1
  103. data/lib/rubocop/cop/layout/empty_lines_around_module_body.rb +16 -2
  104. data/lib/rubocop/cop/layout/end_alignment.rb +23 -15
  105. data/lib/rubocop/cop/layout/extra_spacing.rb +109 -3
  106. data/lib/rubocop/cop/layout/first_argument_indentation.rb +81 -2
  107. data/lib/rubocop/cop/layout/first_array_element_indentation.rb +18 -5
  108. data/lib/rubocop/cop/layout/first_array_element_line_break.rb +41 -0
  109. data/lib/rubocop/cop/layout/first_hash_element_indentation.rb +36 -23
  110. data/lib/rubocop/cop/layout/first_hash_element_line_break.rb +25 -25
  111. data/lib/rubocop/cop/layout/first_method_argument_line_break.rb +6 -0
  112. data/lib/rubocop/cop/layout/first_method_parameter_line_break.rb +4 -0
  113. data/lib/rubocop/cop/layout/first_parameter_indentation.rb +11 -0
  114. data/lib/rubocop/cop/layout/hash_alignment.rb +16 -11
  115. data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +8 -4
  116. data/lib/rubocop/cop/layout/heredoc_indentation.rb +48 -3
  117. data/lib/rubocop/cop/layout/indentation_consistency.rb +22 -5
  118. data/lib/rubocop/cop/layout/indentation_style.rb +5 -2
  119. data/lib/rubocop/cop/layout/indentation_width.rb +158 -12
  120. data/lib/rubocop/cop/layout/leading_comment_space.rb +27 -0
  121. data/lib/rubocop/cop/layout/line_continuation_spacing.rb +10 -4
  122. data/lib/rubocop/cop/layout/line_end_string_concatenation_indentation.rb +25 -9
  123. data/lib/rubocop/cop/layout/line_length.rb +265 -29
  124. data/lib/rubocop/cop/layout/multiline_array_brace_layout.rb +69 -57
  125. data/lib/rubocop/cop/layout/multiline_assignment_layout.rb +8 -2
  126. data/lib/rubocop/cop/layout/multiline_block_layout.rb +10 -1
  127. data/lib/rubocop/cop/layout/multiline_hash_brace_layout.rb +65 -56
  128. data/lib/rubocop/cop/layout/multiline_method_call_brace_layout.rb +7 -1
  129. data/lib/rubocop/cop/layout/multiline_method_call_indentation.rb +268 -38
  130. data/lib/rubocop/cop/layout/multiline_method_definition_brace_layout.rb +4 -0
  131. data/lib/rubocop/cop/layout/parameter_alignment.rb +1 -1
  132. data/lib/rubocop/cop/layout/redundant_line_break.rb +102 -2
  133. data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +19 -5
  134. data/lib/rubocop/cop/layout/single_line_block_chain.rb +10 -2
  135. data/lib/rubocop/cop/layout/space_after_comma.rb +2 -10
  136. data/lib/rubocop/cop/layout/space_after_not.rb +5 -0
  137. data/lib/rubocop/cop/layout/space_after_semicolon.rb +1 -1
  138. data/lib/rubocop/cop/layout/space_around_block_parameters.rb +10 -4
  139. data/lib/rubocop/cop/layout/space_around_keyword.rb +14 -2
  140. data/lib/rubocop/cop/layout/space_around_operators.rb +18 -3
  141. data/lib/rubocop/cop/layout/space_before_block_braces.rb +4 -1
  142. data/lib/rubocop/cop/layout/space_before_brackets.rb +1 -1
  143. data/lib/rubocop/cop/layout/space_in_lambda_literal.rb +9 -8
  144. data/lib/rubocop/cop/layout/space_inside_array_literal_brackets.rb +44 -34
  145. data/lib/rubocop/cop/layout/space_inside_block_braces.rb +31 -8
  146. data/lib/rubocop/cop/layout/space_inside_reference_brackets.rb +2 -12
  147. data/lib/rubocop/cop/layout.rb +114 -0
  148. data/lib/rubocop/cop/lazy_loader.rb +41 -0
  149. data/lib/rubocop/cop/lint/ambiguous_assignment.rb +9 -17
  150. data/lib/rubocop/cop/lint/ambiguous_block_association.rb +72 -1
  151. data/lib/rubocop/cop/lint/ambiguous_operator.rb +1 -1
  152. data/lib/rubocop/cop/lint/ambiguous_operator_precedence.rb +3 -11
  153. data/lib/rubocop/cop/lint/ambiguous_range.rb +1 -2
  154. data/lib/rubocop/cop/lint/ambiguous_regexp_literal.rb +6 -1
  155. data/lib/rubocop/cop/lint/argument_mismatch.rb +99 -0
  156. data/lib/rubocop/cop/lint/assignment_in_condition.rb +15 -1
  157. data/lib/rubocop/cop/lint/circular_argument_reference.rb +45 -3
  158. data/lib/rubocop/cop/lint/constant_overwritten_in_rescue.rb +1 -1
  159. data/lib/rubocop/cop/lint/constant_reassignment.rb +94 -15
  160. data/lib/rubocop/cop/lint/constant_resolution.rb +31 -6
  161. data/lib/rubocop/cop/lint/cop_directive_syntax.rb +165 -15
  162. data/lib/rubocop/cop/lint/data_define_override.rb +63 -0
  163. data/lib/rubocop/cop/lint/debugger.rb +13 -2
  164. data/lib/rubocop/cop/lint/deprecated_constants.rb +2 -8
  165. data/lib/rubocop/cop/lint/deprecated_reference.rb +194 -0
  166. data/lib/rubocop/cop/lint/duplicate_match_pattern.rb +4 -4
  167. data/lib/rubocop/cop/lint/duplicate_methods.rb +405 -28
  168. data/lib/rubocop/cop/lint/else_layout.rb +19 -0
  169. data/lib/rubocop/cop/lint/empty_block.rb +4 -4
  170. data/lib/rubocop/cop/lint/empty_conditional_body.rb +9 -2
  171. data/lib/rubocop/cop/lint/empty_in_pattern.rb +8 -1
  172. data/lib/rubocop/cop/lint/empty_when.rb +8 -1
  173. data/lib/rubocop/cop/lint/ensure_return.rb +19 -1
  174. data/lib/rubocop/cop/lint/erb_new_arguments.rb +4 -2
  175. data/lib/rubocop/cop/lint/float_comparison.rb +2 -1
  176. data/lib/rubocop/cop/lint/heredoc_method_call_position.rb +4 -0
  177. data/lib/rubocop/cop/lint/implicit_string_concatenation.rb +1 -2
  178. data/lib/rubocop/cop/lint/incompatible_io_select_with_fiber_scheduler.rb +5 -1
  179. data/lib/rubocop/cop/lint/ineffective_access_modifier.rb +1 -2
  180. data/lib/rubocop/cop/lint/inherit_exception.rb +53 -7
  181. data/lib/rubocop/cop/lint/interpolation_check.rb +25 -6
  182. data/lib/rubocop/cop/lint/lambda_without_literal_block.rb +1 -1
  183. data/lib/rubocop/cop/lint/literal_as_condition.rb +36 -9
  184. data/lib/rubocop/cop/lint/literal_assignment_in_condition.rb +11 -1
  185. data/lib/rubocop/cop/lint/literal_in_interpolation.rb +75 -37
  186. data/lib/rubocop/cop/lint/loop.rb +24 -2
  187. data/lib/rubocop/cop/lint/misplaced_magic_comment.rb +245 -0
  188. data/lib/rubocop/cop/lint/missing_cop_enable_directive.rb +46 -18
  189. data/lib/rubocop/cop/lint/missing_super.rb +31 -1
  190. data/lib/rubocop/cop/lint/multiple_comparison.rb +2 -2
  191. data/lib/rubocop/cop/lint/name_typo.rb +270 -0
  192. data/lib/rubocop/cop/lint/nested_method_definition.rb +1 -1
  193. data/lib/rubocop/cop/lint/next_without_accumulator.rb +2 -0
  194. data/lib/rubocop/cop/lint/no_return_in_begin_end_blocks.rb +20 -0
  195. data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +4 -2
  196. data/lib/rubocop/cop/lint/non_local_exit_from_iterator.rb +1 -1
  197. data/lib/rubocop/cop/lint/number_conversion.rb +22 -11
  198. data/lib/rubocop/cop/lint/numbered_parameter_assignment.rb +1 -1
  199. data/lib/rubocop/cop/lint/numeric_operation_with_constant_result.rb +10 -0
  200. data/lib/rubocop/cop/lint/ordered_magic_comments.rb +7 -7
  201. data/lib/rubocop/cop/lint/out_of_range_regexp_ref.rb +15 -4
  202. data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +20 -14
  203. data/lib/rubocop/cop/lint/raise_exception.rb +1 -1
  204. data/lib/rubocop/cop/lint/rand_one.rb +1 -1
  205. data/lib/rubocop/cop/lint/redundant_cop_disable_directive.rb +160 -39
  206. data/lib/rubocop/cop/lint/redundant_cop_enable_directive.rb +53 -19
  207. data/lib/rubocop/cop/lint/redundant_dir_glob_sort.rb +28 -6
  208. data/lib/rubocop/cop/lint/redundant_require_statement.rb +5 -4
  209. data/lib/rubocop/cop/lint/redundant_safe_navigation.rb +37 -14
  210. data/lib/rubocop/cop/lint/redundant_splat_expansion.rb +13 -4
  211. data/lib/rubocop/cop/lint/redundant_type_conversion.rb +11 -5
  212. data/lib/rubocop/cop/lint/redundant_with_index.rb +2 -3
  213. data/lib/rubocop/cop/lint/redundant_with_object.rb +5 -0
  214. data/lib/rubocop/cop/lint/refinement_import_methods.rb +8 -1
  215. data/lib/rubocop/cop/lint/regexp_as_condition.rb +9 -1
  216. data/lib/rubocop/cop/lint/require_parentheses.rb +13 -4
  217. data/lib/rubocop/cop/lint/require_range_parentheses.rb +2 -1
  218. data/lib/rubocop/cop/lint/require_relative_self_path.rb +7 -5
  219. data/lib/rubocop/cop/lint/rescue_type.rb +1 -1
  220. data/lib/rubocop/cop/lint/safe_navigation_chain.rb +24 -0
  221. data/lib/rubocop/cop/lint/safe_navigation_consistency.rb +56 -6
  222. data/lib/rubocop/cop/lint/safe_navigation_with_empty.rb +1 -1
  223. data/lib/rubocop/cop/lint/script_permission.rb +5 -1
  224. data/lib/rubocop/cop/lint/self_assignment.rb +33 -2
  225. data/lib/rubocop/cop/lint/send_with_mixin_argument.rb +1 -1
  226. data/lib/rubocop/cop/lint/shadowed_exception.rb +1 -1
  227. data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +14 -0
  228. data/lib/rubocop/cop/lint/shared_mutable_default.rb +3 -1
  229. data/lib/rubocop/cop/lint/struct_new_override.rb +17 -1
  230. data/lib/rubocop/cop/lint/super_argument_mismatch.rb +179 -0
  231. data/lib/rubocop/cop/lint/suppressed_exception_in_number_conversion.rb +13 -2
  232. data/lib/rubocop/cop/lint/symbol_conversion.rb +22 -4
  233. data/lib/rubocop/cop/lint/syntax.rb +25 -1
  234. data/lib/rubocop/cop/lint/to_enum_arguments.rb +72 -4
  235. data/lib/rubocop/cop/lint/to_json.rb +20 -17
  236. data/lib/rubocop/cop/lint/top_level_return_with_argument.rb +1 -1
  237. data/lib/rubocop/cop/lint/trailing_comma_in_attribute_declaration.rb +5 -1
  238. data/lib/rubocop/cop/lint/unescaped_bracket_in_regexp.rb +54 -11
  239. data/lib/rubocop/cop/lint/unmodified_reduce_accumulator.rb +1 -0
  240. data/lib/rubocop/cop/lint/unreachable_code.rb +15 -9
  241. data/lib/rubocop/cop/lint/unreachable_pattern_branch.rb +113 -0
  242. data/lib/rubocop/cop/lint/unused_method_argument.rb +10 -0
  243. data/lib/rubocop/cop/lint/unused_private_method.rb +234 -0
  244. data/lib/rubocop/cop/lint/useless_access_modifier.rb +1 -2
  245. data/lib/rubocop/cop/lint/useless_assignment.rb +61 -27
  246. data/lib/rubocop/cop/lint/useless_constant_scoping.rb +40 -4
  247. data/lib/rubocop/cop/lint/useless_default_value_argument.rb +2 -0
  248. data/lib/rubocop/cop/lint/useless_method_definition.rb +1 -1
  249. data/lib/rubocop/cop/lint/useless_numeric_operation.rb +10 -10
  250. data/lib/rubocop/cop/lint/useless_or.rb +15 -2
  251. data/lib/rubocop/cop/lint/useless_rescue.rb +1 -2
  252. data/lib/rubocop/cop/lint/useless_ruby2_keywords.rb +10 -4
  253. data/lib/rubocop/cop/lint/useless_setter_call.rb +11 -5
  254. data/lib/rubocop/cop/lint/useless_times.rb +22 -1
  255. data/lib/rubocop/cop/lint/utils/nil_receiver_checker.rb +94 -14
  256. data/lib/rubocop/cop/lint/void.rb +59 -22
  257. data/lib/rubocop/cop/lint.rb +179 -0
  258. data/lib/rubocop/cop/metrics/block_length.rb +1 -1
  259. data/lib/rubocop/cop/metrics/block_nesting.rb +23 -0
  260. data/lib/rubocop/cop/metrics/class_length.rb +4 -2
  261. data/lib/rubocop/cop/metrics/collection_literal_length.rb +1 -1
  262. data/lib/rubocop/cop/metrics/cyclomatic_complexity.rb +0 -4
  263. data/lib/rubocop/cop/metrics/method_length.rb +2 -2
  264. data/lib/rubocop/cop/metrics/module_length.rb +4 -2
  265. data/lib/rubocop/cop/metrics/perceived_complexity.rb +37 -7
  266. data/lib/rubocop/cop/metrics/utils/abc_size_calculator.rb +4 -3
  267. data/lib/rubocop/cop/metrics/utils/code_length_calculator.rb +1 -1
  268. data/lib/rubocop/cop/metrics/utils/iterating_block.rb +1 -1
  269. data/lib/rubocop/cop/metrics.rb +31 -0
  270. data/lib/rubocop/cop/migration/department_name.rb +11 -5
  271. data/lib/rubocop/cop/migration.rb +13 -0
  272. data/lib/rubocop/cop/mixin/alignment.rb +5 -1
  273. data/lib/rubocop/cop/mixin/allowed_methods.rb +5 -5
  274. data/lib/rubocop/cop/mixin/allowed_pattern.rb +5 -1
  275. data/lib/rubocop/cop/mixin/annotation_comment.rb +1 -1
  276. data/lib/rubocop/cop/mixin/check_line_breakable.rb +47 -25
  277. data/lib/rubocop/cop/mixin/check_single_line_suitability.rb +12 -8
  278. data/lib/rubocop/cop/mixin/code_length.rb +10 -2
  279. data/lib/rubocop/cop/mixin/comments_help.rb +1 -2
  280. data/lib/rubocop/cop/mixin/configurable_enforced_style.rb +1 -2
  281. data/lib/rubocop/cop/mixin/configurable_max.rb +6 -5
  282. data/lib/rubocop/cop/mixin/empty_lines_around_body.rb +12 -1
  283. data/lib/rubocop/cop/mixin/endless_method_body_help.rb +105 -0
  284. data/lib/rubocop/cop/mixin/endless_method_rewriter.rb +13 -5
  285. data/lib/rubocop/cop/mixin/forbidden_identifiers.rb +2 -2
  286. data/lib/rubocop/cop/mixin/forbidden_pattern.rb +5 -1
  287. data/lib/rubocop/cop/mixin/hash_alignment_styles.rb +58 -12
  288. data/lib/rubocop/cop/mixin/hash_shorthand_syntax.rb +37 -10
  289. data/lib/rubocop/cop/mixin/hash_subset.rb +9 -2
  290. data/lib/rubocop/cop/mixin/hash_transform_method/autocorrection.rb +63 -0
  291. data/lib/rubocop/cop/mixin/hash_transform_method.rb +14 -60
  292. data/lib/rubocop/cop/mixin/indexed_method_arity.rb +94 -0
  293. data/lib/rubocop/cop/mixin/line_length_help.rb +28 -3
  294. data/lib/rubocop/cop/mixin/method_complexity.rb +1 -1
  295. data/lib/rubocop/cop/mixin/min_branches_count.rb +3 -1
  296. data/lib/rubocop/cop/mixin/multiline_element_line_breaks.rb +11 -1
  297. data/lib/rubocop/cop/mixin/multiline_expression_indentation.rb +1 -1
  298. data/lib/rubocop/cop/mixin/multiline_literal_brace_layout.rb +10 -1
  299. data/lib/rubocop/cop/mixin/ordered_gem_node.rb +1 -1
  300. data/lib/rubocop/cop/mixin/pattern_matching_help.rb +35 -0
  301. data/lib/rubocop/cop/mixin/preceding_following_alignment.rb +79 -8
  302. data/lib/rubocop/cop/mixin/project_index_help.rb +203 -0
  303. data/lib/rubocop/cop/mixin/range_help.rb +1 -2
  304. data/lib/rubocop/cop/mixin/reparsed_equivalence.rb +181 -0
  305. data/lib/rubocop/cop/mixin/space_after_punctuation.rb +5 -4
  306. data/lib/rubocop/cop/mixin/statement_modifier.rb +69 -12
  307. data/lib/rubocop/cop/mixin/trailing_comma.rb +7 -6
  308. data/lib/rubocop/cop/mixin/visibility_help.rb +2 -1
  309. data/lib/rubocop/cop/mixin.rb +93 -0
  310. data/lib/rubocop/cop/naming/accessor_method_name.rb +8 -0
  311. data/lib/rubocop/cop/naming/binary_operator_parameter_name.rb +17 -1
  312. data/lib/rubocop/cop/naming/block_forwarding.rb +4 -1
  313. data/lib/rubocop/cop/naming/block_parameter_name.rb +1 -1
  314. data/lib/rubocop/cop/naming/file_name.rb +4 -3
  315. data/lib/rubocop/cop/naming/heredoc_delimiter_case.rb +9 -2
  316. data/lib/rubocop/cop/naming/heredoc_delimiter_naming.rb +5 -3
  317. data/lib/rubocop/cop/naming/inclusive_language.rb +8 -2
  318. data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +12 -5
  319. data/lib/rubocop/cop/naming/method_name.rb +6 -3
  320. data/lib/rubocop/cop/naming/predicate_method.rb +13 -2
  321. data/lib/rubocop/cop/naming/predicate_prefix.rb +30 -17
  322. data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +12 -7
  323. data/lib/rubocop/cop/naming/variable_number.rb +3 -1
  324. data/lib/rubocop/cop/naming.rb +31 -0
  325. data/lib/rubocop/cop/offense.rb +108 -9
  326. data/lib/rubocop/cop/registry.rb +232 -66
  327. data/lib/rubocop/cop/security/eval.rb +15 -2
  328. data/lib/rubocop/cop/security/io_methods.rb +2 -2
  329. data/lib/rubocop/cop/security/json_load.rb +16 -4
  330. data/lib/rubocop/cop/security/marshal_load.rb +1 -1
  331. data/lib/rubocop/cop/security.rb +19 -0
  332. data/lib/rubocop/cop/severity.rb +12 -0
  333. data/lib/rubocop/cop/style/access_modifier_declarations.rb +55 -8
  334. data/lib/rubocop/cop/style/accessor_grouping.rb +16 -5
  335. data/lib/rubocop/cop/style/alias.rb +33 -8
  336. data/lib/rubocop/cop/style/ambiguous_endless_method_definition.rb +4 -3
  337. data/lib/rubocop/cop/style/and_or.rb +8 -3
  338. data/lib/rubocop/cop/style/arguments_forwarding.rb +61 -17
  339. data/lib/rubocop/cop/style/array_first_last.rb +13 -3
  340. data/lib/rubocop/cop/style/array_intersect.rb +28 -5
  341. data/lib/rubocop/cop/style/array_intersect_with_single_element.rb +3 -0
  342. data/lib/rubocop/cop/style/array_join.rb +4 -2
  343. data/lib/rubocop/cop/style/ascii_comments.rb +6 -3
  344. data/lib/rubocop/cop/style/attr.rb +8 -6
  345. data/lib/rubocop/cop/style/bare_percent_literals.rb +4 -3
  346. data/lib/rubocop/cop/style/begin_block.rb +3 -1
  347. data/lib/rubocop/cop/style/bitwise_predicate.rb +7 -6
  348. data/lib/rubocop/cop/style/block_delimiters.rb +74 -38
  349. data/lib/rubocop/cop/style/case_equality.rb +29 -15
  350. data/lib/rubocop/cop/style/case_like_if.rb +11 -10
  351. data/lib/rubocop/cop/style/character_literal.rb +2 -2
  352. data/lib/rubocop/cop/style/class_and_module_children.rb +151 -35
  353. data/lib/rubocop/cop/style/class_equality_comparison.rb +21 -13
  354. data/lib/rubocop/cop/style/class_methods_definitions.rb +26 -5
  355. data/lib/rubocop/cop/style/collection_compact.rb +37 -17
  356. data/lib/rubocop/cop/style/collection_querying.rb +79 -46
  357. data/lib/rubocop/cop/style/colon_method_call.rb +16 -7
  358. data/lib/rubocop/cop/style/combinable_loops.rb +91 -9
  359. data/lib/rubocop/cop/style/comparable_clamp.rb +12 -1
  360. data/lib/rubocop/cop/style/concat_array_literals.rb +65 -9
  361. data/lib/rubocop/cop/style/conditional_assignment.rb +34 -18
  362. data/lib/rubocop/cop/style/constant_visibility.rb +13 -7
  363. data/lib/rubocop/cop/style/copyright.rb +27 -12
  364. data/lib/rubocop/cop/style/data_inheritance.rb +18 -0
  365. data/lib/rubocop/cop/style/date_time.rb +4 -4
  366. data/lib/rubocop/cop/style/def_with_parentheses.rb +6 -2
  367. data/lib/rubocop/cop/style/dig_chain.rb +5 -0
  368. data/lib/rubocop/cop/style/dir_empty.rb +4 -0
  369. data/lib/rubocop/cop/style/directive_scope.rb +304 -0
  370. data/lib/rubocop/cop/style/disable_cops_within_source_code_directive.rb +184 -20
  371. data/lib/rubocop/cop/style/document_dynamic_eval_definition.rb +6 -1
  372. data/lib/rubocop/cop/style/documentation.rb +53 -6
  373. data/lib/rubocop/cop/style/documentation_method.rb +8 -12
  374. data/lib/rubocop/cop/style/double_negation.rb +11 -0
  375. data/lib/rubocop/cop/style/each_for_simple_loop.rb +1 -1
  376. data/lib/rubocop/cop/style/each_with_object.rb +2 -0
  377. data/lib/rubocop/cop/style/empty_block_parameter.rb +1 -1
  378. data/lib/rubocop/cop/style/empty_case_condition.rb +13 -4
  379. data/lib/rubocop/cop/style/empty_class_definition.rb +126 -0
  380. data/lib/rubocop/cop/style/empty_heredoc.rb +4 -0
  381. data/lib/rubocop/cop/style/empty_lambda_parameter.rb +1 -1
  382. data/lib/rubocop/cop/style/empty_literal.rb +8 -3
  383. data/lib/rubocop/cop/style/empty_method.rb +15 -9
  384. data/lib/rubocop/cop/style/empty_string_inside_interpolation.rb +74 -22
  385. data/lib/rubocop/cop/style/encoding.rb +7 -1
  386. data/lib/rubocop/cop/style/end_block.rb +3 -1
  387. data/lib/rubocop/cop/style/endless_method.rb +100 -21
  388. data/lib/rubocop/cop/style/env_home.rb +4 -0
  389. data/lib/rubocop/cop/style/even_odd.rb +11 -1
  390. data/lib/rubocop/cop/style/exact_regexp_match.rb +52 -8
  391. data/lib/rubocop/cop/style/explicit_block_argument.rb +50 -10
  392. data/lib/rubocop/cop/style/fetch_env_var.rb +1 -1
  393. data/lib/rubocop/cop/style/file_null.rb +6 -4
  394. data/lib/rubocop/cop/style/file_open.rb +84 -0
  395. data/lib/rubocop/cop/style/file_write.rb +21 -16
  396. data/lib/rubocop/cop/style/float_division.rb +28 -14
  397. data/lib/rubocop/cop/style/for.rb +60 -1
  398. data/lib/rubocop/cop/style/format_string.rb +44 -9
  399. data/lib/rubocop/cop/style/format_string_token.rb +50 -7
  400. data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +2 -1
  401. data/lib/rubocop/cop/style/global_vars.rb +5 -2
  402. data/lib/rubocop/cop/style/guard_clause.rb +57 -40
  403. data/lib/rubocop/cop/style/hash_as_last_array_item.rb +31 -9
  404. data/lib/rubocop/cop/style/hash_conversion.rb +39 -11
  405. data/lib/rubocop/cop/style/hash_each_methods.rb +1 -2
  406. data/lib/rubocop/cop/style/hash_lookup_method.rb +128 -0
  407. data/lib/rubocop/cop/style/hash_slice.rb +16 -0
  408. data/lib/rubocop/cop/style/hash_syntax.rb +19 -5
  409. data/lib/rubocop/cop/style/hash_transform_keys.rb +17 -7
  410. data/lib/rubocop/cop/style/hash_transform_values.rb +17 -7
  411. data/lib/rubocop/cop/style/identical_conditional_branches.rb +38 -10
  412. data/lib/rubocop/cop/style/if_inside_else.rb +36 -8
  413. data/lib/rubocop/cop/style/if_unless_modifier.rb +80 -76
  414. data/lib/rubocop/cop/style/if_unless_modifier_of_if_unless.rb +17 -14
  415. data/lib/rubocop/cop/style/if_with_boolean_literal_branches.rb +4 -1
  416. data/lib/rubocop/cop/style/if_with_semicolon.rb +61 -8
  417. data/lib/rubocop/cop/style/inline_comment.rb +5 -2
  418. data/lib/rubocop/cop/style/inverse_methods.rb +24 -2
  419. data/lib/rubocop/cop/style/invertible_unless_condition.rb +25 -5
  420. data/lib/rubocop/cop/style/ip_addresses.rb +1 -2
  421. data/lib/rubocop/cop/style/it_block_parameter.rb +94 -4
  422. data/lib/rubocop/cop/style/keyword_arguments_merging.rb +4 -0
  423. data/lib/rubocop/cop/style/keyword_parameters_order.rb +10 -4
  424. data/lib/rubocop/cop/style/lambda.rb +45 -2
  425. data/lib/rubocop/cop/style/lambda_call.rb +24 -8
  426. data/lib/rubocop/cop/style/magic_comment_format.rb +4 -4
  427. data/lib/rubocop/cop/style/map_compact_with_conditional_block.rb +11 -0
  428. data/lib/rubocop/cop/style/map_into_array.rb +2 -3
  429. data/lib/rubocop/cop/style/map_join.rb +123 -0
  430. data/lib/rubocop/cop/style/map_to_hash.rb +1 -2
  431. data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +102 -20
  432. data/lib/rubocop/cop/style/method_call_with_args_parentheses/require_parentheses.rb +15 -2
  433. data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +42 -6
  434. data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +36 -8
  435. data/lib/rubocop/cop/style/method_def_parentheses.rb +36 -8
  436. data/lib/rubocop/cop/style/min_max_comparison.rb +4 -1
  437. data/lib/rubocop/cop/style/missing_else.rb +7 -1
  438. data/lib/rubocop/cop/style/missing_respond_to_missing.rb +40 -7
  439. data/lib/rubocop/cop/style/mixin_grouping.rb +12 -3
  440. data/lib/rubocop/cop/style/mixin_usage.rb +1 -1
  441. data/lib/rubocop/cop/style/module_function.rb +4 -2
  442. data/lib/rubocop/cop/style/module_member_existence_check.rb +110 -0
  443. data/lib/rubocop/cop/style/multiline_if_modifier.rb +45 -5
  444. data/lib/rubocop/cop/style/multiline_if_then.rb +10 -4
  445. data/lib/rubocop/cop/style/multiline_in_pattern_then.rb +7 -0
  446. data/lib/rubocop/cop/style/multiline_memoization.rb +7 -1
  447. data/lib/rubocop/cop/style/multiline_method_signature.rb +14 -13
  448. data/lib/rubocop/cop/style/multiline_ternary_operator.rb +7 -3
  449. data/lib/rubocop/cop/style/multiline_when_then.rb +7 -0
  450. data/lib/rubocop/cop/style/multiple_comparison.rb +33 -22
  451. data/lib/rubocop/cop/style/mutable_constant.rb +158 -14
  452. data/lib/rubocop/cop/style/negated_if_else_condition.rb +3 -3
  453. data/lib/rubocop/cop/style/negative_array_index.rb +228 -0
  454. data/lib/rubocop/cop/style/nested_modifier.rb +36 -12
  455. data/lib/rubocop/cop/style/nested_ternary_operator.rb +26 -8
  456. data/lib/rubocop/cop/style/next.rb +24 -10
  457. data/lib/rubocop/cop/style/nil_comparison.rb +50 -12
  458. data/lib/rubocop/cop/style/nil_lambda.rb +9 -1
  459. data/lib/rubocop/cop/style/non_nil_check.rb +21 -11
  460. data/lib/rubocop/cop/style/not.rb +12 -3
  461. data/lib/rubocop/cop/style/numeric_literal_prefix.rb +11 -1
  462. data/lib/rubocop/cop/style/numeric_literals.rb +3 -2
  463. data/lib/rubocop/cop/style/numeric_predicate.rb +22 -6
  464. data/lib/rubocop/cop/style/one_class_per_file.rb +115 -0
  465. data/lib/rubocop/cop/style/one_line_conditional.rb +18 -6
  466. data/lib/rubocop/cop/style/open_struct_use.rb +1 -1
  467. data/lib/rubocop/cop/style/operator_method_call.rb +10 -2
  468. data/lib/rubocop/cop/style/option_hash.rb +1 -1
  469. data/lib/rubocop/cop/style/optional_arguments.rb +1 -0
  470. data/lib/rubocop/cop/style/parallel_assignment.rb +26 -7
  471. data/lib/rubocop/cop/style/parentheses_around_condition.rb +7 -2
  472. data/lib/rubocop/cop/style/partition_instead_of_double_select.rb +270 -0
  473. data/lib/rubocop/cop/style/percent_literal_delimiters.rb +18 -3
  474. data/lib/rubocop/cop/style/perl_backrefs.rb +5 -3
  475. data/lib/rubocop/cop/style/predicate_with_kind.rb +84 -0
  476. data/lib/rubocop/cop/style/preferred_hash_methods.rb +12 -12
  477. data/lib/rubocop/cop/style/proc.rb +3 -2
  478. data/lib/rubocop/cop/style/raise_args.rb +20 -10
  479. data/lib/rubocop/cop/style/reduce_to_hash.rb +216 -0
  480. data/lib/rubocop/cop/style/redundant_argument.rb +2 -0
  481. data/lib/rubocop/cop/style/redundant_array_constructor.rb +2 -2
  482. data/lib/rubocop/cop/style/redundant_assignment.rb +12 -2
  483. data/lib/rubocop/cop/style/redundant_begin.rb +25 -7
  484. data/lib/rubocop/cop/style/redundant_condition.rb +41 -23
  485. data/lib/rubocop/cop/style/redundant_constant_base.rb +42 -6
  486. data/lib/rubocop/cop/style/redundant_current_directory_in_path.rb +13 -1
  487. data/lib/rubocop/cop/style/redundant_double_splat_hash_braces.rb +17 -3
  488. data/lib/rubocop/cop/style/redundant_each.rb +4 -5
  489. data/lib/rubocop/cop/style/redundant_exception.rb +21 -3
  490. data/lib/rubocop/cop/style/redundant_fetch_block.rb +10 -2
  491. data/lib/rubocop/cop/style/redundant_file_extension_in_require.rb +9 -0
  492. data/lib/rubocop/cop/style/redundant_filter_chain.rb +1 -1
  493. data/lib/rubocop/cop/style/redundant_format.rb +43 -7
  494. data/lib/rubocop/cop/style/redundant_freeze.rb +11 -3
  495. data/lib/rubocop/cop/style/redundant_heredoc_delimiter_quotes.rb +6 -1
  496. data/lib/rubocop/cop/style/redundant_interpolation_unfreeze.rb +49 -10
  497. data/lib/rubocop/cop/style/redundant_line_continuation.rb +82 -115
  498. data/lib/rubocop/cop/style/redundant_min_max_by.rb +93 -0
  499. data/lib/rubocop/cop/style/redundant_parentheses.rb +105 -83
  500. data/lib/rubocop/cop/style/redundant_percent_q.rb +5 -3
  501. data/lib/rubocop/cop/style/redundant_regexp_argument.rb +13 -2
  502. data/lib/rubocop/cop/style/redundant_regexp_character_class.rb +6 -5
  503. data/lib/rubocop/cop/style/redundant_regexp_constructor.rb +27 -7
  504. data/lib/rubocop/cop/style/redundant_regexp_escape.rb +12 -4
  505. data/lib/rubocop/cop/style/redundant_return.rb +4 -3
  506. data/lib/rubocop/cop/style/redundant_self.rb +11 -2
  507. data/lib/rubocop/cop/style/redundant_self_assignment.rb +1 -2
  508. data/lib/rubocop/cop/style/redundant_self_assignment_branch.rb +27 -4
  509. data/lib/rubocop/cop/style/redundant_sort.rb +45 -11
  510. data/lib/rubocop/cop/style/redundant_string_escape.rb +1 -2
  511. data/lib/rubocop/cop/style/redundant_struct_keyword_init.rb +133 -0
  512. data/lib/rubocop/cop/style/regexp_literal.rb +106 -28
  513. data/lib/rubocop/cop/style/require_order.rb +25 -8
  514. data/lib/rubocop/cop/style/rescue_modifier.rb +15 -14
  515. data/lib/rubocop/cop/style/return_nil.rb +17 -2
  516. data/lib/rubocop/cop/style/return_nil_in_predicate_method_definition.rb +11 -1
  517. data/lib/rubocop/cop/style/reverse_find.rb +51 -0
  518. data/lib/rubocop/cop/style/safe_navigation.rb +18 -9
  519. data/lib/rubocop/cop/style/sample.rb +19 -13
  520. data/lib/rubocop/cop/style/select_by_kind.rb +158 -0
  521. data/lib/rubocop/cop/style/select_by_range.rb +197 -0
  522. data/lib/rubocop/cop/style/select_by_regexp.rb +52 -23
  523. data/lib/rubocop/cop/style/self_assignment.rb +13 -16
  524. data/lib/rubocop/cop/style/semicolon.rb +39 -13
  525. data/lib/rubocop/cop/style/send_with_literal_method_name.rb +4 -0
  526. data/lib/rubocop/cop/style/single_line_block_params.rb +2 -2
  527. data/lib/rubocop/cop/style/single_line_do_end_block.rb +19 -7
  528. data/lib/rubocop/cop/style/single_line_methods.rb +24 -5
  529. data/lib/rubocop/cop/style/sole_nested_conditional.rb +25 -7
  530. data/lib/rubocop/cop/style/special_global_vars.rb +7 -2
  531. data/lib/rubocop/cop/style/stabby_lambda_parentheses.rb +31 -5
  532. data/lib/rubocop/cop/style/static_class.rb +21 -0
  533. data/lib/rubocop/cop/style/string_concatenation.rb +25 -6
  534. data/lib/rubocop/cop/style/string_hash_keys.rb +1 -0
  535. data/lib/rubocop/cop/style/struct_inheritance.rb +36 -1
  536. data/lib/rubocop/cop/style/super_arguments.rb +6 -4
  537. data/lib/rubocop/cop/style/symbol_proc.rb +32 -14
  538. data/lib/rubocop/cop/style/tally_method.rb +181 -0
  539. data/lib/rubocop/cop/style/ternary_parentheses.rb +34 -1
  540. data/lib/rubocop/cop/style/time_now.rb +41 -0
  541. data/lib/rubocop/cop/style/top_level_method_definition.rb +2 -2
  542. data/lib/rubocop/cop/style/trailing_comma_in_block_args.rb +1 -1
  543. data/lib/rubocop/cop/style/trailing_method_end_statement.rb +1 -0
  544. data/lib/rubocop/cop/style/trailing_underscore_variable.rb +35 -32
  545. data/lib/rubocop/cop/style/trivial_accessors.rb +1 -1
  546. data/lib/rubocop/cop/style/unless_logical_operators.rb +3 -3
  547. data/lib/rubocop/cop/style/while_until_do.rb +7 -0
  548. data/lib/rubocop/cop/style/while_until_modifier.rb +16 -0
  549. data/lib/rubocop/cop/style/word_array.rb +1 -0
  550. data/lib/rubocop/cop/style/yoda_condition.rb +26 -12
  551. data/lib/rubocop/cop/style/yoda_expression.rb +11 -2
  552. data/lib/rubocop/cop/style/zero_length_predicate.rb +6 -3
  553. data/lib/rubocop/cop/style.rb +311 -0
  554. data/lib/rubocop/cop/team.rb +171 -48
  555. data/lib/rubocop/cop/util.rb +5 -8
  556. data/lib/rubocop/cop/variable_force/assignment.rb +1 -1
  557. data/lib/rubocop/cop/variable_force/branch.rb +30 -6
  558. data/lib/rubocop/cop/variable_force/variable.rb +33 -9
  559. data/lib/rubocop/cops_documentation_generator.rb +27 -9
  560. data/lib/rubocop/directive_comment.rb +116 -7
  561. data/lib/rubocop/feature_loader.rb +0 -6
  562. data/lib/rubocop/file_patterns.rb +9 -1
  563. data/lib/rubocop/formatter/base_formatter.rb +22 -0
  564. data/lib/rubocop/formatter/clang_style_formatter.rb +5 -2
  565. data/lib/rubocop/formatter/disabled_config_formatter.rb +39 -10
  566. data/lib/rubocop/formatter/emacs_style_formatter.rb +3 -1
  567. data/lib/rubocop/formatter/formatter_set.rb +7 -2
  568. data/lib/rubocop/formatter/github_actions_formatter.rb +6 -5
  569. data/lib/rubocop/formatter/html_formatter.rb +2 -4
  570. data/lib/rubocop/formatter/json_formatter.rb +82 -7
  571. data/lib/rubocop/formatter/junit_formatter.rb +27 -10
  572. data/lib/rubocop/formatter/offense_count_formatter.rb +4 -3
  573. data/lib/rubocop/formatter/pacman_formatter.rb +3 -1
  574. data/lib/rubocop/formatter/sarif_formatter.rb +186 -0
  575. data/lib/rubocop/formatter/simple_text_formatter.rb +4 -5
  576. data/lib/rubocop/formatter/tap_formatter.rb +8 -3
  577. data/lib/rubocop/formatter/worst_offenders_formatter.rb +5 -4
  578. data/lib/rubocop/formatter.rb +23 -21
  579. data/lib/rubocop/lockfile.rb +18 -0
  580. data/lib/rubocop/lsp/diagnostic.rb +22 -42
  581. data/lib/rubocop/lsp/disable_comment_edits.rb +135 -0
  582. data/lib/rubocop/lsp/routes.rb +130 -83
  583. data/lib/rubocop/lsp/runtime.rb +64 -15
  584. data/lib/rubocop/lsp/server.rb +6 -2
  585. data/lib/rubocop/lsp/stdin_runner.rb +35 -2
  586. data/lib/rubocop/lsp.rb +5 -2
  587. data/lib/rubocop/magic_comment.rb +47 -0
  588. data/lib/rubocop/mcp/autocorrection_request.rb +52 -0
  589. data/lib/rubocop/mcp/explain_tool.rb +68 -0
  590. data/lib/rubocop/mcp/scope.rb +65 -0
  591. data/lib/rubocop/mcp/server.rb +307 -0
  592. data/lib/rubocop/mcp/source_files.rb +35 -0
  593. data/lib/rubocop/offense_limit.rb +30 -0
  594. data/lib/rubocop/options.rb +141 -13
  595. data/lib/rubocop/path_util.rb +16 -5
  596. data/lib/rubocop/pending_cops_reporter.rb +1 -6
  597. data/lib/rubocop/plugin/configuration_integrator.rb +13 -3
  598. data/lib/rubocop/plugin/loader.rb +2 -2
  599. data/lib/rubocop/project_index_loader.rb +82 -0
  600. data/lib/rubocop/rake_task.rb +2 -3
  601. data/lib/rubocop/remote_config.rb +18 -13
  602. data/lib/rubocop/result_cache.rb +102 -59
  603. data/lib/rubocop/rspec/cop_helper.rb +8 -0
  604. data/lib/rubocop/rspec/expect_offense.rb +2 -4
  605. data/lib/rubocop/rspec/shared_contexts.rb +53 -5
  606. data/lib/rubocop/rspec/support.rb +2 -1
  607. data/lib/rubocop/runner.rb +362 -106
  608. data/lib/rubocop/server/cache.rb +21 -40
  609. data/lib/rubocop/server/cli.rb +2 -4
  610. data/lib/rubocop/server/core.rb +8 -0
  611. data/lib/rubocop/server.rb +14 -0
  612. data/lib/rubocop/target_finder.rb +18 -8
  613. data/lib/rubocop/target_ruby.rb +42 -22
  614. data/lib/rubocop/todo_audit.rb +111 -0
  615. data/lib/rubocop/unified_diff.rb +257 -0
  616. data/lib/rubocop/util.rb +69 -0
  617. data/lib/rubocop/version.rb +23 -7
  618. data/lib/rubocop.rb +34 -701
  619. data/lib/ruby_lsp/rubocop/addon.rb +1 -2
  620. metadata +80 -14
  621. data/lib/rubocop/cop/style/double_cop_disable_directive.rb +0 -46
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/**/*'
@@ -69,6 +60,9 @@ AllCops:
69
60
  - '.git/**/*'
70
61
  # Default formatter will be used if no `-f/--format` option is given.
71
62
  DefaultFormatter: progress
63
+ # The lowest severity that makes a run fail. Offenses below it are still
64
+ # reported. Can be overridden by the `--fail-level` command line option.
65
+ FailLevel: refactor
72
66
  # Cop names are displayed in offense messages by default. Change behavior
73
67
  # by overriding DisplayCopNames, or by giving the `--no-display-cop-names`
74
68
  # option.
@@ -113,11 +107,32 @@ AllCops:
113
107
  # When `NewCops` is `disable`, pending cops are disabled in bulk. Can be overridden by
114
108
  # the `--disable-pending-cops` command-line option.
115
109
  NewCops: pending
110
+ # When `true`, RuboCop builds a project index (a project-wide map of declarations and references)
111
+ # once per run and makes it available to cops that opt in.
112
+ # The project index is implemented by the optional `rubydex` gem; when `rubydex` is not installed,
113
+ # a warning is shown and the flag has no effect.
114
+ # The default `false` preserves RuboCop's traditional file-local analysis.
115
+ UseProjectIndex: false
116
+ # When the project index is enabled, also index the sources of the gems in
117
+ # the project's bundle. This lets index-aware cops resolve ancestry chains
118
+ # and members that live in gems (e.g. framework base classes), at the cost
119
+ # of extra memory proportional to the bundle's size. Has no effect when
120
+ # `UseProjectIndex` is `false` or when RuboCop does not run inside Bundler.
121
+ ProjectIndexIncludesGems: false
122
+ # Projects opt in to preview with `Preview: true` here, or with the `--preview`
123
+ # command line option. In this file the key instead holds the `AllCops`
124
+ # settings expected to change in the next major release: they apply under
125
+ # preview and are dropped otherwise, exactly like a cop's `Preview` section.
126
+ Preview:
127
+ # Style offenses are reported but stop failing the build; `Lint` and
128
+ # `Security` offenses still do.
129
+ FailLevel: warning
130
+
116
131
  # Enables the result cache if `true`. Can be overridden by the `--cache` command
117
132
  # line option.
118
133
  UseCache: true
119
134
  # Threshold for how many files can be stored in the result cache before some
120
- # of the files are automatically removed.
135
+ # of the files are automatically removed. Set to false to disable cache pruning.
121
136
  MaxFilesInCache: 20000
122
137
  # The cache will be stored in "rubocop_cache" under this directory. If
123
138
  # CacheRootDirectory is ~ (nil), which it is by default, the root will be
@@ -168,6 +183,7 @@ AllCops:
168
183
  rubocop-capybara: [capybara]
169
184
  rubocop-factory_bot: [factory_bot, factory_bot_rails]
170
185
  rubocop-rspec_rails: [rspec-rails]
186
+ rubocop-i18n: [i18n, gettext]
171
187
  # Enable/Disable checking the methods extended by Active Support.
172
188
  ActiveSupportExtensionsEnabled: false
173
189
  # Future version of Ruby will freeze string literals by default.
@@ -203,12 +219,12 @@ Bundler/GemComment:
203
219
  Description: 'Add a comment describing each gem.'
204
220
  Enabled: false
205
221
  VersionAdded: '0.59'
206
- VersionChanged: '0.85'
222
+ VersionChanged: '1.88'
207
223
  Include:
208
224
  - '**/*.gemfile'
209
225
  - '**/Gemfile'
210
226
  - '**/gems.rb'
211
- IgnoredGems: []
227
+ AllowedGems: []
212
228
  OnlyFor: []
213
229
 
214
230
  Bundler/GemFilename:
@@ -258,6 +274,10 @@ Bundler/OrderedGems:
258
274
  Description: >-
259
275
  Gems within groups in the Gemfile should be alphabetically sorted.
260
276
  Enabled: true
277
+ # Expected to be disabled by default in the next major release.
278
+ # Alphabetical Gemfiles are a preference; grouping gems by purpose is as common.
279
+ Preview:
280
+ Enabled: false
261
281
  VersionAdded: '0.46'
262
282
  VersionChanged: '0.47'
263
283
  TreatCommentsAsGroupSeparators: true
@@ -375,7 +395,7 @@ Gemspec/RubyVersionGlobalsUsage:
375
395
  Include:
376
396
  - '**/*.gemspec'
377
397
 
378
- #################### Layout ###########################
398
+ #################### Layout ################################
379
399
 
380
400
  Layout/AccessModifierIndentation:
381
401
  Description: Checks indentation of private/protected visibility modifiers.
@@ -412,6 +432,10 @@ Layout/ArgumentAlignment:
412
432
  # method_call(a,
413
433
  # b)
414
434
  EnforcedStyle: with_first_argument
435
+ # Expected to become the default in the next major release.
436
+ # Same preference as `ParameterAlignment`.
437
+ Preview:
438
+ EnforcedStyle: with_fixed_indentation
415
439
  SupportedStyles:
416
440
  - with_first_argument
417
441
  - with_fixed_indentation
@@ -423,7 +447,7 @@ Layout/ArrayAlignment:
423
447
  Description: >-
424
448
  Align the elements of an array literal if they span more than
425
449
  one line.
426
- StyleGuide: '#no-double-indent'
450
+ StyleGuide: '#align-multiline-arrays'
427
451
  Enabled: true
428
452
  VersionAdded: '0.49'
429
453
  VersionChanged: '0.77'
@@ -470,6 +494,7 @@ Layout/BeginEndAlignment:
470
494
  SupportedStylesAlignWith:
471
495
  - start_of_line
472
496
  - begin
497
+ # A misaligned `end` usually means a structural mistake, so this reports as a lint would.
473
498
  Severity: warning
474
499
 
475
500
  Layout/BlockAlignment:
@@ -493,12 +518,16 @@ Layout/BlockEndNewline:
493
518
  VersionAdded: '0.49'
494
519
 
495
520
  Layout/CaseIndentation:
496
- Description: 'Indentation of when in a case/(when|in)/[else/]end.'
521
+ Description: 'Checks how the `when` and `in` clauses of a `case` expression are indented.'
497
522
  StyleGuide: '#indent-when-to-case'
498
523
  Enabled: true
499
524
  VersionAdded: '0.49'
500
525
  VersionChanged: '1.16'
501
526
  EnforcedStyle: case
527
+ # Expected to become the default in the next major release.
528
+ # `when` aligned with `end` is the pick of nearly every project that sets this.
529
+ Preview:
530
+ EnforcedStyle: end
502
531
  SupportedStyles:
503
532
  - case
504
533
  - end
@@ -514,7 +543,7 @@ Layout/ClassStructure:
514
543
  Enabled: false
515
544
  SafeAutoCorrect: false
516
545
  VersionAdded: '0.52'
517
- VersionChanged: '1.53'
546
+ VersionChanged: '1.89'
518
547
  Categories:
519
548
  module_inclusion:
520
549
  - include
@@ -527,6 +556,7 @@ Layout/ClassStructure:
527
556
  - initializer
528
557
  - public_methods
529
558
  - protected_methods
559
+ - private_class_methods
530
560
  - private_methods
531
561
 
532
562
  Layout/ClosingHeredocIndentation:
@@ -538,15 +568,22 @@ Layout/ClosingParenthesisIndentation:
538
568
  Description: 'Checks the indentation of hanging closing parentheses.'
539
569
  Enabled: true
540
570
  VersionAdded: '0.49'
571
+ VersionChanged: '1.86'
572
+ # By default the indentation width from `Layout/IndentationWidth` is used,
573
+ # but it can be overridden by setting this parameter.
574
+ IndentationWidth: ~
541
575
 
542
576
  Layout/CommentIndentation:
543
- Description: 'Indentation of comments.'
577
+ Description: 'Checks the indentation of comments.'
544
578
  Enabled: true
579
+ VersionAdded: '0.49'
580
+ VersionChanged: '1.86'
545
581
  # When true, allows comments to have extra indentation if that aligns them
546
582
  # with a comment on the preceding line.
547
583
  AllowForAlignment: false
548
- VersionAdded: '0.49'
549
- VersionChanged: '1.24'
584
+ # By default the indentation width from `Layout/IndentationWidth` is used,
585
+ # but it can be overridden by setting this parameter.
586
+ IndentationWidth: ~
550
587
 
551
588
  Layout/ConditionPosition:
552
589
  Description: >-
@@ -569,6 +606,7 @@ Layout/DefEndAlignment:
569
606
  SupportedStylesAlignWith:
570
607
  - start_of_line
571
608
  - def
609
+ # A misaligned `end` usually means a structural mistake, so this reports as a lint would.
572
610
  Severity: warning
573
611
 
574
612
  Layout/DotPosition:
@@ -598,6 +636,10 @@ Layout/EmptyComment:
598
636
  Layout/EmptyLineAfterGuardClause:
599
637
  Description: 'Add empty line after guard clause.'
600
638
  Enabled: true
639
+ # Expected to be disabled by default in the next major release.
640
+ # Goes with `GuardClause`; a blank line after a guard is a preference.
641
+ Preview:
642
+ Enabled: false
601
643
  VersionAdded: '0.56'
602
644
  VersionChanged: '0.59'
603
645
 
@@ -606,6 +648,12 @@ Layout/EmptyLineAfterMagicComment:
606
648
  StyleGuide: '#separate-magic-comments-from-code'
607
649
  Enabled: true
608
650
  VersionAdded: '0.49'
651
+ VersionChanged: '1.91'
652
+ # The minimum number of empty lines required after the last magic comment. Set this
653
+ # to `2` when using YARD, which otherwise treats the magic comments as documentation
654
+ # for the first module or class in the file. `Layout/EmptyLines` has to be disabled
655
+ # for values greater than `1`.
656
+ NumberOfEmptyLines: 1
609
657
 
610
658
  Layout/EmptyLineAfterMultilineCondition:
611
659
  Description: 'Enforces empty line after multiline condition.'
@@ -742,10 +790,15 @@ Layout/EndAlignment:
742
790
  # The value `start_of_line` means that `end` should be aligned with the start
743
791
  # of the line which the matching keyword appears on.
744
792
  EnforcedStyleAlignWith: keyword
793
+ # Expected to become the default in the next major release.
794
+ # Aligning `end` with the variable is the pick of most projects that set this.
795
+ Preview:
796
+ EnforcedStyleAlignWith: variable
745
797
  SupportedStylesAlignWith:
746
798
  - keyword
747
799
  - variable
748
800
  - start_of_line
801
+ # A misaligned `end` usually means a structural mistake, so this reports as a lint would.
749
802
  Severity: warning
750
803
 
751
804
  Layout/EndOfLine:
@@ -821,6 +874,10 @@ Layout/FirstArrayElementIndentation:
821
874
  # The value `align_brackets` means that the indentation of the first element
822
875
  # shall always be relative to the position of the opening bracket.
823
876
  EnforcedStyle: special_inside_parentheses
877
+ # Expected to become the default in the next major release.
878
+ # Same preference as `FirstHashElementIndentation`.
879
+ Preview:
880
+ EnforcedStyle: consistent
824
881
  SupportedStyles:
825
882
  - special_inside_parentheses
826
883
  - consistent
@@ -835,6 +892,7 @@ Layout/FirstArrayElementLineBreak:
835
892
  multi-line array.
836
893
  Enabled: false
837
894
  VersionAdded: '0.49'
895
+ AllowImplicitArrayLiterals: false
838
896
  AllowMultilineFinalElement: false
839
897
 
840
898
  Layout/FirstHashElementIndentation:
@@ -854,6 +912,10 @@ Layout/FirstHashElementIndentation:
854
912
  # The value `align_braces` means that the indentation of the first key shall
855
913
  # always be relative to the position of the opening brace.
856
914
  EnforcedStyle: special_inside_parentheses
915
+ # Expected to become the default in the next major release.
916
+ # A consistent indent wins over the parentheses-sensitive rule by a wide margin.
917
+ Preview:
918
+ EnforcedStyle: consistent
857
919
  SupportedStyles:
858
920
  - special_inside_parentheses
859
921
  - consistent
@@ -907,9 +969,9 @@ Layout/HashAlignment:
907
969
  Align the elements of a hash literal if they span more than
908
970
  one line.
909
971
  Enabled: true
910
- AllowMultipleStyles: true
911
972
  VersionAdded: '0.49'
912
973
  VersionChanged: '1.16'
974
+ AllowMultipleStyles: true
913
975
  # Alignment of entries using hash rocket as separator. Valid values are:
914
976
  #
915
977
  # key - left alignment of keys
@@ -984,8 +1046,8 @@ Layout/HeredocArgumentClosingParenthesis:
984
1046
  Description: >-
985
1047
  Checks for the placement of the closing parenthesis in a
986
1048
  method call that passes a HEREDOC string as an argument.
987
- Enabled: false
988
1049
  StyleGuide: '#heredoc-argument-closing-parentheses'
1050
+ Enabled: false
989
1051
  VersionAdded: '0.68'
990
1052
 
991
1053
  Layout/HeredocIndentation:
@@ -1037,6 +1099,15 @@ Layout/IndentationWidth:
1037
1099
  VersionAdded: '0.49'
1038
1100
  # Number of spaces for each indentation level.
1039
1101
  Width: 2
1102
+ # Block body indentation for method chain blocks.
1103
+ # The value `start_of_line` means that block bodies are indented
1104
+ # relative to the start of the line where the block starts.
1105
+ # The value `relative_to_receiver` means that block bodies are indented
1106
+ # relative to the method call position in the chain.
1107
+ EnforcedStyleAlignWith: start_of_line
1108
+ SupportedStylesAlignWith:
1109
+ - start_of_line
1110
+ - relative_to_receiver
1040
1111
  AllowedPatterns: []
1041
1112
 
1042
1113
  Layout/InitialIndentation:
@@ -1055,6 +1126,7 @@ Layout/LeadingCommentSpace:
1055
1126
  AllowGemfileRubyComment: false
1056
1127
  AllowRBSInlineAnnotation: false
1057
1128
  AllowSteepAnnotation: false
1129
+ AllowYARDCommentBlockSeparator: false
1058
1130
 
1059
1131
  Layout/LeadingEmptyLines:
1060
1132
  Description: Checks for unnecessary blank lines at the beginning of a file.
@@ -1102,7 +1174,7 @@ Layout/LineLength:
1102
1174
  StyleGuide: '#max-line-length'
1103
1175
  Enabled: true
1104
1176
  VersionAdded: '0.25'
1105
- VersionChanged: '1.69'
1177
+ VersionChanged: '1.82'
1106
1178
  Max: 120
1107
1179
  AllowHeredoc: true
1108
1180
  # To make it possible to copy or click on URIs in the code, we allow lines
@@ -1112,9 +1184,12 @@ Layout/LineLength:
1112
1184
  URISchemes:
1113
1185
  - http
1114
1186
  - https
1115
- # The IgnoreCopDirectives option causes the LineLength rule to ignore cop
1187
+ # The AllowRBSInlineAnnotation option makes LineLength allow RBS::Inline annotations
1188
+ # such as `#: (?date: Date) -> Foo` when calculating line length.
1189
+ AllowRBSInlineAnnotation: false
1190
+ # The AllowCopDirectives option causes the LineLength rule to ignore cop
1116
1191
  # directives like '# rubocop: enable ...' when calculating a line's length.
1117
- IgnoreCopDirectives: true
1192
+ AllowCopDirectives: true
1118
1193
  # The AllowedPatterns option is a list of !ruby/regexp and/or string
1119
1194
  # elements. Strings will be converted to Regexp objects. A line that matches
1120
1195
  # any regular expression listed in this option will be ignored by LineLength.
@@ -1228,6 +1303,10 @@ Layout/MultilineMethodCallIndentation:
1228
1303
  Enabled: true
1229
1304
  VersionAdded: '0.49'
1230
1305
  EnforcedStyle: aligned
1306
+ # Expected to become the default in the next major release.
1307
+ # Indenting continuation lines wins over aligning them by a wide margin.
1308
+ Preview:
1309
+ EnforcedStyle: indented
1231
1310
  SupportedStyles:
1232
1311
  - aligned
1233
1312
  - indented
@@ -1267,6 +1346,10 @@ Layout/MultilineOperationIndentation:
1267
1346
  Enabled: true
1268
1347
  VersionAdded: '0.49'
1269
1348
  EnforcedStyle: aligned
1349
+ # Expected to become the default in the next major release.
1350
+ # Same preference as `MultilineMethodCallIndentation`.
1351
+ Preview:
1352
+ EnforcedStyle: indented
1270
1353
  SupportedStyles:
1271
1354
  - aligned
1272
1355
  - indented
@@ -1296,6 +1379,10 @@ Layout/ParameterAlignment:
1296
1379
  # def method_foo(a,
1297
1380
  # b)
1298
1381
  EnforcedStyle: with_first_parameter
1382
+ # Expected to become the default in the next major release.
1383
+ # A fixed indent wins over aligning with the first parameter.
1384
+ Preview:
1385
+ EnforcedStyle: with_fixed_indentation
1299
1386
  SupportedStyles:
1300
1387
  - with_first_parameter
1301
1388
  - with_fixed_indentation
@@ -1390,6 +1477,7 @@ Layout/SpaceAroundOperators:
1390
1477
  StyleGuide: '#spaces-operators'
1391
1478
  Enabled: true
1392
1479
  VersionAdded: '0.49'
1480
+ VersionChanged: '1.90'
1393
1481
  # When `true`, allows most uses of extra spacing if the intent is to align
1394
1482
  # with an operator on the previous or next line, not counting empty lines
1395
1483
  # or comment lines.
@@ -1409,6 +1497,7 @@ Layout/SpaceBeforeBlockBraces:
1409
1497
  before it.
1410
1498
  Enabled: true
1411
1499
  VersionAdded: '0.49'
1500
+ VersionChanged: '0.52'
1412
1501
  EnforcedStyle: space
1413
1502
  SupportedStyles:
1414
1503
  - space
@@ -1417,7 +1506,6 @@ Layout/SpaceBeforeBlockBraces:
1417
1506
  SupportedStylesForEmptyBraces:
1418
1507
  - space
1419
1508
  - no_space
1420
- VersionChanged: '0.52'
1421
1509
 
1422
1510
  Layout/SpaceBeforeBrackets:
1423
1511
  Description: 'Checks for receiver with a space before the opening brackets.'
@@ -1598,7 +1686,7 @@ Lint/AmbiguousBlockAssociation:
1598
1686
  parentheses.
1599
1687
  Enabled: true
1600
1688
  VersionAdded: '0.48'
1601
- VersionChanged: '1.13'
1689
+ VersionChanged: '1.89'
1602
1690
  AllowedMethods: []
1603
1691
  AllowedPatterns: []
1604
1692
 
@@ -1633,6 +1721,13 @@ Lint/AmbiguousRegexpLiteral:
1633
1721
  VersionAdded: '0.17'
1634
1722
  VersionChanged: '0.83'
1635
1723
 
1724
+ Lint/ArgumentMismatch:
1725
+ Description: >-
1726
+ Checks for calls that pass the wrong number of positional arguments
1727
+ to a method, using the project index.
1728
+ Enabled: pending
1729
+ VersionAdded: '1.90'
1730
+
1636
1731
  Lint/ArrayLiteralInRegexp:
1637
1732
  Description: 'Checks for an array literal interpolated inside a regexp.'
1638
1733
  Enabled: pending
@@ -1692,9 +1787,11 @@ Lint/ConstantReassignment:
1692
1787
  Description: 'Checks for constant reassignments.'
1693
1788
  Enabled: pending
1694
1789
  VersionAdded: '1.70'
1790
+ VersionChanged: '1.87'
1695
1791
 
1696
1792
  Lint/ConstantResolution:
1697
1793
  Description: 'Checks that constants are fully qualified with `::`.'
1794
+ VersionChanged: '1.89'
1698
1795
  Enabled: false
1699
1796
  VersionAdded: '0.86'
1700
1797
  # Restrict this cop to only looking at certain names
@@ -1704,8 +1801,14 @@ Lint/ConstantResolution:
1704
1801
 
1705
1802
  Lint/CopDirectiveSyntax:
1706
1803
  Description: 'Checks that `# rubocop:` directives are strictly formatted.'
1707
- Enabled: pending
1804
+ Enabled: true
1708
1805
  VersionAdded: '1.72'
1806
+ VersionChanged: '1.91'
1807
+
1808
+ Lint/DataDefineOverride:
1809
+ Description: 'Disallow overriding the `Data` built-in methods via `Data.define`.'
1810
+ Enabled: pending
1811
+ VersionAdded: '1.85'
1709
1812
 
1710
1813
  Lint/Debugger:
1711
1814
  Description: 'Checks for debugger calls.'
@@ -1806,8 +1909,17 @@ Lint/DeprecatedOpenSSLConstant:
1806
1909
  Enabled: true
1807
1910
  VersionAdded: '0.84'
1808
1911
 
1912
+ Lint/DeprecatedReference:
1913
+ Description: >-
1914
+ Checks for references to methods and constants documented
1915
+ as deprecated with a YARD `@deprecated` tag.
1916
+ Requires `AllCops/UseProjectIndex` to be enabled.
1917
+ Enabled: pending
1918
+ VersionAdded: '1.89'
1919
+
1809
1920
  Lint/DisjunctiveAssignmentInConstructor:
1810
1921
  Description: 'In constructor, plain assignment is preferred over disjunctive.'
1922
+ StyleGuide: '#disjunctive-assignment-in-constructor'
1811
1923
  Enabled: true
1812
1924
  Safe: false
1813
1925
  VersionAdded: '0.62'
@@ -1852,6 +1964,22 @@ Lint/DuplicateMethods:
1852
1964
  Description: 'Checks for duplicate method definitions.'
1853
1965
  Enabled: true
1854
1966
  VersionAdded: '0.29'
1967
+ VersionChanged: '1.90'
1968
+ # Methods that define instance methods by delegation, in the style of
1969
+ # Active Support's `delegate` (`delegate :foo, :bar, to: :target`). Register
1970
+ # a project's own `delegate`-shaped macros here so the cop recognizes the
1971
+ # methods they define. Only takes effect when `AllCops/ActiveSupportExtensionsEnabled`
1972
+ # is `true`.
1973
+ DelegatingMethods:
1974
+ - delegate
1975
+ # Cross-file duplicates (detected with `AllCops/UseProjectIndex`) whose other
1976
+ # definition lives in a file matching one of these patterns are not reported.
1977
+ # Useful for files that redefine application methods but are never loaded
1978
+ # together with them, such as standalone scripts. Patterns follow the same
1979
+ # glob (or regexp) semantics as `Exclude` and are matched against the other
1980
+ # file's path relative to the directory of the config file; absolute patterns
1981
+ # are matched against the absolute path.
1982
+ AllowedCrossFilePaths: []
1855
1983
 
1856
1984
  Lint/DuplicateRegexpCharacterClassElement:
1857
1985
  Description: 'Checks for duplicate elements in Regexp character classes.'
@@ -1904,9 +2032,9 @@ Lint/EmptyConditionalBody:
1904
2032
  Description: 'Checks for the presence of `if`, `elsif` and `unless` branches without a body.'
1905
2033
  Enabled: true
1906
2034
  AutoCorrect: contextual
1907
- AllowComments: true
1908
2035
  VersionAdded: '0.89'
1909
2036
  VersionChanged: '1.73'
2037
+ AllowComments: true
1910
2038
 
1911
2039
  Lint/EmptyEnsure:
1912
2040
  Description: 'Checks for empty ensure block.'
@@ -1942,9 +2070,9 @@ Lint/EmptyInterpolation:
1942
2070
  Lint/EmptyWhen:
1943
2071
  Description: 'Checks for `when` branches with empty bodies.'
1944
2072
  Enabled: true
1945
- AllowComments: true
1946
2073
  VersionAdded: '0.45'
1947
2074
  VersionChanged: '0.83'
2075
+ AllowComments: true
1948
2076
 
1949
2077
  Lint/EnsureReturn:
1950
2078
  Description: 'Do not use return in an ensure block.'
@@ -1978,7 +2106,7 @@ Lint/FloatOutOfRange:
1978
2106
  VersionAdded: '0.36'
1979
2107
 
1980
2108
  Lint/FormatParameterMismatch:
1981
- Description: 'The number of parameters to format/sprint must match the fields.'
2109
+ Description: 'Checks for a mismatch between the format fields and the arguments to `format`/`sprintf`/`%`.'
1982
2110
  Enabled: true
1983
2111
  VersionAdded: '0.33'
1984
2112
 
@@ -1998,14 +2126,14 @@ Lint/HeredocMethodCallPosition:
1998
2126
  Description: >-
1999
2127
  Checks for the ordering of a method call where
2000
2128
  the receiver of the call is a HEREDOC.
2001
- Enabled: false
2002
2129
  StyleGuide: '#heredoc-method-calls'
2130
+ Enabled: false
2003
2131
  VersionAdded: '0.68'
2004
2132
 
2005
2133
  Lint/IdentityComparison:
2006
2134
  Description: 'Prefer `equal?` over `==` when comparing `object_id`.'
2007
- Enabled: true
2008
2135
  StyleGuide: '#identity-comparison'
2136
+ Enabled: true
2009
2137
  VersionAdded: '0.91'
2010
2138
 
2011
2139
  Lint/ImplicitStringConcatenation:
@@ -2034,7 +2162,7 @@ Lint/InheritException:
2034
2162
  Enabled: true
2035
2163
  SafeAutoCorrect: false
2036
2164
  VersionAdded: '0.41'
2037
- VersionChanged: '1.26'
2165
+ VersionChanged: '1.89'
2038
2166
  # The default base class in favour of `Exception`.
2039
2167
  EnforcedStyle: standard_error
2040
2168
  SupportedStyles:
@@ -2087,10 +2215,18 @@ Lint/Loop:
2087
2215
  VersionChanged: '1.3'
2088
2216
  Safe: false
2089
2217
 
2218
+ Lint/MisplacedMagicComment:
2219
+ Description: 'Checks for magic comments placed where Ruby silently ignores them.'
2220
+ StyleGuide: '#magic-comments-first'
2221
+ Enabled: pending
2222
+ SafeAutoCorrect: false
2223
+ VersionAdded: '1.91'
2224
+
2090
2225
  Lint/MissingCopEnableDirective:
2091
2226
  Description: 'Checks for a `# rubocop:enable` after `# rubocop:disable`.'
2092
2227
  Enabled: true
2093
2228
  VersionAdded: '0.52'
2229
+ VersionChanged: '1.90'
2094
2230
  # Maximum number of consecutive lines the cop can be disabled for.
2095
2231
  # 0 allows only single-line disables
2096
2232
  # 1 would mean the maximum allowed is the following:
@@ -2098,16 +2234,16 @@ Lint/MissingCopEnableDirective:
2098
2234
  # a = 1
2099
2235
  # # rubocop:enable SomeCop
2100
2236
  # .inf for any size
2101
- MaximumRangeSize: .inf
2237
+ MaxRangeSize: .inf
2102
2238
 
2103
2239
  Lint/MissingSuper:
2104
2240
  Description: >-
2105
2241
  Checks for the presence of constructors and lifecycle callbacks
2106
2242
  without calls to `super`.
2107
2243
  Enabled: true
2108
- AllowedParentClasses: []
2109
2244
  VersionAdded: '0.89'
2110
- VersionChanged: '1.4'
2245
+ VersionChanged: '1.89'
2246
+ AllowedParentClasses: []
2111
2247
 
2112
2248
  Lint/MixedCaseRange:
2113
2249
  Description: 'Checks for mixed-case character ranges since they include likely unintended characters.'
@@ -2117,6 +2253,7 @@ Lint/MixedCaseRange:
2117
2253
 
2118
2254
  Lint/MixedRegexpCaptureTypes:
2119
2255
  Description: 'Do not mix named captures and numbered captures in a Regexp literal.'
2256
+ StyleGuide: '#do-not-mix-named-and-numbered-captures'
2120
2257
  Enabled: true
2121
2258
  VersionAdded: '0.85'
2122
2259
 
@@ -2126,6 +2263,16 @@ Lint/MultipleComparison:
2126
2263
  VersionAdded: '0.47'
2127
2264
  VersionChanged: '1.1'
2128
2265
 
2266
+ Lint/NameTypo:
2267
+ Description: >-
2268
+ Checks for probable typos in constant and method names,
2269
+ using the project index.
2270
+ Enabled: pending
2271
+ CheckConstants: true
2272
+ CheckMethods: true
2273
+ AllowedNames: []
2274
+ VersionAdded: '1.89'
2275
+
2129
2276
  Lint/NestedMethodDefinition:
2130
2277
  Description: 'Do not use nested method definitions.'
2131
2278
  StyleGuide: '#no-nested-methods'
@@ -2173,11 +2320,11 @@ Lint/NumberConversion:
2173
2320
  Description: 'Checks unsafe usage of number conversion methods.'
2174
2321
  Enabled: false
2175
2322
  VersionAdded: '0.53'
2176
- VersionChanged: '1.1'
2323
+ VersionChanged: '1.88'
2177
2324
  SafeAutoCorrect: false
2178
2325
  AllowedMethods: []
2179
2326
  AllowedPatterns: []
2180
- IgnoredClasses:
2327
+ AllowedClasses:
2181
2328
  - Time
2182
2329
  - DateTime
2183
2330
 
@@ -2189,7 +2336,9 @@ Lint/NumberedParameterAssignment:
2189
2336
  Lint/NumericOperationWithConstantResult:
2190
2337
  Description: 'Checks for numeric operations with constant results.'
2191
2338
  Enabled: pending
2339
+ SafeAutoCorrect: false
2192
2340
  VersionAdded: '1.69'
2341
+ VersionChanged: '1.88'
2193
2342
 
2194
2343
  Lint/OrAssignmentToConstant:
2195
2344
  Description: 'Checks unintended or-assignment to constant.'
@@ -2202,7 +2351,7 @@ Lint/OrderedMagicComments:
2202
2351
  Enabled: true
2203
2352
  SafeAutoCorrect: false
2204
2353
  VersionAdded: '0.53'
2205
- VersionChanged: '1.37'
2354
+ VersionChanged: '1.91'
2206
2355
 
2207
2356
  Lint/OutOfRangeRegexpRef:
2208
2357
  Description: 'Checks for out of range reference for Regexp because it always returns nil.'
@@ -2261,6 +2410,7 @@ Lint/RedundantCopEnableDirective:
2261
2410
  Description: Checks for rubocop:enable comments that can be removed.
2262
2411
  Enabled: true
2263
2412
  VersionAdded: '0.76'
2413
+ VersionChanged: '1.90'
2264
2414
 
2265
2415
  Lint/RedundantDirGlobSort:
2266
2416
  Description: 'Checks for redundant `sort` method to `Dir.glob` and `Dir[]`.'
@@ -2327,13 +2477,16 @@ Lint/RedundantWithIndex:
2327
2477
  Lint/RedundantWithObject:
2328
2478
  Description: 'Checks for redundant `with_object`.'
2329
2479
  Enabled: true
2480
+ SafeAutoCorrect: false
2330
2481
  VersionAdded: '0.51'
2482
+ VersionChanged: '1.88'
2331
2483
 
2332
2484
  Lint/RefinementImportMethods:
2333
2485
  Description: 'Use `Refinement#import_methods` when using `include` or `prepend` in `refine` block.'
2334
2486
  Enabled: pending
2335
2487
  SafeAutoCorrect: false
2336
2488
  VersionAdded: '1.27'
2489
+ VersionChanged: '1.88'
2337
2490
 
2338
2491
  Lint/RegexpAsCondition:
2339
2492
  Description: >-
@@ -2380,8 +2533,9 @@ Lint/ReturnInVoidContext:
2380
2533
  Lint/SafeNavigationChain:
2381
2534
  Description: 'Do not chain ordinary method call after safe navigation operator.'
2382
2535
  Enabled: true
2536
+ SafeAutoCorrect: false
2383
2537
  VersionAdded: '0.47'
2384
- VersionChanged: '0.77'
2538
+ VersionChanged: '1.89'
2385
2539
  AllowedMethods:
2386
2540
  - present?
2387
2541
  - blank?
@@ -2396,8 +2550,9 @@ Lint/SafeNavigationConsistency:
2396
2550
  consistent and appropriate safe navigation, without excess or deficiency,
2397
2551
  is used for all method calls on the same object.
2398
2552
  Enabled: true
2553
+ SafeAutoCorrect: false
2399
2554
  VersionAdded: '0.55'
2400
- VersionChanged: '0.77'
2555
+ VersionChanged: '1.85'
2401
2556
  AllowedMethods:
2402
2557
  - present?
2403
2558
  - blank?
@@ -2438,6 +2593,7 @@ Lint/ShadowedException:
2438
2593
  Description: >-
2439
2594
  Avoid rescuing a higher level exception
2440
2595
  before a lower level exception.
2596
+ StyleGuide: '#exception-ordering'
2441
2597
  Enabled: true
2442
2598
  VersionAdded: '0.41'
2443
2599
 
@@ -2460,14 +2616,21 @@ Lint/StructNewOverride:
2460
2616
  Enabled: true
2461
2617
  VersionAdded: '0.81'
2462
2618
 
2619
+ Lint/SuperArgumentMismatch:
2620
+ Description: >-
2621
+ Checks for `super` calls that pass the wrong number of positional
2622
+ arguments to the overridden implementation, using the project index.
2623
+ Enabled: pending
2624
+ VersionAdded: '1.90'
2625
+
2463
2626
  Lint/SuppressedException:
2464
2627
  Description: "Don't suppress exceptions."
2465
2628
  StyleGuide: '#dont-hide-exceptions'
2466
2629
  Enabled: true
2467
- AllowComments: true
2468
- AllowNil: true
2469
2630
  VersionAdded: '0.9'
2470
2631
  VersionChanged: '1.12'
2632
+ AllowComments: true
2633
+ AllowNil: true
2471
2634
 
2472
2635
  Lint/SuppressedExceptionInNumberConversion:
2473
2636
  Description: 'Checks for cases where exceptions unrelated to the numeric constructors may be unintentionally swallowed.'
@@ -2550,6 +2713,7 @@ Lint/UnexpectedBlockArity:
2550
2713
 
2551
2714
  Lint/UnifiedInteger:
2552
2715
  Description: 'Use Integer instead of Fixnum or Bignum.'
2716
+ StyleGuide: '#integer-type-checking'
2553
2717
  Enabled: true
2554
2718
  VersionAdded: '0.43'
2555
2719
 
@@ -2560,7 +2724,7 @@ Lint/UnmodifiedReduceAccumulator:
2560
2724
  VersionChanged: '1.5'
2561
2725
 
2562
2726
  Lint/UnreachableCode:
2563
- Description: 'Unreachable code.'
2727
+ Description: 'Checks for unreachable code.'
2564
2728
  Enabled: true
2565
2729
  VersionAdded: '0.9'
2566
2730
 
@@ -2574,6 +2738,11 @@ Lint/UnreachableLoop:
2574
2738
  # eg. `exactly(2).times`
2575
2739
  - !ruby/regexp /(exactly|at_least|at_most)\(\d+\)\.times/
2576
2740
 
2741
+ Lint/UnreachablePatternBranch:
2742
+ Description: 'Checks for unreachable `in` pattern branches after an unconditional catch-all pattern.'
2743
+ Enabled: pending
2744
+ VersionAdded: '1.85'
2745
+
2577
2746
  Lint/UnusedBlockArgument:
2578
2747
  Description: 'Checks for unused block arguments.'
2579
2748
  StyleGuide: '#underscore-unused-vars'
@@ -2597,6 +2766,21 @@ Lint/UnusedMethodArgument:
2597
2766
  NotImplementedExceptions:
2598
2767
  - NotImplementedError
2599
2768
 
2769
+ Lint/UnusedPrivateMethod:
2770
+ Description: >-
2771
+ Checks for private instance methods that are not referenced
2772
+ anywhere in the project. Requires `AllCops/UseProjectIndex`
2773
+ to be enabled.
2774
+ # This cop is disabled by default because symbol-based references from other
2775
+ # files (e.g. Rails callbacks declared in a concern) cannot be detected and
2776
+ # would be reported as false positives. It is intended for occasional
2777
+ # dead-code sweeps rather than permanent enforcement.
2778
+ Enabled: false
2779
+ AllowedNames: []
2780
+ AllowedPatterns: []
2781
+ VersionAdded: '1.89'
2782
+ VersionChanged: '1.90'
2783
+
2600
2784
  Lint/UriEscapeUnescape:
2601
2785
  Description: >-
2602
2786
  `URI.escape` method is obsolete and should not be used. Instead, use
@@ -2634,6 +2818,7 @@ Lint/UselessConstantScoping:
2634
2818
  Description: 'Checks for useless constant scoping.'
2635
2819
  Enabled: pending
2636
2820
  VersionAdded: '1.72'
2821
+ VersionChanged: '1.90'
2637
2822
 
2638
2823
  Lint/UselessDefaultValueArgument:
2639
2824
  Description: 'Checks for usage of `fetch` or `Array.new` with default value argument and block.'
@@ -2669,7 +2854,10 @@ Lint/UselessNumericOperation:
2669
2854
  Lint/UselessOr:
2670
2855
  Description: 'Checks for useless OR expressions.'
2671
2856
  Enabled: pending
2857
+ SafeAutoCorrect: false
2858
+ AutoCorrect: contextual
2672
2859
  VersionAdded: '1.76'
2860
+ VersionChanged: '1.82'
2673
2861
 
2674
2862
  Lint/UselessRescue:
2675
2863
  Description: 'Checks for useless `rescue`s.'
@@ -2697,7 +2885,7 @@ Lint/UselessTimes:
2697
2885
  VersionChanged: '1.61'
2698
2886
 
2699
2887
  Lint/Void:
2700
- Description: 'Possible use of operator/literal/variable in void context.'
2888
+ Description: 'Checks for operators, literals, lambdas, and procs used in void context.'
2701
2889
  Enabled: true
2702
2890
  AutoCorrect: contextual
2703
2891
  VersionAdded: '0.9'
@@ -2707,13 +2895,15 @@ Lint/Void:
2707
2895
  #################### Metrics ###############################
2708
2896
 
2709
2897
  Metrics/AbcSize:
2710
- Description: >-
2711
- A calculated magnitude based on number of assignments,
2712
- branches, and conditions.
2898
+ Description: 'Checks that the ABC size of methods is not higher than the configured maximum.'
2713
2899
  References:
2714
2900
  - https://wiki.c2.com/?AbcMetric
2715
2901
  - https://en.wikipedia.org/wiki/ABC_Software_Metric
2716
2902
  Enabled: true
2903
+ # Expected to be disabled by default in the next major release.
2904
+ # Rejected by more than a third of projects; those that keep it split evenly between 20 and 30.
2905
+ Preview:
2906
+ Enabled: false
2717
2907
  VersionAdded: '0.27'
2718
2908
  VersionChanged: '1.5'
2719
2909
  # The ABC size is a calculated magnitude, so this number can be an Integer or
@@ -2726,6 +2916,10 @@ Metrics/AbcSize:
2726
2916
  Metrics/BlockLength:
2727
2917
  Description: 'Avoid long blocks with many lines.'
2728
2918
  Enabled: true
2919
+ # Expected to be disabled by default in the next major release.
2920
+ # Rejected by nearly a third of projects; the raised limits range from 30 to 300.
2921
+ Preview:
2922
+ Enabled: false
2729
2923
  VersionAdded: '0.44'
2730
2924
  VersionChanged: '1.5'
2731
2925
  CountComments: false # count full line comments?
@@ -2743,6 +2937,10 @@ Metrics/BlockNesting:
2743
2937
  Description: 'Avoid excessive block nesting.'
2744
2938
  StyleGuide: '#three-is-the-number-thou-shalt-count'
2745
2939
  Enabled: true
2940
+ # Expected to be disabled by default in the next major release.
2941
+ # Rejected by a fifth of projects; almost nobody adjusts the limit instead.
2942
+ Preview:
2943
+ Enabled: false
2746
2944
  VersionAdded: '0.25'
2747
2945
  VersionChanged: '1.65'
2748
2946
  CountBlocks: false
@@ -2752,6 +2950,10 @@ Metrics/BlockNesting:
2752
2950
  Metrics/ClassLength:
2753
2951
  Description: 'Avoid classes longer than 100 lines of code.'
2754
2952
  Enabled: true
2953
+ # Expected to be disabled by default in the next major release.
2954
+ # Rejected by a third of projects; those that keep it set the limit three times higher.
2955
+ Preview:
2956
+ Enabled: false
2755
2957
  VersionAdded: '0.25'
2756
2958
  VersionChanged: '0.87'
2757
2959
  CountComments: false # count full line comments?
@@ -2762,14 +2964,17 @@ Metrics/CollectionLiteralLength:
2762
2964
  Description: 'Checks for `Array` or `Hash` literals with many entries.'
2763
2965
  Enabled: pending
2764
2966
  VersionAdded: '1.47'
2765
- LengthThreshold: 250
2967
+ VersionChanged: '1.88'
2968
+ Max: 250
2766
2969
 
2767
2970
  # Avoid complex methods.
2768
2971
  Metrics/CyclomaticComplexity:
2769
- Description: >-
2770
- A complexity metric that is strongly correlated to the number
2771
- of test cases needed to validate a method.
2972
+ Description: 'Checks that the cyclomatic complexity of methods is not higher than the configured maximum.'
2772
2973
  Enabled: true
2974
+ # Expected to be disabled by default in the next major release.
2975
+ # Rejected by a third of projects; those that keep it raise the limit to 10 or more.
2976
+ Preview:
2977
+ Enabled: false
2773
2978
  VersionAdded: '0.25'
2774
2979
  VersionChanged: '0.81'
2775
2980
  AllowedMethods: []
@@ -2780,6 +2985,10 @@ Metrics/MethodLength:
2780
2985
  Description: 'Avoid methods longer than 10 lines of code.'
2781
2986
  StyleGuide: '#short-methods'
2782
2987
  Enabled: true
2988
+ # Expected to be disabled by default in the next major release.
2989
+ # Rejected outright by a third of projects; the ones that keep it disagree on the limit.
2990
+ Preview:
2991
+ Enabled: false
2783
2992
  VersionAdded: '0.25'
2784
2993
  VersionChanged: '1.5'
2785
2994
  CountComments: false # count full line comments?
@@ -2791,6 +3000,10 @@ Metrics/MethodLength:
2791
3000
  Metrics/ModuleLength:
2792
3001
  Description: 'Avoid modules longer than 100 lines of code.'
2793
3002
  Enabled: true
3003
+ # Expected to be disabled by default in the next major release.
3004
+ # Same story as `ClassLength`.
3005
+ Preview:
3006
+ Enabled: false
2794
3007
  VersionAdded: '0.31'
2795
3008
  VersionChanged: '0.87'
2796
3009
  CountComments: false # count full line comments?
@@ -2801,6 +3014,10 @@ Metrics/ParameterLists:
2801
3014
  Description: 'Avoid parameter lists longer than three or four parameters.'
2802
3015
  StyleGuide: '#too-many-params'
2803
3016
  Enabled: true
3017
+ # Expected to be disabled by default in the next major release.
3018
+ # Rejected by a fifth of projects, more than raise the limit.
3019
+ Preview:
3020
+ Enabled: false
2804
3021
  VersionAdded: '0.25'
2805
3022
  VersionChanged: '1.5'
2806
3023
  Max: 5
@@ -2808,30 +3025,31 @@ Metrics/ParameterLists:
2808
3025
  MaxOptionalParameters: 3
2809
3026
 
2810
3027
  Metrics/PerceivedComplexity:
2811
- Description: >-
2812
- A complexity metric geared towards measuring complexity for a
2813
- human reader.
3028
+ Description: 'Checks that the perceived complexity of methods is not higher than the configured maximum.'
2814
3029
  Enabled: true
3030
+ # Expected to be disabled by default in the next major release.
3031
+ # Same story as `CyclomaticComplexity`.
3032
+ Preview:
3033
+ Enabled: false
2815
3034
  VersionAdded: '0.25'
2816
- VersionChanged: '0.81'
3035
+ VersionChanged: '1.88'
2817
3036
  AllowedMethods: []
2818
3037
  AllowedPatterns: []
2819
3038
  Max: 8
2820
3039
 
2821
- ################## Migration #############################
3040
+ #################### Migration #############################
2822
3041
 
2823
3042
  Migration/DepartmentName:
2824
- Description: >-
2825
- Check that cop names in rubocop:disable (etc) comments are
2826
- given with department name.
3043
+ Description: 'Checks that cop names in `rubocop:disable` (etc.) comments are given with a department name.'
2827
3044
  Enabled: true
2828
3045
  VersionAdded: '0.75'
2829
3046
 
2830
- #################### Naming ##############################
3047
+ #################### Naming ################################
2831
3048
 
2832
3049
  Naming/AccessorMethodName:
2833
3050
  Description: Checks the naming of accessor methods for get_/set_.
2834
3051
  StyleGuide: '#accessor_mutator_method_names'
3052
+ VersionChanged: '1.89'
2835
3053
  Enabled: true
2836
3054
  VersionAdded: '0.50'
2837
3055
 
@@ -2844,7 +3062,7 @@ Naming/AsciiIdentifiers:
2844
3062
  AsciiConstants: true
2845
3063
 
2846
3064
  Naming/BinaryOperatorParameterName:
2847
- Description: 'When defining binary operators, name the argument other.'
3065
+ Description: 'Checks that the sole parameter of binary operator methods is named `other`.'
2848
3066
  StyleGuide: '#other-arg'
2849
3067
  Enabled: true
2850
3068
  VersionAdded: '0.50'
@@ -2985,6 +3203,10 @@ Naming/HeredocDelimiterNaming:
2985
3203
  Description: 'Use descriptive heredoc delimiters.'
2986
3204
  StyleGuide: '#heredoc-delimiters'
2987
3205
  Enabled: true
3206
+ # Expected to be disabled by default in the next major release.
3207
+ # Heredoc delimiter names are rarely worth policing.
3208
+ Preview:
3209
+ Enabled: false
2988
3210
  VersionAdded: '0.50'
2989
3211
  ForbiddenDelimiters:
2990
3212
  - !ruby/regexp '/(^|\s)(EO[A-Z]{1}|END)(\s|$)/i'
@@ -3014,7 +3236,10 @@ Naming/InclusiveLanguage:
3014
3236
  - block
3015
3237
  slave:
3016
3238
  WholeWord: true
3017
- Suggestions: ['replica', 'secondary', 'follower']
3239
+ Suggestions:
3240
+ - replica
3241
+ - secondary
3242
+ - follower
3018
3243
 
3019
3244
  Naming/MemoizedInstanceVariableName:
3020
3245
  Description: >-
@@ -3097,14 +3322,15 @@ Naming/PredicateMethod:
3097
3322
  AllowBangMethods: false
3098
3323
  # Methods that are known to not return a boolean value, despite ending in `?`.
3099
3324
  WaywardPredicates:
3325
+ - infinite?
3100
3326
  - nonzero?
3101
3327
 
3102
3328
  Naming/PredicatePrefix:
3103
- Description: 'Predicate method names should not be prefixed and end with a `?`.'
3329
+ Description: 'Checks that predicate method names end with a question mark and do not start with a forbidden prefix.'
3104
3330
  StyleGuide: '#bool-methods-qmark'
3105
3331
  Enabled: true
3106
3332
  VersionAdded: '0.50'
3107
- VersionChanged: '1.75'
3333
+ VersionChanged: '1.89'
3108
3334
  # Predicate name prefixes.
3109
3335
  NamePrefix:
3110
3336
  - is_
@@ -3158,6 +3384,10 @@ Naming/VariableNumber:
3158
3384
  Description: 'Use the configured style when numbering symbols, methods and variables.'
3159
3385
  StyleGuide: '#snake-case-symbols-methods-vars-with-numbers'
3160
3386
  Enabled: true
3387
+ # Expected to be disabled by default in the next major release.
3388
+ # A naming convention few projects want enforced.
3389
+ Preview:
3390
+ Enabled: false
3161
3391
  VersionAdded: '0.50'
3162
3392
  VersionChanged: '1.4'
3163
3393
  EnforcedStyle: normalcase
@@ -3182,14 +3412,14 @@ Naming/VariableNumber:
3182
3412
  #################### Security ##############################
3183
3413
 
3184
3414
  Security/CompoundHash:
3185
- Description: 'When overwriting Object#hash to combine values, prefer delegating to Array#hash over writing a custom implementation.'
3415
+ Description: 'Checks for `hash` implementations that combine values manually instead of delegating to `Array#hash`.'
3186
3416
  Enabled: pending
3187
3417
  Safe: false
3188
3418
  VersionAdded: '1.28'
3189
3419
  VersionChanged: '1.51'
3190
3420
 
3191
3421
  Security/Eval:
3192
- Description: 'The use of eval represents a serious security risk.'
3422
+ Description: 'Checks for the use of `Kernel#eval` and `Binding#eval` with dynamic arguments.'
3193
3423
  Enabled: true
3194
3424
  VersionAdded: '0.47'
3195
3425
 
@@ -3225,7 +3455,7 @@ Security/MarshalLoad:
3225
3455
  VersionAdded: '0.47'
3226
3456
 
3227
3457
  Security/Open:
3228
- Description: 'The use of `Kernel#open` and `URI.open` represent a serious security risk.'
3458
+ Description: 'Checks for the use of `Kernel#open` and `URI.open` with dynamic data.'
3229
3459
  Enabled: true
3230
3460
  VersionAdded: '0.53'
3231
3461
  VersionChanged: '1.0'
@@ -3241,7 +3471,7 @@ Security/YAMLLoad:
3241
3471
  VersionAdded: '0.47'
3242
3472
  SafeAutoCorrect: false
3243
3473
 
3244
- #################### Style ###############################
3474
+ #################### Style #################################
3245
3475
 
3246
3476
  Style/AccessModifierDeclarations:
3247
3477
  Description: 'Checks style of how access modifiers are used.'
@@ -3275,13 +3505,17 @@ Style/Alias:
3275
3505
  VersionAdded: '0.9'
3276
3506
  VersionChanged: '0.36'
3277
3507
  EnforcedStyle: prefer_alias
3508
+ # Expected to become the default in the next major release.
3509
+ # `alias_method` is the pick of most projects that set this.
3510
+ Preview:
3511
+ EnforcedStyle: prefer_alias_method
3278
3512
  SupportedStyles:
3279
3513
  - prefer_alias
3280
3514
  - prefer_alias_method
3281
3515
 
3282
3516
  Style/AmbiguousEndlessMethodDefinition:
3283
3517
  Description: 'Checks for endless methods inside operators of lower precedence.'
3284
- StyleGuide: '#ambiguous-endless-method-defintions'
3518
+ StyleGuide: '#ambiguous-endless-method-definitions'
3285
3519
  Enabled: pending
3286
3520
  VersionAdded: '1.68'
3287
3521
 
@@ -3303,6 +3537,8 @@ Style/ArgumentsForwarding:
3303
3537
  Description: 'Use arguments forwarding.'
3304
3538
  StyleGuide: '#arguments-forwarding'
3305
3539
  Enabled: pending
3540
+ VersionAdded: '1.1'
3541
+ VersionChanged: '1.58'
3306
3542
  AllowOnlyRestArgument: true
3307
3543
  UseAnonymousForwarding: true
3308
3544
  RedundantRestArgumentNames:
@@ -3316,8 +3552,6 @@ Style/ArgumentsForwarding:
3316
3552
  - blk
3317
3553
  - block
3318
3554
  - proc
3319
- VersionAdded: '1.1'
3320
- VersionChanged: '1.58'
3321
3555
 
3322
3556
  Style/ArrayCoercion:
3323
3557
  Description: >-
@@ -3330,6 +3564,7 @@ Style/ArrayCoercion:
3330
3564
 
3331
3565
  Style/ArrayFirstLast:
3332
3566
  Description: 'Use `arr.first` and `arr.last` instead of `arr[0]` and `arr[-1]`.'
3567
+ StyleGuide: '#first-and-last'
3333
3568
  References:
3334
3569
  - '#first-and-last'
3335
3570
  Enabled: false
@@ -3420,6 +3655,10 @@ Style/BlockDelimiters:
3420
3655
  Prefer {...} over do...end for single-line blocks.
3421
3656
  StyleGuide: '#single-line-blocks'
3422
3657
  Enabled: true
3658
+ # Expected to be disabled by default in the next major release.
3659
+ # Brace-versus-`do` rules by line count are widely overridden or switched off.
3660
+ Preview:
3661
+ Enabled: false
3423
3662
  VersionAdded: '0.30'
3424
3663
  VersionChanged: '0.35'
3425
3664
  EnforcedStyle: line_count_based
@@ -3525,9 +3764,11 @@ Style/BlockDelimiters:
3525
3764
  BracesRequiredMethods: []
3526
3765
 
3527
3766
  Style/CaseEquality:
3528
- Description: 'Avoid explicit use of the case equality operator(===).'
3767
+ Description: 'Avoid explicit use of the case equality operator (`===`).'
3529
3768
  StyleGuide: '#no-case-equality'
3530
3769
  Enabled: true
3770
+ References:
3771
+ - 'https://docs.rubocop.org/rubocop-performance/cops_performance.html#performanceregexpmatch'
3531
3772
  VersionAdded: '0.9'
3532
3773
  VersionChanged: '0.89'
3533
3774
  # If `AllowOnConstant` option is enabled, the cop will ignore violations when the receiver of
@@ -3570,13 +3811,18 @@ Style/ClassAndModuleChildren:
3570
3811
  StyleGuide: '#namespace-definition'
3571
3812
  # Moving from compact to nested children requires knowledge of whether the
3572
3813
  # outer parent is a module or a class. Moving from nested to compact requires
3573
- # verification that the outer parent is defined elsewhere. RuboCop does not
3574
- # have the knowledge to perform either operation safely and thus requires
3575
- # manual oversight.
3814
+ # verification that the outer parent is defined elsewhere. By default RuboCop
3815
+ # does not have the knowledge to perform either operation safely and thus
3816
+ # requires manual oversight. When `AllCops/UseProjectIndex` is enabled, the
3817
+ # project-wide index is consulted for both operations.
3576
3818
  SafeAutoCorrect: false
3577
3819
  Enabled: true
3820
+ # Expected to be disabled by default in the next major release.
3821
+ # Fights Rails autoloading conventions, and the autocorrect is unsafe.
3822
+ Preview:
3823
+ Enabled: false
3578
3824
  VersionAdded: '0.19'
3579
- VersionChanged: '1.74'
3825
+ VersionChanged: '1.89'
3580
3826
  #
3581
3827
  # Basically there are two different styles:
3582
3828
  #
@@ -3666,7 +3912,7 @@ Style/CollectionCompact:
3666
3912
 
3667
3913
  # Align with the style guide.
3668
3914
  Style/CollectionMethods:
3669
- Description: 'Preferred collection methods.'
3915
+ Description: 'Enforces the use of consistent method names from the `Enumerable` module.'
3670
3916
  StyleGuide: '#map-find-select-reduce-include-size'
3671
3917
  Enabled: false
3672
3918
  VersionAdded: '0.9'
@@ -3697,6 +3943,7 @@ Style/CollectionQuerying:
3697
3943
  StyleGuide: '#collection-querying'
3698
3944
  Enabled: pending
3699
3945
  VersionAdded: '1.77'
3946
+ VersionChanged: '1.92'
3700
3947
  Safe: false
3701
3948
 
3702
3949
  Style/ColonMethodCall:
@@ -3768,11 +4015,11 @@ Style/CommentedKeyword:
3768
4015
 
3769
4016
  Style/ComparableBetween:
3770
4017
  Description: 'Enforces the use of `Comparable#between?` instead of logical comparison.'
4018
+ StyleGuide: '#ranges-or-between'
3771
4019
  Enabled: pending
3772
4020
  Safe: false
3773
4021
  VersionAdded: '1.74'
3774
4022
  VersionChanged: '1.75'
3775
- StyleGuide: '#ranges-or-between'
3776
4023
 
3777
4024
  Style/ComparableClamp:
3778
4025
  Description: 'Enforces the use of `Comparable#clamp` instead of comparison by minimum and maximum.'
@@ -3790,6 +4037,7 @@ Style/ConditionalAssignment:
3790
4037
  Use the return value of `if` and `case` statements for
3791
4038
  assignment to a variable and variable comparison instead
3792
4039
  of assigning that variable inside of each branch.
4040
+ StyleGuide: '#use-if-case-returns'
3793
4041
  Enabled: true
3794
4042
  VersionAdded: '0.36'
3795
4043
  VersionChanged: '0.47'
@@ -3850,7 +4098,7 @@ Style/DataInheritance:
3850
4098
 
3851
4099
  Style/DateTime:
3852
4100
  Description: 'Use Time over DateTime.'
3853
- StyleGuide: '#date-time'
4101
+ StyleGuide: '#no-datetime'
3854
4102
  Enabled: false
3855
4103
  VersionAdded: '0.51'
3856
4104
  VersionChanged: '0.92'
@@ -3883,13 +4131,33 @@ Style/DirEmpty:
3883
4131
  Enabled: pending
3884
4132
  VersionAdded: '1.48'
3885
4133
 
4134
+ Style/DirectiveScope:
4135
+ Description: >-
4136
+ Checks for directive scopes that can be expressed with the
4137
+ tighter `disable-next` form.
4138
+ Enabled: pending
4139
+ SafeAutoCorrect: false
4140
+ VersionAdded: '1.90'
4141
+ VersionChanged: '1.91'
4142
+
3886
4143
  Style/DisableCopsWithinSourceCodeDirective:
3887
4144
  Description: >-
3888
4145
  Forbids disabling/enabling cops within source code.
3889
4146
  Enabled: false
3890
4147
  VersionAdded: '0.82'
3891
- VersionChanged: '1.9'
4148
+ VersionChanged: '1.92'
4149
+ # Cop or department names. A directive is exempt only when everything it
4150
+ # disables is listed here.
3892
4151
  AllowedCops: []
4152
+ # Cop or department names. When set, only directives touching these are
4153
+ # flagged.
4154
+ DisallowedCops: []
4155
+ # Permit a directive that carries a `-- reason` justification, instead of
4156
+ # forbidding directives outright.
4157
+ AllowWithReason: false
4158
+ # Directive forms this cop ignores entirely. One or more of `disable`,
4159
+ # `todo`, `disable-next`, `todo-next`, `push`, `next`.
4160
+ AllowedDirectives: []
3893
4161
 
3894
4162
  Style/DocumentDynamicEvalDefinition:
3895
4163
  Description: >-
@@ -3903,7 +4171,12 @@ Style/DocumentDynamicEvalDefinition:
3903
4171
  Style/Documentation:
3904
4172
  Description: 'Document classes and non-namespace modules.'
3905
4173
  Enabled: true
4174
+ # Turned off by over half of the projects that configure RuboCop at all, so it
4175
+ # is expected to be disabled by default in the next major release.
4176
+ Preview:
4177
+ Enabled: false
3906
4178
  VersionAdded: '0.9'
4179
+ VersionChanged: '1.89'
3907
4180
  AllowedConstants: []
3908
4181
  Exclude:
3909
4182
  - 'spec/**/*'
@@ -3919,15 +4192,14 @@ Style/DocumentationMethod:
3919
4192
  - 'test/**/*'
3920
4193
  RequireForNonPublicMethods: false
3921
4194
 
3922
- Style/DoubleCopDisableDirective:
3923
- Description: 'Checks for double rubocop:disable comments on a single line.'
3924
- Enabled: true
3925
- VersionAdded: '0.73'
3926
-
3927
4195
  Style/DoubleNegation:
3928
4196
  Description: 'Checks for uses of double negation (!!).'
3929
4197
  StyleGuide: '#no-bang-bang'
3930
4198
  Enabled: true
4199
+ # Expected to be disabled by default in the next major release.
4200
+ # `!!` is the idiomatic boolean coercion.
4201
+ Preview:
4202
+ Enabled: false
3931
4203
  VersionAdded: '0.19'
3932
4204
  VersionChanged: '1.2'
3933
4205
  EnforcedStyle: allowed_in_returns
@@ -3959,6 +4231,19 @@ Style/EmptyCaseCondition:
3959
4231
  Enabled: true
3960
4232
  VersionAdded: '0.40'
3961
4233
 
4234
+ Style/EmptyClassDefinition:
4235
+ Description: 'Enforces consistent style for empty class definitions.'
4236
+ StyleGuide: '#single-line-classes'
4237
+ Enabled: pending
4238
+ VersionAdded: '1.84'
4239
+ VersionChanged: '1.86'
4240
+ EnforcedStyle: class_keyword
4241
+ SupportedStyles:
4242
+ - class_keyword
4243
+ - class_new
4244
+ - class_definition # Deprecated.
4245
+ AllowedParentClasses: []
4246
+
3962
4247
  Style/EmptyElse:
3963
4248
  Description: 'Avoid empty else-clauses.'
3964
4249
  Enabled: true
@@ -4002,6 +4287,10 @@ Style/EmptyMethod:
4002
4287
  VersionAdded: '0.46'
4003
4288
  VersionChanged: '1.61'
4004
4289
  EnforcedStyle: compact
4290
+ # Expected to become the default in the next major release.
4291
+ # Expanded empty methods are the pick of nearly every project that sets this.
4292
+ Preview:
4293
+ EnforcedStyle: expanded
4005
4294
  SupportedStyles:
4006
4295
  - compact
4007
4296
  - expanded
@@ -4081,7 +4370,7 @@ Style/ExplicitBlockArgument:
4081
4370
  VersionChanged: '1.8'
4082
4371
 
4083
4372
  Style/ExponentialNotation:
4084
- Description: 'When using exponential notation, favor a mantissa between 1 (inclusive) and 10 (exclusive).'
4373
+ Description: 'Enforces consistency in the use of exponential (scientific) notation.'
4085
4374
  StyleGuide: '#exponential-notation'
4086
4375
  Enabled: true
4087
4376
  VersionAdded: '0.82'
@@ -4098,8 +4387,9 @@ Style/FetchEnvVar:
4098
4387
  - https://rubystyle.guide/#hash-fetch-defaults
4099
4388
  Enabled: pending
4100
4389
  VersionAdded: '1.28'
4390
+ VersionChanged: '1.88'
4101
4391
  # Environment variables to be excluded from the inspection.
4102
- AllowedVars: []
4392
+ AllowedVariables: []
4103
4393
  # When `true`, autocorrects `ENV["key"]` to `ENV.fetch("key", nil)`.
4104
4394
  # When `false`, autocorrects `ENV["key"]` to `ENV.fetch("key")`.
4105
4395
  DefaultToNil: true
@@ -4113,10 +4403,18 @@ Style/FileEmpty:
4113
4403
 
4114
4404
  Style/FileNull:
4115
4405
  Description: 'Use `File::NULL` instead of hardcoding "dev/null".'
4406
+ StyleGuide: '#null-devices'
4116
4407
  Enabled: pending
4117
4408
  SafeAutoCorrect: false
4118
4409
  VersionAdded: '1.69'
4119
4410
 
4411
+ Style/FileOpen:
4412
+ Description: 'Checks for `File.open` without a block, which can leak file descriptors.'
4413
+ StyleGuide: '#auto-release-resources'
4414
+ Enabled: pending
4415
+ Safe: false
4416
+ VersionAdded: '1.85'
4417
+
4120
4418
  Style/FileRead:
4121
4419
  Description: 'Favor `File.(bin)read` convenience methods.'
4122
4420
  StyleGuide: '#file-read'
@@ -4167,6 +4465,10 @@ Style/FormatString:
4167
4465
  Description: 'Enforce the use of Kernel#sprintf, Kernel#format or String#%.'
4168
4466
  StyleGuide: '#sprintf'
4169
4467
  Enabled: true
4468
+ # Expected to be disabled by default in the next major release.
4469
+ # A pure preference between `format`, `sprintf` and `%`.
4470
+ Preview:
4471
+ Enabled: false
4170
4472
  VersionAdded: '0.19'
4171
4473
  VersionChanged: '0.49'
4172
4474
  EnforcedStyle: format
@@ -4177,7 +4479,14 @@ Style/FormatString:
4177
4479
 
4178
4480
  Style/FormatStringToken:
4179
4481
  Description: 'Use a consistent style for format string tokens.'
4482
+ StyleGuide: '#named-format-tokens'
4180
4483
  Enabled: true
4484
+ # Expected to be disabled by default in the next major release.
4485
+ # Most real format strings use `%s`, which is what the cop flags.
4486
+ Preview:
4487
+ Enabled: false
4488
+ VersionAdded: '0.49'
4489
+ VersionChanged: '1.74'
4181
4490
  EnforcedStyle: annotated
4182
4491
  SupportedStyles:
4183
4492
  # Prefer tokens which contain a sprintf like type annotation like
@@ -4196,8 +4505,6 @@ Style/FormatStringToken:
4196
4505
  # only register offenses for strings given to `printf`, `sprintf`,
4197
4506
  # format` and `%` methods. Other strings are not considered.
4198
4507
  Mode: aggressive
4199
- VersionAdded: '0.49'
4200
- VersionChanged: '1.74'
4201
4508
  AllowedMethods: []
4202
4509
  AllowedPatterns: []
4203
4510
 
@@ -4206,6 +4513,10 @@ Style/FrozenStringLiteralComment:
4206
4513
  Add the frozen_string_literal comment to the top of files
4207
4514
  to help transition to frozen string literals by default.
4208
4515
  Enabled: true
4516
+ # Expected to be disabled by default in the next major release.
4517
+ # Ruby is moving towards frozen string literals by default.
4518
+ Preview:
4519
+ Enabled: false
4209
4520
  VersionAdded: '0.36'
4210
4521
  VersionChanged: '0.79'
4211
4522
  EnforcedStyle: always
@@ -4247,6 +4558,10 @@ Style/GuardClause:
4247
4558
  Description: 'Checks for conditionals that can be replaced with guard clauses.'
4248
4559
  StyleGuide: '#no-nested-conditionals'
4249
4560
  Enabled: true
4561
+ # Expected to be disabled by default in the next major release.
4562
+ # Same objection as `IfUnlessModifier`, and among the most inline-suppressed cops.
4563
+ Preview:
4564
+ Enabled: false
4250
4565
  VersionAdded: '0.20'
4251
4566
  VersionChanged: '1.31'
4252
4567
  # `MinBodyLength` defines the number of lines of the a body of an `if` or `unless`
@@ -4310,6 +4625,16 @@ Style/HashLikeCase:
4310
4625
  # to trigger this cop
4311
4626
  MinBranchesCount: 3
4312
4627
 
4628
+ Style/HashLookupMethod:
4629
+ Description: 'Enforces the use of either `Hash#[]` or `Hash#fetch` for hash lookup.'
4630
+ Enabled: false
4631
+ Safe: false
4632
+ VersionAdded: '1.84'
4633
+ EnforcedStyle: brackets
4634
+ SupportedStyles:
4635
+ - brackets
4636
+ - fetch
4637
+
4313
4638
  Style/HashSlice:
4314
4639
  Description: >-
4315
4640
  Checks for usages of `Hash#reject`, `Hash#select`, and `Hash#filter` methods
@@ -4356,6 +4681,7 @@ Style/HashSyntax:
4356
4681
 
4357
4682
  Style/HashTransformKeys:
4358
4683
  Description: 'Prefer `transform_keys` over `each_with_object`, `map`, or `to_h`.'
4684
+ StyleGuide: '#hash-transform-methods'
4359
4685
  Enabled: true
4360
4686
  VersionAdded: '0.80'
4361
4687
  VersionChanged: '0.90'
@@ -4363,6 +4689,7 @@ Style/HashTransformKeys:
4363
4689
 
4364
4690
  Style/HashTransformValues:
4365
4691
  Description: 'Prefer `transform_values` over `each_with_object`, `map`, or `to_h`.'
4692
+ StyleGuide: '#hash-transform-methods'
4366
4693
  Enabled: true
4367
4694
  VersionAdded: '0.80'
4368
4695
  VersionChanged: '0.90'
@@ -4381,9 +4708,9 @@ Style/IdenticalConditionalBranches:
4381
4708
  Style/IfInsideElse:
4382
4709
  Description: 'Finds if nodes inside else, which can be converted to elsif.'
4383
4710
  Enabled: true
4384
- AllowIfModifier: false
4385
4711
  VersionAdded: '0.36'
4386
4712
  VersionChanged: '1.3'
4713
+ AllowIfModifier: false
4387
4714
 
4388
4715
  Style/IfUnlessModifier:
4389
4716
  Description: >-
@@ -4391,6 +4718,10 @@ Style/IfUnlessModifier:
4391
4718
  single-line body.
4392
4719
  StyleGuide: '#if-as-a-modifier'
4393
4720
  Enabled: true
4721
+ # Expected to be disabled by default in the next major release.
4722
+ # Forces a shape on control flow that a quarter of configured projects switch off.
4723
+ Preview:
4724
+ Enabled: false
4394
4725
  VersionAdded: '0.9'
4395
4726
  VersionChanged: '0.30'
4396
4727
 
@@ -4407,6 +4738,7 @@ Style/IfWithBooleanLiteralBranches:
4407
4738
  VersionAdded: '1.9'
4408
4739
  SafeAutoCorrect: false
4409
4740
  AllowedMethods:
4741
+ - infinite?
4410
4742
  - nonzero?
4411
4743
 
4412
4744
  Style/IfWithSemicolon:
@@ -4513,14 +4845,14 @@ Style/ItAssignment:
4513
4845
  Style/ItBlockParameter:
4514
4846
  Description: 'Checks for blocks with one argument where `it` block parameter can be used.'
4515
4847
  Enabled: pending
4848
+ VersionAdded: '1.75'
4849
+ VersionChanged: '1.76'
4516
4850
  EnforcedStyle: allow_single_line
4517
4851
  SupportedStyles:
4518
4852
  - allow_single_line
4519
4853
  - only_numbered_parameters
4520
4854
  - always
4521
4855
  - disallow
4522
- VersionAdded: '1.75'
4523
- VersionChanged: '1.76'
4524
4856
 
4525
4857
  Style/KeywordArgumentsMerging:
4526
4858
  Description: >-
@@ -4532,7 +4864,7 @@ Style/KeywordArgumentsMerging:
4532
4864
 
4533
4865
  Style/KeywordParametersOrder:
4534
4866
  Description: 'Enforces that optional keyword parameters are placed at the end of the parameters list.'
4535
- StyleGuide: '#keyword-parameters-order'
4867
+ StyleGuide: '#keyword-arguments-order'
4536
4868
  Enabled: true
4537
4869
  VersionAdded: '0.90'
4538
4870
  VersionChanged: '1.7'
@@ -4541,6 +4873,10 @@ Style/Lambda:
4541
4873
  Description: 'Use the new lambda literal syntax for single-line blocks.'
4542
4874
  StyleGuide: '#lambda-multi-line'
4543
4875
  Enabled: true
4876
+ # Expected to be disabled by default in the next major release.
4877
+ # A pure preference between `->` and `lambda`.
4878
+ Preview:
4879
+ Enabled: false
4544
4880
  VersionAdded: '0.9'
4545
4881
  VersionChanged: '0.40'
4546
4882
  EnforcedStyle: line_count_dependent
@@ -4565,6 +4901,7 @@ Style/LineEndConcatenation:
4565
4901
  Description: >-
4566
4902
  Use \ instead of + or << to concatenate two string literals at
4567
4903
  line end.
4904
+ StyleGuide: '#heredoc-long-strings'
4568
4905
  Enabled: true
4569
4906
  SafeAutoCorrect: false
4570
4907
  VersionAdded: '0.18'
@@ -4574,6 +4911,7 @@ Style/MagicCommentFormat:
4574
4911
  Description: 'Use a consistent style for magic comments.'
4575
4912
  Enabled: pending
4576
4913
  VersionAdded: '1.35'
4914
+ VersionChanged: '1.91'
4577
4915
  EnforcedStyle: snake_case
4578
4916
  SupportedStyles:
4579
4917
  # `snake` will enforce the magic comment is written
@@ -4593,7 +4931,9 @@ Style/MagicCommentFormat:
4593
4931
  Style/MapCompactWithConditionalBlock:
4594
4932
  Description: 'Prefer `select` or `reject` over `map { ... }.compact`.'
4595
4933
  Enabled: pending
4934
+ SafeAutoCorrect: false
4596
4935
  VersionAdded: '1.30'
4936
+ VersionChanged: '1.88'
4597
4937
 
4598
4938
  Style/MapIntoArray:
4599
4939
  Description: 'Checks for usages of `each` with `<<`, `push`, or `append` which can be replaced by `map`.'
@@ -4603,6 +4943,12 @@ Style/MapIntoArray:
4603
4943
  VersionChanged: '1.67'
4604
4944
  Safe: false
4605
4945
 
4946
+ Style/MapJoin:
4947
+ Description: 'Checks for redundant `map(&:to_s)` before `join`.'
4948
+ Enabled: pending
4949
+ Safe: false
4950
+ VersionAdded: '1.85'
4951
+
4606
4952
  Style/MapToHash:
4607
4953
  Description: 'Prefer `to_h` with a block over `map.to_h`.'
4608
4954
  Enabled: pending
@@ -4625,6 +4971,7 @@ Style/MethodCallWithArgsParentheses:
4625
4971
  AllowedMethods: []
4626
4972
  AllowedPatterns: []
4627
4973
  IncludedMacros: []
4974
+ IncludedMacroPatterns: []
4628
4975
  AllowParenthesesInMultilineCall: false
4629
4976
  AllowParenthesesInChaining: false
4630
4977
  AllowParenthesesInCamelCaseMethod: false
@@ -4638,10 +4985,10 @@ Style/MethodCallWithoutArgsParentheses:
4638
4985
  Description: 'Do not use parentheses for method calls with no arguments.'
4639
4986
  StyleGuide: '#method-invocation-parens'
4640
4987
  Enabled: true
4641
- AllowedMethods: []
4642
- AllowedPatterns: []
4643
4988
  VersionAdded: '0.47'
4644
4989
  VersionChanged: '0.55'
4990
+ AllowedMethods: []
4991
+ AllowedPatterns: []
4645
4992
 
4646
4993
  Style/MethodCalledOnDoEndBlock:
4647
4994
  Description: 'Avoid chaining a method call on a do...end block.'
@@ -4702,6 +5049,7 @@ Style/MissingRespondToMissing:
4702
5049
  StyleGuide: '#no-method-missing'
4703
5050
  Enabled: true
4704
5051
  VersionAdded: '0.56'
5052
+ VersionChanged: '1.89'
4705
5053
 
4706
5054
  Style/MixinGrouping:
4707
5055
  Description: 'Checks for grouping of mixins in `class` and `module` bodies.'
@@ -4725,6 +5073,10 @@ Style/ModuleFunction:
4725
5073
  Description: 'Checks for usage of `extend self` in modules.'
4726
5074
  StyleGuide: '#module-function'
4727
5075
  Enabled: true
5076
+ # Expected to be disabled by default in the next major release.
5077
+ # `module_function` versus `extend self` is a preference, and the autocorrect is unsafe.
5078
+ Preview:
5079
+ Enabled: false
4728
5080
  VersionAdded: '0.11'
4729
5081
  VersionChanged: '0.65'
4730
5082
  EnforcedStyle: module_function
@@ -4735,6 +5087,11 @@ Style/ModuleFunction:
4735
5087
  Autocorrect: false
4736
5088
  SafeAutoCorrect: false
4737
5089
 
5090
+ Style/ModuleMemberExistenceCheck:
5091
+ Description: 'Checks for usage of `Module` methods returning arrays that can be replaced with equivalent predicates.'
5092
+ Enabled: pending
5093
+ VersionAdded: '1.82'
5094
+
4738
5095
  Style/MultilineBlockChain:
4739
5096
  Description: 'Avoid multi-line chains of blocks.'
4740
5097
  StyleGuide: '#single-line-blocks'
@@ -4742,7 +5099,7 @@ Style/MultilineBlockChain:
4742
5099
  VersionAdded: '0.13'
4743
5100
 
4744
5101
  Style/MultilineIfModifier:
4745
- Description: 'Only use if/unless modifiers on single line statements.'
5102
+ Description: 'Checks for uses of `if`/`unless` modifiers with multiline bodies.'
4746
5103
  StyleGuide: '#no-multiline-if-modifiers'
4747
5104
  Enabled: true
4748
5105
  VersionAdded: '0.45'
@@ -4805,7 +5162,7 @@ Style/MutableConstant:
4805
5162
  Description: 'Do not assign mutable objects to constants.'
4806
5163
  Enabled: true
4807
5164
  VersionAdded: '0.34'
4808
- VersionChanged: '1.8'
5165
+ VersionChanged: '1.88'
4809
5166
  SafeAutoCorrect: false
4810
5167
  EnforcedStyle: literals
4811
5168
  SupportedStyles:
@@ -4817,6 +5174,9 @@ Style/MutableConstant:
4817
5174
  # no harm in freezing an already frozen object.
4818
5175
  - literals
4819
5176
  - strict
5177
+ # When `true`, recursively check and freeze mutable literals nested inside
5178
+ # arrays and hashes (e.g. `[{a: []}]` becomes `[{a: [].freeze}.freeze].freeze`).
5179
+ Recursive: false
4820
5180
 
4821
5181
  Style/NegatedIf:
4822
5182
  Description: >-
@@ -4824,6 +5184,10 @@ Style/NegatedIf:
4824
5184
  (or control flow or).
4825
5185
  StyleGuide: '#unless-for-negatives'
4826
5186
  Enabled: true
5187
+ # Expected to be disabled by default in the next major release.
5188
+ # `if !x` versus `unless x` is a preference, and `unless` is contested on its own.
5189
+ Preview:
5190
+ Enabled: false
4827
5191
  VersionAdded: '0.20'
4828
5192
  VersionChanged: '0.48'
4829
5193
  EnforcedStyle: both
@@ -4844,7 +5208,7 @@ Style/NegatedIfElseCondition:
4844
5208
 
4845
5209
  Style/NegatedUnless:
4846
5210
  Description: 'Favor if over unless for negative conditions.'
4847
- StyleGuide: '#if-for-negatives'
5211
+ StyleGuide: '#unless-for-negatives'
4848
5212
  Enabled: true
4849
5213
  VersionAdded: '0.69'
4850
5214
  EnforcedStyle: both
@@ -4862,6 +5226,16 @@ Style/NegatedWhile:
4862
5226
  Enabled: true
4863
5227
  VersionAdded: '0.20'
4864
5228
 
5229
+ Style/NegativeArrayIndex:
5230
+ Description: >-
5231
+ Use negative array indices instead of calculating array length minus a value.
5232
+ Also handles range patterns with length calculations. Recognizes preserving methods
5233
+ and their combinations, allowing safe replacement when the receiver matches.
5234
+ Enabled: pending
5235
+ Safe: false
5236
+ VersionAdded: '1.84'
5237
+ VersionChanged: '1.92'
5238
+
4865
5239
  Style/NestedFileDirname:
4866
5240
  Description: 'Checks for nested `File.dirname`.'
4867
5241
  Enabled: pending
@@ -4910,6 +5284,10 @@ Style/Next:
4910
5284
  Description: 'Use `next` to skip iteration instead of a condition at the end.'
4911
5285
  StyleGuide: '#no-nested-conditionals'
4912
5286
  Enabled: true
5287
+ # Expected to be disabled by default in the next major release.
5288
+ # Same objection as `IfUnlessModifier`: it forces a shape on loop bodies.
5289
+ Preview:
5290
+ Enabled: false
4913
5291
  VersionAdded: '0.22'
4914
5292
  VersionChanged: '1.75'
4915
5293
  # With `always` all conditions at the end of an iteration needs to be
@@ -4993,6 +5371,10 @@ Style/NumericLiterals:
4993
5371
  readability.
4994
5372
  StyleGuide: '#underscores-in-numerics'
4995
5373
  Enabled: true
5374
+ # Expected to be disabled by default in the next major release.
5375
+ # Underscores in long numbers are a preference, and generated tables trip it constantly.
5376
+ Preview:
5377
+ Enabled: false
4996
5378
  VersionAdded: '0.9'
4997
5379
  VersionChanged: '0.48'
4998
5380
  MinDigits: 5
@@ -5011,6 +5393,10 @@ Style/NumericPredicate:
5011
5393
  # of the variables which rubocop doesn't have.
5012
5394
  Safe: false
5013
5395
  Enabled: true
5396
+ # Expected to be disabled by default in the next major release.
5397
+ # A pure preference between `x > 0` and `x.positive?`.
5398
+ Preview:
5399
+ Enabled: false
5014
5400
  VersionAdded: '0.42'
5015
5401
  VersionChanged: '0.59'
5016
5402
  EnforcedStyle: predicate
@@ -5037,15 +5423,26 @@ Style/ObjectThen:
5037
5423
  - then
5038
5424
  - yield_self
5039
5425
 
5426
+ Style/OneClassPerFile:
5427
+ Description: 'Checks that each source file defines at most one top-level class or module.'
5428
+ StyleGuide: '#one-class-per-file'
5429
+ Enabled: pending
5430
+ VersionAdded: '1.85'
5431
+ VersionChanged: '1.86'
5432
+ AllowedClasses: []
5433
+ Exclude:
5434
+ - 'spec/**/*'
5435
+ - 'test/**/*'
5436
+
5040
5437
  Style/OneLineConditional:
5041
5438
  Description: >-
5042
5439
  Favor the ternary operator (?:) or multi-line constructs over
5043
5440
  single-line if/then/else/end constructs.
5044
5441
  StyleGuide: '#ternary-operator'
5045
5442
  Enabled: true
5046
- AlwaysCorrectToMultiline: false
5047
5443
  VersionAdded: '0.9'
5048
5444
  VersionChanged: '0.90'
5445
+ AlwaysCorrectToMultiline: false
5049
5446
 
5050
5447
  Style/OpenStructUse:
5051
5448
  Description: >-
@@ -5112,6 +5509,10 @@ Style/ParallelAssignment:
5112
5509
  matches on both sides of the assignment.
5113
5510
  StyleGuide: '#parallel-assignment'
5114
5511
  Enabled: true
5512
+ # Expected to be disabled by default in the next major release.
5513
+ # `a, b = 1, 2` is often the clearer form.
5514
+ Preview:
5515
+ Enabled: false
5115
5516
  VersionAdded: '0.32'
5116
5517
 
5117
5518
  Style/ParenthesesAroundCondition:
@@ -5125,11 +5526,20 @@ Style/ParenthesesAroundCondition:
5125
5526
  AllowSafeAssignment: true
5126
5527
  AllowInMultilineConditions: false
5127
5528
 
5529
+ Style/PartitionInsteadOfDoubleSelect:
5530
+ Description: >-
5531
+ Checks for consecutive `select`/`filter`/`find_all` and `reject` calls
5532
+ on the same receiver with the same block body.
5533
+ Enabled: pending
5534
+ Safe: false
5535
+ VersionAdded: '1.85'
5536
+
5128
5537
  Style/PercentLiteralDelimiters:
5129
5538
  Description: 'Use `%`-literal delimiters consistently.'
5130
5539
  StyleGuide: '#percent-literal-braces'
5131
5540
  Enabled: true
5132
5541
  VersionAdded: '0.19'
5542
+ VersionChanged: '0.48'
5133
5543
  # Specify the default preferred delimiter for all types with the 'default' key
5134
5544
  # Override individual delimiters (even with default specified) by specifying
5135
5545
  # an individual key
@@ -5140,7 +5550,6 @@ Style/PercentLiteralDelimiters:
5140
5550
  '%r': '{}'
5141
5551
  '%w': '[]'
5142
5552
  '%W': '[]'
5143
- VersionChanged: '0.48'
5144
5553
 
5145
5554
  Style/PercentQLiterals:
5146
5555
  Description: 'Checks if uses of %Q/%q match the configured preference.'
@@ -5155,8 +5564,18 @@ Style/PerlBackrefs:
5155
5564
  Description: 'Avoid Perl-style regex back references.'
5156
5565
  StyleGuide: '#no-perl-regexp-last-matchers'
5157
5566
  Enabled: true
5567
+ # Expected to be disabled by default in the next major release.
5568
+ # `$1` is idiomatic Ruby.
5569
+ Preview:
5570
+ Enabled: false
5158
5571
  VersionAdded: '0.13'
5159
5572
 
5573
+ Style/PredicateWithKind:
5574
+ Description: 'Prefer `any?(Klass)` to `any? { |x| x.is_a?(Klass) }`.'
5575
+ Enabled: pending
5576
+ SafeAutoCorrect: false
5577
+ VersionAdded: '1.85'
5578
+
5160
5579
  Style/PreferredHashMethods:
5161
5580
  Description: 'Checks use of `has_key?` and `has_value?` Hash methods.'
5162
5581
  StyleGuide: '#hash-key'
@@ -5190,6 +5609,10 @@ Style/RaiseArgs:
5190
5609
  Description: 'Checks the arguments passed to raise/fail.'
5191
5610
  StyleGuide: '#exception-class-messages'
5192
5611
  Enabled: true
5612
+ # Expected to be disabled by default in the next major release.
5613
+ # A pure preference between `raise Foo, msg` and `raise Foo.new(msg)`.
5614
+ Preview:
5615
+ Enabled: false
5193
5616
  Safe: false
5194
5617
  VersionAdded: '0.14'
5195
5618
  VersionChanged: '1.61'
@@ -5207,6 +5630,12 @@ Style/RandomWithOffset:
5207
5630
  Enabled: true
5208
5631
  VersionAdded: '0.52'
5209
5632
 
5633
+ Style/ReduceToHash:
5634
+ Description: 'Use `to_h { ... }` instead of `each_with_object`, `inject`, or `reduce` to build a hash.'
5635
+ Enabled: pending
5636
+ Safe: false
5637
+ VersionAdded: '1.85'
5638
+
5210
5639
  Style/RedundantArgument:
5211
5640
  Description: 'Checks for a redundant argument passed to certain methods.'
5212
5641
  Enabled: pending
@@ -5222,6 +5651,8 @@ Style/RedundantArgument:
5222
5651
  exit: true
5223
5652
  # Kernel.#exit!
5224
5653
  exit!: false
5654
+ # String#to_i
5655
+ to_i: 10
5225
5656
  # String#split
5226
5657
  split: ' '
5227
5658
  # String#chomp
@@ -5263,6 +5694,7 @@ Style/RedundantCondition:
5263
5694
  VersionAdded: '0.76'
5264
5695
  VersionChanged: '1.73'
5265
5696
  AllowedMethods:
5697
+ - infinite?
5266
5698
  - nonzero?
5267
5699
 
5268
5700
  Style/RedundantConditional:
@@ -5272,6 +5704,7 @@ Style/RedundantConditional:
5272
5704
 
5273
5705
  Style/RedundantConstantBase:
5274
5706
  Description: Avoid redundant `::` prefix on constant.
5707
+ VersionChanged: '1.89'
5275
5708
  Enabled: pending
5276
5709
  VersionAdded: '1.40'
5277
5710
 
@@ -5352,9 +5785,9 @@ Style/RedundantInitialize:
5352
5785
  Enabled: pending
5353
5786
  AutoCorrect: contextual
5354
5787
  Safe: false
5355
- AllowComments: true
5356
5788
  VersionAdded: '1.27'
5357
5789
  VersionChanged: '1.61'
5790
+ AllowComments: true
5358
5791
 
5359
5792
  Style/RedundantInterpolation:
5360
5793
  Description: 'Checks for strings that are just an interpolated expression.'
@@ -5370,9 +5803,15 @@ Style/RedundantInterpolationUnfreeze:
5370
5803
 
5371
5804
  Style/RedundantLineContinuation:
5372
5805
  Description: 'Checks for redundant line continuation.'
5806
+ StyleGuide: '#no-trailing-backslash'
5373
5807
  Enabled: pending
5374
5808
  VersionAdded: '1.49'
5375
5809
 
5810
+ Style/RedundantMinMaxBy:
5811
+ Description: 'Identifies places where `max_by`/`min_by` can be replaced by `max`/`min`.'
5812
+ Enabled: pending
5813
+ VersionAdded: '1.85'
5814
+
5376
5815
  Style/RedundantParentheses:
5377
5816
  Description: "Checks for parentheses that seem not to serve any purpose."
5378
5817
  Enabled: true
@@ -5401,6 +5840,7 @@ Style/RedundantRegexpConstructor:
5401
5840
 
5402
5841
  Style/RedundantRegexpEscape:
5403
5842
  Description: 'Checks for redundant escapes in Regexps.'
5843
+ StyleGuide: '#limit-escapes'
5404
5844
  Enabled: true
5405
5845
  VersionAdded: '0.85'
5406
5846
 
@@ -5450,10 +5890,21 @@ Style/RedundantStringEscape:
5450
5890
  Enabled: pending
5451
5891
  VersionAdded: '1.37'
5452
5892
 
5893
+ Style/RedundantStructKeywordInit:
5894
+ Description: 'Checks for redundant `keyword_init` option for `Struct.new`.'
5895
+ Enabled: false
5896
+ SafeAutoCorrect: false
5897
+ VersionAdded: '1.85'
5898
+ VersionChanged: '1.86'
5899
+
5453
5900
  Style/RegexpLiteral:
5454
5901
  Description: 'Use / or %r around regular expressions.'
5455
5902
  StyleGuide: '#percent-r'
5456
5903
  Enabled: true
5904
+ # Expected to be disabled by default in the next major release.
5905
+ # A pure preference between `//` and `%r{}`.
5906
+ Preview:
5907
+ Enabled: false
5457
5908
  VersionAdded: '0.9'
5458
5909
  VersionChanged: '0.30'
5459
5910
  EnforcedStyle: slashes
@@ -5486,6 +5937,10 @@ Style/RescueStandardError:
5486
5937
  Enabled: true
5487
5938
  VersionAdded: '0.52'
5488
5939
  EnforcedStyle: explicit
5940
+ # Expected to become the default in the next major release.
5941
+ # A bare `rescue` is the pick of most projects that set this.
5942
+ Preview:
5943
+ EnforcedStyle: implicit
5489
5944
  # implicit: Do not include the error class, `rescue`
5490
5945
  # explicit: Require an error class `rescue StandardError`
5491
5946
  SupportedStyles:
@@ -5506,10 +5961,16 @@ Style/ReturnNilInPredicateMethodDefinition:
5506
5961
  StyleGuide: '#bool-methods-qmark'
5507
5962
  Enabled: pending
5508
5963
  SafeAutoCorrect: false
5509
- AllowedMethods: []
5510
- AllowedPatterns: []
5511
5964
  VersionAdded: '1.53'
5512
5965
  VersionChanged: '1.67'
5966
+ AllowedMethods: []
5967
+ AllowedPatterns: []
5968
+
5969
+ Style/ReverseFind:
5970
+ Description: 'Use `array.rfind` instead of `array.reverse.find`.'
5971
+ Enabled: pending
5972
+ Safe: false
5973
+ VersionAdded: '1.84'
5513
5974
 
5514
5975
  Style/SafeNavigation:
5515
5976
  Description: >-
@@ -5550,8 +6011,20 @@ Style/Sample:
5550
6011
  Enabled: true
5551
6012
  VersionAdded: '0.30'
5552
6013
 
6014
+ Style/SelectByKind:
6015
+ Description: 'Prefer grep/grep_v to select/reject/find/detect with a kind check.'
6016
+ Enabled: pending
6017
+ SafeAutoCorrect: false
6018
+ VersionAdded: '1.85'
6019
+
6020
+ Style/SelectByRange:
6021
+ Description: 'Prefer grep/grep_v to select/reject/find/detect with a range check.'
6022
+ Enabled: pending
6023
+ SafeAutoCorrect: false
6024
+ VersionAdded: '1.85'
6025
+
5553
6026
  Style/SelectByRegexp:
5554
- Description: 'Prefer grep/grep_v to select/reject with a regexp match.'
6027
+ Description: 'Prefer grep/grep_v to select/reject/find/detect with a regexp match.'
5555
6028
  Enabled: pending
5556
6029
  SafeAutoCorrect: false
5557
6030
  VersionAdded: '1.22'
@@ -5591,6 +6064,10 @@ Style/SignalException:
5591
6064
  Description: 'Checks for proper usage of fail and raise.'
5592
6065
  StyleGuide: '#prefer-raise-over-fail'
5593
6066
  Enabled: true
6067
+ # Expected to be disabled by default in the next major release.
6068
+ # `raise` versus `fail` stopped being a meaningful distinction long ago.
6069
+ Preview:
6070
+ Enabled: false
5594
6071
  VersionAdded: '0.11'
5595
6072
  VersionChanged: '0.37'
5596
6073
  EnforcedStyle: only_raise
@@ -5652,6 +6129,10 @@ Style/SpecialGlobalVars:
5652
6129
  Description: 'Avoid Perl-style global variables.'
5653
6130
  StyleGuide: '#no-cryptic-perlisms'
5654
6131
  Enabled: true
6132
+ # Expected to be disabled by default in the next major release.
6133
+ # The long names need `require 'English'`; the short ones are idiomatic.
6134
+ Preview:
6135
+ Enabled: false
5655
6136
  VersionAdded: '0.13'
5656
6137
  VersionChanged: '0.36'
5657
6138
  SafeAutoCorrect: false
@@ -5675,6 +6156,7 @@ Style/StabbyLambdaParentheses:
5675
6156
  Style/StaticClass:
5676
6157
  Description: 'Prefer modules to classes with only class methods.'
5677
6158
  StyleGuide: '#modules-vs-classes'
6159
+ VersionChanged: '1.89'
5678
6160
  Enabled: false
5679
6161
  Safe: false
5680
6162
  VersionAdded: '1.3'
@@ -5716,6 +6198,10 @@ Style/StringLiterals:
5716
6198
  VersionAdded: '0.9'
5717
6199
  VersionChanged: '0.36'
5718
6200
  EnforcedStyle: single_quotes
6201
+ # Expected to become the default in the next major release.
6202
+ # Double quotes are what most Ruby is written with; Standard and omakase pick them too.
6203
+ Preview:
6204
+ EnforcedStyle: double_quotes
5719
6205
  SupportedStyles:
5720
6206
  - single_quotes
5721
6207
  - double_quotes
@@ -5730,6 +6216,10 @@ Style/StringLiteralsInInterpolation:
5730
6216
  Enabled: true
5731
6217
  VersionAdded: '0.27'
5732
6218
  EnforcedStyle: single_quotes
6219
+ # Expected to become the default in the next major release.
6220
+ # Follows `Style/StringLiterals`.
6221
+ Preview:
6222
+ EnforcedStyle: double_quotes
5733
6223
  SupportedStyles:
5734
6224
  - single_quotes
5735
6225
  - double_quotes
@@ -5786,6 +6276,10 @@ Style/SymbolArray:
5786
6276
  VersionAdded: '0.9'
5787
6277
  VersionChanged: '0.49'
5788
6278
  EnforcedStyle: percent
6279
+ # Expected to become the default in the next major release.
6280
+ # Bracketed arrays are the pick of nearly every project that sets this; Standard turns the cop off instead.
6281
+ Preview:
6282
+ EnforcedStyle: brackets
5789
6283
  MinSize: 2
5790
6284
  SupportedStyles:
5791
6285
  - percent
@@ -5810,18 +6304,34 @@ Style/SymbolProc:
5810
6304
  AllowedPatterns: []
5811
6305
  AllowComments: false
5812
6306
 
6307
+ Style/TallyMethod:
6308
+ Description: 'Prefer `Enumerable#tally` over manual counting patterns.'
6309
+ Enabled: pending
6310
+ Safe: false
6311
+ VersionAdded: '1.85'
6312
+
5813
6313
  Style/TernaryParentheses:
5814
6314
  Description: 'Checks for use of parentheses around ternary conditions.'
5815
6315
  Enabled: true
5816
6316
  VersionAdded: '0.42'
5817
6317
  VersionChanged: '0.46'
5818
6318
  EnforcedStyle: require_no_parentheses
6319
+ # Expected to become the default in the next major release.
6320
+ # Parentheses only around complex conditions is the pick of nearly every project that sets this.
6321
+ Preview:
6322
+ EnforcedStyle: require_parentheses_when_complex
5819
6323
  SupportedStyles:
5820
6324
  - require_parentheses
5821
6325
  - require_no_parentheses
5822
6326
  - require_parentheses_when_complex
5823
6327
  AllowSafeAssignment: true
5824
6328
 
6329
+ Style/TimeNow:
6330
+ Description: 'Prefer `Time.now` over `Time.new` when retrieving the current system time.'
6331
+ StyleGuide: '#time-now'
6332
+ Enabled: pending
6333
+ VersionAdded: '1.90'
6334
+
5825
6335
  Style/TopLevelMethodDefinition:
5826
6336
  Description: 'Looks for top-level method definitions.'
5827
6337
  StyleGuide: '#top-level-methods'
@@ -5834,12 +6344,12 @@ Style/TrailingBodyOnClass:
5834
6344
  VersionAdded: '0.53'
5835
6345
 
5836
6346
  Style/TrailingBodyOnMethodDefinition:
5837
- Description: 'Method body goes below definition.'
6347
+ Description: 'Checks for trailing code after the method definition.'
5838
6348
  Enabled: true
5839
6349
  VersionAdded: '0.52'
5840
6350
 
5841
6351
  Style/TrailingBodyOnModule:
5842
- Description: 'Module body goes below module statement.'
6352
+ Description: 'Checks for trailing code after the module definition.'
5843
6353
  Enabled: true
5844
6354
  VersionAdded: '0.53'
5845
6355
 
@@ -5912,10 +6422,11 @@ Style/TrailingUnderscoreVariable:
5912
6422
  Description: >-
5913
6423
  Checks for the usage of unneeded trailing underscores at the
5914
6424
  end of parallel variable assignment.
5915
- AllowNamedUnderscoreVariables: true
6425
+ StyleGuide: '#trailing-underscore-variables'
5916
6426
  Enabled: true
5917
6427
  VersionAdded: '0.31'
5918
6428
  VersionChanged: '0.35'
6429
+ AllowNamedUnderscoreVariables: true
5919
6430
 
5920
6431
  # `TrivialAccessors` requires exact name matches and doesn't allow
5921
6432
  # predicated methods by default.
@@ -6026,6 +6537,10 @@ Style/WordArray:
6026
6537
  VersionAdded: '0.9'
6027
6538
  VersionChanged: '1.19'
6028
6539
  EnforcedStyle: percent
6540
+ # Expected to become the default in the next major release.
6541
+ # Same preference as `SymbolArray`, and the two are configured together in practice.
6542
+ Preview:
6543
+ EnforcedStyle: brackets
6029
6544
  SupportedStyles:
6030
6545
  # percent style: %w(word1 word2)
6031
6546
  - percent
@@ -6048,6 +6563,9 @@ Style/YodaCondition:
6048
6563
  References:
6049
6564
  - 'https://en.wikipedia.org/wiki/Yoda_conditions'
6050
6565
  Enabled: true
6566
+ Safe: false
6567
+ VersionAdded: '0.49'
6568
+ VersionChanged: '0.75'
6051
6569
  EnforcedStyle: forbid_for_all_comparison_operators
6052
6570
  SupportedStyles:
6053
6571
  # check all comparison operators
@@ -6058,9 +6576,6 @@ Style/YodaCondition:
6058
6576
  - require_for_all_comparison_operators
6059
6577
  # enforce yoda only for equality operators: `!=` and `==`
6060
6578
  - require_for_equality_operators_only
6061
- Safe: false
6062
- VersionAdded: '0.49'
6063
- VersionChanged: '0.75'
6064
6579
 
6065
6580
  Style/YodaExpression:
6066
6581
  Description: 'Forbid the use of yoda expressions.'