rubocop 1.67.0 → 1.76.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (488) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +1 -1
  3. data/README.md +22 -16
  4. data/config/default.yml +313 -51
  5. data/config/internal_affairs.yml +20 -0
  6. data/config/obsoletion.yml +8 -3
  7. data/lib/rubocop/cached_data.rb +12 -4
  8. data/lib/rubocop/cli/command/execute_runner.rb +4 -4
  9. data/lib/rubocop/cli/command/show_cops.rb +24 -2
  10. data/lib/rubocop/cli/command/suggest_extensions.rb +7 -1
  11. data/lib/rubocop/cli/command/version.rb +2 -2
  12. data/lib/rubocop/cli.rb +1 -1
  13. data/lib/rubocop/comment_config.rb +2 -2
  14. data/lib/rubocop/config.rb +52 -10
  15. data/lib/rubocop/config_loader.rb +52 -9
  16. data/lib/rubocop/config_loader_resolver.rb +36 -10
  17. data/lib/rubocop/config_obsoletion/extracted_cop.rb +4 -3
  18. data/lib/rubocop/config_obsoletion/renamed_cop.rb +18 -3
  19. data/lib/rubocop/config_obsoletion.rb +46 -2
  20. data/lib/rubocop/config_validator.rb +25 -14
  21. data/lib/rubocop/cop/autocorrect_logic.rb +51 -26
  22. data/lib/rubocop/cop/base.rb +7 -1
  23. data/lib/rubocop/cop/bundler/duplicated_gem.rb +2 -2
  24. data/lib/rubocop/cop/bundler/gem_comment.rb +1 -1
  25. data/lib/rubocop/cop/bundler/gem_filename.rb +0 -1
  26. data/lib/rubocop/cop/bundler/insecure_protocol_source.rb +0 -1
  27. data/lib/rubocop/cop/bundler/ordered_gems.rb +1 -1
  28. data/lib/rubocop/cop/correctors/alignment_corrector.rb +1 -12
  29. data/lib/rubocop/cop/correctors/for_to_each_corrector.rb +1 -1
  30. data/lib/rubocop/cop/correctors/percent_literal_corrector.rb +10 -0
  31. data/lib/rubocop/cop/gemspec/deprecated_attribute_assignment.rb +1 -2
  32. data/lib/rubocop/cop/gemspec/duplicated_assignment.rb +50 -6
  33. data/lib/rubocop/cop/gemspec/ordered_dependencies.rb +1 -1
  34. data/lib/rubocop/cop/gemspec/required_ruby_version.rb +0 -2
  35. data/lib/rubocop/cop/generator.rb +6 -0
  36. data/lib/rubocop/cop/internal_affairs/cop_enabled.rb +85 -0
  37. data/lib/rubocop/cop/internal_affairs/example_description.rb +8 -4
  38. data/lib/rubocop/cop/internal_affairs/location_exists.rb +116 -0
  39. data/lib/rubocop/cop/internal_affairs/location_expression.rb +2 -1
  40. data/lib/rubocop/cop/internal_affairs/location_line_equality_comparison.rb +3 -4
  41. data/lib/rubocop/cop/internal_affairs/node_first_or_last_argument.rb +3 -2
  42. data/lib/rubocop/cop/internal_affairs/node_matcher_directive.rb +1 -1
  43. data/lib/rubocop/cop/internal_affairs/node_pattern_groups/ast_processor.rb +63 -0
  44. data/lib/rubocop/cop/internal_affairs/node_pattern_groups/ast_walker.rb +131 -0
  45. data/lib/rubocop/cop/internal_affairs/node_pattern_groups.rb +231 -0
  46. data/lib/rubocop/cop/internal_affairs/node_type_group.rb +91 -0
  47. data/lib/rubocop/cop/internal_affairs/node_type_multiple_predicates.rb +126 -0
  48. data/lib/rubocop/cop/internal_affairs/node_type_predicate.rb +4 -3
  49. data/lib/rubocop/cop/internal_affairs/numblock_handler.rb +1 -1
  50. data/lib/rubocop/cop/internal_affairs/on_send_without_on_csend.rb +90 -0
  51. data/lib/rubocop/cop/internal_affairs/operator_keyword.rb +48 -0
  52. data/lib/rubocop/cop/internal_affairs/plugin.rb +33 -0
  53. data/lib/rubocop/cop/internal_affairs/redundant_described_class_as_subject.rb +6 -5
  54. data/lib/rubocop/cop/internal_affairs/redundant_source_range.rb +3 -1
  55. data/lib/rubocop/cop/internal_affairs/single_line_comparison.rb +5 -4
  56. data/lib/rubocop/cop/internal_affairs/style_detected_api_use.rb +0 -2
  57. data/lib/rubocop/cop/internal_affairs/undefined_config.rb +13 -2
  58. data/lib/rubocop/cop/internal_affairs.rb +7 -16
  59. data/lib/rubocop/cop/layout/access_modifier_indentation.rb +1 -1
  60. data/lib/rubocop/cop/layout/argument_alignment.rb +2 -9
  61. data/lib/rubocop/cop/layout/array_alignment.rb +1 -1
  62. data/lib/rubocop/cop/layout/begin_end_alignment.rb +0 -1
  63. data/lib/rubocop/cop/layout/block_alignment.rb +3 -2
  64. data/lib/rubocop/cop/layout/block_end_newline.rb +1 -0
  65. data/lib/rubocop/cop/layout/class_structure.rb +44 -9
  66. data/lib/rubocop/cop/layout/closing_parenthesis_indentation.rb +4 -4
  67. data/lib/rubocop/cop/layout/def_end_alignment.rb +1 -1
  68. data/lib/rubocop/cop/layout/dot_position.rb +1 -1
  69. data/lib/rubocop/cop/layout/else_alignment.rb +2 -2
  70. data/lib/rubocop/cop/layout/empty_line_after_guard_clause.rb +3 -3
  71. data/lib/rubocop/cop/layout/empty_line_between_defs.rb +7 -11
  72. data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +36 -6
  73. data/lib/rubocop/cop/layout/empty_lines_around_begin_body.rb +5 -6
  74. data/lib/rubocop/cop/layout/empty_lines_around_block_body.rb +1 -0
  75. data/lib/rubocop/cop/layout/empty_lines_around_exception_handling_keywords.rb +4 -5
  76. data/lib/rubocop/cop/layout/empty_lines_around_method_body.rb +23 -1
  77. data/lib/rubocop/cop/layout/end_alignment.rb +1 -1
  78. data/lib/rubocop/cop/layout/extra_spacing.rb +1 -1
  79. data/lib/rubocop/cop/layout/first_argument_indentation.rb +4 -9
  80. data/lib/rubocop/cop/layout/first_array_element_indentation.rb +2 -7
  81. data/lib/rubocop/cop/layout/first_hash_element_indentation.rb +2 -7
  82. data/lib/rubocop/cop/layout/first_hash_element_line_break.rb +1 -1
  83. data/lib/rubocop/cop/layout/first_parameter_indentation.rb +2 -2
  84. data/lib/rubocop/cop/layout/hash_alignment.rb +8 -6
  85. data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +2 -1
  86. data/lib/rubocop/cop/layout/indentation_width.rb +8 -7
  87. data/lib/rubocop/cop/layout/leading_comment_space.rb +57 -2
  88. data/lib/rubocop/cop/layout/line_continuation_leading_space.rb +11 -2
  89. data/lib/rubocop/cop/layout/line_continuation_spacing.rb +7 -1
  90. data/lib/rubocop/cop/layout/line_end_string_concatenation_indentation.rb +2 -2
  91. data/lib/rubocop/cop/layout/line_length.rb +123 -4
  92. data/lib/rubocop/cop/layout/multiline_block_layout.rb +1 -0
  93. data/lib/rubocop/cop/layout/multiline_hash_key_line_breaks.rb +1 -1
  94. data/lib/rubocop/cop/layout/multiline_method_argument_line_breaks.rb +25 -0
  95. data/lib/rubocop/cop/layout/multiline_method_call_brace_layout.rb +2 -1
  96. data/lib/rubocop/cop/layout/multiline_method_call_indentation.rb +4 -4
  97. data/lib/rubocop/cop/layout/multiline_method_definition_brace_layout.rb +1 -1
  98. data/lib/rubocop/cop/layout/multiline_method_parameter_line_breaks.rb +1 -0
  99. data/lib/rubocop/cop/layout/multiline_operation_indentation.rb +3 -4
  100. data/lib/rubocop/cop/layout/parameter_alignment.rb +3 -4
  101. data/lib/rubocop/cop/layout/redundant_line_break.rb +19 -46
  102. data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +6 -7
  103. data/lib/rubocop/cop/layout/single_line_block_chain.rb +1 -1
  104. data/lib/rubocop/cop/layout/space_after_colon.rb +2 -2
  105. data/lib/rubocop/cop/layout/space_after_comma.rb +1 -1
  106. data/lib/rubocop/cop/layout/space_after_method_name.rb +1 -1
  107. data/lib/rubocop/cop/layout/space_after_semicolon.rb +11 -1
  108. data/lib/rubocop/cop/layout/space_around_keyword.rb +2 -1
  109. data/lib/rubocop/cop/layout/space_around_method_call_operator.rb +1 -1
  110. data/lib/rubocop/cop/layout/space_around_operators.rb +23 -21
  111. data/lib/rubocop/cop/layout/space_before_block_braces.rb +1 -0
  112. data/lib/rubocop/cop/layout/space_before_brackets.rb +8 -34
  113. data/lib/rubocop/cop/layout/space_before_comma.rb +1 -1
  114. data/lib/rubocop/cop/layout/space_before_semicolon.rb +1 -1
  115. data/lib/rubocop/cop/layout/space_inside_array_literal_brackets.rb +11 -1
  116. data/lib/rubocop/cop/layout/space_inside_block_braces.rb +5 -0
  117. data/lib/rubocop/cop/layout/space_inside_hash_literal_braces.rb +7 -0
  118. data/lib/rubocop/cop/layout/space_inside_string_interpolation.rb +0 -1
  119. data/lib/rubocop/cop/layout/trailing_whitespace.rb +5 -3
  120. data/lib/rubocop/cop/lint/ambiguous_block_association.rb +1 -1
  121. data/lib/rubocop/cop/lint/array_literal_in_regexp.rb +118 -0
  122. data/lib/rubocop/cop/lint/assignment_in_condition.rb +1 -3
  123. data/lib/rubocop/cop/lint/binary_operator_with_identical_operands.rb +10 -12
  124. data/lib/rubocop/cop/lint/boolean_symbol.rb +1 -1
  125. data/lib/rubocop/cop/lint/circular_argument_reference.rb +4 -1
  126. data/lib/rubocop/cop/lint/constant_definition_in_block.rb +3 -3
  127. data/lib/rubocop/cop/lint/constant_reassignment.rb +148 -0
  128. data/lib/rubocop/cop/lint/cop_directive_syntax.rb +84 -0
  129. data/lib/rubocop/cop/lint/debugger.rb +3 -3
  130. data/lib/rubocop/cop/lint/deprecated_class_methods.rb +1 -1
  131. data/lib/rubocop/cop/lint/deprecated_open_ssl_constant.rb +3 -2
  132. data/lib/rubocop/cop/lint/duplicate_branch.rb +39 -4
  133. data/lib/rubocop/cop/lint/duplicate_match_pattern.rb +1 -1
  134. data/lib/rubocop/cop/lint/duplicate_methods.rb +86 -19
  135. data/lib/rubocop/cop/lint/duplicate_regexp_character_class_element.rb +1 -1
  136. data/lib/rubocop/cop/lint/duplicate_set_element.rb +20 -7
  137. data/lib/rubocop/cop/lint/empty_conditional_body.rb +14 -64
  138. data/lib/rubocop/cop/lint/empty_ensure.rb +1 -1
  139. data/lib/rubocop/cop/lint/empty_expression.rb +0 -2
  140. data/lib/rubocop/cop/lint/empty_file.rb +0 -2
  141. data/lib/rubocop/cop/lint/empty_interpolation.rb +3 -1
  142. data/lib/rubocop/cop/lint/ensure_return.rb +1 -1
  143. data/lib/rubocop/cop/lint/erb_new_arguments.rb +0 -6
  144. data/lib/rubocop/cop/lint/float_comparison.rb +47 -14
  145. data/lib/rubocop/cop/lint/float_out_of_range.rb +2 -4
  146. data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +2 -2
  147. data/lib/rubocop/cop/lint/hash_new_with_keyword_arguments_as_default.rb +55 -0
  148. data/lib/rubocop/cop/lint/identity_comparison.rb +19 -15
  149. data/lib/rubocop/cop/lint/implicit_string_concatenation.rb +1 -1
  150. data/lib/rubocop/cop/lint/interpolation_check.rb +9 -0
  151. data/lib/rubocop/cop/lint/it_without_arguments_in_block.rb +3 -0
  152. data/lib/rubocop/cop/lint/literal_as_condition.rb +110 -9
  153. data/lib/rubocop/cop/lint/literal_assignment_in_condition.rb +1 -1
  154. data/lib/rubocop/cop/lint/literal_in_interpolation.rb +24 -6
  155. data/lib/rubocop/cop/lint/missing_cop_enable_directive.rb +1 -1
  156. data/lib/rubocop/cop/lint/missing_super.rb +2 -2
  157. data/lib/rubocop/cop/lint/mixed_case_range.rb +5 -8
  158. data/lib/rubocop/cop/lint/mixed_regexp_capture_types.rb +1 -1
  159. data/lib/rubocop/cop/lint/nested_method_definition.rb +10 -6
  160. data/lib/rubocop/cop/lint/next_without_accumulator.rb +1 -1
  161. data/lib/rubocop/cop/lint/no_return_in_begin_end_blocks.rb +2 -2
  162. data/lib/rubocop/cop/lint/non_atomic_file_operation.rb +12 -3
  163. data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +3 -3
  164. data/lib/rubocop/cop/lint/non_local_exit_from_iterator.rb +3 -3
  165. data/lib/rubocop/cop/lint/number_conversion.rb +0 -1
  166. data/lib/rubocop/cop/lint/numbered_parameter_assignment.rb +1 -2
  167. data/lib/rubocop/cop/lint/numeric_operation_with_constant_result.rb +93 -0
  168. data/lib/rubocop/cop/lint/or_assignment_to_constant.rb +2 -3
  169. data/lib/rubocop/cop/lint/out_of_range_regexp_ref.rb +3 -2
  170. data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +1 -5
  171. data/lib/rubocop/cop/lint/raise_exception.rb +29 -10
  172. data/lib/rubocop/cop/lint/redundant_cop_enable_directive.rb +1 -1
  173. data/lib/rubocop/cop/lint/redundant_regexp_quantifiers.rb +1 -1
  174. data/lib/rubocop/cop/lint/redundant_require_statement.rb +0 -21
  175. data/lib/rubocop/cop/lint/redundant_safe_navigation.rb +12 -7
  176. data/lib/rubocop/cop/lint/redundant_splat_expansion.rb +8 -7
  177. data/lib/rubocop/cop/lint/redundant_string_coercion.rb +2 -2
  178. data/lib/rubocop/cop/lint/redundant_type_conversion.rb +261 -0
  179. data/lib/rubocop/cop/lint/redundant_with_index.rb +3 -0
  180. data/lib/rubocop/cop/lint/redundant_with_object.rb +3 -0
  181. data/lib/rubocop/cop/lint/refinement_import_methods.rb +1 -1
  182. data/lib/rubocop/cop/lint/regexp_as_condition.rb +0 -1
  183. data/lib/rubocop/cop/lint/rescue_exception.rb +1 -1
  184. data/lib/rubocop/cop/lint/rescue_type.rb +3 -7
  185. data/lib/rubocop/cop/lint/return_in_void_context.rb +9 -11
  186. data/lib/rubocop/cop/lint/safe_navigation_chain.rb +17 -1
  187. data/lib/rubocop/cop/lint/safe_navigation_consistency.rb +5 -1
  188. data/lib/rubocop/cop/lint/self_assignment.rb +8 -10
  189. data/lib/rubocop/cop/lint/shadowed_exception.rb +1 -1
  190. data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +13 -1
  191. data/lib/rubocop/cop/lint/shared_mutable_default.rb +76 -0
  192. data/lib/rubocop/cop/lint/suppressed_exception.rb +1 -1
  193. data/lib/rubocop/cop/lint/suppressed_exception_in_number_conversion.rb +111 -0
  194. data/lib/rubocop/cop/lint/symbol_conversion.rb +1 -1
  195. data/lib/rubocop/cop/lint/syntax.rb +4 -1
  196. data/lib/rubocop/cop/lint/to_enum_arguments.rb +1 -1
  197. data/lib/rubocop/cop/lint/top_level_return_with_argument.rb +1 -1
  198. data/lib/rubocop/cop/lint/unescaped_bracket_in_regexp.rb +88 -0
  199. data/lib/rubocop/cop/lint/unexpected_block_arity.rb +3 -1
  200. data/lib/rubocop/cop/lint/unmodified_reduce_accumulator.rb +1 -1
  201. data/lib/rubocop/cop/lint/unreachable_code.rb +52 -2
  202. data/lib/rubocop/cop/lint/unreachable_loop.rb +6 -6
  203. data/lib/rubocop/cop/lint/unused_method_argument.rb +18 -2
  204. data/lib/rubocop/cop/lint/useless_access_modifier.rb +5 -4
  205. data/lib/rubocop/cop/lint/useless_assignment.rb +3 -1
  206. data/lib/rubocop/cop/lint/useless_constant_scoping.rb +71 -0
  207. data/lib/rubocop/cop/lint/useless_default_value_argument.rb +87 -0
  208. data/lib/rubocop/cop/lint/useless_defined.rb +55 -0
  209. data/lib/rubocop/cop/lint/useless_else_without_rescue.rb +4 -0
  210. data/lib/rubocop/cop/lint/useless_method_definition.rb +1 -1
  211. data/lib/rubocop/cop/lint/useless_numeric_operation.rb +2 -1
  212. data/lib/rubocop/cop/lint/useless_or.rb +98 -0
  213. data/lib/rubocop/cop/lint/useless_rescue.rb +2 -2
  214. data/lib/rubocop/cop/lint/useless_ruby2_keywords.rb +2 -2
  215. data/lib/rubocop/cop/lint/useless_setter_call.rb +14 -25
  216. data/lib/rubocop/cop/lint/void.rb +16 -12
  217. data/lib/rubocop/cop/message_annotator.rb +7 -3
  218. data/lib/rubocop/cop/metrics/abc_size.rb +1 -1
  219. data/lib/rubocop/cop/metrics/block_length.rb +1 -0
  220. data/lib/rubocop/cop/metrics/block_nesting.rb +1 -1
  221. data/lib/rubocop/cop/metrics/class_length.rb +9 -9
  222. data/lib/rubocop/cop/metrics/collection_literal_length.rb +7 -0
  223. data/lib/rubocop/cop/metrics/cyclomatic_complexity.rb +5 -2
  224. data/lib/rubocop/cop/metrics/method_length.rb +9 -1
  225. data/lib/rubocop/cop/metrics/module_length.rb +1 -1
  226. data/lib/rubocop/cop/metrics/perceived_complexity.rb +1 -1
  227. data/lib/rubocop/cop/metrics/utils/abc_size_calculator.rb +1 -1
  228. data/lib/rubocop/cop/metrics/utils/code_length_calculator.rb +3 -4
  229. data/lib/rubocop/cop/metrics/utils/repeated_attribute_discount.rb +7 -7
  230. data/lib/rubocop/cop/mixin/alignment.rb +2 -2
  231. data/lib/rubocop/cop/mixin/allowed_pattern.rb +4 -4
  232. data/lib/rubocop/cop/mixin/check_assignment.rb +4 -12
  233. data/lib/rubocop/cop/mixin/check_line_breakable.rb +22 -12
  234. data/lib/rubocop/cop/mixin/check_single_line_suitability.rb +49 -0
  235. data/lib/rubocop/cop/mixin/comments_help.rb +8 -3
  236. data/lib/rubocop/cop/mixin/def_node.rb +1 -1
  237. data/lib/rubocop/cop/mixin/dig_help.rb +27 -0
  238. data/lib/rubocop/cop/mixin/empty_lines_around_body.rb +1 -1
  239. data/lib/rubocop/cop/mixin/endless_method_rewriter.rb +24 -0
  240. data/lib/rubocop/cop/mixin/forbidden_identifiers.rb +20 -0
  241. data/lib/rubocop/cop/mixin/forbidden_pattern.rb +16 -0
  242. data/lib/rubocop/cop/mixin/frozen_string_literal.rb +3 -2
  243. data/lib/rubocop/cop/mixin/hash_alignment_styles.rb +15 -14
  244. data/lib/rubocop/cop/mixin/hash_shorthand_syntax.rb +22 -22
  245. data/lib/rubocop/cop/mixin/hash_subset.rb +203 -0
  246. data/lib/rubocop/cop/mixin/hash_transform_method.rb +74 -74
  247. data/lib/rubocop/cop/mixin/line_length_help.rb +5 -4
  248. data/lib/rubocop/cop/mixin/method_complexity.rb +2 -1
  249. data/lib/rubocop/cop/mixin/multiline_expression_indentation.rb +7 -9
  250. data/lib/rubocop/cop/mixin/ordered_gem_node.rb +1 -1
  251. data/lib/rubocop/cop/mixin/percent_literal.rb +1 -1
  252. data/lib/rubocop/cop/mixin/preceding_following_alignment.rb +68 -30
  253. data/lib/rubocop/cop/mixin/range_help.rb +15 -4
  254. data/lib/rubocop/cop/mixin/space_before_punctuation.rb +1 -1
  255. data/lib/rubocop/cop/mixin/statement_modifier.rb +8 -3
  256. data/lib/rubocop/cop/mixin/string_help.rb +2 -2
  257. data/lib/rubocop/cop/mixin/string_literals_help.rb +1 -1
  258. data/lib/rubocop/cop/mixin/target_ruby_version.rb +17 -1
  259. data/lib/rubocop/cop/mixin/trailing_comma.rb +21 -5
  260. data/lib/rubocop/cop/naming/accessor_method_name.rb +6 -6
  261. data/lib/rubocop/cop/naming/block_forwarding.rb +20 -16
  262. data/lib/rubocop/cop/naming/constant_name.rb +6 -7
  263. data/lib/rubocop/cop/naming/file_name.rb +0 -2
  264. data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +12 -13
  265. data/lib/rubocop/cop/naming/method_name.rb +64 -8
  266. data/lib/rubocop/cop/naming/predicate_method.rb +216 -0
  267. data/lib/rubocop/cop/naming/{predicate_name.rb → predicate_prefix.rb} +46 -2
  268. data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +6 -14
  269. data/lib/rubocop/cop/naming/variable_name.rb +50 -6
  270. data/lib/rubocop/cop/naming/variable_number.rb +2 -3
  271. data/lib/rubocop/cop/offense.rb +2 -3
  272. data/lib/rubocop/cop/registry.rb +9 -6
  273. data/lib/rubocop/cop/security/compound_hash.rb +2 -0
  274. data/lib/rubocop/cop/security/yaml_load.rb +3 -2
  275. data/lib/rubocop/cop/style/access_modifier_declarations.rb +114 -34
  276. data/lib/rubocop/cop/style/accessor_grouping.rb +19 -5
  277. data/lib/rubocop/cop/style/ambiguous_endless_method_definition.rb +79 -0
  278. data/lib/rubocop/cop/style/and_or.rb +1 -1
  279. data/lib/rubocop/cop/style/arguments_forwarding.rb +47 -28
  280. data/lib/rubocop/cop/style/array_first_last.rb +18 -2
  281. data/lib/rubocop/cop/style/array_intersect.rb +42 -30
  282. data/lib/rubocop/cop/style/bitwise_predicate.rb +100 -0
  283. data/lib/rubocop/cop/style/block_delimiters.rb +43 -25
  284. data/lib/rubocop/cop/style/case_like_if.rb +8 -11
  285. data/lib/rubocop/cop/style/class_and_module_children.rb +52 -11
  286. data/lib/rubocop/cop/style/class_equality_comparison.rb +1 -1
  287. data/lib/rubocop/cop/style/collection_methods.rb +2 -1
  288. data/lib/rubocop/cop/style/combinable_defined.rb +115 -0
  289. data/lib/rubocop/cop/style/combinable_loops.rb +3 -2
  290. data/lib/rubocop/cop/style/command_literal.rb +1 -1
  291. data/lib/rubocop/cop/style/commented_keyword.rb +20 -3
  292. data/lib/rubocop/cop/style/comparable_between.rb +78 -0
  293. data/lib/rubocop/cop/style/concat_array_literals.rb +1 -1
  294. data/lib/rubocop/cop/style/conditional_assignment.rb +39 -27
  295. data/lib/rubocop/cop/style/constant_visibility.rb +3 -12
  296. data/lib/rubocop/cop/style/data_inheritance.rb +7 -0
  297. data/lib/rubocop/cop/style/def_with_parentheses.rb +18 -5
  298. data/lib/rubocop/cop/style/dig_chain.rb +89 -0
  299. data/lib/rubocop/cop/style/documentation.rb +1 -1
  300. data/lib/rubocop/cop/style/double_negation.rb +4 -4
  301. data/lib/rubocop/cop/style/each_for_simple_loop.rb +4 -7
  302. data/lib/rubocop/cop/style/each_with_object.rb +2 -3
  303. data/lib/rubocop/cop/style/empty_else.rb +4 -2
  304. data/lib/rubocop/cop/style/empty_literal.rb +5 -1
  305. data/lib/rubocop/cop/style/empty_method.rb +1 -1
  306. data/lib/rubocop/cop/style/empty_string_inside_interpolation.rb +100 -0
  307. data/lib/rubocop/cop/style/endless_method.rb +150 -18
  308. data/lib/rubocop/cop/style/eval_with_location.rb +4 -4
  309. data/lib/rubocop/cop/style/exact_regexp_match.rb +2 -3
  310. data/lib/rubocop/cop/style/expand_path_arguments.rb +2 -7
  311. data/lib/rubocop/cop/style/explicit_block_argument.rb +16 -3
  312. data/lib/rubocop/cop/style/exponential_notation.rb +3 -3
  313. data/lib/rubocop/cop/style/fetch_env_var.rb +2 -1
  314. data/lib/rubocop/cop/style/file_null.rb +89 -0
  315. data/lib/rubocop/cop/style/file_touch.rb +75 -0
  316. data/lib/rubocop/cop/style/float_division.rb +8 -4
  317. data/lib/rubocop/cop/style/for.rb +1 -1
  318. data/lib/rubocop/cop/style/format_string_token.rb +38 -11
  319. data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +3 -2
  320. data/lib/rubocop/cop/style/global_std_stream.rb +3 -0
  321. data/lib/rubocop/cop/style/global_vars.rb +1 -3
  322. data/lib/rubocop/cop/style/guard_clause.rb +17 -3
  323. data/lib/rubocop/cop/style/hash_conversion.rb +1 -2
  324. data/lib/rubocop/cop/style/hash_each_methods.rb +6 -8
  325. data/lib/rubocop/cop/style/hash_except.rb +35 -147
  326. data/lib/rubocop/cop/style/hash_fetch_chain.rb +104 -0
  327. data/lib/rubocop/cop/style/hash_slice.rb +80 -0
  328. data/lib/rubocop/cop/style/hash_syntax.rb +9 -3
  329. data/lib/rubocop/cop/style/hash_transform_keys.rb +2 -2
  330. data/lib/rubocop/cop/style/hash_transform_values.rb +2 -2
  331. data/lib/rubocop/cop/style/identical_conditional_branches.rb +25 -6
  332. data/lib/rubocop/cop/style/if_inside_else.rb +10 -14
  333. data/lib/rubocop/cop/style/if_unless_modifier.rb +25 -7
  334. data/lib/rubocop/cop/style/if_unless_modifier_of_if_unless.rb +4 -7
  335. data/lib/rubocop/cop/style/if_with_boolean_literal_branches.rb +3 -4
  336. data/lib/rubocop/cop/style/if_with_semicolon.rb +20 -9
  337. data/lib/rubocop/cop/style/infinite_loop.rb +1 -1
  338. data/lib/rubocop/cop/style/inverse_methods.rb +15 -12
  339. data/lib/rubocop/cop/style/invertible_unless_condition.rb +2 -2
  340. data/lib/rubocop/cop/style/ip_addresses.rb +2 -2
  341. data/lib/rubocop/cop/style/it_assignment.rb +36 -0
  342. data/lib/rubocop/cop/style/it_block_parameter.rb +119 -0
  343. data/lib/rubocop/cop/style/keyword_arguments_merging.rb +67 -0
  344. data/lib/rubocop/cop/style/keyword_parameters_order.rb +14 -8
  345. data/lib/rubocop/cop/style/lambda.rb +1 -0
  346. data/lib/rubocop/cop/style/lambda_call.rb +10 -4
  347. data/lib/rubocop/cop/style/line_end_concatenation.rb +10 -4
  348. data/lib/rubocop/cop/style/map_into_array.rb +11 -3
  349. data/lib/rubocop/cop/style/map_to_hash.rb +12 -1
  350. data/lib/rubocop/cop/style/map_to_set.rb +3 -2
  351. data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +27 -17
  352. data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +2 -0
  353. data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +8 -11
  354. data/lib/rubocop/cop/style/method_called_on_do_end_block.rb +3 -4
  355. data/lib/rubocop/cop/style/method_def_parentheses.rb +1 -1
  356. data/lib/rubocop/cop/style/missing_else.rb +2 -0
  357. data/lib/rubocop/cop/style/missing_respond_to_missing.rb +33 -3
  358. data/lib/rubocop/cop/style/multiline_block_chain.rb +3 -2
  359. data/lib/rubocop/cop/style/multiline_if_modifier.rb +2 -0
  360. data/lib/rubocop/cop/style/multiline_memoization.rb +1 -1
  361. data/lib/rubocop/cop/style/multiline_method_signature.rb +1 -9
  362. data/lib/rubocop/cop/style/multiple_comparison.rb +52 -51
  363. data/lib/rubocop/cop/style/mutable_constant.rb +7 -8
  364. data/lib/rubocop/cop/style/negated_if_else_condition.rb +7 -5
  365. data/lib/rubocop/cop/style/nested_parenthesized_calls.rb +1 -1
  366. data/lib/rubocop/cop/style/nested_ternary_operator.rb +5 -4
  367. data/lib/rubocop/cop/style/next.rb +44 -0
  368. data/lib/rubocop/cop/style/not.rb +1 -1
  369. data/lib/rubocop/cop/style/object_then.rb +15 -15
  370. data/lib/rubocop/cop/style/one_line_conditional.rb +25 -4
  371. data/lib/rubocop/cop/style/open_struct_use.rb +5 -5
  372. data/lib/rubocop/cop/style/operator_method_call.rb +5 -6
  373. data/lib/rubocop/cop/style/or_assignment.rb +3 -6
  374. data/lib/rubocop/cop/style/parallel_assignment.rb +9 -18
  375. data/lib/rubocop/cop/style/parentheses_around_condition.rb +2 -2
  376. data/lib/rubocop/cop/style/percent_literal_delimiters.rb +1 -1
  377. data/lib/rubocop/cop/style/percent_q_literals.rb +1 -1
  378. data/lib/rubocop/cop/style/proc.rb +2 -2
  379. data/lib/rubocop/cop/style/quoted_symbols.rb +1 -1
  380. data/lib/rubocop/cop/style/raise_args.rb +15 -13
  381. data/lib/rubocop/cop/style/random_with_offset.rb +3 -3
  382. data/lib/rubocop/cop/style/redundant_argument.rb +3 -1
  383. data/lib/rubocop/cop/style/redundant_array_flatten.rb +48 -0
  384. data/lib/rubocop/cop/style/redundant_assignment.rb +1 -1
  385. data/lib/rubocop/cop/style/redundant_begin.rb +2 -1
  386. data/lib/rubocop/cop/style/redundant_condition.rb +95 -23
  387. data/lib/rubocop/cop/style/redundant_current_directory_in_path.rb +16 -5
  388. data/lib/rubocop/cop/style/redundant_double_splat_hash_braces.rb +6 -10
  389. data/lib/rubocop/cop/style/redundant_each.rb +1 -1
  390. data/lib/rubocop/cop/style/redundant_exception.rb +2 -2
  391. data/lib/rubocop/cop/style/redundant_format.rb +262 -0
  392. data/lib/rubocop/cop/style/redundant_freeze.rb +3 -3
  393. data/lib/rubocop/cop/style/redundant_initialize.rb +12 -3
  394. data/lib/rubocop/cop/style/redundant_line_continuation.rb +54 -18
  395. data/lib/rubocop/cop/style/redundant_parentheses.rb +67 -26
  396. data/lib/rubocop/cop/style/redundant_regexp_argument.rb +4 -0
  397. data/lib/rubocop/cop/style/redundant_regexp_character_class.rb +1 -1
  398. data/lib/rubocop/cop/style/redundant_regexp_escape.rb +1 -1
  399. data/lib/rubocop/cop/style/redundant_return.rb +2 -2
  400. data/lib/rubocop/cop/style/redundant_self.rb +9 -15
  401. data/lib/rubocop/cop/style/redundant_self_assignment.rb +20 -32
  402. data/lib/rubocop/cop/style/redundant_self_assignment_branch.rb +4 -4
  403. data/lib/rubocop/cop/style/redundant_sort.rb +3 -3
  404. data/lib/rubocop/cop/style/redundant_sort_by.rb +17 -1
  405. data/lib/rubocop/cop/style/redundant_string_escape.rb +2 -2
  406. data/lib/rubocop/cop/style/regexp_literal.rb +1 -1
  407. data/lib/rubocop/cop/style/rescue_modifier.rb +5 -3
  408. data/lib/rubocop/cop/style/return_nil.rb +2 -2
  409. data/lib/rubocop/cop/style/safe_navigation.rb +42 -12
  410. data/lib/rubocop/cop/style/safe_navigation_chain_length.rb +52 -0
  411. data/lib/rubocop/cop/style/select_by_regexp.rb +5 -2
  412. data/lib/rubocop/cop/style/self_assignment.rb +11 -17
  413. data/lib/rubocop/cop/style/semicolon.rb +1 -1
  414. data/lib/rubocop/cop/style/send_with_literal_method_name.rb +2 -1
  415. data/lib/rubocop/cop/style/signal_exception.rb +2 -3
  416. data/lib/rubocop/cop/style/single_argument_dig.rb +9 -5
  417. data/lib/rubocop/cop/style/single_line_block_params.rb +1 -1
  418. data/lib/rubocop/cop/style/single_line_do_end_block.rb +15 -4
  419. data/lib/rubocop/cop/style/single_line_methods.rb +6 -7
  420. data/lib/rubocop/cop/style/slicing_with_range.rb +40 -11
  421. data/lib/rubocop/cop/style/sole_nested_conditional.rb +42 -106
  422. data/lib/rubocop/cop/style/special_global_vars.rb +1 -1
  423. data/lib/rubocop/cop/style/string_concatenation.rb +15 -15
  424. data/lib/rubocop/cop/style/string_literals.rb +1 -1
  425. data/lib/rubocop/cop/style/string_methods.rb +1 -1
  426. data/lib/rubocop/cop/style/struct_inheritance.rb +8 -1
  427. data/lib/rubocop/cop/style/super_arguments.rb +66 -19
  428. data/lib/rubocop/cop/style/swap_values.rb +4 -15
  429. data/lib/rubocop/cop/style/symbol_proc.rb +2 -0
  430. data/lib/rubocop/cop/style/ternary_parentheses.rb +25 -4
  431. data/lib/rubocop/cop/style/top_level_method_definition.rb +2 -1
  432. data/lib/rubocop/cop/style/trailing_comma_in_arguments.rb +11 -2
  433. data/lib/rubocop/cop/style/trailing_comma_in_array_literal.rb +47 -6
  434. data/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb +48 -6
  435. data/lib/rubocop/cop/style/trailing_underscore_variable.rb +4 -4
  436. data/lib/rubocop/cop/style/trivial_accessors.rb +1 -1
  437. data/lib/rubocop/cop/style/variable_interpolation.rb +1 -2
  438. data/lib/rubocop/cop/style/while_until_modifier.rb +0 -1
  439. data/lib/rubocop/cop/style/yoda_condition.rb +8 -4
  440. data/lib/rubocop/cop/style/yoda_expression.rb +2 -1
  441. data/lib/rubocop/cop/team.rb +1 -1
  442. data/lib/rubocop/cop/util.rb +12 -5
  443. data/lib/rubocop/cop/utils/format_string.rb +10 -5
  444. data/lib/rubocop/cop/variable_force/assignment.rb +24 -5
  445. data/lib/rubocop/cop/variable_force/branch.rb +1 -1
  446. data/lib/rubocop/cop/variable_force/scope.rb +1 -1
  447. data/lib/rubocop/cop/variable_force/variable.rb +14 -3
  448. data/lib/rubocop/cop/variable_force/variable_table.rb +5 -5
  449. data/lib/rubocop/cop/variable_force.rb +5 -11
  450. data/lib/rubocop/cops_documentation_generator.rb +50 -25
  451. data/lib/rubocop/directive_comment.rb +45 -11
  452. data/lib/rubocop/ext/regexp_node.rb +0 -1
  453. data/lib/rubocop/formatter/disabled_config_formatter.rb +3 -2
  454. data/lib/rubocop/formatter/formatter_set.rb +1 -1
  455. data/lib/rubocop/formatter/html_formatter.rb +1 -1
  456. data/lib/rubocop/formatter/pacman_formatter.rb +1 -1
  457. data/lib/rubocop/lsp/diagnostic.rb +189 -0
  458. data/lib/rubocop/lsp/logger.rb +2 -2
  459. data/lib/rubocop/lsp/routes.rb +7 -23
  460. data/lib/rubocop/lsp/runtime.rb +18 -50
  461. data/lib/rubocop/lsp/server.rb +0 -2
  462. data/lib/rubocop/lsp/stdin_runner.rb +85 -0
  463. data/lib/rubocop/magic_comment.rb +11 -3
  464. data/lib/rubocop/options.rb +28 -12
  465. data/lib/rubocop/path_util.rb +15 -8
  466. data/lib/rubocop/plugin/configuration_integrator.rb +143 -0
  467. data/lib/rubocop/plugin/load_error.rb +26 -0
  468. data/lib/rubocop/plugin/loader.rb +100 -0
  469. data/lib/rubocop/plugin/not_supported_error.rb +29 -0
  470. data/lib/rubocop/plugin.rb +46 -0
  471. data/lib/rubocop/rake_task.rb +4 -1
  472. data/lib/rubocop/result_cache.rb +13 -13
  473. data/lib/rubocop/rspec/cop_helper.rb +13 -1
  474. data/lib/rubocop/rspec/expect_offense.rb +6 -2
  475. data/lib/rubocop/rspec/shared_contexts.rb +38 -1
  476. data/lib/rubocop/rspec/support.rb +4 -2
  477. data/lib/rubocop/runner.rb +26 -15
  478. data/lib/rubocop/server/cache.rb +47 -11
  479. data/lib/rubocop/server/cli.rb +2 -2
  480. data/lib/rubocop/target_finder.rb +7 -2
  481. data/lib/rubocop/target_ruby.rb +17 -2
  482. data/lib/rubocop/version.rb +53 -12
  483. data/lib/rubocop.rb +38 -2
  484. data/lib/ruby_lsp/rubocop/addon.rb +75 -0
  485. data/lib/ruby_lsp/rubocop/runtime_adapter.rb +65 -0
  486. metadata +85 -21
  487. data/lib/rubocop/cop/utils/regexp_ranges.rb +0 -113
  488. data/lib/rubocop/rspec/host_environment_simulation_helper.rb +0 -28
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
 
