rubocop 1.69.2 → 1.75.4

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 (372) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +1 -1
  3. data/README.md +4 -4
  4. data/config/default.yml +183 -41
  5. data/config/internal_affairs.yml +20 -0
  6. data/config/obsoletion.yml +3 -1
  7. data/lib/rubocop/cli/command/execute_runner.rb +3 -3
  8. data/lib/rubocop/cli/command/show_cops.rb +24 -2
  9. data/lib/rubocop/cli/command/suggest_extensions.rb +7 -1
  10. data/lib/rubocop/cli.rb +1 -1
  11. data/lib/rubocop/comment_config.rb +2 -2
  12. data/lib/rubocop/config.rb +52 -10
  13. data/lib/rubocop/config_loader.rb +52 -9
  14. data/lib/rubocop/config_loader_resolver.rb +36 -10
  15. data/lib/rubocop/config_obsoletion/extracted_cop.rb +4 -3
  16. data/lib/rubocop/config_obsoletion/renamed_cop.rb +18 -3
  17. data/lib/rubocop/config_obsoletion.rb +46 -2
  18. data/lib/rubocop/config_validator.rb +25 -14
  19. data/lib/rubocop/cop/autocorrect_logic.rb +1 -1
  20. data/lib/rubocop/cop/base.rb +6 -0
  21. data/lib/rubocop/cop/bundler/duplicated_gem.rb +1 -1
  22. data/lib/rubocop/cop/bundler/gem_comment.rb +1 -1
  23. data/lib/rubocop/cop/internal_affairs/cop_enabled.rb +85 -0
  24. data/lib/rubocop/cop/internal_affairs/example_description.rb +8 -4
  25. data/lib/rubocop/cop/internal_affairs/location_exists.rb +116 -0
  26. data/lib/rubocop/cop/internal_affairs/location_expression.rb +2 -1
  27. data/lib/rubocop/cop/internal_affairs/node_first_or_last_argument.rb +3 -2
  28. data/lib/rubocop/cop/internal_affairs/node_matcher_directive.rb +1 -1
  29. data/lib/rubocop/cop/internal_affairs/node_pattern_groups/ast_processor.rb +63 -0
  30. data/lib/rubocop/cop/internal_affairs/node_pattern_groups/ast_walker.rb +131 -0
  31. data/lib/rubocop/cop/internal_affairs/node_pattern_groups.rb +230 -0
  32. data/lib/rubocop/cop/internal_affairs/node_type_group.rb +91 -0
  33. data/lib/rubocop/cop/internal_affairs/node_type_multiple_predicates.rb +126 -0
  34. data/lib/rubocop/cop/internal_affairs/node_type_predicate.rb +4 -3
  35. data/lib/rubocop/cop/internal_affairs/on_send_without_on_csend.rb +90 -0
  36. data/lib/rubocop/cop/internal_affairs/plugin.rb +33 -0
  37. data/lib/rubocop/cop/internal_affairs/redundant_described_class_as_subject.rb +6 -5
  38. data/lib/rubocop/cop/internal_affairs/redundant_source_range.rb +3 -1
  39. data/lib/rubocop/cop/internal_affairs/single_line_comparison.rb +5 -4
  40. data/lib/rubocop/cop/internal_affairs/undefined_config.rb +13 -2
  41. data/lib/rubocop/cop/internal_affairs.rb +6 -16
  42. data/lib/rubocop/cop/layout/access_modifier_indentation.rb +1 -1
  43. data/lib/rubocop/cop/layout/argument_alignment.rb +2 -8
  44. data/lib/rubocop/cop/layout/block_alignment.rb +3 -1
  45. data/lib/rubocop/cop/layout/block_end_newline.rb +1 -0
  46. data/lib/rubocop/cop/layout/class_structure.rb +9 -9
  47. data/lib/rubocop/cop/layout/closing_parenthesis_indentation.rb +4 -4
  48. data/lib/rubocop/cop/layout/def_end_alignment.rb +1 -1
  49. data/lib/rubocop/cop/layout/dot_position.rb +1 -1
  50. data/lib/rubocop/cop/layout/else_alignment.rb +2 -2
  51. data/lib/rubocop/cop/layout/empty_line_after_guard_clause.rb +2 -2
  52. data/lib/rubocop/cop/layout/empty_line_between_defs.rb +7 -11
  53. data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +28 -1
  54. data/lib/rubocop/cop/layout/empty_lines_around_block_body.rb +1 -0
  55. data/lib/rubocop/cop/layout/empty_lines_around_exception_handling_keywords.rb +1 -1
  56. data/lib/rubocop/cop/layout/empty_lines_around_method_body.rb +22 -2
  57. data/lib/rubocop/cop/layout/end_alignment.rb +1 -1
  58. data/lib/rubocop/cop/layout/extra_spacing.rb +1 -1
  59. data/lib/rubocop/cop/layout/first_argument_indentation.rb +3 -8
  60. data/lib/rubocop/cop/layout/first_array_element_indentation.rb +2 -7
  61. data/lib/rubocop/cop/layout/first_hash_element_indentation.rb +2 -7
  62. data/lib/rubocop/cop/layout/first_hash_element_line_break.rb +1 -1
  63. data/lib/rubocop/cop/layout/first_parameter_indentation.rb +2 -2
  64. data/lib/rubocop/cop/layout/hash_alignment.rb +7 -5
  65. data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +2 -1
  66. data/lib/rubocop/cop/layout/indentation_width.rb +1 -0
  67. data/lib/rubocop/cop/layout/line_continuation_spacing.rb +7 -1
  68. data/lib/rubocop/cop/layout/line_end_string_concatenation_indentation.rb +2 -2
  69. data/lib/rubocop/cop/layout/line_length.rb +9 -4
  70. data/lib/rubocop/cop/layout/multiline_block_layout.rb +1 -0
  71. data/lib/rubocop/cop/layout/multiline_hash_key_line_breaks.rb +1 -1
  72. data/lib/rubocop/cop/layout/multiline_method_argument_line_breaks.rb +25 -0
  73. data/lib/rubocop/cop/layout/multiline_method_call_brace_layout.rb +1 -0
  74. data/lib/rubocop/cop/layout/multiline_method_call_indentation.rb +4 -4
  75. data/lib/rubocop/cop/layout/multiline_method_parameter_line_breaks.rb +1 -0
  76. data/lib/rubocop/cop/layout/multiline_operation_indentation.rb +1 -1
  77. data/lib/rubocop/cop/layout/redundant_line_break.rb +16 -11
  78. data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +3 -5
  79. data/lib/rubocop/cop/layout/single_line_block_chain.rb +1 -1
  80. data/lib/rubocop/cop/layout/space_after_colon.rb +2 -2
  81. data/lib/rubocop/cop/layout/space_after_comma.rb +1 -1
  82. data/lib/rubocop/cop/layout/space_after_method_name.rb +1 -1
  83. data/lib/rubocop/cop/layout/space_after_semicolon.rb +1 -1
  84. data/lib/rubocop/cop/layout/space_around_keyword.rb +1 -0
  85. data/lib/rubocop/cop/layout/space_around_method_call_operator.rb +1 -1
  86. data/lib/rubocop/cop/layout/space_around_operators.rb +7 -4
  87. data/lib/rubocop/cop/layout/space_before_block_braces.rb +1 -0
  88. data/lib/rubocop/cop/layout/space_before_comma.rb +1 -1
  89. data/lib/rubocop/cop/layout/space_before_semicolon.rb +1 -1
  90. data/lib/rubocop/cop/layout/space_inside_block_braces.rb +1 -0
  91. data/lib/rubocop/cop/layout/trailing_whitespace.rb +5 -3
  92. data/lib/rubocop/cop/lint/ambiguous_block_association.rb +1 -1
  93. data/lib/rubocop/cop/lint/array_literal_in_regexp.rb +119 -0
  94. data/lib/rubocop/cop/lint/assignment_in_condition.rb +1 -3
  95. data/lib/rubocop/cop/lint/binary_operator_with_identical_operands.rb +1 -1
  96. data/lib/rubocop/cop/lint/boolean_symbol.rb +1 -1
  97. data/lib/rubocop/cop/lint/circular_argument_reference.rb +2 -5
  98. data/lib/rubocop/cop/lint/constant_definition_in_block.rb +3 -3
  99. data/lib/rubocop/cop/lint/constant_reassignment.rb +148 -0
  100. data/lib/rubocop/cop/lint/cop_directive_syntax.rb +84 -0
  101. data/lib/rubocop/cop/lint/debugger.rb +3 -3
  102. data/lib/rubocop/cop/lint/deprecated_open_ssl_constant.rb +1 -1
  103. data/lib/rubocop/cop/lint/duplicate_match_pattern.rb +1 -1
  104. data/lib/rubocop/cop/lint/duplicate_methods.rb +2 -17
  105. data/lib/rubocop/cop/lint/duplicate_regexp_character_class_element.rb +1 -1
  106. data/lib/rubocop/cop/lint/duplicate_set_element.rb +20 -7
  107. data/lib/rubocop/cop/lint/empty_conditional_body.rb +14 -64
  108. data/lib/rubocop/cop/lint/empty_expression.rb +0 -2
  109. data/lib/rubocop/cop/lint/erb_new_arguments.rb +0 -6
  110. data/lib/rubocop/cop/lint/float_comparison.rb +6 -8
  111. data/lib/rubocop/cop/lint/float_out_of_range.rb +1 -1
  112. data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +2 -2
  113. data/lib/rubocop/cop/lint/implicit_string_concatenation.rb +1 -1
  114. data/lib/rubocop/cop/lint/literal_as_condition.rb +117 -9
  115. data/lib/rubocop/cop/lint/literal_in_interpolation.rb +24 -6
  116. data/lib/rubocop/cop/lint/missing_cop_enable_directive.rb +1 -1
  117. data/lib/rubocop/cop/lint/missing_super.rb +2 -2
  118. data/lib/rubocop/cop/lint/mixed_case_range.rb +3 -3
  119. data/lib/rubocop/cop/lint/mixed_regexp_capture_types.rb +1 -1
  120. data/lib/rubocop/cop/lint/nested_method_definition.rb +9 -5
  121. data/lib/rubocop/cop/lint/next_without_accumulator.rb +1 -1
  122. data/lib/rubocop/cop/lint/non_atomic_file_operation.rb +4 -3
  123. data/lib/rubocop/cop/lint/non_local_exit_from_iterator.rb +3 -3
  124. data/lib/rubocop/cop/lint/numeric_operation_with_constant_result.rb +18 -31
  125. data/lib/rubocop/cop/lint/or_assignment_to_constant.rb +1 -1
  126. data/lib/rubocop/cop/lint/out_of_range_regexp_ref.rb +2 -1
  127. data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +1 -5
  128. data/lib/rubocop/cop/lint/raise_exception.rb +29 -10
  129. data/lib/rubocop/cop/lint/redundant_regexp_quantifiers.rb +1 -1
  130. data/lib/rubocop/cop/lint/redundant_require_statement.rb +0 -21
  131. data/lib/rubocop/cop/lint/redundant_string_coercion.rb +2 -2
  132. data/lib/rubocop/cop/lint/redundant_type_conversion.rb +261 -0
  133. data/lib/rubocop/cop/lint/redundant_with_index.rb +3 -0
  134. data/lib/rubocop/cop/lint/redundant_with_object.rb +3 -0
  135. data/lib/rubocop/cop/lint/rescue_exception.rb +1 -1
  136. data/lib/rubocop/cop/lint/return_in_void_context.rb +9 -11
  137. data/lib/rubocop/cop/lint/safe_navigation_chain.rb +8 -1
  138. data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +8 -1
  139. data/lib/rubocop/cop/lint/shared_mutable_default.rb +76 -0
  140. data/lib/rubocop/cop/lint/suppressed_exception.rb +1 -1
  141. data/lib/rubocop/cop/lint/suppressed_exception_in_number_conversion.rb +111 -0
  142. data/lib/rubocop/cop/lint/symbol_conversion.rb +1 -1
  143. data/lib/rubocop/cop/lint/syntax.rb +4 -1
  144. data/lib/rubocop/cop/lint/to_enum_arguments.rb +1 -1
  145. data/lib/rubocop/cop/lint/top_level_return_with_argument.rb +1 -1
  146. data/lib/rubocop/cop/lint/unescaped_bracket_in_regexp.rb +1 -4
  147. data/lib/rubocop/cop/lint/unexpected_block_arity.rb +3 -1
  148. data/lib/rubocop/cop/lint/unmodified_reduce_accumulator.rb +1 -1
  149. data/lib/rubocop/cop/lint/unreachable_code.rb +2 -1
  150. data/lib/rubocop/cop/lint/unreachable_loop.rb +6 -6
  151. data/lib/rubocop/cop/lint/useless_access_modifier.rb +5 -4
  152. data/lib/rubocop/cop/lint/useless_assignment.rb +1 -1
  153. data/lib/rubocop/cop/lint/useless_constant_scoping.rb +71 -0
  154. data/lib/rubocop/cop/lint/useless_method_definition.rb +1 -1
  155. data/lib/rubocop/cop/lint/useless_numeric_operation.rb +2 -1
  156. data/lib/rubocop/cop/lint/useless_rescue.rb +1 -1
  157. data/lib/rubocop/cop/lint/useless_ruby2_keywords.rb +2 -2
  158. data/lib/rubocop/cop/lint/void.rb +12 -9
  159. data/lib/rubocop/cop/message_annotator.rb +7 -3
  160. data/lib/rubocop/cop/metrics/block_length.rb +1 -0
  161. data/lib/rubocop/cop/metrics/block_nesting.rb +1 -1
  162. data/lib/rubocop/cop/metrics/collection_literal_length.rb +7 -0
  163. data/lib/rubocop/cop/metrics/cyclomatic_complexity.rb +1 -1
  164. data/lib/rubocop/cop/metrics/method_length.rb +9 -1
  165. data/lib/rubocop/cop/metrics/module_length.rb +1 -1
  166. data/lib/rubocop/cop/metrics/perceived_complexity.rb +1 -1
  167. data/lib/rubocop/cop/metrics/utils/code_length_calculator.rb +1 -1
  168. data/lib/rubocop/cop/metrics/utils/repeated_attribute_discount.rb +7 -7
  169. data/lib/rubocop/cop/mixin/alignment.rb +2 -2
  170. data/lib/rubocop/cop/mixin/allowed_pattern.rb +4 -4
  171. data/lib/rubocop/cop/mixin/check_line_breakable.rb +13 -13
  172. data/lib/rubocop/cop/mixin/check_single_line_suitability.rb +2 -2
  173. data/lib/rubocop/cop/mixin/comments_help.rb +4 -2
  174. data/lib/rubocop/cop/mixin/def_node.rb +1 -1
  175. data/lib/rubocop/cop/mixin/dig_help.rb +1 -1
  176. data/lib/rubocop/cop/mixin/empty_lines_around_body.rb +1 -1
  177. data/lib/rubocop/cop/mixin/forbidden_identifiers.rb +20 -0
  178. data/lib/rubocop/cop/mixin/forbidden_pattern.rb +16 -0
  179. data/lib/rubocop/cop/mixin/frozen_string_literal.rb +0 -1
  180. data/lib/rubocop/cop/mixin/hash_shorthand_syntax.rb +22 -22
  181. data/lib/rubocop/cop/mixin/hash_subset.rb +203 -0
  182. data/lib/rubocop/cop/mixin/hash_transform_method.rb +74 -74
  183. data/lib/rubocop/cop/mixin/method_complexity.rb +2 -1
  184. data/lib/rubocop/cop/mixin/multiline_expression_indentation.rb +2 -0
  185. data/lib/rubocop/cop/mixin/percent_literal.rb +1 -1
  186. data/lib/rubocop/cop/mixin/preceding_following_alignment.rb +48 -24
  187. data/lib/rubocop/cop/mixin/range_help.rb +15 -3
  188. data/lib/rubocop/cop/mixin/space_before_punctuation.rb +1 -1
  189. data/lib/rubocop/cop/mixin/statement_modifier.rb +8 -3
  190. data/lib/rubocop/cop/mixin/string_help.rb +2 -2
  191. data/lib/rubocop/cop/mixin/string_literals_help.rb +1 -1
  192. data/lib/rubocop/cop/mixin/target_ruby_version.rb +1 -1
  193. data/lib/rubocop/cop/mixin/trailing_comma.rb +16 -4
  194. data/lib/rubocop/cop/naming/block_forwarding.rb +19 -15
  195. data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +1 -1
  196. data/lib/rubocop/cop/naming/method_name.rb +64 -8
  197. data/lib/rubocop/cop/naming/predicate_name.rb +44 -0
  198. data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +3 -3
  199. data/lib/rubocop/cop/naming/variable_name.rb +51 -6
  200. data/lib/rubocop/cop/registry.rb +9 -6
  201. data/lib/rubocop/cop/security/compound_hash.rb +1 -0
  202. data/lib/rubocop/cop/style/access_modifier_declarations.rb +34 -5
  203. data/lib/rubocop/cop/style/accessor_grouping.rb +19 -5
  204. data/lib/rubocop/cop/style/and_or.rb +1 -1
  205. data/lib/rubocop/cop/style/arguments_forwarding.rb +44 -28
  206. data/lib/rubocop/cop/style/array_first_last.rb +18 -2
  207. data/lib/rubocop/cop/style/array_intersect.rb +39 -28
  208. data/lib/rubocop/cop/style/block_delimiters.rb +9 -21
  209. data/lib/rubocop/cop/style/class_and_module_children.rb +52 -11
  210. data/lib/rubocop/cop/style/class_equality_comparison.rb +1 -1
  211. data/lib/rubocop/cop/style/collection_methods.rb +2 -1
  212. data/lib/rubocop/cop/style/combinable_defined.rb +1 -1
  213. data/lib/rubocop/cop/style/combinable_loops.rb +3 -2
  214. data/lib/rubocop/cop/style/commented_keyword.rb +12 -5
  215. data/lib/rubocop/cop/style/comparable_between.rb +75 -0
  216. data/lib/rubocop/cop/style/concat_array_literals.rb +1 -1
  217. data/lib/rubocop/cop/style/conditional_assignment.rb +20 -6
  218. data/lib/rubocop/cop/style/documentation.rb +1 -1
  219. data/lib/rubocop/cop/style/double_negation.rb +4 -4
  220. data/lib/rubocop/cop/style/each_for_simple_loop.rb +4 -7
  221. data/lib/rubocop/cop/style/each_with_object.rb +2 -3
  222. data/lib/rubocop/cop/style/empty_else.rb +4 -2
  223. data/lib/rubocop/cop/style/empty_literal.rb +5 -1
  224. data/lib/rubocop/cop/style/empty_method.rb +1 -1
  225. data/lib/rubocop/cop/style/endless_method.rb +163 -18
  226. data/lib/rubocop/cop/style/eval_with_location.rb +4 -4
  227. data/lib/rubocop/cop/style/exact_regexp_match.rb +3 -10
  228. data/lib/rubocop/cop/style/expand_path_arguments.rb +2 -7
  229. data/lib/rubocop/cop/style/explicit_block_argument.rb +16 -3
  230. data/lib/rubocop/cop/style/exponential_notation.rb +3 -3
  231. data/lib/rubocop/cop/style/fetch_env_var.rb +1 -1
  232. data/lib/rubocop/cop/style/float_division.rb +8 -4
  233. data/lib/rubocop/cop/style/for.rb +1 -0
  234. data/lib/rubocop/cop/style/format_string_token.rb +38 -11
  235. data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +3 -2
  236. data/lib/rubocop/cop/style/global_std_stream.rb +3 -0
  237. data/lib/rubocop/cop/style/guard_clause.rb +2 -1
  238. data/lib/rubocop/cop/style/hash_each_methods.rb +6 -8
  239. data/lib/rubocop/cop/style/hash_except.rb +24 -148
  240. data/lib/rubocop/cop/style/hash_fetch_chain.rb +104 -0
  241. data/lib/rubocop/cop/style/hash_slice.rb +80 -0
  242. data/lib/rubocop/cop/style/hash_syntax.rb +9 -3
  243. data/lib/rubocop/cop/style/hash_transform_keys.rb +2 -2
  244. data/lib/rubocop/cop/style/hash_transform_values.rb +2 -2
  245. data/lib/rubocop/cop/style/identical_conditional_branches.rb +22 -3
  246. data/lib/rubocop/cop/style/if_inside_else.rb +10 -13
  247. data/lib/rubocop/cop/style/if_unless_modifier.rb +5 -5
  248. data/lib/rubocop/cop/style/if_with_boolean_literal_branches.rb +2 -2
  249. data/lib/rubocop/cop/style/if_with_semicolon.rb +2 -2
  250. data/lib/rubocop/cop/style/infinite_loop.rb +1 -1
  251. data/lib/rubocop/cop/style/inverse_methods.rb +15 -11
  252. data/lib/rubocop/cop/style/invertible_unless_condition.rb +2 -2
  253. data/lib/rubocop/cop/style/ip_addresses.rb +2 -2
  254. data/lib/rubocop/cop/style/it_assignment.rb +36 -0
  255. data/lib/rubocop/cop/style/it_block_parameter.rb +100 -0
  256. data/lib/rubocop/cop/style/keyword_parameters_order.rb +14 -8
  257. data/lib/rubocop/cop/style/lambda.rb +1 -0
  258. data/lib/rubocop/cop/style/lambda_call.rb +7 -2
  259. data/lib/rubocop/cop/style/line_end_concatenation.rb +10 -4
  260. data/lib/rubocop/cop/style/map_into_array.rb +5 -2
  261. data/lib/rubocop/cop/style/map_to_hash.rb +1 -1
  262. data/lib/rubocop/cop/style/map_to_set.rb +3 -2
  263. data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +23 -16
  264. data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +2 -0
  265. data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +2 -1
  266. data/lib/rubocop/cop/style/method_called_on_do_end_block.rb +3 -4
  267. data/lib/rubocop/cop/style/method_def_parentheses.rb +1 -1
  268. data/lib/rubocop/cop/style/missing_else.rb +2 -0
  269. data/lib/rubocop/cop/style/multiline_block_chain.rb +3 -2
  270. data/lib/rubocop/cop/style/multiline_method_signature.rb +1 -9
  271. data/lib/rubocop/cop/style/multiple_comparison.rb +26 -20
  272. data/lib/rubocop/cop/style/mutable_constant.rb +3 -3
  273. data/lib/rubocop/cop/style/negated_if_else_condition.rb +1 -1
  274. data/lib/rubocop/cop/style/nested_parenthesized_calls.rb +1 -1
  275. data/lib/rubocop/cop/style/next.rb +44 -0
  276. data/lib/rubocop/cop/style/object_then.rb +14 -15
  277. data/lib/rubocop/cop/style/open_struct_use.rb +5 -5
  278. data/lib/rubocop/cop/style/parallel_assignment.rb +1 -5
  279. data/lib/rubocop/cop/style/parentheses_around_condition.rb +2 -2
  280. data/lib/rubocop/cop/style/percent_literal_delimiters.rb +1 -1
  281. data/lib/rubocop/cop/style/proc.rb +2 -2
  282. data/lib/rubocop/cop/style/quoted_symbols.rb +1 -1
  283. data/lib/rubocop/cop/style/raise_args.rb +14 -12
  284. data/lib/rubocop/cop/style/random_with_offset.rb +3 -3
  285. data/lib/rubocop/cop/style/redundant_begin.rb +2 -1
  286. data/lib/rubocop/cop/style/redundant_condition.rb +59 -2
  287. data/lib/rubocop/cop/style/redundant_current_directory_in_path.rb +16 -5
  288. data/lib/rubocop/cop/style/redundant_double_splat_hash_braces.rb +6 -10
  289. data/lib/rubocop/cop/style/redundant_each.rb +1 -1
  290. data/lib/rubocop/cop/style/redundant_exception.rb +2 -2
  291. data/lib/rubocop/cop/style/redundant_format.rb +257 -0
  292. data/lib/rubocop/cop/style/redundant_freeze.rb +3 -3
  293. data/lib/rubocop/cop/style/redundant_initialize.rb +12 -3
  294. data/lib/rubocop/cop/style/redundant_line_continuation.rb +34 -16
  295. data/lib/rubocop/cop/style/redundant_parentheses.rb +48 -16
  296. data/lib/rubocop/cop/style/redundant_regexp_argument.rb +3 -0
  297. data/lib/rubocop/cop/style/redundant_regexp_character_class.rb +1 -1
  298. data/lib/rubocop/cop/style/redundant_regexp_escape.rb +1 -1
  299. data/lib/rubocop/cop/style/redundant_self.rb +1 -0
  300. data/lib/rubocop/cop/style/redundant_self_assignment.rb +14 -28
  301. data/lib/rubocop/cop/style/redundant_sort.rb +2 -2
  302. data/lib/rubocop/cop/style/redundant_sort_by.rb +17 -1
  303. data/lib/rubocop/cop/style/redundant_string_escape.rb +2 -2
  304. data/lib/rubocop/cop/style/rescue_modifier.rb +3 -0
  305. data/lib/rubocop/cop/style/return_nil.rb +2 -2
  306. data/lib/rubocop/cop/style/safe_navigation.rb +20 -5
  307. data/lib/rubocop/cop/style/select_by_regexp.rb +4 -1
  308. data/lib/rubocop/cop/style/semicolon.rb +1 -1
  309. data/lib/rubocop/cop/style/send_with_literal_method_name.rb +2 -1
  310. data/lib/rubocop/cop/style/single_line_block_params.rb +1 -1
  311. data/lib/rubocop/cop/style/single_line_do_end_block.rb +4 -3
  312. data/lib/rubocop/cop/style/single_line_methods.rb +6 -7
  313. data/lib/rubocop/cop/style/slicing_with_range.rb +40 -11
  314. data/lib/rubocop/cop/style/sole_nested_conditional.rb +41 -106
  315. data/lib/rubocop/cop/style/string_concatenation.rb +2 -2
  316. data/lib/rubocop/cop/style/string_literals.rb +1 -1
  317. data/lib/rubocop/cop/style/string_methods.rb +1 -1
  318. data/lib/rubocop/cop/style/super_arguments.rb +66 -19
  319. data/lib/rubocop/cop/style/symbol_proc.rb +2 -0
  320. data/lib/rubocop/cop/style/ternary_parentheses.rb +1 -1
  321. data/lib/rubocop/cop/style/top_level_method_definition.rb +2 -1
  322. data/lib/rubocop/cop/style/trailing_comma_in_arguments.rb +11 -2
  323. data/lib/rubocop/cop/style/trailing_comma_in_array_literal.rb +47 -6
  324. data/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb +48 -6
  325. data/lib/rubocop/cop/style/trivial_accessors.rb +1 -1
  326. data/lib/rubocop/cop/style/while_until_modifier.rb +0 -1
  327. data/lib/rubocop/cop/style/yoda_condition.rb +8 -4
  328. data/lib/rubocop/cop/style/yoda_expression.rb +2 -1
  329. data/lib/rubocop/cop/util.rb +12 -5
  330. data/lib/rubocop/cop/utils/format_string.rb +10 -5
  331. data/lib/rubocop/cop/variable_force/scope.rb +1 -1
  332. data/lib/rubocop/cop/variable_force/variable.rb +10 -3
  333. data/lib/rubocop/cop/variable_force/variable_table.rb +3 -3
  334. data/lib/rubocop/cop/variable_force.rb +1 -1
  335. data/lib/rubocop/cops_documentation_generator.rb +31 -16
  336. data/lib/rubocop/directive_comment.rb +45 -11
  337. data/lib/rubocop/ext/regexp_node.rb +0 -1
  338. data/lib/rubocop/formatter/disabled_config_formatter.rb +1 -1
  339. data/lib/rubocop/formatter/formatter_set.rb +1 -1
  340. data/lib/rubocop/formatter/pacman_formatter.rb +1 -1
  341. data/lib/rubocop/lsp/diagnostic.rb +189 -0
  342. data/lib/rubocop/lsp/logger.rb +2 -2
  343. data/lib/rubocop/lsp/routes.rb +7 -23
  344. data/lib/rubocop/lsp/runtime.rb +18 -50
  345. data/lib/rubocop/lsp/server.rb +0 -2
  346. data/lib/rubocop/lsp/stdin_runner.rb +85 -0
  347. data/lib/rubocop/magic_comment.rb +8 -0
  348. data/lib/rubocop/options.rb +28 -12
  349. data/lib/rubocop/path_util.rb +15 -8
  350. data/lib/rubocop/plugin/configuration_integrator.rb +143 -0
  351. data/lib/rubocop/plugin/load_error.rb +26 -0
  352. data/lib/rubocop/plugin/loader.rb +100 -0
  353. data/lib/rubocop/plugin/not_supported_error.rb +29 -0
  354. data/lib/rubocop/plugin.rb +46 -0
  355. data/lib/rubocop/rake_task.rb +4 -1
  356. data/lib/rubocop/result_cache.rb +13 -13
  357. data/lib/rubocop/rspec/cop_helper.rb +13 -1
  358. data/lib/rubocop/rspec/expect_offense.rb +6 -2
  359. data/lib/rubocop/rspec/shared_contexts.rb +38 -1
  360. data/lib/rubocop/rspec/support.rb +4 -2
  361. data/lib/rubocop/runner.rb +10 -7
  362. data/lib/rubocop/server/cache.rb +47 -11
  363. data/lib/rubocop/server/cli.rb +2 -2
  364. data/lib/rubocop/target_finder.rb +7 -2
  365. data/lib/rubocop/target_ruby.rb +16 -1
  366. data/lib/rubocop/version.rb +30 -8
  367. data/lib/rubocop.rb +16 -1
  368. data/lib/ruby_lsp/rubocop/addon.rb +75 -0
  369. data/lib/ruby_lsp/rubocop/runtime_adapter.rb +65 -0
  370. metadata +59 -16
  371. data/lib/rubocop/cop/utils/regexp_ranges.rb +0 -113
  372. data/lib/rubocop/rspec/host_environment_simulation_helper.rb +0 -28
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 45af4a986637b8c3dacb16d942870c2138501ae834e79c0875b81bbf09644b54
4
- data.tar.gz: 65961fc4cb25730ad9528201e22a82427def59f6ad5f048cd01a0ca89a437c3c
3
+ metadata.gz: 4fc4cebf1565ee3ced4efc79eb1012c0750f797f0ba74f94620ff50ff1d7be8e
4
+ data.tar.gz: b1e53688b07611ebec3ebc028022f71314960573cc421cfdd1b6c6b831008abf
5
5
  SHA512:
6
- metadata.gz: aa6eb7a2cbf39d99cbda0faff3dfe690a61e9665847c21669bc9a005f9ac316e9404a8babc8cadf7f033bf82afcf317c8c503ede2306e8b3a8c211abaa878cb9
7
- data.tar.gz: 126f20d27ebf2e0098d0a1039230fea4178d2a196693db8c75326a7f3fdc797b1f030af3d116f2d74f69bb70cc033372ede6836962b2c47632a9ecf4f524dd56
6
+ metadata.gz: b124c47ddee3e947bbcda187086ae1a8bf45317702d6ab0bc43f7888b90c8d560c12f61ae6fc4890bf5fec29016d88678cbc08db84e9dad5ee3ec242c8e03884
7
+ data.tar.gz: fcc14e85af8aac9186971fa21371743f29221c8e694c7cf17b44762d628c7246d720b3e241f006286a43f3523e6ab9e587e0c2f0aecb5d34fe849375ca7ad183
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012-24 Bozhidar Batsov
1
+ Copyright (c) 2012-25 Bozhidar Batsov
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -52,7 +52,7 @@ To prevent an unwanted RuboCop update you might want to use a conservative versi
52
52
  in your `Gemfile`:
53
53
 
54
54
  ```rb
55
- gem 'rubocop', '~> 1.69', require: false
55
+ gem 'rubocop', '~> 1.75', require: false
56
56
  ```
