rubocop 1.71.1 → 1.91.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (661) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +1 -1
  3. data/README.md +23 -19
  4. data/config/default.yml +883 -168
  5. data/config/internal_affairs.yml +20 -0
  6. data/config/obsoletion.yml +47 -4
  7. data/exe/rubocop +2 -9
  8. data/lib/rubocop/cache_config.rb +29 -0
  9. data/lib/rubocop/cached_data.rb +7 -2
  10. data/lib/rubocop/changed_files.rb +112 -0
  11. data/lib/rubocop/cli/command/auto_generate_config.rb +36 -4
  12. data/lib/rubocop/cli/command/execute_runner.rb +52 -1
  13. data/lib/rubocop/cli/command/list_enabled_cops_for.rb +40 -0
  14. data/lib/rubocop/cli/command/lsp.rb +1 -1
  15. data/lib/rubocop/cli/command/mcp.rb +19 -0
  16. data/lib/rubocop/cli/command/show_cops.rb +2 -2
  17. data/lib/rubocop/cli/command/show_docs_url.rb +4 -8
  18. data/lib/rubocop/cli/command/suggest_extensions.rb +8 -2
  19. data/lib/rubocop/cli.rb +58 -17
  20. data/lib/rubocop/comment_config/directive_range.rb +34 -0
  21. data/lib/rubocop/comment_config/disable_next.rb +143 -0
  22. data/lib/rubocop/comment_config/push_pop.rb +55 -0
  23. data/lib/rubocop/comment_config.rb +92 -48
  24. data/lib/rubocop/config.rb +137 -19
  25. data/lib/rubocop/config_finder.rb +1 -1
  26. data/lib/rubocop/config_loader.rb +72 -49
  27. data/lib/rubocop/config_loader_resolver.rb +94 -28
  28. data/lib/rubocop/config_obsoletion/cop_rule.rb +2 -1
  29. data/lib/rubocop/config_obsoletion/extracted_cop.rb +6 -3
  30. data/lib/rubocop/config_obsoletion/removed_cop.rb +8 -0
  31. data/lib/rubocop/config_obsoletion/renamed_cop.rb +18 -3
  32. data/lib/rubocop/config_obsoletion.rb +47 -3
  33. data/lib/rubocop/config_store.rb +7 -2
  34. data/lib/rubocop/config_validator.rb +64 -12
  35. data/lib/rubocop/cop/autocorrect_logic.rb +35 -14
  36. data/lib/rubocop/cop/badge.rb +9 -1
  37. data/lib/rubocop/cop/base.rb +93 -21
  38. data/lib/rubocop/cop/bundler/gem_comment.rb +5 -3
  39. data/lib/rubocop/cop/bundler/gem_version.rb +28 -28
  40. data/lib/rubocop/cop/bundler/ordered_gems.rb +2 -3
  41. data/lib/rubocop/cop/bundler.rb +19 -0
  42. data/lib/rubocop/cop/commissioner.rb +13 -11
  43. data/lib/rubocop/cop/corrector.rb +4 -4
  44. data/lib/rubocop/cop/correctors/alignment_corrector.rb +79 -10
  45. data/lib/rubocop/cop/correctors/condition_corrector.rb +1 -1
  46. data/lib/rubocop/cop/correctors/each_to_for_corrector.rb +1 -1
  47. data/lib/rubocop/cop/correctors/for_to_each_corrector.rb +7 -2
  48. data/lib/rubocop/cop/correctors/lambda_literal_to_method_corrector.rb +7 -1
  49. data/lib/rubocop/cop/correctors/multiline_literal_brace_corrector.rb +1 -5
  50. data/lib/rubocop/cop/correctors/ordered_gem_corrector.rb +8 -1
  51. data/lib/rubocop/cop/correctors/parentheses_corrector.rb +36 -2
  52. data/lib/rubocop/cop/correctors/percent_literal_corrector.rb +2 -2
  53. data/lib/rubocop/cop/correctors.rb +28 -0
  54. data/lib/rubocop/cop/documentation.rb +2 -3
  55. data/lib/rubocop/cop/exclude_limit.rb +31 -5
  56. data/lib/rubocop/cop/gemspec/attribute_assignment.rb +91 -0
  57. data/lib/rubocop/cop/gemspec/development_dependencies.rb +1 -1
  58. data/lib/rubocop/cop/gemspec/duplicated_assignment.rb +49 -17
  59. data/lib/rubocop/cop/gemspec/ordered_dependencies.rb +2 -3
  60. data/lib/rubocop/cop/gemspec/require_mfa.rb +22 -5
  61. data/lib/rubocop/cop/gemspec/ruby_version_globals_usage.rb +12 -7
  62. data/lib/rubocop/cop/gemspec.rb +22 -0
  63. data/lib/rubocop/cop/generator/registration_injector.rb +188 -0
  64. data/lib/rubocop/cop/generator.rb +5 -1
  65. data/lib/rubocop/cop/internal_affairs/example_description.rb +9 -5
  66. data/lib/rubocop/cop/internal_affairs/example_heredoc_delimiter.rb +8 -8
  67. data/lib/rubocop/cop/internal_affairs/itblock_handler.rb +69 -0
  68. data/lib/rubocop/cop/internal_affairs/location_exists.rb +142 -0
  69. data/lib/rubocop/cop/internal_affairs/location_line_equality_comparison.rb +1 -0
  70. data/lib/rubocop/cop/internal_affairs/node_matcher_directive.rb +14 -15
  71. data/lib/rubocop/cop/internal_affairs/node_pattern_groups/ast_processor.rb +1 -1
  72. data/lib/rubocop/cop/internal_affairs/node_pattern_groups/ast_walker.rb +1 -2
  73. data/lib/rubocop/cop/internal_affairs/node_pattern_groups.rb +6 -2
  74. data/lib/rubocop/cop/internal_affairs/node_type_group.rb +92 -0
  75. data/lib/rubocop/cop/internal_affairs/on_send_without_on_csend.rb +2 -2
  76. data/lib/rubocop/cop/internal_affairs/plugin.rb +33 -0
  77. data/lib/rubocop/cop/internal_affairs/redundant_described_class_as_subject.rb +6 -5
  78. data/lib/rubocop/cop/internal_affairs/redundant_let_rubocop_config_new.rb +5 -3
  79. data/lib/rubocop/cop/internal_affairs/undefined_config.rb +13 -2
  80. data/lib/rubocop/cop/internal_affairs/useless_message_assertion.rb +4 -4
  81. data/lib/rubocop/cop/internal_affairs/useless_restrict_on_send.rb +1 -1
  82. data/lib/rubocop/cop/internal_affairs.rb +3 -16
  83. data/lib/rubocop/cop/layout/argument_alignment.rb +4 -2
  84. data/lib/rubocop/cop/layout/array_alignment.rb +1 -1
  85. data/lib/rubocop/cop/layout/begin_end_alignment.rb +1 -1
  86. data/lib/rubocop/cop/layout/block_alignment.rb +59 -4
  87. data/lib/rubocop/cop/layout/block_end_newline.rb +1 -0
  88. data/lib/rubocop/cop/layout/case_indentation.rb +3 -1
  89. data/lib/rubocop/cop/layout/class_structure.rb +163 -35
  90. data/lib/rubocop/cop/layout/closing_parenthesis_indentation.rb +5 -5
  91. data/lib/rubocop/cop/layout/comment_indentation.rb +17 -7
  92. data/lib/rubocop/cop/layout/condition_position.rb +13 -3
  93. data/lib/rubocop/cop/layout/def_end_alignment.rb +1 -1
  94. data/lib/rubocop/cop/layout/dot_position.rb +2 -2
  95. data/lib/rubocop/cop/layout/else_alignment.rb +3 -15
  96. data/lib/rubocop/cop/layout/empty_comment.rb +8 -10
  97. data/lib/rubocop/cop/layout/empty_line_after_guard_clause.rb +27 -9
  98. data/lib/rubocop/cop/layout/empty_line_after_magic_comment.rb +63 -5
  99. data/lib/rubocop/cop/layout/empty_line_between_defs.rb +46 -21
  100. data/lib/rubocop/cop/layout/empty_lines_after_module_inclusion.rb +101 -0
  101. data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +34 -4
  102. data/lib/rubocop/cop/layout/empty_lines_around_arguments.rb +8 -29
  103. data/lib/rubocop/cop/layout/empty_lines_around_attribute_accessor.rb +1 -0
  104. data/lib/rubocop/cop/layout/empty_lines_around_block_body.rb +13 -2
  105. data/lib/rubocop/cop/layout/empty_lines_around_class_body.rb +17 -3
  106. data/lib/rubocop/cop/layout/empty_lines_around_method_body.rb +22 -2
  107. data/lib/rubocop/cop/layout/empty_lines_around_module_body.rb +16 -2
  108. data/lib/rubocop/cop/layout/end_alignment.rb +9 -3
  109. data/lib/rubocop/cop/layout/extra_spacing.rb +105 -3
  110. data/lib/rubocop/cop/layout/first_argument_indentation.rb +56 -3
  111. data/lib/rubocop/cop/layout/first_array_element_indentation.rb +18 -5
  112. data/lib/rubocop/cop/layout/first_array_element_line_break.rb +26 -0
  113. data/lib/rubocop/cop/layout/first_hash_element_indentation.rb +20 -15
  114. data/lib/rubocop/cop/layout/first_hash_element_line_break.rb +25 -25
  115. data/lib/rubocop/cop/layout/first_parameter_indentation.rb +11 -0
  116. data/lib/rubocop/cop/layout/hash_alignment.rb +11 -13
  117. data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +3 -3
  118. data/lib/rubocop/cop/layout/heredoc_indentation.rb +33 -3
  119. data/lib/rubocop/cop/layout/indentation_style.rb +1 -1
  120. data/lib/rubocop/cop/layout/indentation_width.rb +157 -10
  121. data/lib/rubocop/cop/layout/leading_comment_space.rb +40 -1
  122. data/lib/rubocop/cop/layout/line_continuation_spacing.rb +2 -3
  123. data/lib/rubocop/cop/layout/line_length.rb +160 -23
  124. data/lib/rubocop/cop/layout/multiline_array_brace_layout.rb +57 -57
  125. data/lib/rubocop/cop/layout/multiline_assignment_layout.rb +8 -2
  126. data/lib/rubocop/cop/layout/multiline_block_layout.rb +3 -0
  127. data/lib/rubocop/cop/layout/multiline_hash_brace_layout.rb +56 -56
  128. data/lib/rubocop/cop/layout/multiline_method_call_brace_layout.rb +1 -1
  129. data/lib/rubocop/cop/layout/multiline_method_call_indentation.rb +245 -40
  130. data/lib/rubocop/cop/layout/multiline_method_parameter_line_breaks.rb +1 -0
  131. data/lib/rubocop/cop/layout/multiline_operation_indentation.rb +9 -5
  132. data/lib/rubocop/cop/layout/parameter_alignment.rb +1 -1
  133. data/lib/rubocop/cop/layout/redundant_line_break.rb +89 -6
  134. data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +14 -7
  135. data/lib/rubocop/cop/layout/space_after_comma.rb +2 -10
  136. data/lib/rubocop/cop/layout/space_after_semicolon.rb +11 -1
  137. data/lib/rubocop/cop/layout/space_around_block_parameters.rb +14 -3
  138. data/lib/rubocop/cop/layout/space_around_keyword.rb +10 -3
  139. data/lib/rubocop/cop/layout/space_around_method_call_operator.rb +1 -1
  140. data/lib/rubocop/cop/layout/space_around_operators.rb +30 -4
  141. data/lib/rubocop/cop/layout/space_before_block_braces.rb +1 -0
  142. data/lib/rubocop/cop/layout/space_before_brackets.rb +6 -39
  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 +42 -36
  145. data/lib/rubocop/cop/layout/space_inside_block_braces.rb +1 -0
  146. data/lib/rubocop/cop/layout/space_inside_hash_literal_braces.rb +3 -0
  147. data/lib/rubocop/cop/layout/trailing_whitespace.rb +1 -1
  148. data/lib/rubocop/cop/layout.rb +114 -0
  149. data/lib/rubocop/cop/lazy_loader.rb +41 -0
  150. data/lib/rubocop/cop/lint/ambiguous_assignment.rb +9 -17
  151. data/lib/rubocop/cop/lint/ambiguous_block_association.rb +72 -1
  152. data/lib/rubocop/cop/lint/ambiguous_operator_precedence.rb +1 -10
  153. data/lib/rubocop/cop/lint/ambiguous_range.rb +6 -2
  154. data/lib/rubocop/cop/lint/argument_mismatch.rb +99 -0
  155. data/lib/rubocop/cop/lint/array_literal_in_regexp.rb +2 -3
  156. data/lib/rubocop/cop/lint/assignment_in_condition.rb +15 -1
  157. data/lib/rubocop/cop/lint/boolean_symbol.rb +1 -1
  158. data/lib/rubocop/cop/lint/circular_argument_reference.rb +47 -8
  159. data/lib/rubocop/cop/lint/constant_overwritten_in_rescue.rb +4 -3
  160. data/lib/rubocop/cop/lint/constant_reassignment.rb +94 -15
  161. data/lib/rubocop/cop/lint/constant_resolution.rb +31 -6
  162. data/lib/rubocop/cop/lint/cop_directive_syntax.rb +240 -0
  163. data/lib/rubocop/cop/lint/data_define_override.rb +63 -0
  164. data/lib/rubocop/cop/lint/debugger.rb +13 -4
  165. data/lib/rubocop/cop/lint/deprecated_class_methods.rb +1 -1
  166. data/lib/rubocop/cop/lint/deprecated_constants.rb +2 -8
  167. data/lib/rubocop/cop/lint/deprecated_open_ssl_constant.rb +5 -2
  168. data/lib/rubocop/cop/lint/deprecated_reference.rb +194 -0
  169. data/lib/rubocop/cop/lint/duplicate_match_pattern.rb +4 -4
  170. data/lib/rubocop/cop/lint/duplicate_methods.rb +506 -41
  171. data/lib/rubocop/cop/lint/duplicate_regexp_character_class_element.rb +5 -42
  172. data/lib/rubocop/cop/lint/else_layout.rb +19 -0
  173. data/lib/rubocop/cop/lint/empty_block.rb +4 -4
  174. data/lib/rubocop/cop/lint/empty_conditional_body.rb +20 -65
  175. data/lib/rubocop/cop/lint/empty_expression.rb +0 -2
  176. data/lib/rubocop/cop/lint/empty_in_pattern.rb +8 -1
  177. data/lib/rubocop/cop/lint/empty_interpolation.rb +14 -1
  178. data/lib/rubocop/cop/lint/empty_when.rb +8 -1
  179. data/lib/rubocop/cop/lint/ensure_return.rb +19 -1
  180. data/lib/rubocop/cop/lint/erb_new_arguments.rb +4 -8
  181. data/lib/rubocop/cop/lint/float_comparison.rb +33 -10
  182. data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +1 -1
  183. data/lib/rubocop/cop/lint/identity_comparison.rb +19 -15
  184. data/lib/rubocop/cop/lint/implicit_string_concatenation.rb +1 -2
  185. data/lib/rubocop/cop/lint/incompatible_io_select_with_fiber_scheduler.rb +5 -1
  186. data/lib/rubocop/cop/lint/ineffective_access_modifier.rb +1 -2
  187. data/lib/rubocop/cop/lint/inherit_exception.rb +53 -7
  188. data/lib/rubocop/cop/lint/interpolation_check.rb +25 -6
  189. data/lib/rubocop/cop/lint/lambda_without_literal_block.rb +1 -1
  190. data/lib/rubocop/cop/lint/literal_as_condition.rb +137 -11
  191. data/lib/rubocop/cop/lint/literal_assignment_in_condition.rb +11 -1
  192. data/lib/rubocop/cop/lint/literal_in_interpolation.rb +13 -19
  193. data/lib/rubocop/cop/lint/misplaced_magic_comment.rb +185 -0
  194. data/lib/rubocop/cop/lint/missing_cop_enable_directive.rb +44 -22
  195. data/lib/rubocop/cop/lint/missing_super.rb +31 -1
  196. data/lib/rubocop/cop/lint/mixed_case_range.rb +2 -2
  197. data/lib/rubocop/cop/lint/multiple_comparison.rb +2 -2
  198. data/lib/rubocop/cop/lint/name_typo.rb +270 -0
  199. data/lib/rubocop/cop/lint/nested_method_definition.rb +2 -2
  200. data/lib/rubocop/cop/lint/next_without_accumulator.rb +2 -0
  201. data/lib/rubocop/cop/lint/no_return_in_begin_end_blocks.rb +20 -0
  202. data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +4 -2
  203. data/lib/rubocop/cop/lint/non_local_exit_from_iterator.rb +4 -4
  204. data/lib/rubocop/cop/lint/number_conversion.rb +19 -10
  205. data/lib/rubocop/cop/lint/numbered_parameter_assignment.rb +1 -1
  206. data/lib/rubocop/cop/lint/numeric_operation_with_constant_result.rb +11 -0
  207. data/lib/rubocop/cop/lint/or_assignment_to_constant.rb +1 -1
  208. data/lib/rubocop/cop/lint/ordered_magic_comments.rb +7 -7
  209. data/lib/rubocop/cop/lint/out_of_range_regexp_ref.rb +15 -4
  210. data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +20 -14
  211. data/lib/rubocop/cop/lint/raise_exception.rb +30 -11
  212. data/lib/rubocop/cop/lint/rand_one.rb +1 -1
  213. data/lib/rubocop/cop/lint/redundant_cop_disable_directive.rb +149 -39
  214. data/lib/rubocop/cop/lint/redundant_cop_enable_directive.rb +53 -19
  215. data/lib/rubocop/cop/lint/redundant_dir_glob_sort.rb +15 -4
  216. data/lib/rubocop/cop/lint/redundant_regexp_quantifiers.rb +1 -1
  217. data/lib/rubocop/cop/lint/redundant_require_statement.rb +5 -25
  218. data/lib/rubocop/cop/lint/redundant_safe_navigation.rb +134 -12
  219. data/lib/rubocop/cop/lint/redundant_splat_expansion.rb +13 -4
  220. data/lib/rubocop/cop/lint/redundant_type_conversion.rb +267 -0
  221. data/lib/rubocop/cop/lint/redundant_with_index.rb +5 -3
  222. data/lib/rubocop/cop/lint/redundant_with_object.rb +8 -0
  223. data/lib/rubocop/cop/lint/refinement_import_methods.rb +8 -1
  224. data/lib/rubocop/cop/lint/regexp_as_condition.rb +9 -1
  225. data/lib/rubocop/cop/lint/require_parentheses.rb +13 -4
  226. data/lib/rubocop/cop/lint/require_range_parentheses.rb +3 -2
  227. data/lib/rubocop/cop/lint/require_relative_self_path.rb +7 -5
  228. data/lib/rubocop/cop/lint/rescue_exception.rb +1 -4
  229. data/lib/rubocop/cop/lint/rescue_type.rb +2 -2
  230. data/lib/rubocop/cop/lint/return_in_void_context.rb +9 -11
  231. data/lib/rubocop/cop/lint/safe_navigation_chain.rb +28 -4
  232. data/lib/rubocop/cop/lint/safe_navigation_consistency.rb +9 -5
  233. data/lib/rubocop/cop/lint/safe_navigation_with_empty.rb +1 -1
  234. data/lib/rubocop/cop/lint/script_permission.rb +5 -1
  235. data/lib/rubocop/cop/lint/self_assignment.rb +63 -6
  236. data/lib/rubocop/cop/lint/send_with_mixin_argument.rb +1 -1
  237. data/lib/rubocop/cop/lint/shadowed_argument.rb +7 -7
  238. data/lib/rubocop/cop/lint/shadowed_exception.rb +1 -1
  239. data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +27 -1
  240. data/lib/rubocop/cop/lint/shared_mutable_default.rb +14 -1
  241. data/lib/rubocop/cop/lint/struct_new_override.rb +17 -1
  242. data/lib/rubocop/cop/lint/super_argument_mismatch.rb +179 -0
  243. data/lib/rubocop/cop/lint/suppressed_exception.rb +1 -1
  244. data/lib/rubocop/cop/lint/suppressed_exception_in_number_conversion.rb +122 -0
  245. data/lib/rubocop/cop/lint/symbol_conversion.rb +21 -4
  246. data/lib/rubocop/cop/lint/syntax.rb +25 -1
  247. data/lib/rubocop/cop/lint/to_enum_arguments.rb +73 -5
  248. data/lib/rubocop/cop/lint/to_json.rb +20 -17
  249. data/lib/rubocop/cop/lint/top_level_return_with_argument.rb +1 -1
  250. data/lib/rubocop/cop/lint/trailing_comma_in_attribute_declaration.rb +5 -1
  251. data/lib/rubocop/cop/lint/unescaped_bracket_in_regexp.rb +36 -10
  252. data/lib/rubocop/cop/lint/unexpected_block_arity.rb +2 -0
  253. data/lib/rubocop/cop/lint/unmodified_reduce_accumulator.rb +2 -1
  254. data/lib/rubocop/cop/lint/unreachable_code.rb +16 -9
  255. data/lib/rubocop/cop/lint/unreachable_loop.rb +5 -5
  256. data/lib/rubocop/cop/lint/unreachable_pattern_branch.rb +113 -0
  257. data/lib/rubocop/cop/lint/unused_method_argument.rb +10 -0
  258. data/lib/rubocop/cop/lint/unused_private_method.rb +234 -0
  259. data/lib/rubocop/cop/lint/uri_escape_unescape.rb +2 -0
  260. data/lib/rubocop/cop/lint/useless_access_modifier.rb +31 -6
  261. data/lib/rubocop/cop/lint/useless_assignment.rb +56 -27
  262. data/lib/rubocop/cop/lint/useless_constant_scoping.rb +107 -0
  263. data/lib/rubocop/cop/lint/useless_default_value_argument.rb +92 -0
  264. data/lib/rubocop/cop/lint/useless_method_definition.rb +1 -1
  265. data/lib/rubocop/cop/lint/useless_numeric_operation.rb +11 -10
  266. data/lib/rubocop/cop/lint/useless_or.rb +111 -0
  267. data/lib/rubocop/cop/lint/useless_rescue.rb +2 -3
  268. data/lib/rubocop/cop/lint/useless_ruby2_keywords.rb +13 -7
  269. data/lib/rubocop/cop/lint/useless_setter_call.rb +4 -1
  270. data/lib/rubocop/cop/lint/useless_times.rb +22 -1
  271. data/lib/rubocop/cop/lint/utils/nil_receiver_checker.rb +201 -0
  272. data/lib/rubocop/cop/lint/void.rb +60 -21
  273. data/lib/rubocop/cop/lint.rb +179 -0
  274. data/lib/rubocop/cop/message_annotator.rb +7 -3
  275. data/lib/rubocop/cop/metrics/abc_size.rb +1 -1
  276. data/lib/rubocop/cop/metrics/block_length.rb +2 -1
  277. data/lib/rubocop/cop/metrics/block_nesting.rb +23 -0
  278. data/lib/rubocop/cop/metrics/collection_literal_length.rb +1 -1
  279. data/lib/rubocop/cop/metrics/method_length.rb +3 -2
  280. data/lib/rubocop/cop/metrics/perceived_complexity.rb +37 -7
  281. data/lib/rubocop/cop/metrics/utils/abc_size_calculator.rb +4 -3
  282. data/lib/rubocop/cop/metrics/utils/code_length_calculator.rb +2 -2
  283. data/lib/rubocop/cop/metrics/utils/iterating_block.rb +1 -1
  284. data/lib/rubocop/cop/metrics/utils/repeated_attribute_discount.rb +7 -7
  285. data/lib/rubocop/cop/metrics.rb +31 -0
  286. data/lib/rubocop/cop/migration/department_name.rb +11 -5
  287. data/lib/rubocop/cop/migration.rb +13 -0
  288. data/lib/rubocop/cop/mixin/alignment.rb +3 -3
  289. data/lib/rubocop/cop/mixin/allowed_methods.rb +5 -5
  290. data/lib/rubocop/cop/mixin/allowed_pattern.rb +9 -5
  291. data/lib/rubocop/cop/mixin/annotation_comment.rb +1 -1
  292. data/lib/rubocop/cop/mixin/check_line_breakable.rb +27 -9
  293. data/lib/rubocop/cop/mixin/check_single_line_suitability.rb +5 -7
  294. data/lib/rubocop/cop/mixin/code_length.rb +1 -1
  295. data/lib/rubocop/cop/mixin/comments_help.rb +2 -3
  296. data/lib/rubocop/cop/mixin/configurable_enforced_style.rb +1 -2
  297. data/lib/rubocop/cop/mixin/configurable_max.rb +6 -5
  298. data/lib/rubocop/cop/mixin/def_node.rb +1 -1
  299. data/lib/rubocop/cop/mixin/empty_lines_around_body.rb +1 -1
  300. data/lib/rubocop/cop/mixin/end_keyword_alignment.rb +1 -7
  301. data/lib/rubocop/cop/mixin/endless_method_rewriter.rb +13 -5
  302. data/lib/rubocop/cop/mixin/forbidden_identifiers.rb +20 -0
  303. data/lib/rubocop/cop/mixin/forbidden_pattern.rb +20 -0
  304. data/lib/rubocop/cop/mixin/frozen_string_literal.rb +1 -2
  305. data/lib/rubocop/cop/mixin/gemspec_help.rb +22 -0
  306. data/lib/rubocop/cop/mixin/hash_alignment_styles.rb +44 -16
  307. data/lib/rubocop/cop/mixin/hash_shorthand_syntax.rb +29 -26
  308. data/lib/rubocop/cop/mixin/hash_subset.rb +28 -6
  309. data/lib/rubocop/cop/mixin/hash_transform_method/autocorrection.rb +63 -0
  310. data/lib/rubocop/cop/mixin/hash_transform_method.rb +32 -78
  311. data/lib/rubocop/cop/mixin/indexed_method_arity.rb +94 -0
  312. data/lib/rubocop/cop/mixin/line_length_help.rb +52 -11
  313. data/lib/rubocop/cop/mixin/method_complexity.rb +2 -1
  314. data/lib/rubocop/cop/mixin/multiline_expression_indentation.rb +3 -1
  315. data/lib/rubocop/cop/mixin/multiline_literal_brace_layout.rb +1 -1
  316. data/lib/rubocop/cop/mixin/ordered_gem_node.rb +1 -1
  317. data/lib/rubocop/cop/mixin/percent_literal.rb +1 -1
  318. data/lib/rubocop/cop/mixin/preceding_following_alignment.rb +62 -6
  319. data/lib/rubocop/cop/mixin/project_index_help.rb +188 -0
  320. data/lib/rubocop/cop/mixin/range_help.rb +16 -5
  321. data/lib/rubocop/cop/mixin/reparsed_equivalence.rb +171 -0
  322. data/lib/rubocop/cop/mixin/space_after_punctuation.rb +5 -4
  323. data/lib/rubocop/cop/mixin/statement_modifier.rb +47 -11
  324. data/lib/rubocop/cop/mixin/string_help.rb +1 -1
  325. data/lib/rubocop/cop/mixin/target_ruby_version.rb +1 -1
  326. data/lib/rubocop/cop/mixin/trailing_comma.rb +23 -6
  327. data/lib/rubocop/cop/mixin.rb +91 -0
  328. data/lib/rubocop/cop/naming/accessor_method_name.rb +24 -0
  329. data/lib/rubocop/cop/naming/binary_operator_parameter_name.rb +17 -1
  330. data/lib/rubocop/cop/naming/block_forwarding.rb +7 -4
  331. data/lib/rubocop/cop/naming/block_parameter_name.rb +1 -1
  332. data/lib/rubocop/cop/naming/file_name.rb +6 -5
  333. data/lib/rubocop/cop/naming/inclusive_language.rb +8 -2
  334. data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +13 -6
  335. data/lib/rubocop/cop/naming/method_name.rb +190 -15
  336. data/lib/rubocop/cop/naming/predicate_method.rb +330 -0
  337. data/lib/rubocop/cop/naming/{predicate_name.rb → predicate_prefix.rb} +80 -8
  338. data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +11 -6
  339. data/lib/rubocop/cop/naming/variable_name.rb +51 -6
  340. data/lib/rubocop/cop/naming/variable_number.rb +3 -1
  341. data/lib/rubocop/cop/naming.rb +31 -0
  342. data/lib/rubocop/cop/offense.rb +52 -9
  343. data/lib/rubocop/cop/registry.rb +233 -64
  344. data/lib/rubocop/cop/security/eval.rb +17 -3
  345. data/lib/rubocop/cop/security/io_methods.rb +2 -2
  346. data/lib/rubocop/cop/security/json_load.rb +33 -11
  347. data/lib/rubocop/cop/security/marshal_load.rb +1 -1
  348. data/lib/rubocop/cop/security/open.rb +1 -0
  349. data/lib/rubocop/cop/security.rb +19 -0
  350. data/lib/rubocop/cop/severity.rb +12 -0
  351. data/lib/rubocop/cop/style/access_modifier_declarations.rb +47 -13
  352. data/lib/rubocop/cop/style/accessor_grouping.rb +47 -10
  353. data/lib/rubocop/cop/style/alias.rb +15 -3
  354. data/lib/rubocop/cop/style/and_or.rb +2 -1
  355. data/lib/rubocop/cop/style/arguments_forwarding.rb +49 -37
  356. data/lib/rubocop/cop/style/array_first_last.rb +13 -3
  357. data/lib/rubocop/cop/style/array_intersect.rb +136 -38
  358. data/lib/rubocop/cop/style/array_intersect_with_single_element.rb +50 -0
  359. data/lib/rubocop/cop/style/array_join.rb +4 -2
  360. data/lib/rubocop/cop/style/ascii_comments.rb +6 -3
  361. data/lib/rubocop/cop/style/attr.rb +5 -2
  362. data/lib/rubocop/cop/style/bare_percent_literals.rb +4 -3
  363. data/lib/rubocop/cop/style/begin_block.rb +3 -1
  364. data/lib/rubocop/cop/style/bitwise_predicate.rb +7 -1
  365. data/lib/rubocop/cop/style/block_delimiters.rb +43 -38
  366. data/lib/rubocop/cop/style/case_equality.rb +29 -15
  367. data/lib/rubocop/cop/style/case_like_if.rb +6 -8
  368. data/lib/rubocop/cop/style/character_literal.rb +2 -2
  369. data/lib/rubocop/cop/style/class_and_module_children.rb +135 -21
  370. data/lib/rubocop/cop/style/class_equality_comparison.rb +22 -14
  371. data/lib/rubocop/cop/style/class_methods_definitions.rb +11 -5
  372. data/lib/rubocop/cop/style/collection_compact.rb +37 -17
  373. data/lib/rubocop/cop/style/collection_methods.rb +1 -0
  374. data/lib/rubocop/cop/style/collection_querying.rb +167 -0
  375. data/lib/rubocop/cop/style/colon_method_call.rb +16 -7
  376. data/lib/rubocop/cop/style/combinable_loops.rb +7 -2
  377. data/lib/rubocop/cop/style/command_literal.rb +1 -1
  378. data/lib/rubocop/cop/style/commented_keyword.rb +12 -5
  379. data/lib/rubocop/cop/style/comparable_between.rb +78 -0
  380. data/lib/rubocop/cop/style/comparable_clamp.rb +12 -1
  381. data/lib/rubocop/cop/style/concat_array_literals.rb +8 -3
  382. data/lib/rubocop/cop/style/conditional_assignment.rb +54 -24
  383. data/lib/rubocop/cop/style/constant_visibility.rb +23 -12
  384. data/lib/rubocop/cop/style/copyright.rb +27 -12
  385. data/lib/rubocop/cop/style/data_inheritance.rb +25 -0
  386. data/lib/rubocop/cop/style/date_time.rb +4 -4
  387. data/lib/rubocop/cop/style/def_with_parentheses.rb +22 -5
  388. data/lib/rubocop/cop/style/dig_chain.rb +6 -1
  389. data/lib/rubocop/cop/style/dir_empty.rb +4 -0
  390. data/lib/rubocop/cop/style/directive_scope.rb +304 -0
  391. data/lib/rubocop/cop/style/disable_cops_within_source_code_directive.rb +122 -14
  392. data/lib/rubocop/cop/style/document_dynamic_eval_definition.rb +6 -1
  393. data/lib/rubocop/cop/style/documentation.rb +53 -6
  394. data/lib/rubocop/cop/style/documentation_method.rb +8 -12
  395. data/lib/rubocop/cop/style/double_negation.rb +3 -3
  396. data/lib/rubocop/cop/style/each_for_simple_loop.rb +1 -1
  397. data/lib/rubocop/cop/style/each_with_object.rb +4 -3
  398. data/lib/rubocop/cop/style/empty_block_parameter.rb +1 -1
  399. data/lib/rubocop/cop/style/empty_case_condition.rb +13 -4
  400. data/lib/rubocop/cop/style/empty_class_definition.rb +126 -0
  401. data/lib/rubocop/cop/style/empty_heredoc.rb +4 -0
  402. data/lib/rubocop/cop/style/empty_lambda_parameter.rb +1 -1
  403. data/lib/rubocop/cop/style/empty_literal.rb +11 -2
  404. data/lib/rubocop/cop/style/empty_method.rb +12 -8
  405. data/lib/rubocop/cop/style/empty_string_inside_interpolation.rb +110 -0
  406. data/lib/rubocop/cop/style/encoding.rb +7 -1
  407. data/lib/rubocop/cop/style/end_block.rb +3 -1
  408. data/lib/rubocop/cop/style/endless_method.rb +191 -19
  409. data/lib/rubocop/cop/style/env_home.rb +4 -0
  410. data/lib/rubocop/cop/style/eval_with_location.rb +3 -3
  411. data/lib/rubocop/cop/style/even_odd.rb +11 -1
  412. data/lib/rubocop/cop/style/exact_regexp_match.rb +8 -1
  413. data/lib/rubocop/cop/style/expand_path_arguments.rb +2 -7
  414. data/lib/rubocop/cop/style/explicit_block_argument.rb +16 -3
  415. data/lib/rubocop/cop/style/exponential_notation.rb +5 -4
  416. data/lib/rubocop/cop/style/fetch_env_var.rb +33 -7
  417. data/lib/rubocop/cop/style/file_null.rb +6 -4
  418. data/lib/rubocop/cop/style/file_open.rb +84 -0
  419. data/lib/rubocop/cop/style/file_write.rb +21 -16
  420. data/lib/rubocop/cop/style/float_division.rb +25 -17
  421. data/lib/rubocop/cop/style/for.rb +9 -0
  422. data/lib/rubocop/cop/style/format_string.rb +17 -4
  423. data/lib/rubocop/cop/style/format_string_token.rb +86 -16
  424. data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +3 -2
  425. data/lib/rubocop/cop/style/global_std_stream.rb +3 -0
  426. data/lib/rubocop/cop/style/global_vars.rb +5 -2
  427. data/lib/rubocop/cop/style/guard_clause.rb +32 -23
  428. data/lib/rubocop/cop/style/hash_as_last_array_item.rb +27 -9
  429. data/lib/rubocop/cop/style/hash_conversion.rb +28 -12
  430. data/lib/rubocop/cop/style/hash_each_methods.rb +4 -4
  431. data/lib/rubocop/cop/style/hash_fetch_chain.rb +104 -0
  432. data/lib/rubocop/cop/style/hash_lookup_method.rb +105 -0
  433. data/lib/rubocop/cop/style/hash_slice.rb +16 -0
  434. data/lib/rubocop/cop/style/hash_syntax.rb +7 -3
  435. data/lib/rubocop/cop/style/hash_transform_keys.rb +19 -9
  436. data/lib/rubocop/cop/style/hash_transform_values.rb +19 -9
  437. data/lib/rubocop/cop/style/identical_conditional_branches.rb +18 -9
  438. data/lib/rubocop/cop/style/if_inside_else.rb +25 -20
  439. data/lib/rubocop/cop/style/if_unless_modifier.rb +71 -46
  440. data/lib/rubocop/cop/style/if_unless_modifier_of_if_unless.rb +15 -19
  441. data/lib/rubocop/cop/style/if_with_boolean_literal_branches.rb +5 -2
  442. data/lib/rubocop/cop/style/if_with_semicolon.rb +16 -6
  443. data/lib/rubocop/cop/style/infinite_loop.rb +1 -1
  444. data/lib/rubocop/cop/style/inline_comment.rb +5 -2
  445. data/lib/rubocop/cop/style/inverse_methods.rb +10 -6
  446. data/lib/rubocop/cop/style/invertible_unless_condition.rb +27 -7
  447. data/lib/rubocop/cop/style/ip_addresses.rb +3 -4
  448. data/lib/rubocop/cop/style/it_assignment.rb +69 -12
  449. data/lib/rubocop/cop/style/it_block_parameter.rb +121 -0
  450. data/lib/rubocop/cop/style/keyword_arguments_merging.rb +4 -0
  451. data/lib/rubocop/cop/style/keyword_parameters_order.rb +20 -10
  452. data/lib/rubocop/cop/style/lambda.rb +12 -1
  453. data/lib/rubocop/cop/style/lambda_call.rb +26 -10
  454. data/lib/rubocop/cop/style/line_end_concatenation.rb +10 -4
  455. data/lib/rubocop/cop/style/magic_comment_format.rb +4 -4
  456. data/lib/rubocop/cop/style/map_compact_with_conditional_block.rb +11 -0
  457. data/lib/rubocop/cop/style/map_into_array.rb +5 -2
  458. data/lib/rubocop/cop/style/map_join.rb +123 -0
  459. data/lib/rubocop/cop/style/map_to_hash.rb +13 -5
  460. data/lib/rubocop/cop/style/map_to_set.rb +1 -3
  461. data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +31 -15
  462. data/lib/rubocop/cop/style/method_call_with_args_parentheses/require_parentheses.rb +15 -2
  463. data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +34 -5
  464. data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +12 -7
  465. data/lib/rubocop/cop/style/method_called_on_do_end_block.rb +2 -1
  466. data/lib/rubocop/cop/style/method_def_parentheses.rb +7 -5
  467. data/lib/rubocop/cop/style/min_max_comparison.rb +17 -6
  468. data/lib/rubocop/cop/style/missing_respond_to_missing.rb +40 -7
  469. data/lib/rubocop/cop/style/mixin_usage.rb +1 -1
  470. data/lib/rubocop/cop/style/module_function.rb +4 -2
  471. data/lib/rubocop/cop/style/module_member_existence_check.rb +110 -0
  472. data/lib/rubocop/cop/style/multiline_block_chain.rb +2 -1
  473. data/lib/rubocop/cop/style/multiline_if_modifier.rb +2 -0
  474. data/lib/rubocop/cop/style/multiline_if_then.rb +10 -4
  475. data/lib/rubocop/cop/style/multiline_memoization.rb +7 -1
  476. data/lib/rubocop/cop/style/multiline_method_signature.rb +14 -18
  477. data/lib/rubocop/cop/style/multiple_comparison.rb +33 -22
  478. data/lib/rubocop/cop/style/mutable_constant.rb +111 -12
  479. data/lib/rubocop/cop/style/negated_if_else_condition.rb +1 -2
  480. data/lib/rubocop/cop/style/negative_array_index.rb +220 -0
  481. data/lib/rubocop/cop/style/nested_modifier.rb +9 -4
  482. data/lib/rubocop/cop/style/next.rb +44 -0
  483. data/lib/rubocop/cop/style/nil_comparison.rb +41 -13
  484. data/lib/rubocop/cop/style/nil_lambda.rb +9 -1
  485. data/lib/rubocop/cop/style/non_nil_check.rb +21 -11
  486. data/lib/rubocop/cop/style/not.rb +5 -1
  487. data/lib/rubocop/cop/style/numeric_literal_prefix.rb +11 -1
  488. data/lib/rubocop/cop/style/numeric_literals.rb +3 -2
  489. data/lib/rubocop/cop/style/numeric_predicate.rb +1 -1
  490. data/lib/rubocop/cop/style/object_then.rb +1 -0
  491. data/lib/rubocop/cop/style/one_class_per_file.rb +115 -0
  492. data/lib/rubocop/cop/style/one_line_conditional.rb +22 -13
  493. data/lib/rubocop/cop/style/open_struct_use.rb +1 -1
  494. data/lib/rubocop/cop/style/operator_method_call.rb +10 -2
  495. data/lib/rubocop/cop/style/option_hash.rb +1 -1
  496. data/lib/rubocop/cop/style/optional_arguments.rb +1 -0
  497. data/lib/rubocop/cop/style/parallel_assignment.rb +58 -27
  498. data/lib/rubocop/cop/style/parentheses_around_condition.rb +6 -1
  499. data/lib/rubocop/cop/style/partition_instead_of_double_select.rb +270 -0
  500. data/lib/rubocop/cop/style/percent_literal_delimiters.rb +4 -0
  501. data/lib/rubocop/cop/style/percent_q_literals.rb +1 -1
  502. data/lib/rubocop/cop/style/perl_backrefs.rb +5 -3
  503. data/lib/rubocop/cop/style/predicate_with_kind.rb +84 -0
  504. data/lib/rubocop/cop/style/preferred_hash_methods.rb +12 -12
  505. data/lib/rubocop/cop/style/proc.rb +4 -2
  506. data/lib/rubocop/cop/style/raise_args.rb +9 -9
  507. data/lib/rubocop/cop/style/reduce_to_hash.rb +200 -0
  508. data/lib/rubocop/cop/style/redundant_argument.rb +2 -0
  509. data/lib/rubocop/cop/style/redundant_array_constructor.rb +2 -2
  510. data/lib/rubocop/cop/style/redundant_array_flatten.rb +50 -0
  511. data/lib/rubocop/cop/style/redundant_assignment.rb +12 -2
  512. data/lib/rubocop/cop/style/redundant_begin.rb +38 -3
  513. data/lib/rubocop/cop/style/redundant_condition.rb +63 -5
  514. data/lib/rubocop/cop/style/redundant_constant_base.rb +42 -6
  515. data/lib/rubocop/cop/style/redundant_current_directory_in_path.rb +26 -4
  516. data/lib/rubocop/cop/style/redundant_double_splat_hash_braces.rb +11 -3
  517. data/lib/rubocop/cop/style/redundant_each.rb +4 -5
  518. data/lib/rubocop/cop/style/redundant_exception.rb +7 -1
  519. data/lib/rubocop/cop/style/redundant_fetch_block.rb +2 -10
  520. data/lib/rubocop/cop/style/redundant_file_extension_in_require.rb +9 -0
  521. data/lib/rubocop/cop/style/redundant_filter_chain.rb +1 -1
  522. data/lib/rubocop/cop/style/redundant_format.rb +319 -0
  523. data/lib/rubocop/cop/style/redundant_freeze.rb +2 -2
  524. data/lib/rubocop/cop/style/redundant_heredoc_delimiter_quotes.rb +6 -1
  525. data/lib/rubocop/cop/style/redundant_interpolation.rb +12 -3
  526. data/lib/rubocop/cop/style/redundant_interpolation_unfreeze.rb +26 -10
  527. data/lib/rubocop/cop/style/redundant_line_continuation.rb +83 -119
  528. data/lib/rubocop/cop/style/redundant_min_max_by.rb +93 -0
  529. data/lib/rubocop/cop/style/redundant_parentheses.rb +164 -82
  530. data/lib/rubocop/cop/style/redundant_percent_q.rb +5 -3
  531. data/lib/rubocop/cop/style/redundant_regexp_argument.rb +8 -0
  532. data/lib/rubocop/cop/style/redundant_regexp_character_class.rb +6 -5
  533. data/lib/rubocop/cop/style/redundant_regexp_constructor.rb +8 -8
  534. data/lib/rubocop/cop/style/redundant_regexp_escape.rb +12 -0
  535. data/lib/rubocop/cop/style/redundant_return.rb +4 -3
  536. data/lib/rubocop/cop/style/redundant_self.rb +20 -7
  537. data/lib/rubocop/cop/style/redundant_self_assignment.rb +2 -3
  538. data/lib/rubocop/cop/style/redundant_self_assignment_branch.rb +0 -5
  539. data/lib/rubocop/cop/style/redundant_sort.rb +7 -7
  540. data/lib/rubocop/cop/style/redundant_sort_by.rb +17 -1
  541. data/lib/rubocop/cop/style/redundant_string_escape.rb +1 -2
  542. data/lib/rubocop/cop/style/redundant_struct_keyword_init.rb +133 -0
  543. data/lib/rubocop/cop/style/regexp_literal.rb +32 -3
  544. data/lib/rubocop/cop/style/rescue_modifier.rb +5 -3
  545. data/lib/rubocop/cop/style/return_nil.rb +2 -2
  546. data/lib/rubocop/cop/style/reverse_find.rb +51 -0
  547. data/lib/rubocop/cop/style/safe_navigation.rb +76 -20
  548. data/lib/rubocop/cop/style/sample.rb +11 -6
  549. data/lib/rubocop/cop/style/select_by_kind.rb +158 -0
  550. data/lib/rubocop/cop/style/select_by_range.rb +197 -0
  551. data/lib/rubocop/cop/style/select_by_regexp.rb +54 -22
  552. data/lib/rubocop/cop/style/self_assignment.rb +1 -1
  553. data/lib/rubocop/cop/style/semicolon.rb +45 -14
  554. data/lib/rubocop/cop/style/single_line_block_params.rb +2 -2
  555. data/lib/rubocop/cop/style/single_line_do_end_block.rb +22 -8
  556. data/lib/rubocop/cop/style/single_line_methods.rb +13 -8
  557. data/lib/rubocop/cop/style/sole_nested_conditional.rb +96 -104
  558. data/lib/rubocop/cop/style/special_global_vars.rb +7 -2
  559. data/lib/rubocop/cop/style/stabby_lambda_parentheses.rb +3 -1
  560. data/lib/rubocop/cop/style/static_class.rb +21 -0
  561. data/lib/rubocop/cop/style/string_concatenation.rb +31 -15
  562. data/lib/rubocop/cop/style/string_hash_keys.rb +1 -0
  563. data/lib/rubocop/cop/style/struct_inheritance.rb +38 -2
  564. data/lib/rubocop/cop/style/super_arguments.rb +4 -6
  565. data/lib/rubocop/cop/style/symbol_array.rb +1 -1
  566. data/lib/rubocop/cop/style/symbol_proc.rb +11 -9
  567. data/lib/rubocop/cop/style/tally_method.rb +181 -0
  568. data/lib/rubocop/cop/style/ternary_parentheses.rb +11 -0
  569. data/lib/rubocop/cop/style/time_now.rb +41 -0
  570. data/lib/rubocop/cop/style/top_level_method_definition.rb +3 -2
  571. data/lib/rubocop/cop/style/trailing_comma_in_arguments.rb +52 -1
  572. data/lib/rubocop/cop/style/trailing_comma_in_array_literal.rb +47 -6
  573. data/lib/rubocop/cop/style/trailing_comma_in_block_args.rb +2 -2
  574. data/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb +48 -6
  575. data/lib/rubocop/cop/style/trailing_method_end_statement.rb +1 -0
  576. data/lib/rubocop/cop/style/trailing_underscore_variable.rb +18 -19
  577. data/lib/rubocop/cop/style/trivial_accessors.rb +2 -2
  578. data/lib/rubocop/cop/style/unless_else.rb +10 -9
  579. data/lib/rubocop/cop/style/unless_logical_operators.rb +3 -3
  580. data/lib/rubocop/cop/style/while_until_do.rb +7 -0
  581. data/lib/rubocop/cop/style/while_until_modifier.rb +16 -1
  582. data/lib/rubocop/cop/style/word_array.rb +1 -0
  583. data/lib/rubocop/cop/style/yoda_condition.rb +2 -3
  584. data/lib/rubocop/cop/style/yoda_expression.rb +1 -1
  585. data/lib/rubocop/cop/style/zero_length_predicate.rb +6 -3
  586. data/lib/rubocop/cop/style.rb +311 -0
  587. data/lib/rubocop/cop/team.rb +163 -45
  588. data/lib/rubocop/cop/util.rb +7 -10
  589. data/lib/rubocop/cop/utils/format_string.rb +20 -5
  590. data/lib/rubocop/cop/variable_force/assignment.rb +7 -3
  591. data/lib/rubocop/cop/variable_force/branch.rb +30 -6
  592. data/lib/rubocop/cop/variable_force/scope.rb +1 -1
  593. data/lib/rubocop/cop/variable_force/variable.rb +28 -10
  594. data/lib/rubocop/cop/variable_force.rb +26 -9
  595. data/lib/rubocop/cops_documentation_generator.rb +49 -15
  596. data/lib/rubocop/directive_comment.rb +147 -5
  597. data/lib/rubocop/ext/regexp_node.rb +0 -1
  598. data/lib/rubocop/feature_loader.rb +0 -6
  599. data/lib/rubocop/file_patterns.rb +9 -1
  600. data/lib/rubocop/formatter/clang_style_formatter.rb +5 -2
  601. data/lib/rubocop/formatter/disabled_config_formatter.rb +57 -14
  602. data/lib/rubocop/formatter/emacs_style_formatter.rb +3 -1
  603. data/lib/rubocop/formatter/formatter_set.rb +3 -2
  604. data/lib/rubocop/formatter/fuubar_style_formatter.rb +1 -1
  605. data/lib/rubocop/formatter/github_actions_formatter.rb +6 -5
  606. data/lib/rubocop/formatter/html_formatter.rb +3 -5
  607. data/lib/rubocop/formatter/json_formatter.rb +11 -6
  608. data/lib/rubocop/formatter/junit_formatter.rb +27 -10
  609. data/lib/rubocop/formatter/markdown_formatter.rb +1 -0
  610. data/lib/rubocop/formatter/offense_count_formatter.rb +2 -3
  611. data/lib/rubocop/formatter/pacman_formatter.rb +2 -1
  612. data/lib/rubocop/formatter/sarif_formatter.rb +181 -0
  613. data/lib/rubocop/formatter/simple_text_formatter.rb +4 -5
  614. data/lib/rubocop/formatter/tap_formatter.rb +8 -3
  615. data/lib/rubocop/formatter/worst_offenders_formatter.rb +2 -3
  616. data/lib/rubocop/formatter.rb +23 -21
  617. data/lib/rubocop/lockfile.rb +18 -0
  618. data/lib/rubocop/lsp/diagnostic.rb +22 -41
  619. data/lib/rubocop/lsp/disable_comment_edits.rb +135 -0
  620. data/lib/rubocop/lsp/routes.rb +136 -33
  621. data/lib/rubocop/lsp/runtime.rb +23 -8
  622. data/lib/rubocop/lsp/server.rb +4 -2
  623. data/lib/rubocop/lsp/stdin_runner.rb +31 -18
  624. data/lib/rubocop/magic_comment.rb +55 -0
  625. data/lib/rubocop/mcp/server.rb +199 -0
  626. data/lib/rubocop/options.rb +129 -21
  627. data/lib/rubocop/path_util.rb +20 -5
  628. data/lib/rubocop/pending_cops_reporter.rb +51 -0
  629. data/lib/rubocop/plugin/configuration_integrator.rb +146 -0
  630. data/lib/rubocop/plugin/load_error.rb +26 -0
  631. data/lib/rubocop/plugin/loader.rb +100 -0
  632. data/lib/rubocop/plugin/not_supported_error.rb +29 -0
  633. data/lib/rubocop/plugin.rb +46 -0
  634. data/lib/rubocop/project_index_loader.rb +82 -0
  635. data/lib/rubocop/rake_task.rb +6 -4
  636. data/lib/rubocop/remote_config.rb +14 -12
  637. data/lib/rubocop/result_cache.rb +90 -52
  638. data/lib/rubocop/rspec/cop_helper.rb +21 -1
  639. data/lib/rubocop/rspec/expect_offense.rb +11 -7
  640. data/lib/rubocop/rspec/shared_contexts.rb +85 -3
  641. data/lib/rubocop/rspec/support.rb +4 -0
  642. data/lib/rubocop/runner.rb +294 -100
  643. data/lib/rubocop/server/cache.rb +67 -48
  644. data/lib/rubocop/server/cli.rb +2 -4
  645. data/lib/rubocop/server/client_command/base.rb +10 -0
  646. data/lib/rubocop/server/client_command/exec.rb +2 -1
  647. data/lib/rubocop/server/client_command/start.rb +11 -1
  648. data/lib/rubocop/server/core.rb +8 -0
  649. data/lib/rubocop/server.rb +14 -0
  650. data/lib/rubocop/target_finder.rb +25 -11
  651. data/lib/rubocop/target_ruby.rb +31 -14
  652. data/lib/rubocop/todo_audit.rb +111 -0
  653. data/lib/rubocop/unified_diff.rb +257 -0
  654. data/lib/rubocop/version.rb +48 -10
  655. data/lib/rubocop.rb +30 -682
  656. data/lib/ruby_lsp/rubocop/addon.rb +28 -17
  657. data/lib/ruby_lsp/rubocop/runtime_adapter.rb +99 -0
  658. metadata +116 -19
  659. data/lib/rubocop/cop/style/double_cop_disable_directive.rb +0 -46
  660. data/lib/rubocop/cop/utils/regexp_ranges.rb +0 -113
  661. data/lib/ruby_lsp/rubocop/wraps_built_in_lsp_runtime.rb +0 -50
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
@@ -146,12 +161,14 @@ AllCops:
146
161
  # Ruby version is still unresolved, RuboCop will use the oldest officially