@@ -1038,6 +1041,7 @@ Layout/LeadingCommentSpace:
1038
1041
  AllowDoxygenCommentStyle: false
1039
1042
  AllowGemfileRubyComment: false
1040
1043
  AllowRBSInlineAnnotation: false
1044
+ AllowSteepAnnotation: false
1041
1045
 
1042
1046
  Layout/LeadingEmptyLines:
1043
1047
  Description: Check for unnecessary blank lines at the beginning of a file.
@@ -1085,11 +1089,11 @@ Layout/LineLength:
1085
1089
  StyleGuide: '#max-line-length'
1086
1090
  Enabled: true
1087
1091
  VersionAdded: '0.25'
1088
- VersionChanged: '1.4'
1092
+ VersionChanged: '1.69'
1089
1093
  Max: 120
1094
+ AllowHeredoc: true
1090
1095
  # To make it possible to copy or click on URIs in the code, we allow lines
1091
1096
  # containing a URI to be longer than Max.
1092
- AllowHeredoc: true
1093
1097
  AllowURI: true
1094
1098
  URISchemes:
1095
1099
  - http
@@ -1101,6 +1105,8 @@ Layout/LineLength:
1101
1105
  # elements. Strings will be converted to Regexp objects. A line that matches
1102
1106
  # any regular expression listed in this option will be ignored by LineLength.