57
57
 
58
58
  See [our versioning policy](https://docs.rubocop.org/rubocop/versioning.html) for further details.
@@ -241,11 +241,11 @@ Become a sponsor and get your logo on our README on GitHub with a link to your s
241
241
  <a href="https://opencollective.com/rubocop/organization/28/website" target="_blank"><img src="https://opencollective.com/rubocop/organization/28/avatar.svg"></a>
242
242
  <a href="https://opencollective.com/rubocop/organization/29/website" target="_blank"><img src="https://opencollective.com/rubocop/organization/29/avatar.svg"></a>
243
243
 
244
- ## Changelog
244
+ ## Release Notes
245
245
 
246
- RuboCop's changelog is available [here](CHANGELOG.md).
246
+ RuboCop's release notes are available [here](https://github.com/rubocop/rubocop/releases).
247
247
 
248
248
  ## Copyright
249
249
 
250
- Copyright (c) 2012-2024 Bozhidar Batsov. See [LICENSE.txt](LICENSE.txt) for
250
+ Copyright (c) 2012-2025 Bozhidar Batsov. See [LICENSE.txt](LICENSE.txt) for
251
251
  further details.
data/config/default.yml CHANGED
@@ -146,12 +146,14 @@ AllCops:
146
146
  # Ruby version is still unresolved, RuboCop will use the oldest officially
147
147
  # supported Ruby version (currently Ruby 2.7).
148
148
  TargetRubyVersion: ~
149
- # You can specify the parser engine. There are two options available:
149
+ # RuboCop choses the parser engine automatically but you can also specify it yourself.
150
+ # These options are available:
151
+ # - `default`
150
152
  # - `parser_whitequark` ... https://github.com/whitequark/parser
151
153
  # - `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
154
+ # Not every parser engine can handle every `TargetRubyVersion`. `parser_whitequark`
155
+ # only works with versions 3.4 and below, `parser_prism` with versions 3.3 and above.
156
+ ParserEngine: default
155
157
  # Determines if a notification for extension libraries should be shown when
156
158
  # rubocop is run. Keys are the name of the extension, and values are an array
157
159
  # of gems in the Gemfile that the extension is suggested for, if not already
@@ -272,7 +274,8 @@ Bundler/OrderedGems:
272
274
  Gemspec/AddRuntimeDependency:
273
275
  Description: 'Prefer `add_dependency` over `add_runtime_dependency`.'
274
276
  StyleGuide: '#add_dependency_vs_add_runtime_dependency'
275
- Reference: https://github.com/rubygems/rubygems/issues/7799#issuecomment-2192720316
277
+ References:
278
+ - https://github.com/rubygems/rubygems/issues/7799#issuecomment-2192720316
276
279
  Enabled: pending
277
280
  VersionAdded: '1.65'
278
281
  Include:
@@ -341,7 +344,7 @@ Gemspec/RequireMFA:
341
344
  Severity: warning
342
345
  VersionAdded: '1.23'
343
346
  VersionChanged: '1.40'
344
- Reference:
347
+ References:
345
348
  - https://guides.rubygems.org/mfa-requirement-opt-in/
346
349
  Include:
347
350
  - '**/*.gemspec'
@@ -602,7 +605,7 @@ Layout/EmptyLineAfterMultilineCondition:
602
605
  # This is disabled, because this style is not very common in practice.
603
606
  Enabled: false
604
607
  VersionAdded: '0.90'
605
- Reference:
608
+ References:
606
609
  - https://github.com/airbnb/ruby#multiline-if-newline
607
610
 
608
611
  Layout/EmptyLineBetweenDefs:
@@ -637,7 +640,7 @@ Layout/EmptyLinesAroundAccessModifier:
637
640
  SupportedStyles:
638
641
  - around
639
642
  - only_before
640
- Reference:
643
+ References:
641
644
  # A reference to `EnforcedStyle: only_before`.
642
645
  - https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#follow-the-coding-conventions
643
646
 
@@ -994,7 +997,7 @@ Layout/IndentationConsistency:
994
997
  SupportedStyles:
995
998
  - normal
996
999
  - indented_internal_methods
997
- Reference:
1000
+ References:
998
1001
  # A reference to `EnforcedStyle: indented_internal_methods`.
999
1002
  - https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#follow-the-coding-conventions
1000
1003
 
@@ -1616,6 +1619,12 @@ Lint/AmbiguousRegexpLiteral:
1616
1619
  VersionAdded: '0.17'
1617
1620
  VersionChanged: '0.83'
1618
1621
 
1622
+ Lint/ArrayLiteralInRegexp:
1623
+ Description: 'Checks for an array literal interpolated inside a regexp.'
1624
+ Enabled: pending
1625
+ VersionAdded: '1.71'
1626
+ SafeAutoCorrect: false
1627
+
1619
1628
  Lint/AssignmentInCondition:
1620
1629
  Description: "Don't use assignment in conditions."
1621
1630
  StyleGuide: '#safe-assignment-in-condition'
@@ -1665,6 +1674,11 @@ Lint/ConstantOverwrittenInRescue:
1665
1674
  Enabled: pending
1666
1675
  VersionAdded: '1.31'
1667
1676
 
1677
+ Lint/ConstantReassignment:
1678
+ Description: 'Checks for constant reassignments.'
1679
+ Enabled: pending
1680
+ VersionAdded: '1.70'
1681
+
1668
1682
  Lint/ConstantResolution:
1669
1683
  Description: 'Check that constants are fully qualified with `::`.'
1670
1684
  Enabled: false
@@ -1674,6 +1688,11 @@ Lint/ConstantResolution:
1674
1688
  # Restrict this cop from only looking at certain names
1675
1689
  Ignore: []
1676
1690
 
1691
+ Lint/CopDirectiveSyntax:
1692
+ Description: 'Checks that `# rubocop:` directives are strictly formatted.'
1693
+ Enabled: pending
1694
+ VersionAdded: '1.72'
1695
+
1677
1696
  Lint/Debugger:
1678
1697
  Description: 'Check for debugger calls.'
1679
1698
  Enabled: true
@@ -1871,10 +1890,9 @@ Lint/EmptyConditionalBody:
1871
1890
  Description: 'Checks for the presence of `if`, `elsif` and `unless` branches without a body.'
1872
1891
  Enabled: true
1873
1892
  AutoCorrect: contextual
1874
- SafeAutoCorrect: false
1875
1893
  AllowComments: true
1876
1894
  VersionAdded: '0.89'
1877
- VersionChanged: '1.61'
1895
+ VersionChanged: '1.73'
1878
1896
 
1879
1897
  Lint/EmptyEnsure:
1880
1898
  Description: 'Checks for empty ensure block.'
@@ -2018,7 +2036,8 @@ Lint/InterpolationCheck:
2018
2036
 
2019
2037
  Lint/ItWithoutArgumentsInBlock:
2020
2038
  Description: 'Checks uses of `it` calls without arguments in block.'
2021
- Reference: 'https://bugs.ruby-lang.org/issues/18980'
2039
+ References:
2040
+ - 'https://bugs.ruby-lang.org/issues/18980'
2022
2041
  Enabled: pending
2023
2042
  VersionAdded: '1.59'
2024
2043
 
@@ -2030,6 +2049,7 @@ Lint/LambdaWithoutLiteralBlock:
2030
2049
  Lint/LiteralAsCondition:
2031
2050
  Description: 'Checks of literals used in conditions.'
2032
2051
  Enabled: true
2052
+ AutoCorrect: contextual
2033
2053
  VersionAdded: '0.51'
2034
2054
 
2035
2055
  Lint/LiteralAssignmentInCondition:
@@ -2243,9 +2263,8 @@ Lint/RedundantRegexpQuantifiers:
2243
2263
  Lint/RedundantRequireStatement:
2244
2264
  Description: 'Checks for unnecessary `require` statement.'
2245
2265
  Enabled: true
2246
- SafeAutoCorrect: false
2247
2266
  VersionAdded: '0.76'
2248
- VersionChanged: '1.57'
2267
+ VersionChanged: '1.73'
2249
2268
 
2250
2269
  Lint/RedundantSafeNavigation:
2251
2270
  Description: 'Checks for redundant safe navigation calls.'
@@ -2274,6 +2293,11 @@ Lint/RedundantStringCoercion:
2274
2293
  VersionAdded: '0.19'
2275
2294
  VersionChanged: '0.77'
2276
2295
 
2296
+ Lint/RedundantTypeConversion:
2297
+ Description: 'Checks for redundantly converting a literal to the same type.'
2298
+ Enabled: pending
2299
+ VersionAdded: '1.72'
2300
+
2277
2301
  Lint/RedundantWithIndex:
2278
2302
  Description: 'Checks for redundant `with_index`.'
2279
2303
  Enabled: true
@@ -2402,6 +2426,12 @@ Lint/ShadowingOuterLocalVariable:
2402
2426
  Enabled: true
2403
2427
  VersionAdded: '0.9'
2404
2428
 
2429
+ Lint/SharedMutableDefault:
2430
+ Description: 'Checks for mutable literals used as default arguments during Hash initialization.'
2431
+ StyleGuide: '#no-mutable-defaults'
2432
+ Enabled: pending
2433
+ VersionAdded: '1.70'
2434
+
2405
2435
  Lint/StructNewOverride:
2406
2436
  Description: 'Disallow overriding the `Struct` built-in methods via `Struct.new`.'
2407
2437
  Enabled: true
@@ -2416,6 +2446,12 @@ Lint/SuppressedException:
2416
2446
  VersionAdded: '0.9'
2417
2447
  VersionChanged: '1.12'
2418
2448
 
2449
+ Lint/SuppressedExceptionInNumberConversion:
2450
+ Description: 'Checks for cases where exceptions unrelated to the numeric constructors may be unintentionally swallowed.'
2451
+ Enabled: pending
2452
+ SafeAutoCorrect: false
2453
+ VersionAdded: '1.72'
2454
+
2419
2455
  Lint/SymbolConversion:
2420
2456
  Description: 'Checks for unnecessary symbol conversions.'
2421
2457
  Enabled: pending
@@ -2571,6 +2607,11 @@ Lint/UselessAssignment:
2571
2607
  VersionAdded: '0.11'
2572
2608
  VersionChanged: '1.66'
2573
2609
 
2610
+ Lint/UselessConstantScoping:
2611
+ Description: 'Checks for useless constant scoping.'
2612
+ Enabled: pending
2613
+ VersionAdded: '1.72'
2614
+
2574
2615
  Lint/UselessDefined:
2575
2616
  Description: 'Checks for calls to `defined?` with strings and symbols. The result of such a call will always be truthy.'
2576
2617
  Enabled: pending
@@ -2634,7 +2675,7 @@ Metrics/AbcSize:
2634
2675
  Description: >-
2635
2676
  A calculated magnitude based on number of assignments,
2636
2677
  branches, and conditions.
2637
- Reference:
2678
+ References:
2638
2679
  - http://c2.com/cgi/wiki?AbcMetric
2639
2680
  - https://en.wikipedia.org/wiki/ABC_Software_Metric
2640
2681
  Enabled: true
@@ -2958,6 +2999,7 @@ Naming/MethodName:
2958
2999
  StyleGuide: '#snake-case-symbols-methods-vars'
2959
3000
  Enabled: true
2960
3001
  VersionAdded: '0.50'
3002
+ VersionChanged: '1.75'
2961
3003
  EnforcedStyle: snake_case
2962
3004
  SupportedStyles:
2963
3005
  - snake_case
@@ -2969,6 +3011,10 @@ Naming/MethodName:
2969
3011
  # - '\A\s*onSelectionCleared\s*'
2970
3012
  #
2971
3013
  AllowedPatterns: []
3014
+ ForbiddenIdentifiers:
3015
+ - __id__
3016
+ - __send__
3017
+ ForbiddenPatterns: []
2972
3018
 
2973
3019
  Naming/MethodParameterName:
2974
3020
  Description: >-
@@ -3005,17 +3051,19 @@ Naming/PredicateName:
3005
3051
  StyleGuide: '#bool-methods-qmark'
3006
3052
  Enabled: true
3007
3053
  VersionAdded: '0.50'
3008
- VersionChanged: '0.77'
3054
+ VersionChanged: '1.75'
3009
3055
  # Predicate name prefixes.
3010
3056
  NamePrefix:
3011
3057
  - is_
3012
3058
  - has_
3013
3059
  - have_
3060
+ - does_
3014
3061
  # Predicate name prefixes that should be removed.
3015
3062
  ForbiddenPrefixes:
3016
3063
  - is_
3017
3064
  - has_
3018
3065
  - have_
3066
+ - does_
3019
3067
  # Predicate names which, despite having a forbidden prefix, or no `?`,
3020
3068
  # should still be accepted
3021
3069
  AllowedMethods:
@@ -3024,6 +3072,8 @@ Naming/PredicateName:
3024
3072
  MethodDefinitionMacros:
3025
3073
  - define_method
3026
3074
  - define_singleton_method
3075
+ # Use Sorbet's T::Boolean return type to detect predicate methods.
3076
+ UseSorbetSigs: false
3027
3077
  # Exclude Rspec specs because there is a strong convention to write spec
3028
3078
  # helpers in the form of `have_something` or `be_something`.
3029
3079
  Exclude:
@@ -3041,13 +3091,15 @@ Naming/VariableName:
3041
3091
  StyleGuide: '#snake-case-symbols-methods-vars'
3042
3092
  Enabled: true
3043
3093
  VersionAdded: '0.50'
3044
- VersionChanged: '1.8'
3094
+ VersionChanged: '1.73'
3045
3095
  EnforcedStyle: snake_case
3046
3096
  SupportedStyles:
3047
3097
  - snake_case
3048
3098
  - camelCase
3049
3099
  AllowedIdentifiers: []
3050
3100
  AllowedPatterns: []
3101
+ ForbiddenIdentifiers: []
3102
+ ForbiddenPatterns: []
3051
3103
 
3052
3104
  Naming/VariableNumber:
3053
3105
  Description: 'Use the configured style when numbering symbols, methods and variables.'
@@ -3063,6 +3115,8 @@ Naming/VariableNumber:
3063
3115
  CheckMethodNames: true
3064
3116
  CheckSymbols: true
3065
3117
  AllowedIdentifiers:
3118
+ - TLS1_1 # OpenSSL::SSL::TLS1_1_VERSION
3119
+ - TLS1_2 # OpenSSL::SSL::TLS1_2_VERSION
3066
3120
  - capture3 # Open3.capture3
3067
3121
  - iso8601 # Time#iso8601
3068
3122
  - rfc1123_date # CGI.rfc1123_date
@@ -3098,7 +3152,8 @@ Security/JSONLoad:
3098
3152
  Description: >-
3099
3153
  Prefer usage of `JSON.parse` over `JSON.load` due to potential
3100
3154
  security issues. See reference for more information.
3101
- Reference: 'https://ruby-doc.org/stdlib-2.7.0/libdoc/json/rdoc/JSON.html#method-i-load'
3155
+ References:
3156
+ - 'https://ruby-doc.org/stdlib-2.7.0/libdoc/json/rdoc/JSON.html#method-i-load'
3102
3157
  Enabled: true
3103
3158
  VersionAdded: '0.43'
3104
3159
  VersionChanged: '1.22'
@@ -3110,7 +3165,8 @@ Security/MarshalLoad:
3110
3165
  Description: >-
3111
3166
  Avoid using of `Marshal.load` or `Marshal.restore` due to potential
3112
3167
  security issues. See reference for more information.
3113
- Reference: 'https://ruby-doc.org/core-2.7.0/Marshal.html#module-Marshal-label-Security+considerations'
3168
+ References:
3169
+ - 'https://ruby-doc.org/core-2.7.0/Marshal.html#module-Marshal-label-Security+considerations'
3114
3170
  Enabled: true
3115
3171
  VersionAdded: '0.47'
3116
3172
 
@@ -3125,7 +3181,8 @@ Security/YAMLLoad:
3125
3181
  Description: >-
3126
3182
  Prefer usage of `YAML.safe_load` over `YAML.load` due to potential
3127
3183
  security issues. See reference for more information.
3128
- Reference: 'https://ruby-doc.org/stdlib-2.7.0/libdoc/yaml/rdoc/YAML.html#module-YAML-label-Security'
3184
+ References:
3185
+ - 'https://ruby-doc.org/stdlib-2.7.0/libdoc/yaml/rdoc/YAML.html#module-YAML-label-Security'
3129
3186
  Enabled: true
3130
3187
  VersionAdded: '0.47'
3131
3188
  SafeAutoCorrect: false
@@ -3136,13 +3193,14 @@ Style/AccessModifierDeclarations:
3136
3193
  Description: 'Checks style of how access modifiers are used.'
3137
3194
  Enabled: true
3138
3195
  VersionAdded: '0.57'
3139
- VersionChanged: '0.81'
3196
+ VersionChanged: '1.70'
3140
3197
  EnforcedStyle: group
3141
3198
  SupportedStyles:
3142
3199
  - inline
3143
3200
  - group
3144
3201
  AllowModifiersOnSymbols: true
3145
3202
  AllowModifiersOnAttrs: true
3203
+ AllowModifiersOnAliasMethod: true
3146
3204
  SafeAutoCorrect: false
3147
3205
 
3148
3206
  Style/AccessorGrouping:
@@ -3218,7 +3276,8 @@ Style/ArrayCoercion:
3218
3276
 
3219
3277
  Style/ArrayFirstLast:
3220
3278
  Description: 'Use `arr.first` and `arr.last` instead of `arr[0]` and `arr[-1]`.'
3221
- Reference: '#first-and-last'
3279
+ References:
3280
+ - '#first-and-last'
3222
3281
  Enabled: false
3223
3282
  VersionAdded: '1.58'
3224
3283
  Safe: false
@@ -3457,6 +3516,7 @@ Style/ClassAndModuleChildren:
3457
3516
  SafeAutoCorrect: false
3458
3517
  Enabled: true
3459
3518
  VersionAdded: '0.19'
3519
+ VersionChanged: '1.74'
3460
3520
  #
3461
3521
  # Basically there are two different styles:
3462
3522
  #
@@ -3472,7 +3532,21 @@ Style/ClassAndModuleChildren:
3472
3532
  #
3473
3533
  # The compact style is only forced, for classes or modules with one child.
3474
3534
  EnforcedStyle: nested
3475
- SupportedStyles:
3535
+ SupportedStyles: &supported_styles
3536
+ - nested
3537
+ - compact
3538
+ # Configure classes separately, if desired. If not set, or set to `nil`,
3539
+ # the `EnforcedStyle` value will be used.
3540
+ EnforcedStyleForClasses: ~
3541
+ SupportedStylesForClasses:
3542
+ - ~
3543
+ - nested
3544
+ - compact
3545
+ # Configure modules separately, if desired. If not set, or set to `nil`,
3546
+ # the `EnforcedStyle` value will be used.
3547
+ EnforcedStyleForModules: ~
3548
+ SupportedStylesForModules:
3549
+ - ~
3476
3550
  - nested
3477
3551
  - compact
3478
3552
 
@@ -3625,6 +3699,12 @@ Style/CommentedKeyword:
3625
3699
  VersionAdded: '0.51'
3626
3700
  VersionChanged: '1.19'
3627
3701
 
3702
+ Style/ComparableBetween:
3703
+ Description: 'Enforces the use of `Comparable#between?` instead of logical comparison.'
3704
+ Enabled: pending
3705
+ VersionAdded: '1.74'
3706
+ StyleGuide: '#ranges-or-between'
3707
+
3628
3708
  Style/ComparableClamp:
3629
3709
  Description: 'Enforces the use of `Comparable#clamp` instead of comparison by minimum and maximum.'
3630
3710
  Enabled: pending
@@ -3881,6 +3961,8 @@ Style/EndlessMethod:
3881
3961
  - allow_single_line
3882
3962
  - allow_always
3883
3963
  - disallow
3964
+ - require_single_line
3965
+ - require_always
3884
3966
 
3885
3967
  Style/EnvHome:
3886
3968
  Description: "Checks for consistent usage of `ENV['HOME']`."
@@ -3933,7 +4015,7 @@ Style/ExponentialNotation:
3933
4015
  Style/FetchEnvVar:
3934
4016
  Description: >-
3935
4017
  Suggests `ENV.fetch` for the replacement of `ENV[]`.
3936
- Reference:
4018
+ References:
3937
4019
  - https://rubystyle.guide/#hash-fetch-defaults
3938
4020
  Enabled: pending
3939
4021
  VersionAdded: '1.28'
@@ -3974,7 +4056,8 @@ Style/FileWrite:
3974
4056
  Style/FloatDivision:
3975
4057
  Description: 'For performing float division, coerce one side only.'
3976
4058
  StyleGuide: '#float-division'
3977
- Reference: 'https://blog.rubystyle.guide/ruby/2019/06/21/float-division.html'
4059
+ References:
4060
+ - 'https://blog.rubystyle.guide/ruby/2019/06/21/float-division.html'
3978
4061
  Enabled: true
3979
4062
  VersionAdded: '0.72'
3980
4063
  VersionChanged: '1.9'
@@ -4025,8 +4108,14 @@ Style/FormatStringToken:
4025
4108
  # style token in a format string to be allowed when enforced style is not
4026
4109
  # `unannotated`.
4027
4110
  MaxUnannotatedPlaceholdersAllowed: 1
4111
+ # The mode the cop operates in. Two values are allowed:
4112
+ # * aggressive (default): all strings are considered
4113
+ # * conservative:
4114
+ # only register offenses for strings given to `printf`, `sprintf`,
4115
+ # format` and `%` methods. Other strings are not considered.
4116
+ Mode: aggressive
4028
4117
  VersionAdded: '0.49'
4029
- VersionChanged: '1.0'
4118
+ VersionChanged: '1.74'
4030
4119
  AllowedMethods: []
4031
4120
  AllowedPatterns: []
4032
4121
 
@@ -4051,6 +4140,9 @@ Style/FrozenStringLiteralComment:
4051
4140
  # exist in a file.
4052
4141
  - never
4053
4142
  SafeAutoCorrect: false
4143
+ Exclude:
4144
+ # Prevent the Ruby warning: `'frozen_string_literal' is ignored after any tokens` when using Active Admin.
4145
+ - '**/*.arb'
4054
4146
 
4055
4147
  Style/GlobalStdStream:
4056
4148
  Description: 'Enforces the use of `$stdout/$stderr/$stdin` instead of `STDOUT/STDERR/STDIN`.'
@@ -4062,7 +4154,8 @@ Style/GlobalStdStream:
4062
4154
  Style/GlobalVars:
4063
4155
  Description: 'Do not introduce global variables.'
4064
4156
  StyleGuide: '#instance-vars'
4065
- Reference: 'https://www.zenspider.com/ruby/quickref.html'
4157
+ References:
4158
+ - 'https://www.zenspider.com/ruby/quickref.html'
4066
4159
  Enabled: true
4067
4160
  VersionAdded: '0.13'
4068
4161
  # Built-in global variables are allowed by default.
@@ -4119,6 +4212,12 @@ Style/HashExcept:
4119
4212
  VersionAdded: '1.7'
4120
4213
  VersionChanged: '1.39'
4121
4214
 
4215
+ Style/HashFetchChain:
4216
+ Description: 'Use `Hash#dig` instead of chained `fetch` calls.'
4217
+ Enabled: pending
4218
+ Safe: false
4219
+ VersionAdded: '1.75'
4220
+
4122
4221
  Style/HashLikeCase:
4123
4222
  Description: >-
4124
4223
  Checks for places where `case-when` represents a simple 1:1
@@ -4129,6 +4228,14 @@ Style/HashLikeCase:
4129
4228
  # to trigger this cop
4130
4229
  MinBranchesCount: 3
4131
4230
 
4231
+ Style/HashSlice:
4232
+ Description: >-
4233
+ Checks for usages of `Hash#reject`, `Hash#select`, and `Hash#filter` methods
4234
+ that can be replaced with `Hash#slice` method.
4235
+ Enabled: pending
4236
+ Safe: false
4237
+ VersionAdded: '1.71'
4238
+
4132
4239
  Style/HashSyntax:
4133
4240
  Description: >-
4134
4241
  Prefer Ruby 1.9 hash syntax { a: 1, b: 2 } over 1.8 syntax
@@ -4316,6 +4423,21 @@ Style/IpAddresses:
4316
4423
  - '**/gems.rb'
4317
4424
  - '**/*.gemspec'
4318
4425
 
4426
+ Style/ItAssignment:
4427
+ Description: 'Checks for assignment to `it` inside a block.'
4428
+ Enabled: pending
4429
+ VersionAdded: '1.70'
4430
+
4431
+ Style/ItBlockParameter:
4432
+ Description: 'Checks for blocks with one argument where `it` block parameter can be used.'
4433
+ Enabled: pending
4434
+ EnforcedStyle: only_numbered_parameters
4435
+ SupportedStyles:
4436
+ - only_numbered_parameters
4437
+ - always
4438
+ - disallow
4439
+ VersionAdded: '1.75'
4440
+
4319
4441
  Style/KeywordArgumentsMerging:
4320
4442
  Description: >-
4321
4443
  When passing an existing hash as keyword arguments, provide additional arguments
@@ -4704,7 +4826,7 @@ Style/Next:
4704
4826
  StyleGuide: '#no-nested-conditionals'
4705
4827
  Enabled: true
4706
4828
  VersionAdded: '0.22'
4707
- VersionChanged: '0.35'
4829
+ VersionChanged: '1.75'
4708
4830
  # With `always` all conditions at the end of an iteration needs to be
4709
4831
  # replaced by next - with `skip_modifier_ifs` the modifier if like this one
4710
4832
  # are ignored: [1, 2].each { |a| return 'yes' if a == 1 }
@@ -4712,6 +4834,7 @@ Style/Next:
4712
4834
  # `MinBodyLength` defines the number of lines of the a body of an `if` or `unless`
4713
4835
  # needs to have to trigger this cop
4714
4836
  MinBodyLength: 3
4837
+ AllowConsecutiveConditionals: false
4715
4838
  SupportedStyles:
4716
4839
  - skip_modifier_ifs
4717
4840
  - always
@@ -4843,7 +4966,7 @@ Style/OpenStructUse:
4843
4966
  Description: >-
4844
4967
  Avoid using OpenStruct. As of Ruby 3.0, use is officially discouraged due to performance,
4845
4968
  version compatibility, and potential security issues.
4846
- Reference:
4969
+ References:
4847
4970
  - https://docs.ruby-lang.org/en/3.0.0/OpenStruct.html#class-OpenStruct-label-Caveats
4848
4971
 
4849
4972
  Enabled: pending
@@ -5047,6 +5170,9 @@ Style/RedundantCondition:
5047
5170
  Description: 'Checks for unnecessary conditional expressions.'
5048
5171
  Enabled: true
5049
5172
  VersionAdded: '0.76'
5173
+ VersionChanged: '1.73'
5174
+ AllowedMethods:
5175
+ - nonzero?
5050
5176
 
5051
5177
  Style/RedundantConditional:
5052
5178
  Description: "Don't return true/false from a conditional."
@@ -5059,7 +5185,7 @@ Style/RedundantConstantBase:
5059
5185
  VersionAdded: '1.40'
5060
5186
 
5061
5187
  Style/RedundantCurrentDirectoryInPath:
5062
- Description: 'Checks for uses a redundant current directory in path.'
5188
+ Description: 'Checks for a redundant current directory in a path given to `require_relative`.'
5063
5189
  Enabled: pending
5064
5190
  VersionAdded: '1.53'
5065
5191
 
@@ -5085,7 +5211,8 @@ Style/RedundantFetchBlock:
5085
5211
  Description: >-
5086
5212
  Use `fetch(key, value)` instead of `fetch(key) { value }`
5087
5213
  when value has Numeric, Rational, Complex, Symbol or String type, `false`, `true`, `nil` or is a constant.
5088
- Reference: 'https://github.com/fastruby/fast-ruby#hashfetch-with-argument-vs-hashfetch--block-code'
5214
+ References:
5215
+ - 'https://github.com/fastruby/fast-ruby#hashfetch-with-argument-vs-hashfetch--block-code'
5089
5216
  Enabled: true
5090
5217
  Safe: false
5091
5218
  # If enabled, this cop will autocorrect usages of
@@ -5111,6 +5238,13 @@ Style/RedundantFilterChain:
5111
5238
  VersionAdded: '1.52'
5112
5239
  VersionChanged: '1.57'
5113
5240
 
5241
+ Style/RedundantFormat:
5242
+ Description: 'Checks for usages of `Kernel#format` or `Kernel#sprintf` with only a single argument.'
5243
+ Enabled: pending
5244
+ SafeAutoCorrect: false
5245
+ VersionAdded: '1.72'
5246
+ VersionChanged: '1.72'
5247
+
5114
5248
  Style/RedundantFreeze:
5115
5249
  Description: "Checks usages of Object#freeze on immutable objects."
5116
5250
  Enabled: true
@@ -5320,7 +5454,8 @@ Style/Sample:
5320
5454
  Description: >-
5321
5455
  Use `sample` instead of `shuffle.first`,
5322
5456
  `shuffle.last`, and `shuffle[Integer]`.
5323
- Reference: 'https://github.com/fastruby/fast-ruby#arrayshufflefirst-vs-arraysample-code'
5457
+ References:
5458
+ - 'https://github.com/fastruby/fast-ruby#arrayshufflefirst-vs-arraysample-code'
5324
5459
  Enabled: true
5325
5460
  VersionAdded: '0.30'
5326
5461
 
@@ -5637,14 +5772,17 @@ Style/TrailingCommaInArrayLiteral:
5637
5772
  StyleGuide: '#no-trailing-array-commas'
5638
5773
  Enabled: true
5639
5774
  VersionAdded: '0.53'
5640
- # If `comma`, the cop requires a comma after the last item in an array,
5641
- # but only when each item is on its own line.
5642
- # If `consistent_comma`, the cop requires a comma after the last item of all
5643
- # non-empty, multiline array literals.
5775
+ # If `comma`, the cop requires a comma after the last item in an array, but only when each item is
5776
+ # on its own line.
5777
+ # If `consistent_comma`, the cop requires a comma after the last item of all non-empty, multiline
5778
+ # array literals.
5779
+ # If `diff_comma`, the cop requires a comma after the last item of all non-empty, multiline array
5780
+ # literals, but only when that last item immediately precedes a newline.
5644
5781
  EnforcedStyleForMultiline: no_comma
5645
5782
  SupportedStylesForMultiline:
5646
5783
  - comma
5647
5784
  - consistent_comma
5785
+ - diff_comma
5648
5786
  - no_comma
5649
5787
 
5650
5788
  Style/TrailingCommaInBlockArgs:
@@ -5656,14 +5794,17 @@ Style/TrailingCommaInBlockArgs:
5656
5794
  Style/TrailingCommaInHashLiteral:
5657
5795
  Description: 'Checks for trailing comma in hash literals.'
5658
5796
  Enabled: true
5659
- # If `comma`, the cop requires a comma after the last item in a hash,
5660
- # but only when each item is on its own line.
5661
- # If `consistent_comma`, the cop requires a comma after the last item of all
5662
- # non-empty, multiline hash literals.
5797
+ # If `comma`, the cop requires a comma after the last item in a hash, but only when each item is
5798
+ # on its own line.
5799
+ # If `consistent_comma`, the cop requires a comma after the last item of all non-empty, multiline
5800
+ # hash literals.
5801
+ # If `diff_comma`, the cop requires a comma after the last item of all non-empty, multiline hash
5802
+ # literals, but only when that last item immediately precedes a newline.
5663
5803
  EnforcedStyleForMultiline: no_comma
5664
5804
  SupportedStylesForMultiline:
5665
5805
  - comma
5666
5806
  - consistent_comma
5807
+ - diff_comma
5667
5808
  - no_comma
5668
5809
  VersionAdded: '0.53'
5669
5810
 
@@ -5809,7 +5950,8 @@ Style/YAMLFileRead:
5809
5950
 
5810
5951
  Style/YodaCondition:
5811
5952
  Description: 'Forbid or enforce yoda conditions.'
5812
- Reference: 'https://en.wikipedia.org/wiki/Yoda_conditions'
5953
+ References:
5954
+ - 'https://en.wikipedia.org/wiki/Yoda_conditions'
5813
5955
  Enabled: true
5814
5956
  EnforcedStyle: forbid_for_all_comparison_operators
5815
5957
  SupportedStyles:
@@ -6,6 +6,26 @@ InternalAffairs/CopDescription:
6
6
  Include:
7
7
  - 'lib/rubocop/cop/**/*.rb'
8
8
 
9
+ InternalAffairs/ExampleHeredocDelimiter:
10
+ Include:
11
+ - 'spec/rubocop/cop/**/*.rb'
12
+
13
+ InternalAffairs/ExampleDescription:
14
+ Include:
15
+ - 'spec/rubocop/cop/**/*.rb'
16
+
17
+ InternalAffairs/NodeTypeGroup:
18
+ Include:
19
+ - 'lib/rubocop/cop/**/*.rb'
20
+
21
+ InternalAffairs/OnSendWithoutOnCSend:
22
+ Include:
23
+ - 'lib/rubocop/cop/**/*.rb'
24
+
25
+ InternalAffairs/UndefinedConfig:
26
+ Include:
27
+ - 'lib/rubocop/cop/**/*.rb'
28
+
9
29
  InternalAffairs/UselessMessageAssertion:
10
30
  Include:
11
31
  - '**/*_spec.rb'