147
162
  # supported Ruby version (currently Ruby 2.7).
148
163
  TargetRubyVersion: ~
149
- # You can specify the parser engine. There are two options available:
164
+ # RuboCop choses the parser engine automatically but you can also specify it yourself.
165
+ # These options are available:
166
+ # - `default`
150
167
  # - `parser_whitequark` ... https://github.com/whitequark/parser
151
168
  # - `parser_prism` ... https://github.com/ruby/prism (`Prism::Translation::Parser`)
152
- # By default, `parser` is used. For the `TargetRubyVersion` value, `parser` can be specified for versions `2.0` and above.
153
- # `parser_prism` can be specified for versions `3.3` and above. `parser_prism` is faster but still considered experimental.
154
- ParserEngine: parser_whitequark
169
+ # Not every parser engine can handle every `TargetRubyVersion`. `parser_whitequark`
170
+ # only works with versions 3.4 and below, `parser_prism` with versions 3.3 and above.
171
+ ParserEngine: default
155
172
  # Determines if a notification for extension libraries should be shown when
156
173
  # rubocop is run. Keys are the name of the extension, and values are an array
157
174
  # of gems in the Gemfile that the extension is suggested for, if not already
@@ -166,6 +183,7 @@ AllCops:
166
183
  rubocop-capybara: [capybara]