1103
1107
  AllowedPatterns: []
1108
+ # If SplitStrings is true, long strings will be split using continuations
1109
+ SplitStrings: false
1104
1110
 
1105
1111
  Layout/MultilineArrayBraceLayout:
1106
1112
  Description: >-
@@ -1498,7 +1504,6 @@ Layout/SpaceInsideHashLiteralBraces:
1498
1504
  - space
1499
1505
  - no_space
1500
1506
 
1501
-
1502
1507
  Layout/SpaceInsideParens:
1503
1508
  Description: 'No spaces after ( or before ).'
1504
1509
  StyleGuide: '#spaces-braces'
@@ -1614,6 +1619,12 @@ Lint/AmbiguousRegexpLiteral:
1614
1619
  VersionAdded: '0.17'
1615
1620
  VersionChanged: '0.83'
1616
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
+
1617
1628
  Lint/AssignmentInCondition:
1618
1629
  Description: "Don't use assignment in conditions."
1619
1630
  StyleGuide: '#safe-assignment-in-condition'
@@ -1633,7 +1644,7 @@ Lint/BinaryOperatorWithIdenticalOperands:
1633
1644
  Enabled: true
1634
1645
  Safe: false
1635
1646
  VersionAdded: '0.89'
1636
- VersionChanged: '1.7'
1647
+ VersionChanged: '1.69'
1637
1648
 
