rubocop 1.84.2 → 1.88.1

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