167
184
  rubocop-factory_bot: [factory_bot, factory_bot_rails]
168
185
  rubocop-rspec_rails: [rspec-rails]
186
+ rubocop-i18n: [i18n, gettext]
169
187
  # Enable/Disable checking the methods extended by Active Support.
170
188
  ActiveSupportExtensionsEnabled: false
171
189
  # Future version of Ruby will freeze string literals by default.
@@ -201,12 +219,12 @@ Bundler/GemComment:
201
219
  Description: 'Add a comment describing each gem.'
202
220
  Enabled: false
203
221
  VersionAdded: '0.59'
204
- VersionChanged: '0.85'
222
+ VersionChanged: '1.88'
205
223
  Include:
206
224
  - '**/*.gemfile'
207
225
  - '**/Gemfile'
208
226
  - '**/gems.rb'
209
- IgnoredGems: []
227
+ AllowedGems: []
210
228
  OnlyFor: []
211
229
 
212
230
  Bundler/GemFilename:
@@ -256,6 +274,10 @@ Bundler/OrderedGems:
256
274
  Description: >-
257
275
  Gems within groups in the Gemfile should be alphabetically sorted.
258
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
259
281
  VersionAdded: '0.46'
260
282
  VersionChanged: '0.47'
261
283
  TreatCommentsAsGroupSeparators: true
@@ -272,12 +294,20 @@ Bundler/OrderedGems:
272
294
  Gemspec/AddRuntimeDependency:
273
295
  Description: 'Prefer `add_dependency` over `add_runtime_dependency`.'
274
296
  StyleGuide: '#add_dependency_vs_add_runtime_dependency'
275
- Reference: https://github.com/rubygems/rubygems/issues/7799#issuecomment-2192720316
297
+ References:
298
+ - https://github.com/ruby/rubygems/issues/7799#issuecomment-2192720316
276
299
  Enabled: pending
277
300
  VersionAdded: '1.65'
278
301
  Include:
279
302
  - '**/*.gemspec'
280
303
 
304
+ Gemspec/AttributeAssignment:
305
+ Description: 'Use consistent style for Gemspec attributes assignment.'
306
+ Enabled: pending
307
+ VersionAdded: '1.77'
308
+ Include:
309
+ - '**/*.gemspec'
310
+
281
311
  Gemspec/DependencyVersion:
282
312
  Description: 'Requires or forbids specifying gem dependency versions.'
283
313
  Enabled: false
@@ -341,7 +371,7 @@ Gemspec/RequireMFA:
341
371
  Severity: warning
342
372
  VersionAdded: '1.23'
343
373
  VersionChanged: '1.40'
344
- Reference:
374
+ References:
345
375
  - https://guides.rubygems.org/mfa-requirement-opt-in/
346
376
  Include:
347
377
  - '**/*.gemspec'
@@ -365,10 +395,10 @@ Gemspec/RubyVersionGlobalsUsage:
365
395
  Include:
366
396
  - '**/*.gemspec'
367
397
 
368
- #################### Layout ###########################
398
+ #################### Layout ################################
369
399
 
370
400
  Layout/AccessModifierIndentation:
371
- Description: Check indentation of private/protected visibility modifiers.
401
+ Description: Checks indentation of private/protected visibility modifiers.
372
402
  StyleGuide: '#indent-public-private-protected'
373
403
  Enabled: true
374
404
  VersionAdded: '0.49'
@@ -402,6 +432,10 @@ Layout/ArgumentAlignment:
402
432
  # method_call(a,
403
433
  # b)
404
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
405
439
  SupportedStyles:
406
440
  - with_first_argument
407
441
  - with_fixed_indentation
@@ -413,7 +447,7 @@ Layout/ArrayAlignment:
413
447
  Description: >-
414
448
  Align the elements of an array literal if they span more than
415
449
  one line.
416
- StyleGuide: '#no-double-indent'
450
+ StyleGuide: '#align-multiline-arrays'
417
451
  Enabled: true
418
452
  VersionAdded: '0.49'
419
453
  VersionChanged: '0.77'
@@ -460,6 +494,7 @@ Layout/BeginEndAlignment:
460
494
  SupportedStylesAlignWith:
461
495
  - start_of_line
462
496
  - begin
497
+ # A misaligned `end` usually means a structural mistake, so this reports as a lint would.
463
498
  Severity: warning
464
499
 
465
500
  Layout/BlockAlignment:
@@ -483,12 +518,16 @@ Layout/BlockEndNewline:
483
518
  VersionAdded: '0.49'
484
519
 
485
520
  Layout/CaseIndentation:
486
- 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.'
487
522
  StyleGuide: '#indent-when-to-case'
488
523
  Enabled: true
489
524
  VersionAdded: '0.49'
490
525
  VersionChanged: '1.16'
491
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
492
531
  SupportedStyles:
493
532
  - case
494
533
  - end
@@ -504,7 +543,7 @@ Layout/ClassStructure:
504
543
  Enabled: false
505
544
  SafeAutoCorrect: false
506
545
  VersionAdded: '0.52'
507
- VersionChanged: '1.53'
546
+ VersionChanged: '1.89'
508
547
  Categories:
509
548
  module_inclusion:
510
549
  - include
@@ -517,6 +556,7 @@ Layout/ClassStructure:
517
556
  - initializer
518
557
  - public_methods
519
558
  - protected_methods
559
+ - private_class_methods
520
560
  - private_methods
521
561
 
522
562
  Layout/ClosingHeredocIndentation:
@@ -528,15 +568,22 @@ Layout/ClosingParenthesisIndentation:
528
568
  Description: 'Checks the indentation of hanging closing parentheses.'
529
569
  Enabled: true
530
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: ~
531
575
 
532
576
  Layout/CommentIndentation:
533
- Description: 'Indentation of comments.'
577
+ Description: 'Checks the indentation of comments.'
534
578
  Enabled: true
579
+ VersionAdded: '0.49'
580
+ VersionChanged: '1.86'
535
581
  # When true, allows comments to have extra indentation if that aligns them
536
582
  # with a comment on the preceding line.
537
583
  AllowForAlignment: false
538
- VersionAdded: '0.49'
539
- 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: ~
540
587
 
541
588
  Layout/ConditionPosition:
542
589
  Description: >-
@@ -559,6 +606,7 @@ Layout/DefEndAlignment:
559
606
  SupportedStylesAlignWith:
560
607
  - start_of_line
561
608
  - def
609
+ # A misaligned `end` usually means a structural mistake, so this reports as a lint would.
562
610
  Severity: warning
563
611
 
564
612
  Layout/DotPosition:
@@ -588,6 +636,10 @@ Layout/EmptyComment:
588
636
  Layout/EmptyLineAfterGuardClause:
589
637
  Description: 'Add empty line after guard clause.'
590
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
591
643
  VersionAdded: '0.56'
592
644
  VersionChanged: '0.59'
593
645
 
@@ -596,13 +648,19 @@ Layout/EmptyLineAfterMagicComment:
596
648
  StyleGuide: '#separate-magic-comments-from-code'
597
649
  Enabled: true
598
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
599
657
 
600
658
  Layout/EmptyLineAfterMultilineCondition:
601
659
  Description: 'Enforces empty line after multiline condition.'
602
660
  # This is disabled, because this style is not very common in practice.
603
661
  Enabled: false
604
662
  VersionAdded: '0.90'
605
- Reference:
663
+ References:
606
664
  - https://github.com/airbnb/ruby#multiline-if-newline
607
665
 
608
666
  Layout/EmptyLineBetweenDefs:
@@ -628,6 +686,12 @@ Layout/EmptyLines:
628
686
  Enabled: true
629
687
  VersionAdded: '0.49'
630
688
 
689
+ Layout/EmptyLinesAfterModuleInclusion:
690
+ Description: 'Keeps track of empty lines after module inclusion methods.'
691
+ StyleGuide: '#empty-lines-after-module-inclusion'
692
+ Enabled: pending
693
+ VersionAdded: '1.79'
694
+
631
695
  Layout/EmptyLinesAroundAccessModifier:
632
696
  Description: "Keep blank lines around access modifiers."
633
697
  StyleGuide: '#empty-lines-around-access-modifier'
@@ -637,7 +701,7 @@ Layout/EmptyLinesAroundAccessModifier:
637
701
  SupportedStyles:
638
702
  - around
639
703
  - only_before
640
- Reference:
704
+ References:
641
705
  # A reference to `EnforcedStyle: only_before`.
642
706
  - https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#follow-the-coding-conventions
643
707
 
@@ -726,10 +790,15 @@ Layout/EndAlignment:
726
790
  # The value `start_of_line` means that `end` should be aligned with the start
727
791
  # of the line which the matching keyword appears on.
728
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
729
797
  SupportedStylesAlignWith:
730
798
  - keyword
731
799
  - variable
732
800
  - start_of_line
801
+ # A misaligned `end` usually means a structural mistake, so this reports as a lint would.
733
802
  Severity: warning
734
803
 
735
804
  Layout/EndOfLine:
@@ -805,6 +874,10 @@ Layout/FirstArrayElementIndentation:
805
874
  # The value `align_brackets` means that the indentation of the first element
806
875
  # shall always be relative to the position of the opening bracket.
807
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
808
881
  SupportedStyles:
809
882
  - special_inside_parentheses
810
883
  - consistent
@@ -819,6 +892,7 @@ Layout/FirstArrayElementLineBreak:
819
892
  multi-line array.
820
893
  Enabled: false
821
894
  VersionAdded: '0.49'
895
+ AllowImplicitArrayLiterals: false
822
896
  AllowMultilineFinalElement: false
823
897
 
824
898
  Layout/FirstHashElementIndentation:
@@ -838,6 +912,10 @@ Layout/FirstHashElementIndentation:
838
912
  # The value `align_braces` means that the indentation of the first key shall
839
913
  # always be relative to the position of the opening brace.
840
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
841
919
  SupportedStyles:
842
920
  - special_inside_parentheses
843
921
  - consistent
@@ -891,9 +969,9 @@ Layout/HashAlignment:
891
969
  Align the elements of a hash literal if they span more than