1638
1649
  Lint/BooleanSymbol:
1639
1650
  Description: 'Check for `:true` and `:false` symbols.'
@@ -1663,6 +1674,11 @@ Lint/ConstantOverwrittenInRescue:
1663
1674
  Enabled: pending
1664
1675
  VersionAdded: '1.31'
1665
1676
 
1677
+ Lint/ConstantReassignment:
1678
+ Description: 'Checks for constant reassignments.'
1679
+ Enabled: pending
1680
+ VersionAdded: '1.70'
1681
+
1666
1682
  Lint/ConstantResolution:
1667
1683
  Description: 'Check that constants are fully qualified with `::`.'
1668
1684
  Enabled: false
@@ -1672,6 +1688,11 @@ Lint/ConstantResolution:
1672
1688
  # Restrict this cop from only looking at certain names
1673
1689
  Ignore: []
1674
1690
 
1691
+ Lint/CopDirectiveSyntax:
1692
+ Description: 'Checks that `# rubocop:` directives are strictly formatted.'
1693
+ Enabled: pending
1694
+ VersionAdded: '1.72'
1695
+
1675
1696
  Lint/Debugger:
1676
1697
  Description: 'Check for debugger calls.'
1677
1698
  Enabled: true
@@ -1785,6 +1806,7 @@ Lint/DuplicateBranch:
1785
1806
  VersionChanged: '1.7'