892
970
  one line.
893
971
  Enabled: true
894
- AllowMultipleStyles: true
895
972
  VersionAdded: '0.49'
896
973
  VersionChanged: '1.16'
974
+ AllowMultipleStyles: true
897
975
  # Alignment of entries using hash rocket as separator. Valid values are:
898
976
  #
899
977
  # key - left alignment of keys
@@ -968,8 +1046,8 @@ Layout/HeredocArgumentClosingParenthesis:
968
1046
  Description: >-
969
1047
  Checks for the placement of the closing parenthesis in a
970
1048
  method call that passes a HEREDOC string as an argument.
971
- Enabled: false
972
1049
  StyleGuide: '#heredoc-argument-closing-parentheses'
1050
+ Enabled: false
973
1051
  VersionAdded: '0.68'
974
1052
 
975
1053
  Layout/HeredocIndentation:
@@ -994,7 +1072,7 @@ Layout/IndentationConsistency:
994
1072
  SupportedStyles:
995
1073
  - normal
996
1074
  - indented_internal_methods
997
- Reference:
1075
+ References:
998
1076
  # A reference to `EnforcedStyle: indented_internal_methods`.
999
1077
  - https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#follow-the-coding-conventions
1000
1078
 
@@ -1021,6 +1099,15 @@ Layout/IndentationWidth:
1021
1099
  VersionAdded: '0.49'
1022
1100
  # Number of spaces for each indentation level.
1023
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
1024
1111
  AllowedPatterns: []
1025
1112
 
1026
1113
  Layout/InitialIndentation:
@@ -1039,9 +1126,10 @@ Layout/LeadingCommentSpace:
1039
1126
  AllowGemfileRubyComment: false
1040
1127
  AllowRBSInlineAnnotation: false
1041
1128
  AllowSteepAnnotation: false
1129
+ AllowYARDCommentBlockSeparator: false
1042
1130
 
1043
1131
  Layout/LeadingEmptyLines:
1044
- Description: Check for unnecessary blank lines at the beginning of a file.
1132
+ Description: Checks for unnecessary blank lines at the beginning of a file.
1045
1133
  Enabled: true
1046
1134
  VersionAdded: '0.57'
1047
1135
  VersionChanged: '0.77'
@@ -1086,18 +1174,22 @@ Layout/LineLength:
1086
1174
  StyleGuide: '#max-line-length'
1087
1175
  Enabled: true
1088
1176
  VersionAdded: '0.25'
1089
- VersionChanged: '1.69'
1177
+ VersionChanged: '1.82'
1090
1178
  Max: 120
1091
1179
  AllowHeredoc: true
1092
1180
  # To make it possible to copy or click on URIs in the code, we allow lines
1093
1181
  # containing a URI to be longer than Max.
1094
1182
  AllowURI: true
1183
+ AllowQualifiedName: true
1095
1184
  URISchemes:
1096
1185
  - http
1097
1186
  - https
1098
- # 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
1099
1191
  # directives like '# rubocop: enable ...' when calculating a line's length.
1100
- IgnoreCopDirectives: true
1192
+ AllowCopDirectives: true
1101
1193
  # The AllowedPatterns option is a list of !ruby/regexp and/or string
1102
1194
  # elements. Strings will be converted to Regexp objects. A line that matches
1103
1195
  # any regular expression listed in this option will be ignored by LineLength.
@@ -1130,7 +1222,7 @@ Layout/MultilineArrayLineBreaks:
1130
1222
  AllowMultilineFinalElement: false
1131
1223
 
1132
1224
  Layout/MultilineAssignmentLayout:
1133
- Description: 'Check for a newline after the assignment operator in multi-line assignments.'
1225
+ Description: 'Checks for a newline after the assignment operator in multi-line assignments.'
1134
1226
  StyleGuide: '#indent-conditional-assignment'
1135
1227
  Enabled: false
1136
1228
  VersionAdded: '0.49'
@@ -1211,6 +1303,10 @@ Layout/MultilineMethodCallIndentation:
1211
1303
  Enabled: true
1212
1304
  VersionAdded: '0.49'
1213
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
1214
1310
  SupportedStyles:
1215
1311
  - aligned
1216
1312
  - indented
@@ -1250,6 +1346,10 @@ Layout/MultilineOperationIndentation:
1250
1346
  Enabled: true
1251
1347
  VersionAdded: '0.49'
1252
1348
  EnforcedStyle: aligned
1349
+ # Expected to become the default in the next major release.
1350
+ # Same preference as `MultilineMethodCallIndentation`.
1351
+ Preview:
1352
+ EnforcedStyle: indented
1253
1353
  SupportedStyles:
1254
1354
  - aligned
1255
1355
  - indented
@@ -1279,6 +1379,10 @@ Layout/ParameterAlignment:
1279
1379
  # def method_foo(a,
1280
1380
  # b)
1281
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
1282
1386
  SupportedStyles:
1283
1387
  - with_first_parameter
1284
1388
  - with_fixed_indentation
@@ -1373,6 +1477,7 @@ Layout/SpaceAroundOperators:
1373
1477
  StyleGuide: '#spaces-operators'
1374
1478
  Enabled: true
1375
1479
  VersionAdded: '0.49'
1480
+ VersionChanged: '1.90'
1376
1481
  # When `true`, allows most uses of extra spacing if the intent is to align
1377
1482
  # with an operator on the previous or next line, not counting empty lines
1378
1483
  # or comment lines.
@@ -1392,6 +1497,7 @@ Layout/SpaceBeforeBlockBraces:
1392
1497
  before it.
1393
1498
  Enabled: true
1394
1499
  VersionAdded: '0.49'
1500
+ VersionChanged: '0.52'
1395
1501
  EnforcedStyle: space
1396
1502
  SupportedStyles:
1397
1503
  - space
@@ -1400,7 +1506,6 @@ Layout/SpaceBeforeBlockBraces:
1400
1506
  SupportedStylesForEmptyBraces:
1401
1507
  - space
1402
1508
  - no_space
1403
- VersionChanged: '0.52'
1404
1509
 
1405
1510
  Layout/SpaceBeforeBrackets:
1406
1511
  Description: 'Checks for receiver with a space before the opening brackets.'
@@ -1581,7 +1686,7 @@ Lint/AmbiguousBlockAssociation:
1581
1686
  parentheses.
1582
1687
  Enabled: true
1583
1688
  VersionAdded: '0.48'
1584
- VersionChanged: '1.13'
1689
+ VersionChanged: '1.89'
1585
1690
  AllowedMethods: []
1586
1691
  AllowedPatterns: []
1587
1692
 
@@ -1616,6 +1721,13 @@ Lint/AmbiguousRegexpLiteral:
1616
1721
  VersionAdded: '0.17'
1617
1722
  VersionChanged: '0.83'
1618
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
+
1619
1731
  Lint/ArrayLiteralInRegexp:
1620
1732
  Description: 'Checks for an array literal interpolated inside a regexp.'
1621
1733
  Enabled: pending
@@ -1644,7 +1756,7 @@ Lint/BinaryOperatorWithIdenticalOperands:
1644
1756
  VersionChanged: '1.69'
1645
1757
 
1646
1758
  Lint/BooleanSymbol:
1647
- Description: 'Check for `:true` and `:false` symbols.'
1759
+ Description: 'Checks for `:true` and `:false` symbols.'
1648
1760
  Enabled: true
1649
1761
  SafeAutoCorrect: false
1650
1762
  VersionAdded: '0.50'
@@ -1675,9 +1787,11 @@ Lint/ConstantReassignment:
1675
1787
  Description: 'Checks for constant reassignments.'
1676
1788
  Enabled: pending
1677
1789
  VersionAdded: '1.70'
1790
+ VersionChanged: '1.87'
1678
1791
 
1679
1792
  Lint/ConstantResolution:
1680
- Description: 'Check that constants are fully qualified with `::`.'
1793
+ Description: 'Checks that constants are fully qualified with `::`.'
1794
+ VersionChanged: '1.89'
1681
1795
  Enabled: false
1682
1796
  VersionAdded: '0.86'
1683
1797
  # Restrict this cop to only looking at certain names
@@ -1685,8 +1799,19 @@ Lint/ConstantResolution:
1685
1799
  # Restrict this cop from only looking at certain names
1686
1800
  Ignore: []
1687
1801
 
1802
+ Lint/CopDirectiveSyntax:
1803
+ Description: 'Checks that `# rubocop:` directives are strictly formatted.'
1804
+ Enabled: true
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'
1812
+
1688
1813
  Lint/Debugger:
1689
- Description: 'Check for debugger calls.'
1814
+ Description: 'Checks for debugger calls.'
1690
1815
  Enabled: true
1691
1816
  VersionAdded: '0.14'
1692
1817
  VersionChanged: '1.63'
@@ -1737,7 +1862,7 @@ Lint/Debugger:
1737
1862
  - debug/start
1738
1863
 
1739
1864
  Lint/DeprecatedClassMethods:
1740
- Description: 'Check for deprecated class method calls.'
1865
+ Description: 'Checks for deprecated class method calls.'
1741
1866
  Enabled: true
1742
1867
  VersionAdded: '0.19'
1743
1868
 
@@ -1784,8 +1909,17 @@ Lint/DeprecatedOpenSSLConstant:
1784
1909
  Enabled: true
1785
1910
  VersionAdded: '0.84'
1786
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
+
1787
1920
  Lint/DisjunctiveAssignmentInConstructor:
1788
1921
  Description: 'In constructor, plain assignment is preferred over disjunctive.'
1922
+ StyleGuide: '#disjunctive-assignment-in-constructor'
1789
1923
  Enabled: true
1790
1924
  Safe: false
1791
1925
  VersionAdded: '0.62'
@@ -1811,13 +1945,13 @@ Lint/DuplicateElsifCondition:
1811
1945
  VersionAdded: '0.88'
1812
1946
 
1813
1947
  Lint/DuplicateHashKey:
1814
- Description: 'Check for duplicate keys in hash literals.'
1948
+ Description: 'Checks for duplicate keys in hash literals.'
1815
1949
  Enabled: true
1816
1950
  VersionAdded: '0.34'
1817
1951
  VersionChanged: '0.77'
1818
1952
 
1819
1953
  Lint/DuplicateMagicComment:
1820
- Description: 'Check for duplicated magic comments.'
1954
+ Description: 'Checks for duplicated magic comments.'
1821
1955
  Enabled: pending
1822
1956
  VersionAdded: '1.37'
1823
1957
 
@@ -1827,9 +1961,25 @@ Lint/DuplicateMatchPattern:
1827
1961
  VersionAdded: '1.50'
1828
1962
 
1829
1963
  Lint/DuplicateMethods:
1830
- Description: 'Check for duplicate method definitions.'
1964
+ Description: 'Checks for duplicate method definitions.'
1831
1965
  Enabled: true
1832
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: []
1833
1983
 
1834
1984
  Lint/DuplicateRegexpCharacterClassElement:
1835
1985
  Description: 'Checks for duplicate elements in Regexp character classes.'
@@ -1837,7 +1987,7 @@ Lint/DuplicateRegexpCharacterClassElement:
1837
1987
  VersionAdded: '1.1'
1838
1988
 
1839
1989
  Lint/DuplicateRequire:
1840
- Description: 'Check for duplicate `require`s and `require_relative`s.'
1990
+ Description: 'Checks for duplicate `require`s and `require_relative`s.'
1841
1991
  Enabled: true
1842
1992
  SafeAutoCorrect: false
1843
1993
  VersionAdded: '0.90'
@@ -1854,12 +2004,12 @@ Lint/DuplicateSetElement:
1854
2004
  VersionAdded: '1.67'
1855
2005
 
1856
2006
  Lint/EachWithObjectArgument:
1857
- Description: 'Check for immutable argument given to each_with_object.'
2007
+ Description: 'Checks for immutable argument given to each_with_object.'
1858
2008
  Enabled: true
1859
2009
  VersionAdded: '0.31'
1860
2010
 
1861
2011
  Lint/ElseLayout:
1862
- Description: 'Check for odd code arrangement in an else block.'
2012
+ Description: 'Checks for odd code arrangement in an else block.'
1863
2013
  Enabled: true
1864
2014
  VersionAdded: '0.17'
1865
2015
  VersionChanged: '1.2'
@@ -1882,10 +2032,9 @@ Lint/EmptyConditionalBody:
1882
2032
  Description: 'Checks for the presence of `if`, `elsif` and `unless` branches without a body.'
1883
2033
  Enabled: true
1884
2034
  AutoCorrect: contextual
1885
- SafeAutoCorrect: false
1886
- AllowComments: true
1887
2035
  VersionAdded: '0.89'
1888
- VersionChanged: '1.61'
2036
+ VersionChanged: '1.73'
2037
+ AllowComments: true
1889
2038
 
1890
2039
  Lint/EmptyEnsure:
1891
2040
  Description: 'Checks for empty ensure block.'
@@ -1916,14 +2065,14 @@ Lint/EmptyInterpolation:
1916
2065
  Enabled: true
1917
2066
  AutoCorrect: contextual
1918
2067
  VersionAdded: '0.20'
1919
- VersionChanged: '1.61'
2068
+ VersionChanged: '1.76'
1920
2069
 
1921
2070
  Lint/EmptyWhen:
1922
2071
  Description: 'Checks for `when` branches with empty bodies.'
1923
2072
  Enabled: true
1924
- AllowComments: true
1925
2073
  VersionAdded: '0.45'
1926
2074
  VersionChanged: '0.83'
2075
+ AllowComments: true
1927
2076
 
1928
2077
  Lint/EnsureReturn:
1929
2078
  Description: 'Do not use return in an ensure block.'
@@ -1957,7 +2106,7 @@ Lint/FloatOutOfRange:
1957
2106
  VersionAdded: '0.36'
1958
2107
 
1959
2108
  Lint/FormatParameterMismatch:
1960
- 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`/`%`.'
1961
2110
  Enabled: true
1962
2111
  VersionAdded: '0.33'
1963
2112
 
@@ -1977,14 +2126,14 @@ Lint/HeredocMethodCallPosition:
1977
2126
  Description: >-
1978
2127
  Checks for the ordering of a method call where
1979
2128
  the receiver of the call is a HEREDOC.
1980
- Enabled: false
1981
2129
  StyleGuide: '#heredoc-method-calls'
2130
+ Enabled: false
1982
2131
  VersionAdded: '0.68'
1983
2132
 
1984
2133
  Lint/IdentityComparison:
1985
2134
  Description: 'Prefer `equal?` over `==` when comparing `object_id`.'
1986
- Enabled: true
1987
2135
  StyleGuide: '#identity-comparison'
2136
+ Enabled: true
1988
2137
  VersionAdded: '0.91'
1989
2138
 
1990
2139
  Lint/ImplicitStringConcatenation:
@@ -2013,7 +2162,7 @@ Lint/InheritException:
2013
2162
  Enabled: true
2014
2163
  SafeAutoCorrect: false
2015
2164
  VersionAdded: '0.41'
2016
- VersionChanged: '1.26'
2165
+ VersionChanged: '1.89'
2017
2166
  # The default base class in favour of `Exception`.
2018
2167
  EnforcedStyle: standard_error
2019
2168
  SupportedStyles:
@@ -2029,7 +2178,8 @@ Lint/InterpolationCheck:
2029
2178
 
2030
2179
  Lint/ItWithoutArgumentsInBlock:
2031
2180
  Description: 'Checks uses of `it` calls without arguments in block.'
2032
- Reference: 'https://bugs.ruby-lang.org/issues/18980'
2181
+ References:
2182
+ - 'https://bugs.ruby-lang.org/issues/18980'
2033
2183
  Enabled: pending
2034
2184
  VersionAdded: '1.59'
2035
2185
 
@@ -2041,6 +2191,7 @@ Lint/LambdaWithoutLiteralBlock:
2041
2191
  Lint/LiteralAsCondition:
2042
2192
  Description: 'Checks of literals used in conditions.'
2043
2193
  Enabled: true
2194
+ AutoCorrect: contextual
2044
2195
  VersionAdded: '0.51'
2045
2196
 
2046
2197
  Lint/LiteralAssignmentInCondition:
@@ -2064,10 +2215,18 @@ Lint/Loop:
2064
2215
  VersionChanged: '1.3'
2065
2216
  Safe: false
2066
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
+
2067
2225
  Lint/MissingCopEnableDirective:
2068
2226
  Description: 'Checks for a `# rubocop:enable` after `# rubocop:disable`.'
2069
2227
  Enabled: true
2070
2228
  VersionAdded: '0.52'
2229
+ VersionChanged: '1.90'
2071
2230
  # Maximum number of consecutive lines the cop can be disabled for.
2072
2231
  # 0 allows only single-line disables
2073
2232
  # 1 would mean the maximum allowed is the following:
@@ -2075,16 +2234,16 @@ Lint/MissingCopEnableDirective:
2075
2234
  # a = 1
2076
2235
  # # rubocop:enable SomeCop
2077
2236
  # .inf for any size
2078
- MaximumRangeSize: .inf
2237
+ MaxRangeSize: .inf
2079
2238
 
2080
2239
  Lint/MissingSuper:
2081
2240
  Description: >-
2082
2241
  Checks for the presence of constructors and lifecycle callbacks
2083
2242
  without calls to `super`.
2084
2243
  Enabled: true
2085
- AllowedParentClasses: []
2086
2244
  VersionAdded: '0.89'
2087
- VersionChanged: '1.4'
2245
+ VersionChanged: '1.89'
2246
+ AllowedParentClasses: []
2088
2247
 
2089
2248
  Lint/MixedCaseRange:
2090
2249
  Description: 'Checks for mixed-case character ranges since they include likely unintended characters.'
@@ -2094,6 +2253,7 @@ Lint/MixedCaseRange:
2094
2253
 
2095
2254
  Lint/MixedRegexpCaptureTypes:
2096
2255
  Description: 'Do not mix named captures and numbered captures in a Regexp literal.'
2256
+ StyleGuide: '#do-not-mix-named-and-numbered-captures'
2097
2257
  Enabled: true
2098
2258
  VersionAdded: '0.85'
2099
2259
 
@@ -2103,6 +2263,16 @@ Lint/MultipleComparison:
2103
2263
  VersionAdded: '0.47'
2104
2264
  VersionChanged: '1.1'
2105
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
+
2106
2276
  Lint/NestedMethodDefinition:
2107
2277
  Description: 'Do not use nested method definitions.'
2108
2278
  StyleGuide: '#no-nested-methods'
@@ -2150,11 +2320,11 @@ Lint/NumberConversion:
2150
2320
  Description: 'Checks unsafe usage of number conversion methods.'
2151
2321
  Enabled: false
2152
2322
  VersionAdded: '0.53'
2153
- VersionChanged: '1.1'
2323
+ VersionChanged: '1.88'
2154
2324
  SafeAutoCorrect: false
2155
2325
  AllowedMethods: []
2156
2326
  AllowedPatterns: []
2157
- IgnoredClasses:
2327
+ AllowedClasses:
2158
2328
  - Time
2159
2329
  - DateTime
2160
2330
 
@@ -2166,7 +2336,9 @@ Lint/NumberedParameterAssignment:
2166
2336
  Lint/NumericOperationWithConstantResult:
2167
2337
  Description: 'Checks for numeric operations with constant results.'
2168
2338
  Enabled: pending
2339
+ SafeAutoCorrect: false
2169
2340
  VersionAdded: '1.69'
2341
+ VersionChanged: '1.88'
2170
2342
 
2171
2343
  Lint/OrAssignmentToConstant:
2172
2344
  Description: 'Checks unintended or-assignment to constant.'
@@ -2179,7 +2351,7 @@ Lint/OrderedMagicComments:
2179
2351
  Enabled: true
2180
2352
  SafeAutoCorrect: false
2181
2353
  VersionAdded: '0.53'
2182
- VersionChanged: '1.37'
2354
+ VersionChanged: '1.91'
2183
2355
 
2184
2356
  Lint/OutOfRangeRegexpRef:
2185
2357
  Description: 'Checks for out of range reference for Regexp because it always returns nil.'
@@ -2238,6 +2410,7 @@ Lint/RedundantCopEnableDirective:
2238
2410
  Description: Checks for rubocop:enable comments that can be removed.
2239
2411
  Enabled: true
2240
2412
  VersionAdded: '0.76'
2413
+ VersionChanged: '1.90'
2241
2414
 
2242
2415
  Lint/RedundantDirGlobSort:
2243
2416
  Description: 'Checks for redundant `sort` method to `Dir.glob` and `Dir[]`.'
@@ -2254,14 +2427,14 @@ Lint/RedundantRegexpQuantifiers:
2254
2427
  Lint/RedundantRequireStatement:
2255
2428
  Description: 'Checks for unnecessary `require` statement.'
2256
2429
  Enabled: true
2257
- SafeAutoCorrect: false
2258
2430
  VersionAdded: '0.76'
2259
- VersionChanged: '1.57'
2431
+ VersionChanged: '1.73'
2260
2432
 
2261
2433
  Lint/RedundantSafeNavigation:
2262
2434
  Description: 'Checks for redundant safe navigation calls.'
2263
2435
  Enabled: true
2264
2436
  VersionAdded: '0.93'
2437
+ VersionChanged: '1.79'
2265
2438
  AllowedMethods:
2266
2439
  - instance_of?
2267
2440
  - kind_of?
@@ -2269,6 +2442,12 @@ Lint/RedundantSafeNavigation:
2269
2442
  - eql?
2270
2443
  - respond_to?
2271
2444
  - equal?
2445
+ InferNonNilReceiver: false
2446
+ AdditionalNilMethods:
2447
+ - present?
2448
+ - blank?
2449
+ - try
2450
+ - try!
2272
2451
  Safe: false