1786
1807
  IgnoreLiteralBranches: false
1787
1808
  IgnoreConstantBranches: false
1809
+ IgnoreDuplicateElseBranch: false
1788
1810
 
1789
1811
  Lint/DuplicateCaseCondition:
1790
1812
  Description: 'Do not repeat values in case conditionals.'
@@ -1868,10 +1890,9 @@ Lint/EmptyConditionalBody:
1868
1890
  Description: 'Checks for the presence of `if`, `elsif` and `unless` branches without a body.'
1869
1891
  Enabled: true
1870
1892
  AutoCorrect: contextual
1871
- SafeAutoCorrect: false
1872
1893
  AllowComments: true
1873
1894
  VersionAdded: '0.89'
1874
- VersionChanged: '1.61'
1895
+ VersionChanged: '1.73'
1875
1896
 
1876
1897
  Lint/EmptyEnsure:
1877
1898
  Description: 'Checks for empty ensure block.'
@@ -1902,7 +1923,7 @@ Lint/EmptyInterpolation:
1902
1923
  Enabled: true
1903
1924
  AutoCorrect: contextual
1904
1925
  VersionAdded: '0.20'
1905
- VersionChanged: '1.61'
1926
+ VersionChanged: '1.76'
1906
1927
 
1907
1928
  Lint/EmptyWhen:
1908
1929
  Description: 'Checks for `when` branches with empty bodies.'
@@ -1954,6 +1975,11 @@ Lint/HashCompareByIdentity:
1954
1975
  Safe: false
1955
1976
  VersionAdded: '0.93'
1956
1977
 
1978
+ Lint/HashNewWithKeywordArgumentsAsDefault:
1979
+ Description: 'Checks for the deprecated use of keyword arguments for hash default in `Hash.new`.'
1980
+ Enabled: pending
1981
+ VersionAdded: '1.69'
1982
+
1957
1983
  Lint/HeredocMethodCallPosition:
1958
1984
  Description: >-
1959
1985
  Checks for the ordering of a method call where
@@ -2010,7 +2036,8 @@ Lint/InterpolationCheck:
2010
2036
 
2011
2037
  Lint/ItWithoutArgumentsInBlock:
2012
2038
  Description: 'Checks uses of `it` calls without arguments in block.'
2013
- Reference: 'https://bugs.ruby-lang.org/issues/18980'
2039
+ References:
2040
+ - 'https://bugs.ruby-lang.org/issues/18980'
2014
2041
  Enabled: pending
2015
2042
  VersionAdded: '1.59'
2016
2043
 
@@ -2022,6 +2049,7 @@ Lint/LambdaWithoutLiteralBlock:
2022
2049
  Lint/LiteralAsCondition:
2023
2050
  Description: 'Checks of literals used in conditions.'
2024
2051
  Enabled: true
2052
+ AutoCorrect: contextual
2025
2053
  VersionAdded: '0.51'
2026
2054
 
2027
2055
  Lint/LiteralAssignmentInCondition:
@@ -2144,6 +2172,11 @@ Lint/NumberedParameterAssignment:
2144
2172
  Enabled: pending
2145
2173
  VersionAdded: '1.9'
2146
2174
 
2175
+ Lint/NumericOperationWithConstantResult:
2176
+ Description: 'Checks for numeric operations with constant results.'
2177
+ Enabled: pending
2178
+ VersionAdded: '1.69'
2179
+
2147
2180
  Lint/OrAssignmentToConstant:
2148
2181
  Description: 'Checks unintended or-assignment to constant.'
2149
2182
  Enabled: pending
@@ -2230,9 +2263,8 @@ Lint/RedundantRegexpQuantifiers:
2230
2263
  Lint/RedundantRequireStatement:
2231
2264
  Description: 'Checks for unnecessary `require` statement.'
2232
2265
  Enabled: true
2233
- SafeAutoCorrect: false
2234
2266
  VersionAdded: '0.76'
2235
- VersionChanged: '1.57'
2267
+ VersionChanged: '1.73'
2236
2268
 
2237
2269
  Lint/RedundantSafeNavigation:
2238
2270
  Description: 'Checks for redundant safe navigation calls.'
@@ -2261,6 +2293,11 @@ Lint/RedundantStringCoercion:
2261
2293
  VersionAdded: '0.19'
2262
2294
  VersionChanged: '0.77'
2263
2295
 
2296
+ Lint/RedundantTypeConversion:
2297
+ Description: 'Checks for redundantly converting a literal to the same type.'
2298
+ Enabled: pending
2299
+ VersionAdded: '1.72'
2300
+
2264
2301
  Lint/RedundantWithIndex:
2265
2302
  Description: 'Checks for redundant `with_index`.'
2266
2303
  Enabled: true
@@ -2375,7 +2412,6 @@ Lint/ShadowedArgument:
2375
2412
  VersionAdded: '0.52'
2376
2413
  IgnoreImplicitReferences: false
2377
2414
 
2378
-
2379
2415
  Lint/ShadowedException:
2380
2416
  Description: >-
2381
2417
  Avoid rescuing a higher level exception
@@ -2387,8 +2423,15 @@ Lint/ShadowingOuterLocalVariable:
2387
2423
  Description: >-
2388
2424
  Do not use the same name as outer local variable
2389
2425
  for block arguments or block local variables.
2390
- Enabled: true
2426
+ Enabled: false
2391
2427
  VersionAdded: '0.9'
2428
+ VersionChanged: '1.76'
2429
+
2430
+ Lint/SharedMutableDefault:
2431
+ Description: 'Checks for mutable literals used as default arguments during Hash initialization.'
2432
+ StyleGuide: '#no-mutable-defaults'
2433
+ Enabled: pending
2434
+ VersionAdded: '1.70'
2392
2435
 
2393
2436
  Lint/StructNewOverride:
2394
2437
  Description: 'Disallow overriding the `Struct` built-in methods via `Struct.new`.'
@@ -2404,6 +2447,12 @@ Lint/SuppressedException:
2404
2447
  VersionAdded: '0.9'
2405
2448
  VersionChanged: '1.12'
2406
2449
 
2450
+ Lint/SuppressedExceptionInNumberConversion:
2451
+ Description: 'Checks for cases where exceptions unrelated to the numeric constructors may be unintentionally swallowed.'
2452
+ Enabled: pending
2453
+ SafeAutoCorrect: false
2454
+ VersionAdded: '1.72'
2455
+
2407
2456
  Lint/SymbolConversion:
2408
2457
  Description: 'Checks for unnecessary symbol conversions.'
2409
2458
  Enabled: pending
@@ -2455,6 +2504,11 @@ Lint/UnderscorePrefixedVariableName:
2455
2504
  VersionAdded: '0.21'
2456
2505
  AllowKeywordBlockArguments: false
2457
2506
 
2507
+ Lint/UnescapedBracketInRegexp:
2508
+ Description: 'Checks for unescaped literal `]` in Regexp.'
2509
+ Enabled: pending
2510
+ VersionAdded: '1.68'
2511
+
2458
2512
  Lint/UnexpectedBlockArity:
2459
2513
  Description: 'Looks for blocks that have fewer arguments that the calling method expects.'
2460
2514
  Enabled: pending
@@ -2514,10 +2568,12 @@ Lint/UnusedMethodArgument:
2514
2568
  Enabled: true
2515
2569
  AutoCorrect: contextual
2516
2570
  VersionAdded: '0.21'
2517
- VersionChanged: '1.61'
2571
+ VersionChanged: '1.69'
2518
2572
  AllowUnusedKeywordArguments: false
2519
2573
  IgnoreEmptyMethods: true
2520
2574
  IgnoreNotImplementedMethods: true
2575
+ NotImplementedExceptions:
2576
+ - NotImplementedError
2521
2577
 
2522
2578
  Lint/UriEscapeUnescape:
2523
2579
  Description: >-
@@ -2552,6 +2608,23 @@ Lint/UselessAssignment:
2552
2608
  VersionAdded: '0.11'
2553
2609
  VersionChanged: '1.66'
2554
2610
 
2611
+ Lint/UselessConstantScoping:
2612
+ Description: 'Checks for useless constant scoping.'
2613
+ Enabled: pending
2614
+ VersionAdded: '1.72'
2615
+
2616
+ Lint/UselessDefaultValueArgument:
2617
+ Description: 'Checks for usage of `fetch` or `Array.new` with default value argument and block.'
2618
+ Enabled: pending
2619
+ VersionAdded: '1.76'
2620
+ Safe: false
2621
+ AllowedReceivers: []
2622
+
2623
+ Lint/UselessDefined:
2624
+ Description: 'Checks for calls to `defined?` with strings and symbols. The result of such a call will always be truthy.'
2625
+ Enabled: pending
2626
+ VersionAdded: '1.69'
2627
+
2555
2628
  Lint/UselessElseWithoutRescue:
2556
2629
  Description: 'Checks for useless `else` in `begin..end` without `rescue`.'
2557
2630
  Enabled: true
@@ -2571,6 +2644,11 @@ Lint/UselessNumericOperation:
2571
2644
  Enabled: pending
2572
2645
  VersionAdded: '1.66'
2573
2646
 
2647
+ Lint/UselessOr:
2648
+ Description: 'Checks for useless OR expressions.'
2649
+ Enabled: pending
2650
+ VersionAdded: '1.76'
2651
+
2574
2652
  Lint/UselessRescue:
2575
2653
  Description: 'Checks for useless `rescue`s.'
2576
2654
  Enabled: pending
@@ -2610,7 +2688,7 @@ Metrics/AbcSize:
2610
2688
  Description: >-
2611
2689
  A calculated magnitude based on number of assignments,
2612
2690
  branches, and conditions.
2613
- Reference:
2691
+ References:
2614
2692
  - http://c2.com/cgi/wiki?AbcMetric
2615
2693
  - https://en.wikipedia.org/wiki/ABC_Software_Metric
2616
2694
  Enabled: true
@@ -2934,6 +3012,7 @@ Naming/MethodName:
2934
3012
  StyleGuide: '#snake-case-symbols-methods-vars'
2935
3013
  Enabled: true
2936
3014
  VersionAdded: '0.50'
3015
+ VersionChanged: '1.75'
2937
3016
  EnforcedStyle: snake_case
2938
3017
  SupportedStyles:
2939
3018
  - snake_case
@@ -2945,6 +3024,10 @@ Naming/MethodName:
2945
3024
  # - '\A\s*onSelectionCleared\s*'
2946
3025
  #
2947
3026
  AllowedPatterns: []
3027
+ ForbiddenIdentifiers:
3028
+ - __id__
3029
+ - __send__
3030
+ ForbiddenPatterns: []
2948
3031
 
2949
3032
  Naming/MethodParameterName:
2950
3033
  Description: >-
@@ -2976,22 +3059,36 @@ Naming/MethodParameterName:
2976
3059
  # Forbidden names that will register an offense
2977
3060
  ForbiddenNames: []
2978
3061
 
2979
- Naming/PredicateName:
2980
- Description: 'Check the names of predicate methods.'
3062
+ Naming/PredicateMethod:
3063
+ Description: 'Checks that predicate methods end with `?` and non-predicate methods do not.'
3064
+ Enabled: pending
3065
+ VersionAdded: '1.76'
3066
+ # In `aggressive` mode, the cop will register an offense for predicate methods that
3067
+ # may return a non-boolean value.
3068
+ # In `conservative` mode, the cop will *not* register an offense for predicate methods
3069
+ # that may return a non-boolean value.
3070
+ Mode: conservative
3071
+ AllowedMethods:
3072
+ - call
3073
+
3074
+ Naming/PredicatePrefix:
3075
+ Description: 'Predicate method names should not be prefixed and end with a `?`.'
2981
3076
  StyleGuide: '#bool-methods-qmark'
2982
3077
  Enabled: true
2983
3078
  VersionAdded: '0.50'
2984
- VersionChanged: '0.77'
3079
+ VersionChanged: '1.75'
2985
3080
  # Predicate name prefixes.
2986
3081
  NamePrefix:
2987
3082
  - is_
2988
3083
  - has_
2989
3084
  - have_
3085
+ - does_
2990
3086
  # Predicate name prefixes that should be removed.
2991
3087
  ForbiddenPrefixes:
2992
3088
  - is_
2993
3089
  - has_
2994
3090
  - have_
3091
+ - does_
2995
3092
  # Predicate names which, despite having a forbidden prefix, or no `?`,
2996
3093
  # should still be accepted
2997
3094
  AllowedMethods:
@@ -3000,6 +3097,8 @@ Naming/PredicateName:
3000
3097
  MethodDefinitionMacros:
3001
3098
  - define_method
3002
3099
  - define_singleton_method
3100
+ # Use Sorbet's T::Boolean return type to detect predicate methods.
3101
+ UseSorbetSigs: false
3003
3102
  # Exclude Rspec specs because there is a strong convention to write spec
3004
3103
  # helpers in the form of `have_something` or `be_something`.
3005
3104
  Exclude:
@@ -3017,13 +3116,15 @@ Naming/VariableName:
3017
3116
  StyleGuide: '#snake-case-symbols-methods-vars'
3018
3117
  Enabled: true
3019
3118
  VersionAdded: '0.50'
3020
- VersionChanged: '1.8'
3119
+ VersionChanged: '1.73'
3021
3120
  EnforcedStyle: snake_case
3022
3121
  SupportedStyles:
3023
3122
  - snake_case
3024
3123
  - camelCase
3025
3124
  AllowedIdentifiers: []
3026
3125
  AllowedPatterns: []
3126
+ ForbiddenIdentifiers: []
3127
+ ForbiddenPatterns: []
3027
3128
 
3028
3129
  Naming/VariableNumber:
3029
3130
  Description: 'Use the configured style when numbering symbols, methods and variables.'
@@ -3039,6 +3140,8 @@ Naming/VariableNumber:
3039
3140
  CheckMethodNames: true
3040
3141
  CheckSymbols: true
3041
3142
  AllowedIdentifiers:
3143
+ - TLS1_1 # OpenSSL::SSL::TLS1_1_VERSION
3144
+ - TLS1_2 # OpenSSL::SSL::TLS1_2_VERSION
3042
3145
  - capture3 # Open3.capture3
3043
3146
  - iso8601 # Time#iso8601
3044
3147
  - rfc1123_date # CGI.rfc1123_date
@@ -3074,7 +3177,8 @@ Security/JSONLoad:
3074
3177
  Description: >-
3075
3178
  Prefer usage of `JSON.parse` over `JSON.load` due to potential
3076
3179
  security issues. See reference for more information.
3077
- Reference: 'https://ruby-doc.org/stdlib-2.7.0/libdoc/json/rdoc/JSON.html#method-i-load'
3180
+ References:
3181
+ - 'https://ruby-doc.org/stdlib-2.7.0/libdoc/json/rdoc/JSON.html#method-i-load'
3078
3182
  Enabled: true
3079
3183
  VersionAdded: '0.43'
3080
3184
  VersionChanged: '1.22'
@@ -3086,7 +3190,8 @@ Security/MarshalLoad:
3086
3190
  Description: >-
3087
3191
  Avoid using of `Marshal.load` or `Marshal.restore` due to potential
3088
3192
  security issues. See reference for more information.
3089
- Reference: 'https://ruby-doc.org/core-2.7.0/Marshal.html#module-Marshal-label-Security+considerations'
3193
+ References:
3194
+ - 'https://ruby-doc.org/core-2.7.0/Marshal.html#module-Marshal-label-Security+considerations'
3090
3195
  Enabled: true
3091
3196
  VersionAdded: '0.47'
3092
3197
 
@@ -3101,7 +3206,8 @@ Security/YAMLLoad:
3101
3206
  Description: >-
3102
3207
  Prefer usage of `YAML.safe_load` over `YAML.load` due to potential
3103
3208
  security issues. See reference for more information.
3104
- Reference: 'https://ruby-doc.org/stdlib-2.7.0/libdoc/yaml/rdoc/YAML.html#module-YAML-label-Security'
3209
+ References:
3210
+ - 'https://ruby-doc.org/stdlib-2.7.0/libdoc/yaml/rdoc/YAML.html#module-YAML-label-Security'
3105
3211
  Enabled: true
3106
3212
  VersionAdded: '0.47'
3107
3213
  SafeAutoCorrect: false
@@ -3112,13 +3218,14 @@ Style/AccessModifierDeclarations:
3112
3218
  Description: 'Checks style of how access modifiers are used.'
3113
3219
  Enabled: true
3114
3220
  VersionAdded: '0.57'
3115
- VersionChanged: '0.81'
3221
+ VersionChanged: '1.70'
3116
3222
  EnforcedStyle: group
3117
3223
  SupportedStyles:
3118
3224
  - inline
3119
3225
  - group
3120
3226
  AllowModifiersOnSymbols: true
3121
3227
  AllowModifiersOnAttrs: true
3228
+ AllowModifiersOnAliasMethod: true
3122
3229
  SafeAutoCorrect: false
3123
3230
 
3124
3231
  Style/AccessorGrouping:
@@ -3143,6 +3250,12 @@ Style/Alias:
3143
3250
  - prefer_alias
3144
3251
  - prefer_alias_method
3145
3252
 
3253
+ Style/AmbiguousEndlessMethodDefinition:
3254
+ Description: 'Checks for endless methods inside operators of lower precedence.'
3255
+ StyleGuide: '#ambiguous-endless-method-defintions'
3256
+ Enabled: pending
3257
+ VersionAdded: '1.68'
3258
+
3146
3259
  Style/AndOr:
3147
3260
  Description: 'Use &&/|| instead of and/or.'
3148
3261
  StyleGuide: '#no-and-or-or'