2273
2452
 
2274
2453
  Lint/RedundantSplatExpansion:
@@ -2285,6 +2464,11 @@ Lint/RedundantStringCoercion:
2285
2464
  VersionAdded: '0.19'
2286
2465
  VersionChanged: '0.77'
2287
2466
 
2467
+ Lint/RedundantTypeConversion:
2468
+ Description: 'Checks for redundantly converting a literal to the same type.'
2469
+ Enabled: pending
2470
+ VersionAdded: '1.72'
2471
+
2288
2472
  Lint/RedundantWithIndex:
2289
2473
  Description: 'Checks for redundant `with_index`.'
2290
2474
  Enabled: true
@@ -2293,13 +2477,16 @@ Lint/RedundantWithIndex:
2293
2477
  Lint/RedundantWithObject:
2294
2478
  Description: 'Checks for redundant `with_object`.'
2295
2479
  Enabled: true
2480
+ SafeAutoCorrect: false
2296
2481
  VersionAdded: '0.51'
2482
+ VersionChanged: '1.88'
2297
2483
 
2298
2484
  Lint/RefinementImportMethods:
2299
2485
  Description: 'Use `Refinement#import_methods` when using `include` or `prepend` in `refine` block.'
2300
2486
  Enabled: pending
2301
2487
  SafeAutoCorrect: false
2302
2488
  VersionAdded: '1.27'
2489
+ VersionChanged: '1.88'
2303
2490
 
2304
2491
  Lint/RegexpAsCondition:
2305
2492
  Description: >-
@@ -2346,8 +2533,9 @@ Lint/ReturnInVoidContext:
2346
2533
  Lint/SafeNavigationChain:
2347
2534
  Description: 'Do not chain ordinary method call after safe navigation operator.'
2348
2535
  Enabled: true
2536
+ SafeAutoCorrect: false
2349
2537
  VersionAdded: '0.47'
2350
- VersionChanged: '0.77'
2538
+ VersionChanged: '1.89'
2351
2539
  AllowedMethods:
2352
2540
  - present?
2353
2541
  - blank?
@@ -2362,8 +2550,9 @@ Lint/SafeNavigationConsistency:
2362
2550
  consistent and appropriate safe navigation, without excess or deficiency,
2363
2551
  is used for all method calls on the same object.
2364
2552
  Enabled: true
2553
+ SafeAutoCorrect: false
2365
2554
  VersionAdded: '0.55'
2366
- VersionChanged: '0.77'
2555
+ VersionChanged: '1.85'
2367
2556
  AllowedMethods:
2368
2557
  - present?
2369
2558
  - blank?
@@ -2387,6 +2576,7 @@ Lint/SelfAssignment:
2387
2576
  Description: 'Checks for self-assignments.'
2388
2577
  Enabled: true
2389
2578
  VersionAdded: '0.89'
2579
+ AllowRBSInlineAnnotation: false
2390
2580
 
2391
2581
  Lint/SendWithMixinArgument:
2392
2582
  Description: 'Checks for `send` method when using mixin.'
@@ -2403,6 +2593,7 @@ Lint/ShadowedException:
2403
2593
  Description: >-
2404
2594
  Avoid rescuing a higher level exception
2405
2595
  before a lower level exception.
2596
+ StyleGuide: '#exception-ordering'
2406
2597
  Enabled: true
2407
2598
  VersionAdded: '0.41'
2408
2599
 
@@ -2410,8 +2601,9 @@ Lint/ShadowingOuterLocalVariable:
2410
2601
  Description: >-
2411
2602
  Do not use the same name as outer local variable
2412
2603
  for block arguments or block local variables.
2413
- Enabled: true
2604
+ Enabled: false
2414
2605
  VersionAdded: '0.9'
2606
+ VersionChanged: '1.76'
2415
2607
 
2416
2608
  Lint/SharedMutableDefault:
2417
2609
  Description: 'Checks for mutable literals used as default arguments during Hash initialization.'
@@ -2424,14 +2616,27 @@ Lint/StructNewOverride:
2424
2616
  Enabled: true
2425
2617
  VersionAdded: '0.81'
2426
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
+
2427
2626
  Lint/SuppressedException:
2428
2627
  Description: "Don't suppress exceptions."
2429
2628
  StyleGuide: '#dont-hide-exceptions'
2430
2629
  Enabled: true
2431
- AllowComments: true
2432
- AllowNil: true
2433
2630
  VersionAdded: '0.9'
2434
2631
  VersionChanged: '1.12'
2632
+ AllowComments: true
2633
+ AllowNil: true
2634
+
2635
+ Lint/SuppressedExceptionInNumberConversion:
2636
+ Description: 'Checks for cases where exceptions unrelated to the numeric constructors may be unintentionally swallowed.'
2637
+ Enabled: pending
2638
+ SafeAutoCorrect: false
2639
+ VersionAdded: '1.72'
2435
2640
 
2436
2641
  Lint/SymbolConversion:
2437
2642
  Description: 'Checks for unnecessary symbol conversions.'
@@ -2508,6 +2713,7 @@ Lint/UnexpectedBlockArity:
2508
2713
 
2509
2714
  Lint/UnifiedInteger:
2510
2715
  Description: 'Use Integer instead of Fixnum or Bignum.'
2716
+ StyleGuide: '#integer-type-checking'
2511
2717
  Enabled: true
2512
2718
  VersionAdded: '0.43'
2513
2719
 
@@ -2518,7 +2724,7 @@ Lint/UnmodifiedReduceAccumulator:
2518
2724
  VersionChanged: '1.5'
2519
2725
 
2520
2726
  Lint/UnreachableCode:
2521
- Description: 'Unreachable code.'
2727
+ Description: 'Checks for unreachable code.'
2522
2728
  Enabled: true
2523
2729
  VersionAdded: '0.9'
2524
2730
 
@@ -2532,6 +2738,11 @@ Lint/UnreachableLoop:
2532
2738
  # eg. `exactly(2).times`
2533
2739
  - !ruby/regexp /(exactly|at_least|at_most)\(\d+\)\.times/
2534
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
+
2535
2746
  Lint/UnusedBlockArgument:
2536
2747
  Description: 'Checks for unused block arguments.'
2537
2748
  StyleGuide: '#underscore-unused-vars'
@@ -2555,6 +2766,21 @@ Lint/UnusedMethodArgument:
2555
2766
  NotImplementedExceptions:
2556
2767
  - NotImplementedError
2557
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
+
2558
2784
  Lint/UriEscapeUnescape:
2559
2785
  Description: >-
2560
2786
  `URI.escape` method is obsolete and should not be used. Instead, use
@@ -2588,6 +2814,19 @@ Lint/UselessAssignment:
2588
2814
  VersionAdded: '0.11'
2589
2815
  VersionChanged: '1.66'
2590
2816
 
2817
+ Lint/UselessConstantScoping:
2818
+ Description: 'Checks for useless constant scoping.'
2819
+ Enabled: pending
2820
+ VersionAdded: '1.72'
2821
+ VersionChanged: '1.90'
2822
+
2823
+ Lint/UselessDefaultValueArgument:
2824
+ Description: 'Checks for usage of `fetch` or `Array.new` with default value argument and block.'
2825
+ Enabled: pending
2826
+ VersionAdded: '1.76'
2827
+ Safe: false
2828
+ AllowedReceivers: []
2829
+
2591
2830
  Lint/UselessDefined:
2592
2831
  Description: 'Checks for calls to `defined?` with strings and symbols. The result of such a call will always be truthy.'
2593
2832
  Enabled: pending
@@ -2612,6 +2851,14 @@ Lint/UselessNumericOperation:
2612
2851
  Enabled: pending
2613
2852
  VersionAdded: '1.66'
2614
2853
 
2854
+ Lint/UselessOr:
2855
+ Description: 'Checks for useless OR expressions.'
2856
+ Enabled: pending
2857
+ SafeAutoCorrect: false
2858
+ AutoCorrect: contextual
2859
+ VersionAdded: '1.76'
2860
+ VersionChanged: '1.82'
2861
+
2615
2862
  Lint/UselessRescue:
2616
2863
  Description: 'Checks for useless `rescue`s.'
2617
2864
  Enabled: pending
@@ -2638,7 +2885,7 @@ Lint/UselessTimes:
2638
2885
  VersionChanged: '1.61'
2639
2886
 
2640
2887
  Lint/Void:
2641
- Description: 'Possible use of operator/literal/variable in void context.'
2888
+ Description: 'Checks for operators, literals, lambdas, and procs used in void context.'
2642
2889
  Enabled: true
2643
2890
  AutoCorrect: contextual
2644
2891
  VersionAdded: '0.9'
@@ -2648,13 +2895,15 @@ Lint/Void:
2648
2895
  #################### Metrics ###############################
2649
2896
 
2650
2897
  Metrics/AbcSize:
2651
- Description: >-
2652
- A calculated magnitude based on number of assignments,
2653
- branches, and conditions.
2654
- Reference:
2655
- - http://c2.com/cgi/wiki?AbcMetric
2898
+ Description: 'Checks that the ABC size of methods is not higher than the configured maximum.'
2899
+ References:
2900
+ - https://wiki.c2.com/?AbcMetric
2656
2901
  - https://en.wikipedia.org/wiki/ABC_Software_Metric
2657
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
2658
2907
  VersionAdded: '0.27'
2659
2908
  VersionChanged: '1.5'
2660
2909
  # The ABC size is a calculated magnitude, so this number can be an Integer or
@@ -2667,6 +2916,10 @@ Metrics/AbcSize:
2667
2916
  Metrics/BlockLength:
2668
2917
  Description: 'Avoid long blocks with many lines.'
2669
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
2670
2923
  VersionAdded: '0.44'
2671
2924
  VersionChanged: '1.5'
2672
2925
  CountComments: false # count full line comments?
@@ -2684,6 +2937,10 @@ Metrics/BlockNesting:
2684
2937
  Description: 'Avoid excessive block nesting.'
2685
2938
  StyleGuide: '#three-is-the-number-thou-shalt-count'
2686
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
2687
2944
  VersionAdded: '0.25'
2688
2945
  VersionChanged: '1.65'
2689
2946
  CountBlocks: false
@@ -2693,6 +2950,10 @@ Metrics/BlockNesting:
2693
2950
  Metrics/ClassLength:
2694
2951
  Description: 'Avoid classes longer than 100 lines of code.'
2695
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
2696
2957
  VersionAdded: '0.25'
2697
2958
  VersionChanged: '0.87'
2698
2959
  CountComments: false # count full line comments?
@@ -2703,14 +2964,17 @@ Metrics/CollectionLiteralLength:
2703
2964
  Description: 'Checks for `Array` or `Hash` literals with many entries.'
2704
2965
  Enabled: pending
2705
2966
  VersionAdded: '1.47'
2706
- LengthThreshold: 250
2967
+ VersionChanged: '1.88'
2968
+ Max: 250
2707
2969
 
2708
2970
  # Avoid complex methods.
2709
2971
  Metrics/CyclomaticComplexity:
2710
- Description: >-
2711
- A complexity metric that is strongly correlated to the number
2712
- of test cases needed to validate a method.
2972
+ Description: 'Checks that the cyclomatic complexity of methods is not higher than the configured maximum.'
2713
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
2714
2978
  VersionAdded: '0.25'
2715
2979
  VersionChanged: '0.81'
2716
2980
  AllowedMethods: []
@@ -2721,6 +2985,10 @@ Metrics/MethodLength:
2721
2985
  Description: 'Avoid methods longer than 10 lines of code.'
2722
2986
  StyleGuide: '#short-methods'
2723
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
2724
2992
  VersionAdded: '0.25'
2725
2993
  VersionChanged: '1.5'
2726
2994
  CountComments: false # count full line comments?
@@ -2732,6 +3000,10 @@ Metrics/MethodLength:
2732
3000
  Metrics/ModuleLength:
2733
3001
  Description: 'Avoid modules longer than 100 lines of code.'
2734
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
2735
3007
  VersionAdded: '0.31'
2736
3008
  VersionChanged: '0.87'
2737
3009
  CountComments: false # count full line comments?
@@ -2742,6 +3014,10 @@ Metrics/ParameterLists:
2742
3014
  Description: 'Avoid parameter lists longer than three or four parameters.'
2743
3015
  StyleGuide: '#too-many-params'
2744
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
2745
3021
  VersionAdded: '0.25'
2746
3022
  VersionChanged: '1.5'
2747
3023
  Max: 5
@@ -2749,30 +3025,31 @@ Metrics/ParameterLists:
2749
3025
  MaxOptionalParameters: 3
2750
3026
 
2751
3027
  Metrics/PerceivedComplexity:
2752
- Description: >-
2753
- A complexity metric geared towards measuring complexity for a
2754
- human reader.
3028
+ Description: 'Checks that the perceived complexity of methods is not higher than the configured maximum.'
2755
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
2756
3034
  VersionAdded: '0.25'
2757
- VersionChanged: '0.81'
3035
+ VersionChanged: '1.88'
2758
3036
  AllowedMethods: []
2759
3037
  AllowedPatterns: []
2760
3038
  Max: 8
2761
3039
 
2762
- ################## Migration #############################
3040
+ #################### Migration #############################
2763
3041
 
2764
3042
  Migration/DepartmentName:
2765
- Description: >-
2766
- Check that cop names in rubocop:disable (etc) comments are
2767
- given with department name.
3043
+ Description: 'Checks that cop names in `rubocop:disable` (etc.) comments are given with a department name.'
2768
3044
  Enabled: true
2769
3045
  VersionAdded: '0.75'
2770
3046
 
2771
- #################### Naming ##############################
3047
+ #################### Naming ################################
2772
3048
 
2773
3049
  Naming/AccessorMethodName:
2774
- Description: Check the naming of accessor methods for get_/set_.
3050
+ Description: Checks the naming of accessor methods for get_/set_.
2775
3051
  StyleGuide: '#accessor_mutator_method_names'
3052
+ VersionChanged: '1.89'
2776
3053
  Enabled: true
2777
3054
  VersionAdded: '0.50'
2778
3055
 
@@ -2785,7 +3062,7 @@ Naming/AsciiIdentifiers:
2785
3062
  AsciiConstants: true
2786
3063
 
2787
3064
  Naming/BinaryOperatorParameterName:
2788
- Description: 'When defining binary operators, name the argument other.'
3065
+ Description: 'Checks that the sole parameter of binary operator methods is named `other`.'
2789
3066
  StyleGuide: '#other-arg'
2790
3067
  Enabled: true
2791
3068
  VersionAdded: '0.50'
@@ -2926,6 +3203,10 @@ Naming/HeredocDelimiterNaming:
2926
3203
  Description: 'Use descriptive heredoc delimiters.'
2927
3204
  StyleGuide: '#heredoc-delimiters'
2928
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
2929
3210
  VersionAdded: '0.50'
2930
3211
  ForbiddenDelimiters:
2931
3212
  - !ruby/regexp '/(^|\s)(EO[A-Z]{1}|END)(\s|$)/i'
@@ -2955,7 +3236,10 @@ Naming/InclusiveLanguage:
2955
3236
  - block
2956
3237
  slave:
2957
3238
  WholeWord: true
2958
- Suggestions: ['replica', 'secondary', 'follower']
3239
+ Suggestions:
3240
+ - replica
3241
+ - secondary
3242
+ - follower
2959
3243
 
2960
3244
  Naming/MemoizedInstanceVariableName:
2961
3245
  Description: >-
@@ -2975,6 +3259,7 @@ Naming/MethodName:
2975
3259
  StyleGuide: '#snake-case-symbols-methods-vars'
2976
3260
  Enabled: true
2977
3261
  VersionAdded: '0.50'
3262
+ VersionChanged: '1.75'
2978
3263
  EnforcedStyle: snake_case
2979
3264
  SupportedStyles:
2980
3265
  - snake_case
@@ -2986,6 +3271,10 @@ Naming/MethodName:
2986
3271
  # - '\A\s*onSelectionCleared\s*'
2987
3272
  #
2988
3273
  AllowedPatterns: []
3274
+ ForbiddenIdentifiers:
3275
+ - __id__
3276
+ - __send__
3277
+ ForbiddenPatterns: []
2989
3278
 
2990
3279
  Naming/MethodParameterName:
2991
3280
  Description: >-
@@ -3017,22 +3306,43 @@ Naming/MethodParameterName:
3017
3306
  # Forbidden names that will register an offense
3018
3307
  ForbiddenNames: []
3019
3308
 
3020
- Naming/PredicateName:
3021
- Description: 'Check the names of predicate methods.'
3309
+ Naming/PredicateMethod:
3310
+ Description: 'Checks that predicate methods end with `?` and non-predicate methods do not.'
3311
+ Enabled: pending
3312
+ VersionAdded: '1.76'
3313
+ VersionChanged: '1.78'
3314
+ # In `aggressive` mode, the cop will register an offense for predicate methods that
3315
+ # may return a non-boolean value.
3316
+ # In `conservative` mode, the cop will *not* register an offense for predicate methods
3317
+ # that may return a non-boolean value.
3318
+ Mode: conservative
3319
+ AllowedMethods:
3320
+ - call
3321
+ AllowedPatterns: []
3322
+ AllowBangMethods: false
3323
+ # Methods that are known to not return a boolean value, despite ending in `?`.
3324
+ WaywardPredicates:
3325
+ - infinite?
3326
+ - nonzero?
3327
+
3328
+ Naming/PredicatePrefix:
3329
+ Description: 'Checks that predicate method names end with a question mark and do not start with a forbidden prefix.'
3022
3330
  StyleGuide: '#bool-methods-qmark'
3023
3331
  Enabled: true
3024
3332
  VersionAdded: '0.50'
3025
- VersionChanged: '0.77'
3333
+ VersionChanged: '1.89'
3026
3334
  # Predicate name prefixes.
3027
3335
  NamePrefix:
3028
3336
  - is_
3029
3337
  - has_
3030
3338
  - have_
3339
+ - does_
3031
3340
  # Predicate name prefixes that should be removed.
3032
3341
  ForbiddenPrefixes:
3033
3342
  - is_
3034
3343
  - has_
3035
3344
  - have_
3345
+ - does_
3036
3346
  # Predicate names which, despite having a forbidden prefix, or no `?`,
3037
3347
  # should still be accepted
3038
3348
  AllowedMethods:
@@ -3041,6 +3351,8 @@ Naming/PredicateName:
3041
3351
  MethodDefinitionMacros:
3042
3352
  - define_method
3043
3353
  - define_singleton_method
3354
+ # Use Sorbet's T::Boolean return type to detect predicate methods.
3355
+ UseSorbetSigs: false
3044
3356
  # Exclude Rspec specs because there is a strong convention to write spec
3045
3357
  # helpers in the form of `have_something` or `be_something`.
3046
3358
  Exclude:
@@ -3058,18 +3370,24 @@ Naming/VariableName:
3058
3370
  StyleGuide: '#snake-case-symbols-methods-vars'
3059
3371
  Enabled: true
3060
3372
  VersionAdded: '0.50'
3061
- VersionChanged: '1.8'
3373
+ VersionChanged: '1.73'
3062
3374
  EnforcedStyle: snake_case
3063
3375
  SupportedStyles:
3064
3376
  - snake_case
3065
3377
  - camelCase
3066
3378
  AllowedIdentifiers: []
3067
3379
  AllowedPatterns: []
3380
+ ForbiddenIdentifiers: []
3381
+ ForbiddenPatterns: []
3068
3382
 
3069
3383
  Naming/VariableNumber:
3070
3384
  Description: 'Use the configured style when numbering symbols, methods and variables.'
3071
3385
  StyleGuide: '#snake-case-symbols-methods-vars-with-numbers'
3072
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
3073
3391
  VersionAdded: '0.50'
3074
3392
  VersionChanged: '1.4'
3075
3393
  EnforcedStyle: normalcase
@@ -3080,6 +3398,8 @@ Naming/VariableNumber:
3080
3398
  CheckMethodNames: true
3081
3399
  CheckSymbols: true
3082
3400
  AllowedIdentifiers:
3401
+ - TLS1_1 # OpenSSL::SSL::TLS1_1_VERSION
3402
+ - TLS1_2 # OpenSSL::SSL::TLS1_2_VERSION
3083
3403
  - capture3 # Open3.capture3
3084
3404
  - iso8601 # Time#iso8601
3085
3405
  - rfc1123_date # CGI.rfc1123_date
@@ -3092,14 +3412,14 @@ Naming/VariableNumber:
3092
3412
  #################### Security ##############################
3093
3413
 
3094
3414
  Security/CompoundHash:
3095
- 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`.'
3096
3416
  Enabled: pending
3097
3417
  Safe: false
3098
3418
  VersionAdded: '1.28'
3099
3419
  VersionChanged: '1.51'
3100
3420
 
3101
3421
  Security/Eval:
3102
- 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.'
3103
3423
  Enabled: true
3104
3424
  VersionAdded: '0.47'
3105
3425
 
@@ -3115,7 +3435,9 @@ Security/JSONLoad:
3115
3435
  Description: >-
3116
3436
  Prefer usage of `JSON.parse` over `JSON.load` due to potential
3117
3437
  security issues. See reference for more information.
3118
- Reference: 'https://ruby-doc.org/stdlib-2.7.0/libdoc/json/rdoc/JSON.html#method-i-load'
3438
+ References:
3439
+ - 'https://ruby-doc.org/stdlib-2.7.0/libdoc/json/rdoc/JSON.html#method-i-load'
3440
+ - 'https://bugs.ruby-lang.org/issues/19528'
3119
3441
  Enabled: true
3120
3442
  VersionAdded: '0.43'
3121
3443
  VersionChanged: '1.22'
@@ -3127,12 +3449,13 @@ Security/MarshalLoad:
3127
3449
  Description: >-
3128
3450
  Avoid using of `Marshal.load` or `Marshal.restore` due to potential
3129
3451
  security issues. See reference for more information.
3130
- Reference: 'https://ruby-doc.org/core-2.7.0/Marshal.html#module-Marshal-label-Security+considerations'
3452
+ References:
3453
+ - 'https://ruby-doc.org/core-2.7.0/Marshal.html#module-Marshal-label-Security+considerations'
3131
3454
  Enabled: true
3132
3455
  VersionAdded: '0.47'
3133
3456
 
3134
3457
  Security/Open:
3135
- 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.'
3136
3459
  Enabled: true
3137
3460
  VersionAdded: '0.53'
3138
3461
  VersionChanged: '1.0'
@@ -3142,12 +3465,13 @@ Security/YAMLLoad:
3142
3465
  Description: >-
3143
3466
  Prefer usage of `YAML.safe_load` over `YAML.load` due to potential
3144
3467
  security issues. See reference for more information.
3145
- Reference: 'https://ruby-doc.org/stdlib-2.7.0/libdoc/yaml/rdoc/YAML.html#module-YAML-label-Security'
3468
+ References:
3469
+ - 'https://ruby-doc.org/stdlib-2.7.0/libdoc/yaml/rdoc/YAML.html#module-YAML-label-Security'
3146
3470
  Enabled: true
3147
3471
  VersionAdded: '0.47'
3148
3472
  SafeAutoCorrect: false
3149
3473
 
3150
- #################### Style ###############################
3474
+ #################### Style #################################
3151
3475
 
3152
3476
  Style/AccessModifierDeclarations:
3153
3477
  Description: 'Checks style of how access modifiers are used.'
@@ -3181,13 +3505,17 @@ Style/Alias:
3181
3505
  VersionAdded: '0.9'
3182
3506
  VersionChanged: '0.36'
3183
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
3184
3512
  SupportedStyles:
3185
3513
  - prefer_alias
3186
3514
  - prefer_alias_method
3187
3515
 
3188
3516
  Style/AmbiguousEndlessMethodDefinition:
3189
3517
  Description: 'Checks for endless methods inside operators of lower precedence.'
3190
- StyleGuide: '#ambiguous-endless-method-defintions'
3518
+ StyleGuide: '#ambiguous-endless-method-definitions'
3191
3519
  Enabled: pending
3192
3520
  VersionAdded: '1.68'
3193
3521
 
@@ -3209,6 +3537,8 @@ Style/ArgumentsForwarding:
3209
3537
  Description: 'Use arguments forwarding.'
3210
3538
  StyleGuide: '#arguments-forwarding'
3211
3539
  Enabled: pending
3540
+ VersionAdded: '1.1'
3541
+ VersionChanged: '1.58'
3212
3542
  AllowOnlyRestArgument: true
3213
3543
  UseAnonymousForwarding: true
3214
3544
  RedundantRestArgumentNames:
@@ -3222,8 +3552,6 @@ Style/ArgumentsForwarding:
3222
3552
  - blk
3223
3553
  - block
3224
3554
  - proc
3225
- VersionAdded: '1.1'
3226
- VersionChanged: '1.58'
3227
3555
 
3228
3556
  Style/ArrayCoercion:
3229
3557
  Description: >-
@@ -3236,7 +3564,9 @@ Style/ArrayCoercion:
3236
3564
 
3237
3565
  Style/ArrayFirstLast:
3238
3566
  Description: 'Use `arr.first` and `arr.last` instead of `arr[0]` and `arr[-1]`.'
3239
- Reference: '#first-and-last'
3567
+ StyleGuide: '#first-and-last'
3568
+ References:
3569
+ - '#first-and-last'
3240
3570
  Enabled: false
3241
3571
  VersionAdded: '1.58'
3242
3572
  Safe: false
@@ -3247,6 +3577,12 @@ Style/ArrayIntersect:
3247
3577
  Safe: false
3248
3578
  VersionAdded: '1.40'
3249
3579
 
3580
+ Style/ArrayIntersectWithSingleElement:
3581
+ Description: 'Use `include?(element)` instead of `intersect?([element])`.'
3582
+ Enabled: 'pending'
3583
+ Safe: false
3584
+ VersionAdded: '1.81'
3585
+
3250
3586
  Style/ArrayJoin:
3251
3587
  Description: 'Use Array#join instead of Array#*.'
3252
3588
  StyleGuide: '#array-join'
@@ -3319,6 +3655,10 @@ Style/BlockDelimiters:
3319
3655
  Prefer {...} over do...end for single-line blocks.
3320
3656
  StyleGuide: '#single-line-blocks'
3321
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
3322
3662
  VersionAdded: '0.30'
3323
3663
  VersionChanged: '0.35'
3324
3664
  EnforcedStyle: line_count_based
@@ -3424,9 +3764,11 @@ Style/BlockDelimiters:
3424
3764
  BracesRequiredMethods: []
3425
3765
 
3426
3766
  Style/CaseEquality:
3427
- Description: 'Avoid explicit use of the case equality operator(===).'
3767
+ Description: 'Avoid explicit use of the case equality operator (`===`).'
3428
3768
  StyleGuide: '#no-case-equality'
3429
3769
  Enabled: true
3770
+ References:
3771
+ - 'https://docs.rubocop.org/rubocop-performance/cops_performance.html#performanceregexpmatch'
3430
3772
  VersionAdded: '0.9'
3431
3773
  VersionChanged: '0.89'
3432
3774
  # If `AllowOnConstant` option is enabled, the cop will ignore violations when the receiver of
@@ -3469,12 +3811,18 @@ Style/ClassAndModuleChildren:
3469
3811
  StyleGuide: '#namespace-definition'
3470
3812
  # Moving from compact to nested children requires knowledge of whether the
3471
3813
  # outer parent is a module or a class. Moving from nested to compact requires
3472
- # verification that the outer parent is defined elsewhere. RuboCop does not
3473
- # have the knowledge to perform either operation safely and thus requires
3474
- # 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.
3475
3818
  SafeAutoCorrect: false
3476
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
3477
3824
  VersionAdded: '0.19'
3825
+ VersionChanged: '1.89'
3478
3826
  #
3479
3827
  # Basically there are two different styles:
3480
3828
  #
@@ -3490,7 +3838,21 @@ Style/ClassAndModuleChildren:
3490
3838
  #
3491
3839
  # The compact style is only forced, for classes or modules with one child.
3492
3840
  EnforcedStyle: nested
3493
- SupportedStyles:
3841
+ SupportedStyles: &supported_styles
3842
+ - nested
3843
+ - compact
3844
+ # Configure classes separately, if desired. If not set, or set to `nil`,
3845
+ # the `EnforcedStyle` value will be used.
3846
+ EnforcedStyleForClasses: ~
3847
+ SupportedStylesForClasses:
3848
+ - ~
3849
+ - nested
3850
+ - compact
3851
+ # Configure modules separately, if desired. If not set, or set to `nil`,
3852
+ # the `EnforcedStyle` value will be used.
3853
+ EnforcedStyleForModules: ~
3854
+ SupportedStylesForModules:
3855
+ - ~
3494
3856
  - nested
3495
3857
  - compact
3496
3858
 
@@ -3550,7 +3912,7 @@ Style/CollectionCompact:
3550
3912
 
3551
3913
  # Align with the style guide.
3552
3914
  Style/CollectionMethods:
3553
- Description: 'Preferred collection methods.'
3915
+ Description: 'Enforces the use of consistent method names from the `Enumerable` module.'
3554
3916
  StyleGuide: '#map-find-select-reduce-include-size'
3555
3917
  Enabled: false
3556
3918
  VersionAdded: '0.9'
@@ -3576,6 +3938,13 @@ Style/CollectionMethods:
3576
3938
  - inject
3577
3939
  - reduce
3578
3940
 
3941
+ Style/CollectionQuerying:
3942
+ Description: 'Prefer `Enumerable` predicate methods over expressions with `count`.'
3943
+ StyleGuide: '#collection-querying'
3944
+ Enabled: pending
3945
+ VersionAdded: '1.77'
3946
+ Safe: false
3947
+
3579
3948
  Style/ColonMethodCall:
3580
3949
  Description: 'Do not use :: for method call.'
3581
3950
  StyleGuide: '#double-colons'
@@ -3643,6 +4012,14 @@ Style/CommentedKeyword:
3643
4012
  VersionAdded: '0.51'
3644
4013
  VersionChanged: '1.19'
3645
4014
 
4015
+ Style/ComparableBetween:
4016
+ Description: 'Enforces the use of `Comparable#between?` instead of logical comparison.'
4017
+ StyleGuide: '#ranges-or-between'
4018
+ Enabled: pending
4019
+ Safe: false
4020
+ VersionAdded: '1.74'
4021
+ VersionChanged: '1.75'
4022
+
3646
4023
  Style/ComparableClamp:
3647
4024
  Description: 'Enforces the use of `Comparable#clamp` instead of comparison by minimum and maximum.'
3648
4025
  Enabled: pending
@@ -3659,6 +4036,7 @@ Style/ConditionalAssignment:
3659
4036
  Use the return value of `if` and `case` statements for
3660
4037
  assignment to a variable and variable comparison instead
3661
4038
  of assigning that variable inside of each branch.
4039
+ StyleGuide: '#use-if-case-returns'
3662
4040
  Enabled: true
3663
4041
  VersionAdded: '0.36'
3664
4042
  VersionChanged: '0.47'
@@ -3719,7 +4097,7 @@ Style/DataInheritance:
3719
4097
 
3720
4098
  Style/DateTime:
3721
4099
  Description: 'Use Time over DateTime.'
3722
- StyleGuide: '#date-time'
4100
+ StyleGuide: '#no-datetime'
3723
4101
  Enabled: false
3724
4102
  VersionAdded: '0.51'
3725
4103
  VersionChanged: '0.92'
@@ -3752,13 +4130,33 @@ Style/DirEmpty:
3752
4130
  Enabled: pending
3753
4131
  VersionAdded: '1.48'
3754
4132
 
4133
+ Style/DirectiveScope:
4134
+ Description: >-
4135
+ Checks for directive scopes that can be expressed with the
4136
+ tighter `disable-next` form.
4137
+ Enabled: pending
4138
+ SafeAutoCorrect: false
4139
+ VersionAdded: '1.90'
4140
+ VersionChanged: '1.91'
4141
+
3755
4142
  Style/DisableCopsWithinSourceCodeDirective:
3756
4143
  Description: >-
3757
4144
  Forbids disabling/enabling cops within source code.
3758
4145
  Enabled: false
3759
4146
  VersionAdded: '0.82'
3760
- VersionChanged: '1.9'
4147
+ VersionChanged: '1.90'
4148
+ # Cop or department names. A directive is exempt only when everything it
4149
+ # disables is listed here.
3761
4150
  AllowedCops: []
4151
+ # Cop or department names. When set, only directives touching these are
4152
+ # flagged.
4153
+ DisallowedCops: []
4154
+ # Permit a directive that carries a `-- reason` justification, instead of
4155
+ # forbidding directives outright.
4156
+ AllowWithReason: false
4157
+ # Directive forms this cop ignores entirely. One or more of `disable`,
4158
+ # `todo`, `disable-next`, `todo-next`, `push`, `next`.
4159
+ AllowedDirectives: []
3762
4160
 
3763
4161
  Style/DocumentDynamicEvalDefinition:
3764
4162
  Description: >-
@@ -3772,7 +4170,12 @@ Style/DocumentDynamicEvalDefinition:
3772
4170
  Style/Documentation:
3773
4171
  Description: 'Document classes and non-namespace modules.'
3774
4172
  Enabled: true
4173
+ # Turned off by over half of the projects that configure RuboCop at all, so it
4174
+ # is expected to be disabled by default in the next major release.
4175
+ Preview:
4176
+ Enabled: false
3775
4177
  VersionAdded: '0.9'
4178
+ VersionChanged: '1.89'
3776
4179
  AllowedConstants: []
3777
4180
  Exclude:
3778
4181
  - 'spec/**/*'
@@ -3788,15 +4191,14 @@ Style/DocumentationMethod:
3788
4191
  - 'test/**/*'
3789
4192
  RequireForNonPublicMethods: false
3790
4193
 
3791
- Style/DoubleCopDisableDirective:
3792
- Description: 'Checks for double rubocop:disable comments on a single line.'
3793
- Enabled: true
3794
- VersionAdded: '0.73'
3795
-
3796
4194
  Style/DoubleNegation:
3797
4195
  Description: 'Checks for uses of double negation (!!).'
3798
4196
  StyleGuide: '#no-bang-bang'
3799
4197
  Enabled: true
4198
+ # Expected to be disabled by default in the next major release.
4199
+ # `!!` is the idiomatic boolean coercion.
4200
+ Preview:
4201
+ Enabled: false
3800
4202
  VersionAdded: '0.19'
3801
4203
  VersionChanged: '1.2'
3802
4204
  EnforcedStyle: allowed_in_returns
@@ -3828,6 +4230,19 @@ Style/EmptyCaseCondition:
3828
4230
  Enabled: true
3829
4231
  VersionAdded: '0.40'
3830
4232
 
4233
+ Style/EmptyClassDefinition:
4234
+ Description: 'Enforces consistent style for empty class definitions.'
4235
+ StyleGuide: '#single-line-classes'
4236
+ Enabled: pending
4237
+ VersionAdded: '1.84'
4238
+ VersionChanged: '1.86'
4239
+ EnforcedStyle: class_keyword
4240
+ SupportedStyles:
4241
+ - class_keyword
4242
+ - class_new
4243
+ - class_definition # Deprecated.
4244
+ AllowedParentClasses: []
4245
+
3831
4246
  Style/EmptyElse:
3832
4247
  Description: 'Avoid empty else-clauses.'
3833
4248
  Enabled: true
@@ -3871,10 +4286,24 @@ Style/EmptyMethod:
3871
4286
  VersionAdded: '0.46'
3872
4287
  VersionChanged: '1.61'
3873
4288
  EnforcedStyle: compact
4289
+ # Expected to become the default in the next major release.
4290
+ # Expanded empty methods are the pick of nearly every project that sets this.
4291
+ Preview:
4292
+ EnforcedStyle: expanded
3874
4293
  SupportedStyles:
3875
4294
  - compact
3876
4295
  - expanded
3877
4296
 
4297
+ Style/EmptyStringInsideInterpolation:
4298
+ Description: 'Checks for empty strings being assigned inside string interpolation.'
4299
+ StyleGuide: '#empty-strings-in-interpolation'
4300
+ Enabled: pending
4301
+ EnforcedStyle: trailing_conditional
4302
+ SupportedStyles:
4303
+ - trailing_conditional
4304
+ - ternary
4305
+ VersionAdded: '1.76'
4306
+
3878
4307
  Style/Encoding:
3879
4308
  Description: 'Use UTF-8 as the source file encoding.'
3880
4309
  StyleGuide: '#utf-8'
@@ -3899,6 +4328,8 @@ Style/EndlessMethod:
3899
4328
  - allow_single_line
3900
4329
  - allow_always
3901
4330
  - disallow
4331
+ - require_single_line
4332
+ - require_always
3902
4333
 
3903
4334
  Style/EnvHome:
3904
4335
  Description: "Checks for consistent usage of `ENV['HOME']`."
@@ -3938,7 +4369,7 @@ Style/ExplicitBlockArgument:
3938
4369
  VersionChanged: '1.8'
3939
4370
 
3940
4371
  Style/ExponentialNotation:
3941
- Description: 'When using exponential notation, favor a mantissa between 1 (inclusive) and 10 (exclusive).'
4372
+ Description: 'Enforces consistency in the use of exponential (scientific) notation.'
3942
4373
  StyleGuide: '#exponential-notation'
3943
4374
  Enabled: true
3944
4375
  VersionAdded: '0.82'
@@ -3951,12 +4382,16 @@ Style/ExponentialNotation:
3951
4382
  Style/FetchEnvVar:
3952
4383
  Description: >-
3953
4384
  Suggests `ENV.fetch` for the replacement of `ENV[]`.
3954
- Reference:
4385
+ References:
3955
4386
  - https://rubystyle.guide/#hash-fetch-defaults
3956
4387
  Enabled: pending
3957
4388
  VersionAdded: '1.28'
4389
+ VersionChanged: '1.88'
3958
4390
  # Environment variables to be excluded from the inspection.
3959
- AllowedVars: []
4391
+ AllowedVariables: []
4392
+ # When `true`, autocorrects `ENV["key"]` to `ENV.fetch("key", nil)`.
4393
+ # When `false`, autocorrects `ENV["key"]` to `ENV.fetch("key")`.
4394
+ DefaultToNil: true
3960
4395
 
3961
4396
  Style/FileEmpty:
3962
4397
  Description: >-
@@ -3967,10 +4402,18 @@ Style/FileEmpty:
3967
4402
 
3968
4403
  Style/FileNull:
3969
4404
  Description: 'Use `File::NULL` instead of hardcoding "dev/null".'
4405
+ StyleGuide: '#null-devices'
3970
4406
  Enabled: pending
3971
4407
  SafeAutoCorrect: false
3972
4408
  VersionAdded: '1.69'
3973
4409
 
4410
+ Style/FileOpen:
4411
+ Description: 'Checks for `File.open` without a block, which can leak file descriptors.'
4412
+ StyleGuide: '#auto-release-resources'
4413
+ Enabled: pending
4414
+ Safe: false
4415
+ VersionAdded: '1.85'
4416
+
3974
4417
  Style/FileRead:
3975
4418
  Description: 'Favor `File.(bin)read` convenience methods.'
3976
4419
  StyleGuide: '#file-read'
@@ -3992,7 +4435,8 @@ Style/FileWrite:
3992
4435
  Style/FloatDivision:
3993
4436
  Description: 'For performing float division, coerce one side only.'
3994
4437
  StyleGuide: '#float-division'
3995
- Reference: 'https://blog.rubystyle.guide/ruby/2019/06/21/float-division.html'
4438
+ References:
4439
+ - 'https://blog.rubystyle.guide/ruby/2019/06/21/float-division.html'
3996
4440
  Enabled: true
3997
4441
  VersionAdded: '0.72'
3998
4442
  VersionChanged: '1.9'
@@ -4020,6 +4464,10 @@ Style/FormatString:
4020
4464
  Description: 'Enforce the use of Kernel#sprintf, Kernel#format or String#%.'
4021
4465
  StyleGuide: '#sprintf'
4022
4466
  Enabled: true
4467
+ # Expected to be disabled by default in the next major release.
4468
+ # A pure preference between `format`, `sprintf` and `%`.
4469
+ Preview:
4470
+ Enabled: false
4023
4471
  VersionAdded: '0.19'
4024
4472
  VersionChanged: '0.49'
4025
4473
  EnforcedStyle: format
@@ -4030,7 +4478,14 @@ Style/FormatString:
4030
4478
 
4031
4479
  Style/FormatStringToken:
4032
4480
  Description: 'Use a consistent style for format string tokens.'
4481
+ StyleGuide: '#named-format-tokens'
4033
4482
  Enabled: true
4483
+ # Expected to be disabled by default in the next major release.
4484
+ # Most real format strings use `%s`, which is what the cop flags.
4485
+ Preview:
4486
+ Enabled: false
4487
+ VersionAdded: '0.49'
4488
+ VersionChanged: '1.74'
4034
4489
  EnforcedStyle: annotated
4035
4490
  SupportedStyles:
4036
4491
  # Prefer tokens which contain a sprintf like type annotation like
@@ -4043,8 +4498,12 @@ Style/FormatStringToken:
4043
4498
  # style token in a format string to be allowed when enforced style is not
4044
4499
  # `unannotated`.
4045
4500
  MaxUnannotatedPlaceholdersAllowed: 1
4046
- VersionAdded: '0.49'
4047
- VersionChanged: '1.0'
4501
+ # The mode the cop operates in. Two values are allowed:
4502
+ # * aggressive (default): all strings are considered
4503
+ # * conservative:
4504
+ # only register offenses for strings given to `printf`, `sprintf`,
4505
+ # format` and `%` methods. Other strings are not considered.
4506
+ Mode: aggressive
4048
4507
  AllowedMethods: []
4049
4508
  AllowedPatterns: []
4050
4509
 
@@ -4053,6 +4512,10 @@ Style/FrozenStringLiteralComment:
4053
4512
  Add the frozen_string_literal comment to the top of files
4054
4513
  to help transition to frozen string literals by default.
4055
4514
  Enabled: true
4515
+ # Expected to be disabled by default in the next major release.
4516
+ # Ruby is moving towards frozen string literals by default.
4517
+ Preview:
4518
+ Enabled: false
4056
4519
  VersionAdded: '0.36'
4057
4520
  VersionChanged: '0.79'
4058
4521
  EnforcedStyle: always
@@ -4083,16 +4546,21 @@ Style/GlobalStdStream:
4083
4546
  Style/GlobalVars:
4084
4547
  Description: 'Do not introduce global variables.'
4085
4548
  StyleGuide: '#instance-vars'
4086
- Reference: 'https://www.zenspider.com/ruby/quickref.html'
4549
+ References:
4550
+ - 'https://www.zenspider.com/ruby/quickref.html'
4087
4551
  Enabled: true
4088
4552
  VersionAdded: '0.13'
4089
4553
  # Built-in global variables are allowed by default.
4090
4554
  AllowedVariables: []
4091
4555
 
4092
4556
  Style/GuardClause:
4093
- Description: 'Check for conditionals that can be replaced with guard clauses.'
4557
+ Description: 'Checks for conditionals that can be replaced with guard clauses.'
4094
4558
  StyleGuide: '#no-nested-conditionals'