@@ -3188,7 +3301,8 @@ Style/ArrayCoercion:
3188
3301
 
3189
3302
  Style/ArrayFirstLast:
3190
3303
  Description: 'Use `arr.first` and `arr.last` instead of `arr[0]` and `arr[-1]`.'
3191
- Reference: '#first-and-last'
3304
+ References:
3305
+ - '#first-and-last'
3192
3306
  Enabled: false
3193
3307
  VersionAdded: '1.58'
3194
3308
  Safe: false
@@ -3250,6 +3364,13 @@ Style/BisectedAttrAccessor:
3250
3364
  Enabled: true
3251
3365
  VersionAdded: '0.87'
3252
3366
 
3367
+ Style/BitwisePredicate:
3368
+ Description: 'Prefer bitwise predicate methods over direct comparison operations.'
3369
+ StyleGuide: '#bitwise-predicate-methods'
3370
+ Enabled: pending
3371
+ Safe: false
3372
+ VersionAdded: '1.68'
3373
+
3253
3374
  Style/BlockComments:
3254
3375
  Description: 'Do not use block comments.'
3255
3376
  StyleGuide: '#no-block-comments'
@@ -3420,6 +3541,7 @@ Style/ClassAndModuleChildren:
3420
3541
  SafeAutoCorrect: false
3421
3542
  Enabled: true
3422
3543
  VersionAdded: '0.19'
3544
+ VersionChanged: '1.74'
3423
3545
  #
3424
3546
  # Basically there are two different styles:
3425
3547
  #
@@ -3435,7 +3557,21 @@ Style/ClassAndModuleChildren:
3435
3557
  #
3436
3558
  # The compact style is only forced, for classes or modules with one child.
3437
3559
  EnforcedStyle: nested
3438
- SupportedStyles:
3560
+ SupportedStyles: &supported_styles
3561
+ - nested
3562
+ - compact
3563
+ # Configure classes separately, if desired. If not set, or set to `nil`,
3564
+ # the `EnforcedStyle` value will be used.
3565
+ EnforcedStyleForClasses: ~
3566
+ SupportedStylesForClasses:
3567
+ - ~
3568
+ - nested
3569
+ - compact
3570
+ # Configure modules separately, if desired. If not set, or set to `nil`,
3571
+ # the `EnforcedStyle` value will be used.
3572
+ EnforcedStyleForModules: ~
3573
+ SupportedStylesForModules:
3574
+ - ~
3439
3575
  - nested
3440
3576
  - compact
3441
3577
 
@@ -3533,6 +3669,11 @@ Style/ColonMethodDefinition:
3533
3669
  Enabled: true
3534
3670
  VersionAdded: '0.52'
3535
3671
 
3672
+ Style/CombinableDefined:
3673
+ Description: 'Checks successive `defined?` calls that can be combined into a single call.'
3674
+ Enabled: pending
3675
+ VersionAdded: '1.68'
3676
+
3536
3677
  Style/CombinableLoops:
3537
3678
  Description: >-
3538
3679
  Checks for places where multiple consecutive loops over the same data
@@ -3583,6 +3724,14 @@ Style/CommentedKeyword:
3583
3724
  VersionAdded: '0.51'
3584
3725
  VersionChanged: '1.19'
3585
3726
 
3727
+ Style/ComparableBetween:
3728
+ Description: 'Enforces the use of `Comparable#between?` instead of logical comparison.'
3729
+ Enabled: pending
3730
+ Safe: false
3731
+ VersionAdded: '1.74'
3732
+ VersionChanged: '1.75'
3733
+ StyleGuide: '#ranges-or-between'
3734
+
3586
3735
  Style/ComparableClamp:
3587
3736
  Description: 'Enforces the use of `Comparable#clamp` instead of comparison by minimum and maximum.'
3588
3737
  Enabled: pending
@@ -3673,6 +3822,12 @@ Style/DefWithParentheses:
3673
3822
  VersionAdded: '0.9'
3674
3823
  VersionChanged: '0.12'
3675
3824
 
3825
+ Style/DigChain:
3826
+ Description: 'Use `dig` with multiple parameters instead of chaining multiple calls.'
3827
+ Enabled: pending
3828
+ Safe: false
3829
+ VersionAdded: '1.69'
3830
+
3676
3831
  Style/Dir:
3677
3832
  Description: >-
3678
3833
  Use the `__dir__` method to retrieve the canonicalized
@@ -3809,6 +3964,16 @@ Style/EmptyMethod:
3809
3964
  - compact
3810
3965
  - expanded
3811
3966
 
3967
+ Style/EmptyStringInsideInterpolation:
3968
+ Description: 'Checks for empty strings being assigned inside string interpolation.'
3969
+ StyleGuide: '#empty-strings-in-interpolation'
3970
+ Enabled: pending
3971
+ EnforcedStyle: trailing_conditional
3972
+ SupportedStyles:
3973
+ - trailing_conditional
3974
+ - ternary
3975
+ VersionAdded: '1.76'
3976
+
3812
3977
  Style/Encoding:
3813
3978
  Description: 'Use UTF-8 as the source file encoding.'
3814
3979
  StyleGuide: '#utf-8'
@@ -3833,6 +3998,8 @@ Style/EndlessMethod:
3833
3998
  - allow_single_line
3834
3999
  - allow_always
3835
4000
  - disallow
4001
+ - require_single_line
4002
+ - require_always
3836
4003
 
3837
4004
  Style/EnvHome:
3838
4005
  Description: "Checks for consistent usage of `ENV['HOME']`."
@@ -3885,7 +4052,7 @@ Style/ExponentialNotation:
3885
4052
  Style/FetchEnvVar:
3886
4053
  Description: >-
3887
4054
  Suggests `ENV.fetch` for the replacement of `ENV[]`.
3888
- Reference:
4055
+ References:
3889
4056
  - https://rubystyle.guide/#hash-fetch-defaults
3890
4057
  Enabled: pending
3891
4058
  VersionAdded: '1.28'
@@ -3899,12 +4066,24 @@ Style/FileEmpty:
3899
4066
  Safe: false
3900
4067
  VersionAdded: '1.48'
3901
4068
 
4069
+ Style/FileNull:
4070
+ Description: 'Use `File::NULL` instead of hardcoding "dev/null".'
4071
+ Enabled: pending
4072
+ SafeAutoCorrect: false
4073
+ VersionAdded: '1.69'
4074
+
3902
4075
  Style/FileRead:
3903
4076
  Description: 'Favor `File.(bin)read` convenience methods.'
3904
4077
  StyleGuide: '#file-read'
3905
4078
  Enabled: pending
3906
4079
  VersionAdded: '1.24'
3907
4080
 
4081
+ Style/FileTouch:
4082
+ Description: 'Favor `FileUtils.touch` for touching files.'
4083
+ Enabled: pending
4084
+ VersionAdded: '1.69'
4085
+ SafeAutoCorrect: false
4086
+
3908
4087
  Style/FileWrite:
3909
4088
  Description: 'Favor `File.(bin)write` convenience methods.'
3910
4089
  StyleGuide: '#file-write'
@@ -3914,7 +4093,8 @@ Style/FileWrite:
3914
4093
  Style/FloatDivision:
3915
4094
  Description: 'For performing float division, coerce one side only.'
3916
4095
  StyleGuide: '#float-division'
3917
- Reference: 'https://blog.rubystyle.guide/ruby/2019/06/21/float-division.html'
4096
+ References:
4097
+ - 'https://blog.rubystyle.guide/ruby/2019/06/21/float-division.html'
3918
4098
  Enabled: true
3919
4099
  VersionAdded: '0.72'
3920
4100
  VersionChanged: '1.9'
@@ -3965,8 +4145,14 @@ Style/FormatStringToken:
3965
4145
  # style token in a format string to be allowed when enforced style is not
3966
4146
  # `unannotated`.
3967
4147
  MaxUnannotatedPlaceholdersAllowed: 1
4148
+ # The mode the cop operates in. Two values are allowed:
4149
+ # * aggressive (default): all strings are considered
4150
+ # * conservative:
4151
+ # only register offenses for strings given to `printf`, `sprintf`,
4152
+ # format` and `%` methods. Other strings are not considered.
4153
+ Mode: aggressive
3968
4154
  VersionAdded: '0.49'
3969
- VersionChanged: '1.0'
4155
+ VersionChanged: '1.74'
3970
4156
  AllowedMethods: []
3971
4157
  AllowedPatterns: []
3972
4158
 
@@ -3991,6 +4177,9 @@ Style/FrozenStringLiteralComment:
3991
4177
  # exist in a file.
3992
4178
  - never
3993
4179
  SafeAutoCorrect: false
4180
+ Exclude:
4181
+ # Prevent the Ruby warning: `'frozen_string_literal' is ignored after any tokens` when using Active Admin.
4182
+ - '**/*.arb'
3994
4183
 
3995
4184
  Style/GlobalStdStream:
3996
4185
  Description: 'Enforces the use of `$stdout/$stderr/$stdin` instead of `STDOUT/STDERR/STDIN`.'
@@ -4002,7 +4191,8 @@ Style/GlobalStdStream:
4002
4191
  Style/GlobalVars:
4003
4192
  Description: 'Do not introduce global variables.'
4004
4193
  StyleGuide: '#instance-vars'
4005
- Reference: 'https://www.zenspider.com/ruby/quickref.html'
4194
+ References:
4195
+ - 'https://www.zenspider.com/ruby/quickref.html'
4006
4196
  Enabled: true
4007
4197
  VersionAdded: '0.13'
4008
4198
  # Built-in global variables are allowed by default.
@@ -4059,6 +4249,12 @@ Style/HashExcept:
4059
4249
  VersionAdded: '1.7'
4060
4250
  VersionChanged: '1.39'
4061
4251
 
4252
+ Style/HashFetchChain:
4253
+ Description: 'Use `Hash#dig` instead of chained `fetch` calls.'
4254
+ Enabled: pending
4255
+ Safe: false
4256
+ VersionAdded: '1.75'
4257
+
4062
4258
  Style/HashLikeCase:
4063
4259
  Description: >-
4064
4260
  Checks for places where `case-when` represents a simple 1:1
@@ -4069,6 +4265,14 @@ Style/HashLikeCase:
4069
4265
  # to trigger this cop
4070
4266
  MinBranchesCount: 3
4071
4267
 