4095
4559
  Enabled: true
4560
+ # Expected to be disabled by default in the next major release.
4561
+ # Same objection as `IfUnlessModifier`, and among the most inline-suppressed cops.
4562
+ Preview:
4563
+ Enabled: false
4096
4564
  VersionAdded: '0.20'
4097
4565
  VersionChanged: '1.31'
4098
4566
  # `MinBodyLength` defines the number of lines of the a body of an `if` or `unless`
@@ -4140,6 +4608,12 @@ Style/HashExcept:
4140
4608
  VersionAdded: '1.7'
4141
4609
  VersionChanged: '1.39'
4142
4610
 
4611
+ Style/HashFetchChain:
4612
+ Description: 'Use `Hash#dig` instead of chained `fetch` calls.'
4613
+ Enabled: pending
4614
+ Safe: false
4615
+ VersionAdded: '1.75'
4616
+
4143
4617
  Style/HashLikeCase:
4144
4618
  Description: >-
4145
4619
  Checks for places where `case-when` represents a simple 1:1
@@ -4150,6 +4624,16 @@ Style/HashLikeCase:
4150
4624
  # to trigger this cop
4151
4625
  MinBranchesCount: 3
4152
4626
 
4627
+ Style/HashLookupMethod:
4628
+ Description: 'Enforces the use of either `Hash#[]` or `Hash#fetch` for hash lookup.'
4629
+ Enabled: false
4630
+ Safe: false
4631
+ VersionAdded: '1.84'
4632
+ EnforcedStyle: brackets
4633
+ SupportedStyles:
4634
+ - brackets
4635
+ - fetch
4636
+
4153
4637
  Style/HashSlice:
4154
4638
  Description: >-
4155
4639
  Checks for usages of `Hash#reject`, `Hash#select`, and `Hash#filter` methods
@@ -4196,6 +4680,7 @@ Style/HashSyntax:
4196
4680
 
4197
4681
  Style/HashTransformKeys:
4198
4682
  Description: 'Prefer `transform_keys` over `each_with_object`, `map`, or `to_h`.'
4683
+ StyleGuide: '#hash-transform-methods'
4199
4684
  Enabled: true
4200
4685
  VersionAdded: '0.80'
4201
4686
  VersionChanged: '0.90'
@@ -4203,6 +4688,7 @@ Style/HashTransformKeys:
4203
4688
 
4204
4689
  Style/HashTransformValues:
4205
4690
  Description: 'Prefer `transform_values` over `each_with_object`, `map`, or `to_h`.'
4691
+ StyleGuide: '#hash-transform-methods'
4206
4692
  Enabled: true
4207
4693
  VersionAdded: '0.80'
4208
4694
  VersionChanged: '0.90'
@@ -4221,9 +4707,9 @@ Style/IdenticalConditionalBranches:
4221
4707
  Style/IfInsideElse:
4222
4708
  Description: 'Finds if nodes inside else, which can be converted to elsif.'
4223
4709
  Enabled: true
4224
- AllowIfModifier: false
4225
4710
  VersionAdded: '0.36'
4226
4711
  VersionChanged: '1.3'
4712
+ AllowIfModifier: false
4227
4713
 
4228
4714
  Style/IfUnlessModifier:
4229
4715
  Description: >-
@@ -4231,6 +4717,10 @@ Style/IfUnlessModifier:
4231
4717
  single-line body.
4232
4718
  StyleGuide: '#if-as-a-modifier'
4233
4719
  Enabled: true
4720
+ # Expected to be disabled by default in the next major release.
4721
+ # Forces a shape on control flow that a quarter of configured projects switch off.
4722
+ Preview:
4723
+ Enabled: false
4234
4724
  VersionAdded: '0.9'
4235
4725
  VersionChanged: '0.30'
4236
4726
 
@@ -4247,6 +4737,7 @@ Style/IfWithBooleanLiteralBranches:
4247
4737
  VersionAdded: '1.9'
4248
4738
  SafeAutoCorrect: false
4249
4739
  AllowedMethods:
4740
+ - infinite?
4250
4741
  - nonzero?
4251
4742
 
4252
4743
  Style/IfWithSemicolon:
@@ -4346,10 +4837,22 @@ Style/IpAddresses:
4346
4837
  - '**/*.gemspec'
4347
4838
 
4348
4839
  Style/ItAssignment:
4349
- Description: 'Checks for assignment to `it` inside a block.'
4840
+ Description: 'Checks for local variables and method parameters named `it`.'
4350
4841
  Enabled: pending
4351
4842
  VersionAdded: '1.70'
4352
4843
 
4844
+ Style/ItBlockParameter:
4845
+ Description: 'Checks for blocks with one argument where `it` block parameter can be used.'
4846
+ Enabled: pending
4847
+ VersionAdded: '1.75'
4848
+ VersionChanged: '1.76'
4849
+ EnforcedStyle: allow_single_line
4850
+ SupportedStyles:
4851
+ - allow_single_line
4852
+ - only_numbered_parameters
4853
+ - always
4854
+ - disallow
4855
+
4353
4856
  Style/KeywordArgumentsMerging:
4354
4857
  Description: >-
4355
4858
  When passing an existing hash as keyword arguments, provide additional arguments
@@ -4360,7 +4863,7 @@ Style/KeywordArgumentsMerging:
4360
4863
 
4361
4864
  Style/KeywordParametersOrder:
4362
4865
  Description: 'Enforces that optional keyword parameters are placed at the end of the parameters list.'
4363
- StyleGuide: '#keyword-parameters-order'
4866
+ StyleGuide: '#keyword-arguments-order'
4364
4867
  Enabled: true
4365
4868
  VersionAdded: '0.90'
4366
4869
  VersionChanged: '1.7'
@@ -4369,6 +4872,10 @@ Style/Lambda:
4369
4872
  Description: 'Use the new lambda literal syntax for single-line blocks.'
4370
4873
  StyleGuide: '#lambda-multi-line'
4371
4874
  Enabled: true
4875
+ # Expected to be disabled by default in the next major release.
4876
+ # A pure preference between `->` and `lambda`.
4877
+ Preview:
4878
+ Enabled: false
4372
4879
  VersionAdded: '0.9'
4373
4880
  VersionChanged: '0.40'
4374
4881
  EnforcedStyle: line_count_dependent
@@ -4381,8 +4888,9 @@ Style/LambdaCall:
4381
4888
  Description: 'Use lambda.call(...) instead of lambda.(...).'
4382
4889
  StyleGuide: '#proc-call'
4383
4890
  Enabled: true
4891
+ AutoCorrect: contextual
4384
4892
  VersionAdded: '0.13'
4385
- VersionChanged: '0.14'
4893
+ VersionChanged: '1.81'
4386
4894
  EnforcedStyle: call
4387
4895
  SupportedStyles:
4388
4896
  - call
@@ -4392,6 +4900,7 @@ Style/LineEndConcatenation:
4392
4900
  Description: >-
4393
4901
  Use \ instead of + or << to concatenate two string literals at
4394
4902
  line end.
4903
+ StyleGuide: '#heredoc-long-strings'
4395
4904
  Enabled: true
4396
4905
  SafeAutoCorrect: false
4397
4906
  VersionAdded: '0.18'
@@ -4401,6 +4910,7 @@ Style/MagicCommentFormat:
4401
4910
  Description: 'Use a consistent style for magic comments.'
4402
4911
  Enabled: pending
4403
4912
  VersionAdded: '1.35'
4913
+ VersionChanged: '1.91'
4404
4914
  EnforcedStyle: snake_case
4405
4915
  SupportedStyles:
4406
4916
  # `snake` will enforce the magic comment is written
@@ -4420,7 +4930,9 @@ Style/MagicCommentFormat:
4420
4930
  Style/MapCompactWithConditionalBlock:
4421
4931
  Description: 'Prefer `select` or `reject` over `map { ... }.compact`.'
4422
4932
  Enabled: pending
4933
+ SafeAutoCorrect: false
4423
4934
  VersionAdded: '1.30'
4935
+ VersionChanged: '1.88'
4424
4936
 
4425
4937
  Style/MapIntoArray:
4426
4938
  Description: 'Checks for usages of `each` with `<<`, `push`, or `append` which can be replaced by `map`.'
@@ -4430,6 +4942,12 @@ Style/MapIntoArray:
4430
4942
  VersionChanged: '1.67'
4431
4943
  Safe: false
4432
4944
 
4945
+ Style/MapJoin:
4946
+ Description: 'Checks for redundant `map(&:to_s)` before `join`.'
4947
+ Enabled: pending
4948
+ Safe: false
4949
+ VersionAdded: '1.85'
4950
+
4433
4951
  Style/MapToHash:
4434
4952
  Description: 'Prefer `to_h` with a block over `map.to_h`.'
4435
4953
  Enabled: pending
@@ -4452,6 +4970,7 @@ Style/MethodCallWithArgsParentheses:
4452
4970
  AllowedMethods: []
4453
4971
  AllowedPatterns: []
4454
4972
  IncludedMacros: []
4973
+ IncludedMacroPatterns: []
4455
4974
  AllowParenthesesInMultilineCall: false
4456
4975
  AllowParenthesesInChaining: false
4457
4976
  AllowParenthesesInCamelCaseMethod: false
@@ -4465,10 +4984,10 @@ Style/MethodCallWithoutArgsParentheses:
4465
4984
  Description: 'Do not use parentheses for method calls with no arguments.'
4466
4985
  StyleGuide: '#method-invocation-parens'
4467
4986
  Enabled: true
4468
- AllowedMethods: []
4469
- AllowedPatterns: []
4470
4987
  VersionAdded: '0.47'
4471
4988
  VersionChanged: '0.55'
4989
+ AllowedMethods: []
4990
+ AllowedPatterns: []
4472
4991
 
4473
4992
  Style/MethodCalledOnDoEndBlock:
4474
4993
  Description: 'Avoid chaining a method call on a do...end block.'
@@ -4529,6 +5048,7 @@ Style/MissingRespondToMissing:
4529
5048
  StyleGuide: '#no-method-missing'
4530
5049
  Enabled: true
4531
5050
  VersionAdded: '0.56'
5051
+ VersionChanged: '1.89'
4532
5052
 
4533
5053
  Style/MixinGrouping:
4534
5054
  Description: 'Checks for grouping of mixins in `class` and `module` bodies.'
@@ -4552,6 +5072,10 @@ Style/ModuleFunction:
4552
5072
  Description: 'Checks for usage of `extend self` in modules.'
4553
5073
  StyleGuide: '#module-function'
4554
5074
  Enabled: true
5075
+ # Expected to be disabled by default in the next major release.
5076
+ # `module_function` versus `extend self` is a preference, and the autocorrect is unsafe.
5077
+ Preview:
5078
+ Enabled: false
4555
5079
  VersionAdded: '0.11'
4556
5080
  VersionChanged: '0.65'
4557
5081
  EnforcedStyle: module_function
@@ -4562,6 +5086,11 @@ Style/ModuleFunction:
4562
5086
  Autocorrect: false
4563
5087
  SafeAutoCorrect: false
4564
5088
 
5089
+ Style/ModuleMemberExistenceCheck:
5090
+ Description: 'Checks for usage of `Module` methods returning arrays that can be replaced with equivalent predicates.'
5091
+ Enabled: pending
5092
+ VersionAdded: '1.82'
5093
+
4565
5094
  Style/MultilineBlockChain:
4566
5095
  Description: 'Avoid multi-line chains of blocks.'
4567
5096
  StyleGuide: '#single-line-blocks'
@@ -4569,7 +5098,7 @@ Style/MultilineBlockChain:
4569
5098
  VersionAdded: '0.13'
4570
5099
 
4571
5100
  Style/MultilineIfModifier:
4572
- Description: 'Only use if/unless modifiers on single line statements.'
5101
+ Description: 'Checks for uses of `if`/`unless` modifiers with multiline bodies.'
4573
5102
  StyleGuide: '#no-multiline-if-modifiers'
4574
5103
  Enabled: true
4575
5104
  VersionAdded: '0.45'
@@ -4632,7 +5161,7 @@ Style/MutableConstant:
4632
5161
  Description: 'Do not assign mutable objects to constants.'
4633
5162
  Enabled: true
4634
5163
  VersionAdded: '0.34'
4635
- VersionChanged: '1.8'
5164
+ VersionChanged: '1.88'
4636
5165
  SafeAutoCorrect: false
4637
5166
  EnforcedStyle: literals
4638
5167
  SupportedStyles:
@@ -4644,6 +5173,9 @@ Style/MutableConstant:
4644
5173
  # no harm in freezing an already frozen object.
4645
5174
  - literals
4646
5175
  - strict
5176
+ # When `true`, recursively check and freeze mutable literals nested inside
5177
+ # arrays and hashes (e.g. `[{a: []}]` becomes `[{a: [].freeze}.freeze].freeze`).
5178
+ Recursive: false
4647
5179
 
4648
5180
  Style/NegatedIf:
4649
5181
  Description: >-
@@ -4651,6 +5183,10 @@ Style/NegatedIf:
4651
5183
  (or control flow or).
4652
5184
  StyleGuide: '#unless-for-negatives'
4653
5185
  Enabled: true
5186
+ # Expected to be disabled by default in the next major release.
5187
+ # `if !x` versus `unless x` is a preference, and `unless` is contested on its own.
5188
+ Preview:
5189
+ Enabled: false
4654
5190
  VersionAdded: '0.20'
4655
5191
  VersionChanged: '0.48'
4656
5192
  EnforcedStyle: both
@@ -4671,7 +5207,7 @@ Style/NegatedIfElseCondition:
4671
5207
 
4672
5208
  Style/NegatedUnless:
4673
5209
  Description: 'Favor if over unless for negative conditions.'
4674
- StyleGuide: '#if-for-negatives'
5210
+ StyleGuide: '#unless-for-negatives'
4675
5211
  Enabled: true
4676
5212
  VersionAdded: '0.69'
4677
5213
  EnforcedStyle: both
@@ -4689,6 +5225,14 @@ Style/NegatedWhile:
4689
5225
  Enabled: true
4690
5226
  VersionAdded: '0.20'
4691
5227
 
5228
+ Style/NegativeArrayIndex:
5229
+ Description: >-
5230
+ Use negative array indices instead of calculating array length minus a value.
5231
+ Also handles range patterns with length calculations. Recognizes preserving methods
5232
+ and their combinations, allowing safe replacement when the receiver matches.
5233
+ Enabled: pending
5234
+ VersionAdded: '1.84'
5235
+
4692
5236
  Style/NestedFileDirname:
4693
5237
  Description: 'Checks for nested `File.dirname`.'
4694
5238
  Enabled: pending
@@ -4737,8 +5281,12 @@ Style/Next:
4737
5281
  Description: 'Use `next` to skip iteration instead of a condition at the end.'
4738
5282
  StyleGuide: '#no-nested-conditionals'
4739
5283
  Enabled: true
5284
+ # Expected to be disabled by default in the next major release.
5285
+ # Same objection as `IfUnlessModifier`: it forces a shape on loop bodies.
5286
+ Preview:
5287
+ Enabled: false
4740
5288
  VersionAdded: '0.22'
4741
- VersionChanged: '0.35'
5289
+ VersionChanged: '1.75'
4742
5290
  # With `always` all conditions at the end of an iteration needs to be
4743
5291
  # replaced by next - with `skip_modifier_ifs` the modifier if like this one
4744
5292
  # are ignored: [1, 2].each { |a| return 'yes' if a == 1 }
@@ -4746,6 +5294,7 @@ Style/Next:
4746
5294
  # `MinBodyLength` defines the number of lines of the a body of an `if` or `unless`
4747
5295
  # needs to have to trigger this cop
4748
5296
  MinBodyLength: 3
5297
+ AllowConsecutiveConditionals: false
4749
5298
  SupportedStyles:
4750
5299
  - skip_modifier_ifs
4751
5300
  - always
@@ -4819,6 +5368,10 @@ Style/NumericLiterals:
4819
5368
  readability.
4820
5369
  StyleGuide: '#underscores-in-numerics'
4821
5370
  Enabled: true
5371
+ # Expected to be disabled by default in the next major release.
5372
+ # Underscores in long numbers are a preference, and generated tables trip it constantly.
5373
+ Preview:
5374
+ Enabled: false
4822
5375
  VersionAdded: '0.9'
4823
5376
  VersionChanged: '0.48'
4824
5377
  MinDigits: 5
@@ -4837,6 +5390,10 @@ Style/NumericPredicate:
4837
5390
  # of the variables which rubocop doesn't have.
4838
5391
  Safe: false
4839
5392
  Enabled: true
5393
+ # Expected to be disabled by default in the next major release.
5394
+ # A pure preference between `x > 0` and `x.positive?`.
5395
+ Preview:
5396
+ Enabled: false
4840
5397
  VersionAdded: '0.42'
4841
5398
  VersionChanged: '0.59'
4842
5399
  EnforcedStyle: predicate
@@ -4863,22 +5420,33 @@ Style/ObjectThen:
4863
5420
  - then
4864
5421
  - yield_self
4865
5422
 
5423
+ Style/OneClassPerFile:
5424
+ Description: 'Checks that each source file defines at most one top-level class or module.'
5425
+ StyleGuide: '#one-class-per-file'
5426
+ Enabled: pending
5427
+ VersionAdded: '1.85'
5428
+ VersionChanged: '1.86'
5429
+ AllowedClasses: []
5430
+ Exclude:
5431
+ - 'spec/**/*'
5432
+ - 'test/**/*'
5433
+
4866
5434
  Style/OneLineConditional:
4867
5435
  Description: >-
4868
5436
  Favor the ternary operator (?:) or multi-line constructs over
4869
5437
  single-line if/then/else/end constructs.
4870
5438
  StyleGuide: '#ternary-operator'
4871
5439
  Enabled: true
4872
- AlwaysCorrectToMultiline: false
4873
5440
  VersionAdded: '0.9'
4874
5441
  VersionChanged: '0.90'
5442
+ AlwaysCorrectToMultiline: false
4875
5443
 
4876
5444
  Style/OpenStructUse:
4877
5445
  Description: >-
4878
5446
  Avoid using OpenStruct. As of Ruby 3.0, use is officially discouraged due to performance,
4879
5447
  version compatibility, and potential security issues.
4880
- Reference:
4881
- - https://docs.ruby-lang.org/en/3.0.0/OpenStruct.html#class-OpenStruct-label-Caveats
5448
+ References:
5449
+ - https://docs.ruby-lang.org/en/3.0/OpenStruct.html#class-OpenStruct-label-Caveats
4882
5450
 
4883
5451
  Enabled: pending
4884
5452
  Safe: false
@@ -4938,6 +5506,10 @@ Style/ParallelAssignment:
4938
5506
  matches on both sides of the assignment.
4939
5507
  StyleGuide: '#parallel-assignment'
4940
5508
  Enabled: true
5509
+ # Expected to be disabled by default in the next major release.
5510
+ # `a, b = 1, 2` is often the clearer form.
5511
+ Preview:
5512
+ Enabled: false
4941
5513
  VersionAdded: '0.32'
4942
5514
 
4943
5515
  Style/ParenthesesAroundCondition:
@@ -4951,11 +5523,20 @@ Style/ParenthesesAroundCondition:
4951
5523
  AllowSafeAssignment: true
4952
5524
  AllowInMultilineConditions: false
4953
5525
 
5526
+ Style/PartitionInsteadOfDoubleSelect:
5527
+ Description: >-
5528
+ Checks for consecutive `select`/`filter`/`find_all` and `reject` calls
5529
+ on the same receiver with the same block body.
5530
+ Enabled: pending
5531
+ Safe: false
5532
+ VersionAdded: '1.85'
5533
+
4954
5534
  Style/PercentLiteralDelimiters:
4955
5535
  Description: 'Use `%`-literal delimiters consistently.'
4956
5536
  StyleGuide: '#percent-literal-braces'
4957
5537
  Enabled: true
4958
5538
  VersionAdded: '0.19'
5539
+ VersionChanged: '0.48'
4959
5540
  # Specify the default preferred delimiter for all types with the 'default' key
4960
5541
  # Override individual delimiters (even with default specified) by specifying
4961
5542
  # an individual key
@@ -4966,7 +5547,6 @@ Style/PercentLiteralDelimiters:
4966
5547
  '%r': '{}'
4967
5548
  '%w': '[]'
4968
5549
  '%W': '[]'
4969
- VersionChanged: '0.48'
4970
5550
 
4971
5551
  Style/PercentQLiterals:
4972
5552
  Description: 'Checks if uses of %Q/%q match the configured preference.'
@@ -4981,8 +5561,18 @@ Style/PerlBackrefs:
4981
5561
  Description: 'Avoid Perl-style regex back references.'
4982
5562
  StyleGuide: '#no-perl-regexp-last-matchers'
4983
5563
  Enabled: true
5564
+ # Expected to be disabled by default in the next major release.
5565
+ # `$1` is idiomatic Ruby.
5566
+ Preview:
5567
+ Enabled: false
4984
5568
  VersionAdded: '0.13'
4985
5569
 
5570
+ Style/PredicateWithKind:
5571
+ Description: 'Prefer `any?(Klass)` to `any? { |x| x.is_a?(Klass) }`.'
5572
+ Enabled: pending
5573
+ SafeAutoCorrect: false
5574
+ VersionAdded: '1.85'
5575
+
4986
5576
  Style/PreferredHashMethods:
4987
5577
  Description: 'Checks use of `has_key?` and `has_value?` Hash methods.'
4988
5578
  StyleGuide: '#hash-key'
@@ -5016,6 +5606,10 @@ Style/RaiseArgs:
5016
5606
  Description: 'Checks the arguments passed to raise/fail.'
5017
5607
  StyleGuide: '#exception-class-messages'
5018
5608
  Enabled: true
5609
+ # Expected to be disabled by default in the next major release.
5610
+ # A pure preference between `raise Foo, msg` and `raise Foo.new(msg)`.
5611
+ Preview:
5612
+ Enabled: false
5019
5613
  Safe: false
5020
5614
  VersionAdded: '0.14'
5021
5615
  VersionChanged: '1.61'
@@ -5033,8 +5627,14 @@ Style/RandomWithOffset:
5033
5627
  Enabled: true
5034
5628
  VersionAdded: '0.52'
5035
5629
 
5630
+ Style/ReduceToHash:
5631
+ Description: 'Use `to_h { ... }` instead of `each_with_object`, `inject`, or `reduce` to build a hash.'
5632
+ Enabled: pending
5633
+ Safe: false
5634
+ VersionAdded: '1.85'
5635
+
5036
5636
  Style/RedundantArgument:
5037
- Description: 'Check for a redundant argument passed to certain methods.'
5637
+ Description: 'Checks for a redundant argument passed to certain methods.'
5038
5638
  Enabled: pending
5039
5639
  Safe: false
5040
5640
  VersionAdded: '1.4'
@@ -5048,6 +5648,8 @@ Style/RedundantArgument:
5048
5648
  exit: true
5049
5649
  # Kernel.#exit!
5050
5650
  exit!: false
5651
+ # String#to_i
5652
+ to_i: 10
5051
5653
  # String#split
5052
5654
  split: ' '
5053
5655
  # String#chomp
@@ -5060,6 +5662,12 @@ Style/RedundantArrayConstructor:
5060
5662
  Enabled: pending
5061
5663
  VersionAdded: '1.52'
5062
5664
 
5665
+ Style/RedundantArrayFlatten:
5666
+ Description: 'Checks for redundant calls of `Array#flatten`.'
5667
+ Enabled: pending
5668
+ Safe: false
5669
+ VersionAdded: '1.76'
5670
+
5063
5671
  Style/RedundantAssignment:
5064
5672
  Description: 'Checks for redundant assignment before returning.'
5065
5673
  Enabled: true
@@ -5081,6 +5689,10 @@ Style/RedundantCondition:
5081
5689
  Description: 'Checks for unnecessary conditional expressions.'
5082
5690
  Enabled: true
5083
5691
  VersionAdded: '0.76'
5692
+ VersionChanged: '1.73'
5693
+ AllowedMethods:
5694
+ - infinite?
5695
+ - nonzero?
5084
5696
 
5085
5697
  Style/RedundantConditional:
5086
5698
  Description: "Don't return true/false from a conditional."
@@ -5089,6 +5701,7 @@ Style/RedundantConditional:
5089
5701
 
5090
5702
  Style/RedundantConstantBase:
5091
5703
  Description: Avoid redundant `::` prefix on constant.
5704
+ VersionChanged: '1.89'
5092
5705
  Enabled: pending
5093
5706
  VersionAdded: '1.40'
5094
5707
 
@@ -5119,7 +5732,8 @@ Style/RedundantFetchBlock:
5119
5732
  Description: >-
5120
5733
  Use `fetch(key, value)` instead of `fetch(key) { value }`
5121
5734
  when value has Numeric, Rational, Complex, Symbol or String type, `false`, `true`, `nil` or is a constant.
5122
- Reference: 'https://github.com/fastruby/fast-ruby#hashfetch-with-argument-vs-hashfetch--block-code'
5735
+ References:
5736
+ - 'https://github.com/fastruby/fast-ruby#hashfetch-with-argument-vs-hashfetch--block-code'
5123
5737
  Enabled: true
5124
5738
  Safe: false
5125
5739
  # If enabled, this cop will autocorrect usages of
@@ -5145,6 +5759,13 @@ Style/RedundantFilterChain:
5145
5759
  VersionAdded: '1.52'
5146
5760
  VersionChanged: '1.57'
5147
5761
 
5762
+ Style/RedundantFormat:
5763
+ Description: 'Checks for usages of `Kernel#format` or `Kernel#sprintf` with only a single argument.'
5764
+ Enabled: pending
5765
+ SafeAutoCorrect: false
5766
+ VersionAdded: '1.72'
5767
+ VersionChanged: '1.72'
5768
+
5148
5769
  Style/RedundantFreeze:
5149
5770
  Description: "Checks usages of Object#freeze on immutable objects."
5150
5771
  Enabled: true
@@ -5161,9 +5782,9 @@ Style/RedundantInitialize:
5161
5782
  Enabled: pending
5162
5783
  AutoCorrect: contextual
5163
5784
  Safe: false
5164
- AllowComments: true
5165
5785
  VersionAdded: '1.27'
5166
5786
  VersionChanged: '1.61'
5787
+ AllowComments: true
5167
5788
 
5168
5789
  Style/RedundantInterpolation:
5169
5790
  Description: 'Checks for strings that are just an interpolated expression.'
@@ -5178,10 +5799,16 @@ Style/RedundantInterpolationUnfreeze:
5178
5799
  VersionAdded: '1.66'
5179
5800
 
5180
5801
  Style/RedundantLineContinuation:
5181
- Description: 'Check for redundant line continuation.'
5802
+ Description: 'Checks for redundant line continuation.'
5803
+ StyleGuide: '#no-trailing-backslash'
5182
5804
  Enabled: pending
5183
5805
  VersionAdded: '1.49'
5184
5806
 
5807
+ Style/RedundantMinMaxBy:
5808
+ Description: 'Identifies places where `max_by`/`min_by` can be replaced by `max`/`min`.'
5809
+ Enabled: pending
5810
+ VersionAdded: '1.85'
5811
+
5185
5812
  Style/RedundantParentheses:
5186
5813
  Description: "Checks for parentheses that seem not to serve any purpose."
5187
5814
  Enabled: true
@@ -5210,6 +5837,7 @@ Style/RedundantRegexpConstructor:
5210
5837
 
5211
5838
  Style/RedundantRegexpEscape:
5212
5839
  Description: 'Checks for redundant escapes in Regexps.'
5840
+ StyleGuide: '#limit-escapes'
5213
5841
  Enabled: true
5214
5842
  VersionAdded: '0.85'
5215
5843
 
@@ -5259,10 +5887,21 @@ Style/RedundantStringEscape:
5259
5887
  Enabled: pending
5260
5888
  VersionAdded: '1.37'
5261
5889
 
5890
+ Style/RedundantStructKeywordInit:
5891
+ Description: 'Checks for redundant `keyword_init` option for `Struct.new`.'
5892
+ Enabled: false
5893
+ SafeAutoCorrect: false
5894
+ VersionAdded: '1.85'
5895
+ VersionChanged: '1.86'
5896
+
5262
5897
  Style/RegexpLiteral:
5263
5898
  Description: 'Use / or %r around regular expressions.'
5264
5899
  StyleGuide: '#percent-r'
5265
5900
  Enabled: true
5901
+ # Expected to be disabled by default in the next major release.
5902
+ # A pure preference between `//` and `%r{}`.
5903
+ Preview:
5904
+ Enabled: false
5266
5905
  VersionAdded: '0.9'
5267
5906
  VersionChanged: '0.30'
5268
5907
  EnforcedStyle: slashes
@@ -5295,6 +5934,10 @@ Style/RescueStandardError:
5295
5934
  Enabled: true
5296
5935
  VersionAdded: '0.52'
5297
5936
  EnforcedStyle: explicit
5937
+ # Expected to become the default in the next major release.
5938
+ # A bare `rescue` is the pick of most projects that set this.
5939
+ Preview:
5940
+ EnforcedStyle: implicit
5298
5941
  # implicit: Do not include the error class, `rescue`
5299
5942
  # explicit: Require an error class `rescue StandardError`
5300
5943
  SupportedStyles:
@@ -5315,10 +5958,16 @@ Style/ReturnNilInPredicateMethodDefinition:
5315
5958
  StyleGuide: '#bool-methods-qmark'
5316
5959
  Enabled: pending
5317
5960
  SafeAutoCorrect: false
5318
- AllowedMethods: []
5319
- AllowedPatterns: []
5320
5961
  VersionAdded: '1.53'
5321
5962
  VersionChanged: '1.67'
5963
+ AllowedMethods: []
5964
+ AllowedPatterns: []
5965
+
5966
+ Style/ReverseFind:
5967
+ Description: 'Use `array.rfind` instead of `array.reverse.find`.'
5968
+ Enabled: pending
5969
+ Safe: false
5970
+ VersionAdded: '1.84'
5322
5971
 
5323
5972
  Style/SafeNavigation:
5324
5973
  Description: >-
@@ -5354,12 +6003,25 @@ Style/Sample:
5354
6003
  Description: >-
5355
6004
  Use `sample` instead of `shuffle.first`,
5356
6005
  `shuffle.last`, and `shuffle[Integer]`.
5357
- Reference: 'https://github.com/fastruby/fast-ruby#arrayshufflefirst-vs-arraysample-code'
6006
+ References:
6007
+ - 'https://github.com/fastruby/fast-ruby#arrayshufflefirst-vs-arraysample-code'
5358
6008
  Enabled: true
5359
6009
  VersionAdded: '0.30'
5360
6010
 
6011
+ Style/SelectByKind:
6012
+ Description: 'Prefer grep/grep_v to select/reject/find/detect with a kind check.'
6013
+ Enabled: pending
6014
+ SafeAutoCorrect: false
6015
+ VersionAdded: '1.85'
6016
+
6017
+ Style/SelectByRange:
6018
+ Description: 'Prefer grep/grep_v to select/reject/find/detect with a range check.'
6019
+ Enabled: pending
6020
+ SafeAutoCorrect: false
6021
+ VersionAdded: '1.85'
6022
+
5361
6023
  Style/SelectByRegexp:
5362
- Description: 'Prefer grep/grep_v to select/reject with a regexp match.'
6024
+ Description: 'Prefer grep/grep_v to select/reject/find/detect with a regexp match.'
5363
6025
  Enabled: pending
5364
6026
  SafeAutoCorrect: false
5365
6027
  VersionAdded: '1.22'
@@ -5399,6 +6061,10 @@ Style/SignalException:
5399
6061
  Description: 'Checks for proper usage of fail and raise.'
5400
6062
  StyleGuide: '#prefer-raise-over-fail'
5401
6063
  Enabled: true
6064
+ # Expected to be disabled by default in the next major release.
6065
+ # `raise` versus `fail` stopped being a meaningful distinction long ago.
6066
+ Preview:
6067
+ Enabled: false
5402
6068
  VersionAdded: '0.11'
5403
6069
  VersionChanged: '0.37'
5404
6070
  EnforcedStyle: only_raise
@@ -5460,6 +6126,10 @@ Style/SpecialGlobalVars:
5460
6126
  Description: 'Avoid Perl-style global variables.'
5461
6127
  StyleGuide: '#no-cryptic-perlisms'
5462
6128
  Enabled: true
6129
+ # Expected to be disabled by default in the next major release.
6130
+ # The long names need `require 'English'`; the short ones are idiomatic.
6131
+ Preview:
6132
+ Enabled: false
5463
6133
  VersionAdded: '0.13'
5464
6134
  VersionChanged: '0.36'
5465
6135
  SafeAutoCorrect: false
@@ -5471,7 +6141,7 @@ Style/SpecialGlobalVars:
5471
6141
  - use_builtin_english_names
5472
6142
 
5473
6143
  Style/StabbyLambdaParentheses:
5474
- Description: 'Check for the usage of parentheses around stabby lambda arguments.'
6144
+ Description: 'Checks for the usage of parentheses around stabby lambda arguments.'
5475
6145
  StyleGuide: '#stabby-lambda-with-args'
5476
6146
  Enabled: true
5477
6147
  VersionAdded: '0.35'
@@ -5483,6 +6153,7 @@ Style/StabbyLambdaParentheses:
5483
6153
  Style/StaticClass:
5484
6154
  Description: 'Prefer modules to classes with only class methods.'
5485
6155
  StyleGuide: '#modules-vs-classes'
6156
+ VersionChanged: '1.89'
5486
6157
  Enabled: false
5487
6158
  Safe: false
5488
6159
  VersionAdded: '1.3'
@@ -5524,6 +6195,10 @@ Style/StringLiterals:
5524
6195
  VersionAdded: '0.9'
5525
6196
  VersionChanged: '0.36'
5526
6197
  EnforcedStyle: single_quotes
6198
+ # Expected to become the default in the next major release.
6199
+ # Double quotes are what most Ruby is written with; Standard and omakase pick them too.
6200
+ Preview:
6201
+ EnforcedStyle: double_quotes
5527
6202
  SupportedStyles:
5528
6203
  - single_quotes
5529
6204
  - double_quotes
@@ -5538,6 +6213,10 @@ Style/StringLiteralsInInterpolation:
5538
6213
  Enabled: true
5539
6214
  VersionAdded: '0.27'
5540
6215
  EnforcedStyle: single_quotes
6216
+ # Expected to become the default in the next major release.
6217
+ # Follows `Style/StringLiterals`.
6218
+ Preview:
6219
+ EnforcedStyle: double_quotes
5541
6220
  SupportedStyles:
5542
6221
  - single_quotes
5543
6222
  - double_quotes
@@ -5594,6 +6273,10 @@ Style/SymbolArray:
5594
6273
  VersionAdded: '0.9'
5595
6274
  VersionChanged: '0.49'
5596
6275
  EnforcedStyle: percent
6276
+ # Expected to become the default in the next major release.
6277
+ # Bracketed arrays are the pick of nearly every project that sets this; Standard turns the cop off instead.
6278
+ Preview:
6279
+ EnforcedStyle: brackets
5597
6280
  MinSize: 2
5598
6281
  SupportedStyles:
5599
6282
  - percent
@@ -5618,18 +6301,34 @@ Style/SymbolProc:
5618
6301
  AllowedPatterns: []
5619
6302
  AllowComments: false
5620
6303
 
6304
+ Style/TallyMethod:
6305
+ Description: 'Prefer `Enumerable#tally` over manual counting patterns.'
6306
+ Enabled: pending
6307
+ Safe: false
6308
+ VersionAdded: '1.85'
6309
+
5621
6310
  Style/TernaryParentheses:
5622
6311
  Description: 'Checks for use of parentheses around ternary conditions.'
5623
6312
  Enabled: true
5624
6313
  VersionAdded: '0.42'
5625
6314
  VersionChanged: '0.46'
5626
6315
  EnforcedStyle: require_no_parentheses
6316
+ # Expected to become the default in the next major release.
6317
+ # Parentheses only around complex conditions is the pick of nearly every project that sets this.
6318
+ Preview:
6319
+ EnforcedStyle: require_parentheses_when_complex
5627
6320
  SupportedStyles:
5628
6321
  - require_parentheses
5629
6322
  - require_no_parentheses
5630
6323
  - require_parentheses_when_complex
5631
6324
  AllowSafeAssignment: true
5632
6325
 
6326
+ Style/TimeNow:
6327
+ Description: 'Prefer `Time.now` over `Time.new` when retrieving the current system time.'
6328
+ StyleGuide: '#time-now'
6329
+ Enabled: pending
6330
+ VersionAdded: '1.90'
6331
+
5633
6332
  Style/TopLevelMethodDefinition:
5634
6333
  Description: 'Looks for top-level method definitions.'
5635
6334
  StyleGuide: '#top-level-methods'
@@ -5642,12 +6341,12 @@ Style/TrailingBodyOnClass:
5642
6341
  VersionAdded: '0.53'
5643
6342
 
5644
6343
  Style/TrailingBodyOnMethodDefinition:
5645
- Description: 'Method body goes below definition.'
6344
+ Description: 'Checks for trailing code after the method definition.'
5646
6345
  Enabled: true
5647
6346
  VersionAdded: '0.52'
5648
6347
 
5649
6348
  Style/TrailingBodyOnModule:
5650
- Description: 'Module body goes below module statement.'
6349
+ Description: 'Checks for trailing code after the module definition.'
5651
6350
  Enabled: true
5652
6351
  VersionAdded: '0.53'
5653
6352
 
@@ -5660,10 +6359,14 @@ Style/TrailingCommaInArguments:
5660
6359
  # parenthesized method calls where each argument is on its own line.
5661
6360
  # If `consistent_comma`, the cop requires a comma after the last argument,
5662
6361
  # for all parenthesized method calls with arguments.
6362
+ # If `diff_comma`, the cop requires a comma after the last argument, but only
6363
+ # when that argument is followed by an immediate newline, even if
6364
+ # there is an inline comment.
5663
6365
  EnforcedStyleForMultiline: no_comma
5664
6366
  SupportedStylesForMultiline:
5665
6367
  - comma
5666
6368
  - consistent_comma
6369
+ - diff_comma
5667
6370
  - no_comma
5668
6371
 
5669
6372
  Style/TrailingCommaInArrayLiteral:
@@ -5671,14 +6374,17 @@ Style/TrailingCommaInArrayLiteral:
5671
6374
  StyleGuide: '#no-trailing-array-commas'
5672
6375
  Enabled: true
5673
6376
  VersionAdded: '0.53'
5674
- # If `comma`, the cop requires a comma after the last item in an array,
5675
- # but only when each item is on its own line.
5676
- # If `consistent_comma`, the cop requires a comma after the last item of all
5677
- # non-empty, multiline array literals.
6377
+ # If `comma`, the cop requires a comma after the last item in an array, but only when each item is
6378
+ # on its own line.
6379
+ # If `consistent_comma`, the cop requires a comma after the last item of all non-empty, multiline
6380
+ # array literals.
6381
+ # If `diff_comma`, the cop requires a comma after the last item of all non-empty, multiline array
6382
+ # literals, but only when that last item immediately precedes a newline.
5678
6383
  EnforcedStyleForMultiline: no_comma
5679
6384
  SupportedStylesForMultiline:
5680
6385
  - comma
5681
6386
  - consistent_comma
6387
+ - diff_comma
5682
6388
  - no_comma
5683
6389
 
5684
6390
  Style/TrailingCommaInBlockArgs:
@@ -5690,14 +6396,17 @@ Style/TrailingCommaInBlockArgs:
5690
6396
  Style/TrailingCommaInHashLiteral:
5691
6397
  Description: 'Checks for trailing comma in hash literals.'
5692
6398
  Enabled: true
5693
- # If `comma`, the cop requires a comma after the last item in a hash,
5694
- # but only when each item is on its own line.
5695
- # If `consistent_comma`, the cop requires a comma after the last item of all
5696
- # non-empty, multiline hash literals.
6399
+ # If `comma`, the cop requires a comma after the last item in a hash, but only when each item is
6400
+ # on its own line.
6401
+ # If `consistent_comma`, the cop requires a comma after the last item of all non-empty, multiline
6402
+ # hash literals.
6403
+ # If `diff_comma`, the cop requires a comma after the last item of all non-empty, multiline hash
6404
+ # literals, but only when that last item immediately precedes a newline.
5697
6405
  EnforcedStyleForMultiline: no_comma
5698
6406
  SupportedStylesForMultiline:
5699
6407
  - comma
5700
6408
  - consistent_comma
6409
+ - diff_comma
5701
6410
  - no_comma
5702
6411
  VersionAdded: '0.53'
5703
6412
 
@@ -5710,10 +6419,11 @@ Style/TrailingUnderscoreVariable:
5710
6419
  Description: >-
5711
6420
  Checks for the usage of unneeded trailing underscores at the
5712
6421
  end of parallel variable assignment.
5713
- AllowNamedUnderscoreVariables: true
6422
+ StyleGuide: '#trailing-underscore-variables'
5714
6423
  Enabled: true
5715
6424
  VersionAdded: '0.31'
5716
6425
  VersionChanged: '0.35'
6426
+ AllowNamedUnderscoreVariables: true
5717
6427
 
5718
6428
  # `TrivialAccessors` requires exact name matches and doesn't allow
5719
6429
  # predicated methods by default.
@@ -5824,6 +6534,10 @@ Style/WordArray:
5824
6534
  VersionAdded: '0.9'
5825
6535
  VersionChanged: '1.19'
5826
6536
  EnforcedStyle: percent
6537
+ # Expected to become the default in the next major release.
6538
+ # Same preference as `SymbolArray`, and the two are configured together in practice.
6539
+ Preview:
6540
+ EnforcedStyle: brackets
5827
6541
  SupportedStyles:
5828
6542
  # percent style: %w(word1 word2)
5829
6543
  - percent
@@ -5843,8 +6557,12 @@ Style/YAMLFileRead:
5843
6557
 
5844
6558
  Style/YodaCondition:
5845
6559
  Description: 'Forbid or enforce yoda conditions.'
5846
- Reference: 'https://en.wikipedia.org/wiki/Yoda_conditions'
6560
+ References:
6561
+ - 'https://en.wikipedia.org/wiki/Yoda_conditions'
5847
6562
  Enabled: true
6563
+ Safe: false
6564
+ VersionAdded: '0.49'
6565
+ VersionChanged: '0.75'
5848
6566
  EnforcedStyle: forbid_for_all_comparison_operators
5849
6567
  SupportedStyles:
5850
6568
  # check all comparison operators
@@ -5855,9 +6573,6 @@ Style/YodaCondition:
5855
6573
  - require_for_all_comparison_operators
5856
6574
  # enforce yoda only for equality operators: `!=` and `==`
5857
6575
  - require_for_equality_operators_only
5858
- Safe: false
5859
- VersionAdded: '0.49'
5860
- VersionChanged: '0.75'
5861
6576
 
5862
6577
  Style/YodaExpression:
5863
6578
  Description: 'Forbid the use of yoda expressions.'