4268
+ Style/HashSlice:
4269
+ Description: >-
4270
+ Checks for usages of `Hash#reject`, `Hash#select`, and `Hash#filter` methods
4271
+ that can be replaced with `Hash#slice` method.
4272
+ Enabled: pending
4273
+ Safe: false
4274
+ VersionAdded: '1.71'
4275
+
4072
4276
  Style/HashSyntax:
4073
4277
  Description: >-
4074
4278
  Prefer Ruby 1.9 hash syntax { a: 1, b: 2 } over 1.8 syntax
@@ -4256,6 +4460,31 @@ Style/IpAddresses:
4256
4460
  - '**/gems.rb'
4257
4461
  - '**/*.gemspec'
4258
4462
 
4463
+ Style/ItAssignment:
4464
+ Description: 'Checks for assignment to `it` inside a block.'
4465
+ Enabled: pending
4466
+ VersionAdded: '1.70'
4467
+
4468
+ Style/ItBlockParameter:
4469
+ Description: 'Checks for blocks with one argument where `it` block parameter can be used.'
4470
+ Enabled: pending
4471
+ EnforcedStyle: allow_single_line
4472
+ SupportedStyles:
4473
+ - allow_single_line
4474
+ - only_numbered_parameters
4475
+ - always
4476
+ - disallow
4477
+ VersionAdded: '1.75'
4478
+ VersionChanged: '1.76'
4479
+
4480
+ Style/KeywordArgumentsMerging:
4481
+ Description: >-
4482
+ When passing an existing hash as keyword arguments, provide additional arguments
4483
+ directly rather than using `merge`.
4484
+ StyleGuide: '#merging-keyword-arguments'
4485
+ Enabled: pending
4486
+ VersionAdded: '1.68'
4487
+
4259
4488
  Style/KeywordParametersOrder:
4260
4489
  Description: 'Enforces that optional keyword parameters are placed at the end of the parameters list.'
4261
4490
  StyleGuide: '#keyword-parameters-order'
@@ -4636,7 +4865,7 @@ Style/Next:
4636
4865
  StyleGuide: '#no-nested-conditionals'
4637
4866
  Enabled: true
4638
4867
  VersionAdded: '0.22'
4639
- VersionChanged: '0.35'
4868
+ VersionChanged: '1.75'
4640
4869
  # With `always` all conditions at the end of an iteration needs to be
4641
4870
  # replaced by next - with `skip_modifier_ifs` the modifier if like this one
4642
4871
  # are ignored: [1, 2].each { |a| return 'yes' if a == 1 }
@@ -4644,6 +4873,7 @@ Style/Next:
4644
4873
  # `MinBodyLength` defines the number of lines of the a body of an `if` or `unless`
4645
4874
  # needs to have to trigger this cop
4646
4875
  MinBodyLength: 3
4876
+ AllowConsecutiveConditionals: false
4647
4877
  SupportedStyles:
4648
4878
  - skip_modifier_ifs
4649
4879
  - always
@@ -4775,7 +5005,7 @@ Style/OpenStructUse:
4775
5005
  Description: >-
4776
5006
  Avoid using OpenStruct. As of Ruby 3.0, use is officially discouraged due to performance,
4777
5007
  version compatibility, and potential security issues.
4778
- Reference:
5008
+ References:
4779
5009
  - https://docs.ruby-lang.org/en/3.0.0/OpenStruct.html#class-OpenStruct-label-Caveats
4780
5010
 
4781
5011
  Enabled: pending
@@ -4958,6 +5188,12 @@ Style/RedundantArrayConstructor:
4958
5188
  Enabled: pending
4959
5189
  VersionAdded: '1.52'
4960
5190
 
5191
+ Style/RedundantArrayFlatten:
5192
+ Description: 'Checks for redundant calls of `Array#flatten`.'
5193
+ Enabled: pending
5194
+ Safe: false
5195
+ VersionAdded: '1.76'
5196
+
4961
5197
  Style/RedundantAssignment:
4962
5198
  Description: 'Checks for redundant assignment before returning.'
4963
5199
  Enabled: true
@@ -4979,6 +5215,9 @@ Style/RedundantCondition:
4979
5215
  Description: 'Checks for unnecessary conditional expressions.'
4980
5216
  Enabled: true
4981
5217
  VersionAdded: '0.76'
5218
+ VersionChanged: '1.73'
5219
+ AllowedMethods:
5220
+ - nonzero?
4982
5221
 
4983
5222
  Style/RedundantConditional:
4984
5223
  Description: "Don't return true/false from a conditional."
@@ -4991,7 +5230,7 @@ Style/RedundantConstantBase:
4991
5230
  VersionAdded: '1.40'
4992
5231
 
4993
5232
  Style/RedundantCurrentDirectoryInPath:
4994
- Description: 'Checks for uses a redundant current directory in path.'
5233
+ Description: 'Checks for a redundant current directory in a path given to `require_relative`.'
4995
5234
  Enabled: pending
4996
5235
  VersionAdded: '1.53'
4997
5236
 
@@ -5017,7 +5256,8 @@ Style/RedundantFetchBlock:
5017
5256
  Description: >-
5018
5257
  Use `fetch(key, value)` instead of `fetch(key) { value }`
5019
5258
  when value has Numeric, Rational, Complex, Symbol or String type, `false`, `true`, `nil` or is a constant.
5020
- Reference: 'https://github.com/fastruby/fast-ruby#hashfetch-with-argument-vs-hashfetch--block-code'
5259
+ References:
5260
+ - 'https://github.com/fastruby/fast-ruby#hashfetch-with-argument-vs-hashfetch--block-code'
5021
5261
  Enabled: true
5022
5262
  Safe: false
5023
5263
  # If enabled, this cop will autocorrect usages of
@@ -5043,6 +5283,13 @@ Style/RedundantFilterChain:
5043
5283
  VersionAdded: '1.52'
5044
5284
  VersionChanged: '1.57'
5045
5285
 
5286
+ Style/RedundantFormat:
5287
+ Description: 'Checks for usages of `Kernel#format` or `Kernel#sprintf` with only a single argument.'
5288
+ Enabled: pending
5289
+ SafeAutoCorrect: false
5290
+ VersionAdded: '1.72'
5291
+ VersionChanged: '1.72'
5292
+
5046
5293
  Style/RedundantFreeze:
5047
5294
  Description: "Checks usages of Object#freeze on immutable objects."
5048
5295
  Enabled: true
@@ -5241,11 +5488,19 @@ Style/SafeNavigation:
5241
5488
  # Maximum length of method chains for register an offense.
5242
5489
  MaxChainLength: 2
5243
5490
 
5491
+ Style/SafeNavigationChainLength:
5492
+ Description: 'Enforces safe navigation chains length to not exceed the configured maximum.'
5493
+ StyleGuide: '#safe-navigation'
5494
+ Enabled: pending
5495
+ VersionAdded: '1.68'
5496
+ Max: 2
5497
+
5244
5498
  Style/Sample:
5245
5499
  Description: >-
5246
5500
  Use `sample` instead of `shuffle.first`,
5247
5501
  `shuffle.last`, and `shuffle[Integer]`.
5248
- Reference: 'https://github.com/fastruby/fast-ruby#arrayshufflefirst-vs-arraysample-code'
5502
+ References:
5503
+ - 'https://github.com/fastruby/fast-ruby#arrayshufflefirst-vs-arraysample-code'
5249
5504
  Enabled: true
5250
5505
  VersionAdded: '0.30'
5251
5506
 
@@ -5562,14 +5817,17 @@ Style/TrailingCommaInArrayLiteral:
5562
5817
  StyleGuide: '#no-trailing-array-commas'
5563
5818
  Enabled: true
5564
5819
  VersionAdded: '0.53'
5565
- # If `comma`, the cop requires a comma after the last item in an array,
5566
- # but only when each item is on its own line.
5567
- # If `consistent_comma`, the cop requires a comma after the last item of all
5568
- # non-empty, multiline array literals.
5820
+ # If `comma`, the cop requires a comma after the last item in an array, but only when each item is
5821
+ # on its own line.
5822
+ # If `consistent_comma`, the cop requires a comma after the last item of all non-empty, multiline
5823
+ # array literals.
5824
+ # If `diff_comma`, the cop requires a comma after the last item of all non-empty, multiline array
5825
+ # literals, but only when that last item immediately precedes a newline.
5569
5826
  EnforcedStyleForMultiline: no_comma
5570
5827
  SupportedStylesForMultiline:
5571
5828
  - comma
5572
5829
  - consistent_comma
5830
+ - diff_comma
5573
5831
  - no_comma
5574
5832
 
5575
5833
  Style/TrailingCommaInBlockArgs:
@@ -5581,14 +5839,17 @@ Style/TrailingCommaInBlockArgs:
5581
5839
  Style/TrailingCommaInHashLiteral:
5582
5840
  Description: 'Checks for trailing comma in hash literals.'
5583
5841
  Enabled: true
5584
- # If `comma`, the cop requires a comma after the last item in a hash,
5585
- # but only when each item is on its own line.
5586
- # If `consistent_comma`, the cop requires a comma after the last item of all
5587
- # non-empty, multiline hash literals.
5842
+ # If `comma`, the cop requires a comma after the last item in a hash, but only when each item is
5843
+ # on its own line.
5844
+ # If `consistent_comma`, the cop requires a comma after the last item of all non-empty, multiline
5845
+ # hash literals.
5846
+ # If `diff_comma`, the cop requires a comma after the last item of all non-empty, multiline hash
5847
+ # literals, but only when that last item immediately precedes a newline.
5588
5848
  EnforcedStyleForMultiline: no_comma
5589
5849
  SupportedStylesForMultiline:
5590
5850
  - comma
5591
5851
  - consistent_comma
5852
+ - diff_comma
5592
5853
  - no_comma
5593
5854
  VersionAdded: '0.53'
5594
5855
 
@@ -5734,7 +5995,8 @@ Style/YAMLFileRead:
5734
5995
 
5735
5996
  Style/YodaCondition:
5736
5997
  Description: 'Forbid or enforce yoda conditions.'
5737
- Reference: 'https://en.wikipedia.org/wiki/Yoda_conditions'
5998
+ References:
5999
+ - 'https://en.wikipedia.org/wiki/Yoda_conditions'
5738
6000
  Enabled: true
5739
6001
  EnforcedStyle: forbid_for_all_comparison_operators
5740
6002
  SupportedStyles: