rubocop 1.69.0 → 1.79.2

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 (448) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +1 -1
  3. data/README.md +23 -19
  4. data/config/default.yml +290 -65
  5. data/config/internal_affairs.yml +20 -0
  6. data/config/obsoletion.yml +8 -3
  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 +13 -2
  11. data/lib/rubocop/comment_config.rb +2 -2
  12. data/lib/rubocop/config.rb +52 -10
  13. data/lib/rubocop/config_loader.rb +53 -47
  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 +44 -39
  20. data/lib/rubocop/cop/base.rb +6 -0
  21. data/lib/rubocop/cop/bundler/duplicated_gem.rb +2 -2
  22. data/lib/rubocop/cop/bundler/gem_comment.rb +1 -1
  23. data/lib/rubocop/cop/bundler/ordered_gems.rb +1 -1
  24. data/lib/rubocop/cop/correctors/parentheses_corrector.rb +5 -2
  25. data/lib/rubocop/cop/gemspec/attribute_assignment.rb +91 -0
  26. data/lib/rubocop/cop/gemspec/duplicated_assignment.rb +37 -15
  27. data/lib/rubocop/cop/gemspec/ordered_dependencies.rb +1 -1
  28. data/lib/rubocop/cop/gemspec/require_mfa.rb +15 -1
  29. data/lib/rubocop/cop/generator.rb +6 -0
  30. data/lib/rubocop/cop/internal_affairs/cop_enabled.rb +85 -0
  31. data/lib/rubocop/cop/internal_affairs/example_description.rb +9 -5
  32. data/lib/rubocop/cop/internal_affairs/location_exists.rb +116 -0
  33. data/lib/rubocop/cop/internal_affairs/location_expression.rb +2 -1
  34. data/lib/rubocop/cop/internal_affairs/location_line_equality_comparison.rb +1 -0
  35. data/lib/rubocop/cop/internal_affairs/node_first_or_last_argument.rb +3 -2
  36. data/lib/rubocop/cop/internal_affairs/node_matcher_directive.rb +5 -5
  37. data/lib/rubocop/cop/internal_affairs/node_pattern_groups/ast_processor.rb +63 -0
  38. data/lib/rubocop/cop/internal_affairs/node_pattern_groups/ast_walker.rb +131 -0
  39. data/lib/rubocop/cop/internal_affairs/node_pattern_groups.rb +231 -0
  40. data/lib/rubocop/cop/internal_affairs/node_type_group.rb +92 -0
  41. data/lib/rubocop/cop/internal_affairs/node_type_multiple_predicates.rb +126 -0
  42. data/lib/rubocop/cop/internal_affairs/node_type_predicate.rb +4 -3
  43. data/lib/rubocop/cop/internal_affairs/on_send_without_on_csend.rb +90 -0
  44. data/lib/rubocop/cop/internal_affairs/operator_keyword.rb +4 -2
  45. data/lib/rubocop/cop/internal_affairs/plugin.rb +33 -0
  46. data/lib/rubocop/cop/internal_affairs/redundant_described_class_as_subject.rb +6 -5
  47. data/lib/rubocop/cop/internal_affairs/redundant_source_range.rb +3 -1
  48. data/lib/rubocop/cop/internal_affairs/single_line_comparison.rb +5 -4
  49. data/lib/rubocop/cop/internal_affairs/undefined_config.rb +13 -2
  50. data/lib/rubocop/cop/internal_affairs/useless_restrict_on_send.rb +1 -1
  51. data/lib/rubocop/cop/internal_affairs.rb +6 -16
  52. data/lib/rubocop/cop/layout/access_modifier_indentation.rb +1 -1
  53. data/lib/rubocop/cop/layout/argument_alignment.rb +2 -8
  54. data/lib/rubocop/cop/layout/block_alignment.rb +3 -1
  55. data/lib/rubocop/cop/layout/block_end_newline.rb +1 -0
  56. data/lib/rubocop/cop/layout/class_structure.rb +44 -9
  57. data/lib/rubocop/cop/layout/closing_parenthesis_indentation.rb +5 -5
  58. data/lib/rubocop/cop/layout/def_end_alignment.rb +1 -1
  59. data/lib/rubocop/cop/layout/dot_position.rb +1 -1
  60. data/lib/rubocop/cop/layout/else_alignment.rb +2 -2
  61. data/lib/rubocop/cop/layout/empty_line_after_guard_clause.rb +2 -2
  62. data/lib/rubocop/cop/layout/empty_line_between_defs.rb +7 -11
  63. data/lib/rubocop/cop/layout/empty_lines_after_module_inclusion.rb +101 -0
  64. data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +35 -4
  65. data/lib/rubocop/cop/layout/empty_lines_around_arguments.rb +8 -29
  66. data/lib/rubocop/cop/layout/empty_lines_around_begin_body.rb +5 -6
  67. data/lib/rubocop/cop/layout/empty_lines_around_block_body.rb +1 -0
  68. data/lib/rubocop/cop/layout/empty_lines_around_class_body.rb +1 -1
  69. data/lib/rubocop/cop/layout/empty_lines_around_exception_handling_keywords.rb +1 -1
  70. data/lib/rubocop/cop/layout/empty_lines_around_method_body.rb +22 -2
  71. data/lib/rubocop/cop/layout/end_alignment.rb +1 -1
  72. data/lib/rubocop/cop/layout/extra_spacing.rb +1 -1
  73. data/lib/rubocop/cop/layout/first_argument_indentation.rb +4 -9
  74. data/lib/rubocop/cop/layout/first_array_element_indentation.rb +2 -7
  75. data/lib/rubocop/cop/layout/first_hash_element_indentation.rb +2 -7
  76. data/lib/rubocop/cop/layout/first_hash_element_line_break.rb +1 -1
  77. data/lib/rubocop/cop/layout/first_parameter_indentation.rb +2 -2
  78. data/lib/rubocop/cop/layout/hash_alignment.rb +8 -6
  79. data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +2 -1
  80. data/lib/rubocop/cop/layout/indentation_width.rb +1 -0
  81. data/lib/rubocop/cop/layout/leading_comment_space.rb +13 -1
  82. data/lib/rubocop/cop/layout/line_continuation_leading_space.rb +11 -2
  83. data/lib/rubocop/cop/layout/line_continuation_spacing.rb +7 -1
  84. data/lib/rubocop/cop/layout/line_end_string_concatenation_indentation.rb +2 -2
  85. data/lib/rubocop/cop/layout/line_length.rb +35 -9
  86. data/lib/rubocop/cop/layout/multiline_block_layout.rb +1 -0
  87. data/lib/rubocop/cop/layout/multiline_hash_key_line_breaks.rb +1 -1
  88. data/lib/rubocop/cop/layout/multiline_method_argument_line_breaks.rb +25 -0
  89. data/lib/rubocop/cop/layout/multiline_method_call_brace_layout.rb +1 -0
  90. data/lib/rubocop/cop/layout/multiline_method_call_indentation.rb +4 -4
  91. data/lib/rubocop/cop/layout/multiline_method_parameter_line_breaks.rb +1 -0
  92. data/lib/rubocop/cop/layout/multiline_operation_indentation.rb +1 -1
  93. data/lib/rubocop/cop/layout/redundant_line_break.rb +16 -11
  94. data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +3 -5
  95. data/lib/rubocop/cop/layout/single_line_block_chain.rb +1 -1
  96. data/lib/rubocop/cop/layout/space_after_colon.rb +2 -2
  97. data/lib/rubocop/cop/layout/space_after_comma.rb +1 -1
  98. data/lib/rubocop/cop/layout/space_after_method_name.rb +1 -1
  99. data/lib/rubocop/cop/layout/space_after_semicolon.rb +11 -1
  100. data/lib/rubocop/cop/layout/space_around_keyword.rb +7 -1
  101. data/lib/rubocop/cop/layout/space_around_method_call_operator.rb +1 -1
  102. data/lib/rubocop/cop/layout/space_around_operators.rb +15 -4
  103. data/lib/rubocop/cop/layout/space_before_block_braces.rb +1 -0
  104. data/lib/rubocop/cop/layout/space_before_brackets.rb +5 -38
  105. data/lib/rubocop/cop/layout/space_before_comma.rb +1 -1
  106. data/lib/rubocop/cop/layout/space_before_semicolon.rb +1 -1
  107. data/lib/rubocop/cop/layout/space_inside_array_literal_brackets.rb +12 -3
  108. data/lib/rubocop/cop/layout/space_inside_block_braces.rb +1 -0
  109. data/lib/rubocop/cop/layout/space_inside_hash_literal_braces.rb +3 -0
  110. data/lib/rubocop/cop/layout/trailing_whitespace.rb +5 -3
  111. data/lib/rubocop/cop/lint/ambiguous_block_association.rb +1 -1
  112. data/lib/rubocop/cop/lint/ambiguous_range.rb +5 -0
  113. data/lib/rubocop/cop/lint/array_literal_in_regexp.rb +118 -0
  114. data/lib/rubocop/cop/lint/assignment_in_condition.rb +1 -3
  115. data/lib/rubocop/cop/lint/binary_operator_with_identical_operands.rb +2 -3
  116. data/lib/rubocop/cop/lint/boolean_symbol.rb +1 -1
  117. data/lib/rubocop/cop/lint/circular_argument_reference.rb +4 -3
  118. data/lib/rubocop/cop/lint/constant_definition_in_block.rb +3 -3
  119. data/lib/rubocop/cop/lint/constant_reassignment.rb +148 -0
  120. data/lib/rubocop/cop/lint/cop_directive_syntax.rb +84 -0
  121. data/lib/rubocop/cop/lint/debugger.rb +3 -3
  122. data/lib/rubocop/cop/lint/deprecated_class_methods.rb +1 -1
  123. data/lib/rubocop/cop/lint/deprecated_open_ssl_constant.rb +2 -1
  124. data/lib/rubocop/cop/lint/duplicate_match_pattern.rb +1 -1
  125. data/lib/rubocop/cop/lint/duplicate_methods.rb +111 -23
  126. data/lib/rubocop/cop/lint/duplicate_regexp_character_class_element.rb +1 -1
  127. data/lib/rubocop/cop/lint/duplicate_set_element.rb +20 -7
  128. data/lib/rubocop/cop/lint/empty_conditional_body.rb +14 -64
  129. data/lib/rubocop/cop/lint/empty_expression.rb +0 -2
  130. data/lib/rubocop/cop/lint/empty_interpolation.rb +3 -1
  131. data/lib/rubocop/cop/lint/erb_new_arguments.rb +0 -6
  132. data/lib/rubocop/cop/lint/float_comparison.rb +37 -12
  133. data/lib/rubocop/cop/lint/float_out_of_range.rb +1 -1
  134. data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +2 -2
  135. data/lib/rubocop/cop/lint/identity_comparison.rb +19 -15
  136. data/lib/rubocop/cop/lint/implicit_string_concatenation.rb +1 -1
  137. data/lib/rubocop/cop/lint/literal_as_condition.rb +125 -10
  138. data/lib/rubocop/cop/lint/literal_in_interpolation.rb +24 -6
  139. data/lib/rubocop/cop/lint/missing_cop_enable_directive.rb +1 -1
  140. data/lib/rubocop/cop/lint/missing_super.rb +2 -2
  141. data/lib/rubocop/cop/lint/mixed_case_range.rb +3 -3
  142. data/lib/rubocop/cop/lint/mixed_regexp_capture_types.rb +1 -1
  143. data/lib/rubocop/cop/lint/nested_method_definition.rb +9 -5
  144. data/lib/rubocop/cop/lint/next_without_accumulator.rb +1 -1
  145. data/lib/rubocop/cop/lint/non_atomic_file_operation.rb +4 -2
  146. data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +3 -3
  147. data/lib/rubocop/cop/lint/non_local_exit_from_iterator.rb +3 -3
  148. data/lib/rubocop/cop/lint/numeric_operation_with_constant_result.rb +19 -31
  149. data/lib/rubocop/cop/lint/or_assignment_to_constant.rb +1 -1
  150. data/lib/rubocop/cop/lint/out_of_range_regexp_ref.rb +2 -1
  151. data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +1 -5
  152. data/lib/rubocop/cop/lint/raise_exception.rb +29 -10
  153. data/lib/rubocop/cop/lint/redundant_regexp_quantifiers.rb +2 -2
  154. data/lib/rubocop/cop/lint/redundant_require_statement.rb +0 -21
  155. data/lib/rubocop/cop/lint/redundant_safe_navigation.rb +101 -2
  156. data/lib/rubocop/cop/lint/redundant_string_coercion.rb +2 -2
  157. data/lib/rubocop/cop/lint/redundant_type_conversion.rb +261 -0
  158. data/lib/rubocop/cop/lint/redundant_with_index.rb +3 -0
  159. data/lib/rubocop/cop/lint/redundant_with_object.rb +3 -0
  160. data/lib/rubocop/cop/lint/refinement_import_methods.rb +1 -1
  161. data/lib/rubocop/cop/lint/require_range_parentheses.rb +1 -1
  162. data/lib/rubocop/cop/lint/rescue_exception.rb +1 -1
  163. data/lib/rubocop/cop/lint/rescue_type.rb +1 -1
  164. data/lib/rubocop/cop/lint/return_in_void_context.rb +9 -11
  165. data/lib/rubocop/cop/lint/safe_navigation_chain.rb +8 -1
  166. data/lib/rubocop/cop/lint/self_assignment.rb +25 -0
  167. data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +13 -1
  168. data/lib/rubocop/cop/lint/shared_mutable_default.rb +76 -0
  169. data/lib/rubocop/cop/lint/suppressed_exception.rb +1 -1
  170. data/lib/rubocop/cop/lint/suppressed_exception_in_number_conversion.rb +111 -0
  171. data/lib/rubocop/cop/lint/symbol_conversion.rb +1 -1
  172. data/lib/rubocop/cop/lint/syntax.rb +4 -1
  173. data/lib/rubocop/cop/lint/to_enum_arguments.rb +1 -1
  174. data/lib/rubocop/cop/lint/top_level_return_with_argument.rb +1 -1
  175. data/lib/rubocop/cop/lint/unescaped_bracket_in_regexp.rb +1 -1
  176. data/lib/rubocop/cop/lint/unexpected_block_arity.rb +3 -1
  177. data/lib/rubocop/cop/lint/unmodified_reduce_accumulator.rb +1 -1
  178. data/lib/rubocop/cop/lint/unreachable_code.rb +52 -2
  179. data/lib/rubocop/cop/lint/unreachable_loop.rb +6 -6
  180. data/lib/rubocop/cop/lint/useless_access_modifier.rb +34 -8
  181. data/lib/rubocop/cop/lint/useless_assignment.rb +3 -1
  182. data/lib/rubocop/cop/lint/useless_constant_scoping.rb +71 -0
  183. data/lib/rubocop/cop/lint/useless_default_value_argument.rb +90 -0
  184. data/lib/rubocop/cop/lint/useless_else_without_rescue.rb +4 -0
  185. data/lib/rubocop/cop/lint/useless_method_definition.rb +1 -1
  186. data/lib/rubocop/cop/lint/useless_numeric_operation.rb +3 -1
  187. data/lib/rubocop/cop/lint/useless_or.rb +98 -0
  188. data/lib/rubocop/cop/lint/useless_rescue.rb +1 -1
  189. data/lib/rubocop/cop/lint/useless_ruby2_keywords.rb +5 -5
  190. data/lib/rubocop/cop/lint/utils/nil_receiver_checker.rb +121 -0
  191. data/lib/rubocop/cop/lint/void.rb +14 -11
  192. data/lib/rubocop/cop/message_annotator.rb +7 -3
  193. data/lib/rubocop/cop/metrics/abc_size.rb +1 -1
  194. data/lib/rubocop/cop/metrics/block_length.rb +1 -0
  195. data/lib/rubocop/cop/metrics/block_nesting.rb +1 -1
  196. data/lib/rubocop/cop/metrics/class_length.rb +9 -9
  197. data/lib/rubocop/cop/metrics/collection_literal_length.rb +7 -0
  198. data/lib/rubocop/cop/metrics/cyclomatic_complexity.rb +1 -1
  199. data/lib/rubocop/cop/metrics/method_length.rb +9 -1
  200. data/lib/rubocop/cop/metrics/module_length.rb +1 -1
  201. data/lib/rubocop/cop/metrics/perceived_complexity.rb +1 -1
  202. data/lib/rubocop/cop/metrics/utils/code_length_calculator.rb +2 -2
  203. data/lib/rubocop/cop/metrics/utils/repeated_attribute_discount.rb +7 -7
  204. data/lib/rubocop/cop/mixin/alignment.rb +3 -3
  205. data/lib/rubocop/cop/mixin/allowed_pattern.rb +4 -4
  206. data/lib/rubocop/cop/mixin/check_line_breakable.rb +13 -13
  207. data/lib/rubocop/cop/mixin/check_single_line_suitability.rb +2 -2
  208. data/lib/rubocop/cop/mixin/comments_help.rb +8 -3
  209. data/lib/rubocop/cop/mixin/def_node.rb +1 -1
  210. data/lib/rubocop/cop/mixin/dig_help.rb +1 -1
  211. data/lib/rubocop/cop/mixin/empty_lines_around_body.rb +1 -1
  212. data/lib/rubocop/cop/mixin/forbidden_identifiers.rb +20 -0
  213. data/lib/rubocop/cop/mixin/forbidden_pattern.rb +16 -0
  214. data/lib/rubocop/cop/mixin/frozen_string_literal.rb +1 -2
  215. data/lib/rubocop/cop/mixin/gemspec_help.rb +22 -0
  216. data/lib/rubocop/cop/mixin/hash_alignment_styles.rb +15 -14
  217. data/lib/rubocop/cop/mixin/hash_shorthand_syntax.rb +22 -22
  218. data/lib/rubocop/cop/mixin/hash_subset.rb +203 -0
  219. data/lib/rubocop/cop/mixin/hash_transform_method.rb +74 -74
  220. data/lib/rubocop/cop/mixin/line_length_help.rb +27 -10
  221. data/lib/rubocop/cop/mixin/method_complexity.rb +2 -1
  222. data/lib/rubocop/cop/mixin/multiline_expression_indentation.rb +2 -0
  223. data/lib/rubocop/cop/mixin/ordered_gem_node.rb +1 -1
  224. data/lib/rubocop/cop/mixin/percent_literal.rb +1 -1
  225. data/lib/rubocop/cop/mixin/preceding_following_alignment.rb +68 -30
  226. data/lib/rubocop/cop/mixin/range_help.rb +15 -3
  227. data/lib/rubocop/cop/mixin/space_before_punctuation.rb +1 -1
  228. data/lib/rubocop/cop/mixin/statement_modifier.rb +8 -3
  229. data/lib/rubocop/cop/mixin/string_help.rb +2 -2
  230. data/lib/rubocop/cop/mixin/string_literals_help.rb +1 -1
  231. data/lib/rubocop/cop/mixin/target_ruby_version.rb +1 -1
  232. data/lib/rubocop/cop/mixin/trailing_comma.rb +21 -5
  233. data/lib/rubocop/cop/naming/accessor_method_name.rb +6 -6
  234. data/lib/rubocop/cop/naming/block_forwarding.rb +19 -15
  235. data/lib/rubocop/cop/naming/file_name.rb +2 -2
  236. data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +1 -1
  237. data/lib/rubocop/cop/naming/method_name.rb +185 -15
  238. data/lib/rubocop/cop/naming/predicate_method.rb +306 -0
  239. data/lib/rubocop/cop/naming/{predicate_name.rb → predicate_prefix.rb} +48 -4
  240. data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +4 -4
  241. data/lib/rubocop/cop/naming/variable_name.rb +51 -6
  242. data/lib/rubocop/cop/registry.rb +9 -6
  243. data/lib/rubocop/cop/security/compound_hash.rb +2 -0
  244. data/lib/rubocop/cop/security/eval.rb +2 -1
  245. data/lib/rubocop/cop/security/open.rb +1 -0
  246. data/lib/rubocop/cop/security/yaml_load.rb +3 -2
  247. data/lib/rubocop/cop/style/access_modifier_declarations.rb +66 -15
  248. data/lib/rubocop/cop/style/accessor_grouping.rb +32 -6
  249. data/lib/rubocop/cop/style/and_or.rb +1 -1
  250. data/lib/rubocop/cop/style/arguments_forwarding.rb +57 -44
  251. data/lib/rubocop/cop/style/array_first_last.rb +18 -2
  252. data/lib/rubocop/cop/style/array_intersect.rb +81 -40
  253. data/lib/rubocop/cop/style/block_delimiters.rb +27 -24
  254. data/lib/rubocop/cop/style/case_like_if.rb +1 -1
  255. data/lib/rubocop/cop/style/class_and_module_children.rb +52 -11
  256. data/lib/rubocop/cop/style/class_equality_comparison.rb +1 -1
  257. data/lib/rubocop/cop/style/collection_methods.rb +2 -1
  258. data/lib/rubocop/cop/style/collection_querying.rb +167 -0
  259. data/lib/rubocop/cop/style/combinable_defined.rb +1 -1
  260. data/lib/rubocop/cop/style/combinable_loops.rb +3 -2
  261. data/lib/rubocop/cop/style/command_literal.rb +1 -1
  262. data/lib/rubocop/cop/style/commented_keyword.rb +12 -5
  263. data/lib/rubocop/cop/style/comparable_between.rb +78 -0
  264. data/lib/rubocop/cop/style/concat_array_literals.rb +1 -1
  265. data/lib/rubocop/cop/style/conditional_assignment.rb +23 -7
  266. data/lib/rubocop/cop/style/data_inheritance.rb +7 -0
  267. data/lib/rubocop/cop/style/def_with_parentheses.rb +18 -5
  268. data/lib/rubocop/cop/style/dig_chain.rb +6 -7
  269. data/lib/rubocop/cop/style/documentation.rb +1 -1
  270. data/lib/rubocop/cop/style/double_negation.rb +4 -4
  271. data/lib/rubocop/cop/style/each_for_simple_loop.rb +4 -7
  272. data/lib/rubocop/cop/style/each_with_object.rb +2 -3
  273. data/lib/rubocop/cop/style/empty_else.rb +4 -2
  274. data/lib/rubocop/cop/style/empty_literal.rb +5 -1
  275. data/lib/rubocop/cop/style/empty_method.rb +1 -1
  276. data/lib/rubocop/cop/style/empty_string_inside_interpolation.rb +100 -0
  277. data/lib/rubocop/cop/style/endless_method.rb +163 -18
  278. data/lib/rubocop/cop/style/eval_with_location.rb +4 -4
  279. data/lib/rubocop/cop/style/exact_regexp_match.rb +2 -3
  280. data/lib/rubocop/cop/style/expand_path_arguments.rb +2 -7
  281. data/lib/rubocop/cop/style/explicit_block_argument.rb +16 -3
  282. data/lib/rubocop/cop/style/exponential_notation.rb +6 -5
  283. data/lib/rubocop/cop/style/fetch_env_var.rb +34 -7
  284. data/lib/rubocop/cop/style/file_null.rb +20 -4
  285. data/lib/rubocop/cop/style/float_division.rb +8 -4
  286. data/lib/rubocop/cop/style/for.rb +1 -0
  287. data/lib/rubocop/cop/style/format_string_token.rb +38 -11
  288. data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +3 -2
  289. data/lib/rubocop/cop/style/global_std_stream.rb +3 -0
  290. data/lib/rubocop/cop/style/guard_clause.rb +2 -1
  291. data/lib/rubocop/cop/style/hash_conversion.rb +16 -8
  292. data/lib/rubocop/cop/style/hash_each_methods.rb +6 -8
  293. data/lib/rubocop/cop/style/hash_except.rb +35 -147
  294. data/lib/rubocop/cop/style/hash_fetch_chain.rb +104 -0
  295. data/lib/rubocop/cop/style/hash_slice.rb +80 -0
  296. data/lib/rubocop/cop/style/hash_syntax.rb +9 -3
  297. data/lib/rubocop/cop/style/hash_transform_keys.rb +2 -2
  298. data/lib/rubocop/cop/style/hash_transform_values.rb +2 -2
  299. data/lib/rubocop/cop/style/identical_conditional_branches.rb +25 -6
  300. data/lib/rubocop/cop/style/if_inside_else.rb +10 -13
  301. data/lib/rubocop/cop/style/if_unless_modifier.rb +36 -9
  302. data/lib/rubocop/cop/style/if_unless_modifier_of_if_unless.rb +4 -7
  303. data/lib/rubocop/cop/style/if_with_boolean_literal_branches.rb +2 -2
  304. data/lib/rubocop/cop/style/if_with_semicolon.rb +7 -5
  305. data/lib/rubocop/cop/style/infinite_loop.rb +1 -1
  306. data/lib/rubocop/cop/style/inverse_methods.rb +16 -12
  307. data/lib/rubocop/cop/style/invertible_unless_condition.rb +2 -2
  308. data/lib/rubocop/cop/style/ip_addresses.rb +2 -2
  309. data/lib/rubocop/cop/style/it_assignment.rb +93 -0
  310. data/lib/rubocop/cop/style/it_block_parameter.rb +121 -0
  311. data/lib/rubocop/cop/style/keyword_parameters_order.rb +14 -8
  312. data/lib/rubocop/cop/style/lambda.rb +1 -0
  313. data/lib/rubocop/cop/style/lambda_call.rb +10 -3
  314. data/lib/rubocop/cop/style/line_end_concatenation.rb +10 -4
  315. data/lib/rubocop/cop/style/map_into_array.rb +5 -2
  316. data/lib/rubocop/cop/style/map_to_hash.rb +13 -4
  317. data/lib/rubocop/cop/style/map_to_set.rb +4 -5
  318. data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +27 -19
  319. data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +18 -0
  320. data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +3 -2
  321. data/lib/rubocop/cop/style/method_called_on_do_end_block.rb +3 -4
  322. data/lib/rubocop/cop/style/method_def_parentheses.rb +1 -1
  323. data/lib/rubocop/cop/style/min_max_comparison.rb +13 -5
  324. data/lib/rubocop/cop/style/missing_else.rb +2 -0
  325. data/lib/rubocop/cop/style/multiline_block_chain.rb +3 -2
  326. data/lib/rubocop/cop/style/multiline_if_modifier.rb +2 -0
  327. data/lib/rubocop/cop/style/multiline_method_signature.rb +1 -9
  328. data/lib/rubocop/cop/style/multiple_comparison.rb +34 -22
  329. data/lib/rubocop/cop/style/mutable_constant.rb +3 -3
  330. data/lib/rubocop/cop/style/negated_if_else_condition.rb +1 -1
  331. data/lib/rubocop/cop/style/nested_parenthesized_calls.rb +1 -1
  332. data/lib/rubocop/cop/style/next.rb +44 -0
  333. data/lib/rubocop/cop/style/object_then.rb +15 -15
  334. data/lib/rubocop/cop/style/open_struct_use.rb +5 -5
  335. data/lib/rubocop/cop/style/parallel_assignment.rb +33 -25
  336. data/lib/rubocop/cop/style/parentheses_around_condition.rb +2 -2
  337. data/lib/rubocop/cop/style/percent_literal_delimiters.rb +1 -1
  338. data/lib/rubocop/cop/style/percent_q_literals.rb +1 -1
  339. data/lib/rubocop/cop/style/proc.rb +2 -2
  340. data/lib/rubocop/cop/style/quoted_symbols.rb +1 -1
  341. data/lib/rubocop/cop/style/raise_args.rb +14 -12
  342. data/lib/rubocop/cop/style/random_with_offset.rb +3 -3
  343. data/lib/rubocop/cop/style/redundant_argument.rb +3 -1
  344. data/lib/rubocop/cop/style/redundant_array_flatten.rb +50 -0
  345. data/lib/rubocop/cop/style/redundant_begin.rb +2 -1
  346. data/lib/rubocop/cop/style/redundant_condition.rb +59 -2
  347. data/lib/rubocop/cop/style/redundant_current_directory_in_path.rb +16 -5
  348. data/lib/rubocop/cop/style/redundant_double_splat_hash_braces.rb +6 -10
  349. data/lib/rubocop/cop/style/redundant_each.rb +1 -1
  350. data/lib/rubocop/cop/style/redundant_exception.rb +2 -2
  351. data/lib/rubocop/cop/style/redundant_fetch_block.rb +1 -9
  352. data/lib/rubocop/cop/style/redundant_format.rb +262 -0
  353. data/lib/rubocop/cop/style/redundant_freeze.rb +4 -4
  354. data/lib/rubocop/cop/style/redundant_initialize.rb +12 -3
  355. data/lib/rubocop/cop/style/redundant_interpolation.rb +1 -1
  356. data/lib/rubocop/cop/style/redundant_line_continuation.rb +39 -22
  357. data/lib/rubocop/cop/style/redundant_parentheses.rb +85 -17
  358. data/lib/rubocop/cop/style/redundant_regexp_argument.rb +3 -0
  359. data/lib/rubocop/cop/style/redundant_regexp_character_class.rb +1 -1
  360. data/lib/rubocop/cop/style/redundant_regexp_escape.rb +1 -1
  361. data/lib/rubocop/cop/style/redundant_self.rb +10 -6
  362. data/lib/rubocop/cop/style/redundant_self_assignment.rb +14 -28
  363. data/lib/rubocop/cop/style/redundant_sort.rb +2 -2
  364. data/lib/rubocop/cop/style/redundant_sort_by.rb +17 -1
  365. data/lib/rubocop/cop/style/redundant_string_escape.rb +2 -2
  366. data/lib/rubocop/cop/style/regexp_literal.rb +1 -1
  367. data/lib/rubocop/cop/style/rescue_modifier.rb +3 -0
  368. data/lib/rubocop/cop/style/return_nil.rb +2 -2
  369. data/lib/rubocop/cop/style/safe_navigation.rb +46 -16
  370. data/lib/rubocop/cop/style/select_by_regexp.rb +4 -1
  371. data/lib/rubocop/cop/style/semicolon.rb +1 -1
  372. data/lib/rubocop/cop/style/send_with_literal_method_name.rb +2 -1
  373. data/lib/rubocop/cop/style/single_line_block_params.rb +1 -1
  374. data/lib/rubocop/cop/style/single_line_do_end_block.rb +4 -3
  375. data/lib/rubocop/cop/style/single_line_methods.rb +13 -11
  376. data/lib/rubocop/cop/style/slicing_with_range.rb +40 -11
  377. data/lib/rubocop/cop/style/sole_nested_conditional.rb +68 -101
  378. data/lib/rubocop/cop/style/stabby_lambda_parentheses.rb +1 -1
  379. data/lib/rubocop/cop/style/string_concatenation.rb +15 -14
  380. data/lib/rubocop/cop/style/string_literals.rb +1 -1
  381. data/lib/rubocop/cop/style/string_methods.rb +1 -1
  382. data/lib/rubocop/cop/style/struct_inheritance.rb +8 -1
  383. data/lib/rubocop/cop/style/super_arguments.rb +66 -19
  384. data/lib/rubocop/cop/style/symbol_proc.rb +3 -1
  385. data/lib/rubocop/cop/style/ternary_parentheses.rb +1 -1
  386. data/lib/rubocop/cop/style/top_level_method_definition.rb +2 -1
  387. data/lib/rubocop/cop/style/trailing_comma_in_arguments.rb +11 -2
  388. data/lib/rubocop/cop/style/trailing_comma_in_array_literal.rb +47 -6
  389. data/lib/rubocop/cop/style/trailing_comma_in_block_args.rb +1 -1
  390. data/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb +48 -6
  391. data/lib/rubocop/cop/style/trivial_accessors.rb +1 -1
  392. data/lib/rubocop/cop/style/while_until_modifier.rb +0 -1
  393. data/lib/rubocop/cop/style/yoda_condition.rb +8 -4
  394. data/lib/rubocop/cop/style/yoda_expression.rb +2 -1
  395. data/lib/rubocop/cop/team.rb +1 -1
  396. data/lib/rubocop/cop/util.rb +12 -5
  397. data/lib/rubocop/cop/utils/format_string.rb +10 -5
  398. data/lib/rubocop/cop/variable_force/assignment.rb +7 -3
  399. data/lib/rubocop/cop/variable_force/scope.rb +1 -1
  400. data/lib/rubocop/cop/variable_force/variable.rb +10 -3
  401. data/lib/rubocop/cop/variable_force/variable_table.rb +3 -3
  402. data/lib/rubocop/cop/variable_force.rb +23 -8
  403. data/lib/rubocop/cops_documentation_generator.rb +32 -16
  404. data/lib/rubocop/directive_comment.rb +45 -11
  405. data/lib/rubocop/ext/regexp_node.rb +0 -1
  406. data/lib/rubocop/formatter/disabled_config_formatter.rb +2 -1
  407. data/lib/rubocop/formatter/formatter_set.rb +1 -1
  408. data/lib/rubocop/formatter/fuubar_style_formatter.rb +1 -1
  409. data/lib/rubocop/formatter/html_formatter.rb +1 -1
  410. data/lib/rubocop/formatter/markdown_formatter.rb +1 -0
  411. data/lib/rubocop/formatter/offense_count_formatter.rb +1 -1
  412. data/lib/rubocop/formatter/pacman_formatter.rb +2 -1
  413. data/lib/rubocop/lsp/diagnostic.rb +189 -0
  414. data/lib/rubocop/lsp/logger.rb +2 -2
  415. data/lib/rubocop/lsp/routes.rb +10 -26
  416. data/lib/rubocop/lsp/runtime.rb +18 -50
  417. data/lib/rubocop/lsp/server.rb +0 -2
  418. data/lib/rubocop/lsp/stdin_runner.rb +85 -0
  419. data/lib/rubocop/magic_comment.rb +11 -3
  420. data/lib/rubocop/options.rb +28 -12
  421. data/lib/rubocop/path_util.rb +15 -8
  422. data/lib/rubocop/pending_cops_reporter.rb +56 -0
  423. data/lib/rubocop/plugin/configuration_integrator.rb +143 -0
  424. data/lib/rubocop/plugin/load_error.rb +26 -0
  425. data/lib/rubocop/plugin/loader.rb +100 -0
  426. data/lib/rubocop/plugin/not_supported_error.rb +29 -0
  427. data/lib/rubocop/plugin.rb +46 -0
  428. data/lib/rubocop/rake_task.rb +4 -1
  429. data/lib/rubocop/result_cache.rb +26 -24
  430. data/lib/rubocop/rspec/cop_helper.rb +13 -1
  431. data/lib/rubocop/rspec/expect_offense.rb +15 -5
  432. data/lib/rubocop/rspec/shared_contexts.rb +38 -1
  433. data/lib/rubocop/rspec/support.rb +4 -2
  434. data/lib/rubocop/runner.rb +10 -7
  435. data/lib/rubocop/server/cache.rb +51 -13
  436. data/lib/rubocop/server/cli.rb +2 -2
  437. data/lib/rubocop/server/client_command/base.rb +10 -0
  438. data/lib/rubocop/server/client_command/exec.rb +2 -1
  439. data/lib/rubocop/server/client_command/start.rb +11 -1
  440. data/lib/rubocop/target_finder.rb +7 -2
  441. data/lib/rubocop/target_ruby.rb +16 -1
  442. data/lib/rubocop/version.rb +30 -8
  443. data/lib/rubocop.rb +27 -2
  444. data/lib/ruby_lsp/rubocop/addon.rb +75 -0
  445. data/lib/ruby_lsp/rubocop/runtime_adapter.rb +65 -0
  446. metadata +72 -19
  447. data/lib/rubocop/cop/utils/regexp_ranges.rb +0 -113
  448. 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,12 +274,20 @@ 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:
279
282
  - '**/*.gemspec'
280
283
 
284
+ Gemspec/AttributeAssignment:
285
+ Description: 'Use consistent style for Gemspec attributes assignment.'
286
+ Enabled: pending
287
+ VersionAdded: '1.77'
288
+ Include:
289
+ - '**/*.gemspec'
290
+
281
291
  Gemspec/DependencyVersion:
282
292
  Description: 'Requires or forbids specifying gem dependency versions.'
283
293
  Enabled: false
@@ -341,7 +351,7 @@ Gemspec/RequireMFA:
341
351
  Severity: warning
342
352
  VersionAdded: '1.23'
343
353
  VersionChanged: '1.40'
344
- Reference:
354
+ References:
345
355
  - https://guides.rubygems.org/mfa-requirement-opt-in/
346
356
  Include:
347
357
  - '**/*.gemspec'
@@ -368,7 +378,7 @@ Gemspec/RubyVersionGlobalsUsage:
368
378
  #################### Layout ###########################
369
379
 
370
380
  Layout/AccessModifierIndentation:
371
- Description: Check indentation of private/protected visibility modifiers.
381
+ Description: Checks indentation of private/protected visibility modifiers.
372
382
  StyleGuide: '#indent-public-private-protected'
373
383
  Enabled: true
374
384
  VersionAdded: '0.49'
@@ -602,7 +612,7 @@ Layout/EmptyLineAfterMultilineCondition:
602
612
  # This is disabled, because this style is not very common in practice.
603
613
  Enabled: false
604
614
  VersionAdded: '0.90'
605
- Reference:
615
+ References:
606
616
  - https://github.com/airbnb/ruby#multiline-if-newline
607
617
 
608
618
  Layout/EmptyLineBetweenDefs:
@@ -628,6 +638,12 @@ Layout/EmptyLines:
628
638
  Enabled: true
629
639
  VersionAdded: '0.49'
630
640
 
641
+ Layout/EmptyLinesAfterModuleInclusion:
642
+ Description: 'Keeps track of empty lines after module inclusion methods.'
643
+ StyleGuide: '#empty-lines-after-module-inclusion'
644
+ Enabled: pending
645
+ VersionAdded: '1.79'
646
+
631
647
  Layout/EmptyLinesAroundAccessModifier:
632
648
  Description: "Keep blank lines around access modifiers."
633
649
  StyleGuide: '#empty-lines-around-access-modifier'
@@ -637,7 +653,7 @@ Layout/EmptyLinesAroundAccessModifier:
637
653
  SupportedStyles:
638
654
  - around
639
655
  - only_before
640
- Reference:
656
+ References:
641
657
  # A reference to `EnforcedStyle: only_before`.
642
658
  - https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#follow-the-coding-conventions
643
659
 
@@ -994,7 +1010,7 @@ Layout/IndentationConsistency:
994
1010
  SupportedStyles:
995
1011
  - normal
996
1012
  - indented_internal_methods
997
- Reference:
1013
+ References:
998
1014
  # A reference to `EnforcedStyle: indented_internal_methods`.
999
1015
  - https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#follow-the-coding-conventions
1000
1016
 
@@ -1041,7 +1057,7 @@ Layout/LeadingCommentSpace:
1041
1057
  AllowSteepAnnotation: false
1042
1058
 
1043
1059
  Layout/LeadingEmptyLines:
1044
- Description: Check for unnecessary blank lines at the beginning of a file.
1060
+ Description: Checks for unnecessary blank lines at the beginning of a file.
1045
1061
  Enabled: true
1046
1062
  VersionAdded: '0.57'
1047
1063
  VersionChanged: '0.77'
@@ -1092,6 +1108,7 @@ Layout/LineLength:
1092
1108
  # To make it possible to copy or click on URIs in the code, we allow lines
1093
1109
  # containing a URI to be longer than Max.
1094
1110
  AllowURI: true
1111
+ AllowQualifiedName: true
1095
1112
  URISchemes:
1096
1113
  - http
1097
1114
  - https
@@ -1130,7 +1147,7 @@ Layout/MultilineArrayLineBreaks:
1130
1147
  AllowMultilineFinalElement: false
1131
1148
 
1132
1149
  Layout/MultilineAssignmentLayout:
1133
- Description: 'Check for a newline after the assignment operator in multi-line assignments.'
1150
+ Description: 'Checks for a newline after the assignment operator in multi-line assignments.'
1134
1151
  StyleGuide: '#indent-conditional-assignment'
1135
1152
  Enabled: false
1136
1153
  VersionAdded: '0.49'
@@ -1616,6 +1633,12 @@ Lint/AmbiguousRegexpLiteral:
1616
1633
  VersionAdded: '0.17'
1617
1634
  VersionChanged: '0.83'
1618
1635
 
1636
+ Lint/ArrayLiteralInRegexp:
1637
+ Description: 'Checks for an array literal interpolated inside a regexp.'
1638
+ Enabled: pending
1639
+ VersionAdded: '1.71'
1640
+ SafeAutoCorrect: false
1641
+
1619
1642
  Lint/AssignmentInCondition:
1620
1643
  Description: "Don't use assignment in conditions."
1621
1644
  StyleGuide: '#safe-assignment-in-condition'
@@ -1638,7 +1661,7 @@ Lint/BinaryOperatorWithIdenticalOperands:
1638
1661
  VersionChanged: '1.69'
1639
1662
 
1640
1663
  Lint/BooleanSymbol:
1641
- Description: 'Check for `:true` and `:false` symbols.'
1664
+ Description: 'Checks for `:true` and `:false` symbols.'
1642
1665
  Enabled: true
1643
1666
  SafeAutoCorrect: false
1644
1667
  VersionAdded: '0.50'
@@ -1665,8 +1688,13 @@ Lint/ConstantOverwrittenInRescue:
1665
1688
  Enabled: pending
1666
1689
  VersionAdded: '1.31'
1667
1690
 
1691
+ Lint/ConstantReassignment:
1692
+ Description: 'Checks for constant reassignments.'
1693
+ Enabled: pending
1694
+ VersionAdded: '1.70'
1695
+
1668
1696
  Lint/ConstantResolution:
1669
- Description: 'Check that constants are fully qualified with `::`.'
1697
+ Description: 'Checks that constants are fully qualified with `::`.'
1670
1698
  Enabled: false
1671
1699
  VersionAdded: '0.86'
1672
1700
  # Restrict this cop to only looking at certain names
@@ -1674,8 +1702,13 @@ Lint/ConstantResolution:
1674
1702
  # Restrict this cop from only looking at certain names
1675
1703
  Ignore: []
1676
1704
 
1705
+ Lint/CopDirectiveSyntax:
1706
+ Description: 'Checks that `# rubocop:` directives are strictly formatted.'
1707
+ Enabled: pending
1708
+ VersionAdded: '1.72'
1709
+
1677
1710
  Lint/Debugger:
1678
- Description: 'Check for debugger calls.'
1711
+ Description: 'Checks for debugger calls.'
1679
1712
  Enabled: true
1680
1713
  VersionAdded: '0.14'
1681
1714
  VersionChanged: '1.63'
@@ -1726,7 +1759,7 @@ Lint/Debugger:
1726
1759
  - debug/start
1727
1760
 
1728
1761
  Lint/DeprecatedClassMethods:
1729
- Description: 'Check for deprecated class method calls.'
1762
+ Description: 'Checks for deprecated class method calls.'
1730
1763
  Enabled: true
1731
1764
  VersionAdded: '0.19'
1732
1765
 
@@ -1800,13 +1833,13 @@ Lint/DuplicateElsifCondition:
1800
1833
  VersionAdded: '0.88'
1801
1834
 
1802
1835
  Lint/DuplicateHashKey:
1803
- Description: 'Check for duplicate keys in hash literals.'
1836
+ Description: 'Checks for duplicate keys in hash literals.'
1804
1837
  Enabled: true
1805
1838
  VersionAdded: '0.34'
1806
1839
  VersionChanged: '0.77'
1807
1840
 
1808
1841
  Lint/DuplicateMagicComment:
1809
- Description: 'Check for duplicated magic comments.'
1842
+ Description: 'Checks for duplicated magic comments.'
1810
1843
  Enabled: pending
1811
1844
  VersionAdded: '1.37'
1812
1845
 
@@ -1816,7 +1849,7 @@ Lint/DuplicateMatchPattern:
1816
1849
  VersionAdded: '1.50'
1817
1850
 
1818
1851
  Lint/DuplicateMethods:
1819
- Description: 'Check for duplicate method definitions.'
1852
+ Description: 'Checks for duplicate method definitions.'
1820
1853
  Enabled: true
1821
1854
  VersionAdded: '0.29'
1822
1855
 
@@ -1826,7 +1859,7 @@ Lint/DuplicateRegexpCharacterClassElement:
1826
1859
  VersionAdded: '1.1'
1827
1860
 
1828
1861
  Lint/DuplicateRequire:
1829
- Description: 'Check for duplicate `require`s and `require_relative`s.'
1862
+ Description: 'Checks for duplicate `require`s and `require_relative`s.'
1830
1863
  Enabled: true
1831
1864
  SafeAutoCorrect: false
1832
1865
  VersionAdded: '0.90'
@@ -1843,12 +1876,12 @@ Lint/DuplicateSetElement:
1843
1876
  VersionAdded: '1.67'
1844
1877
 
1845
1878
  Lint/EachWithObjectArgument:
1846
- Description: 'Check for immutable argument given to each_with_object.'
1879
+ Description: 'Checks for immutable argument given to each_with_object.'
1847
1880
  Enabled: true
1848
1881
  VersionAdded: '0.31'
1849
1882
 
1850
1883
  Lint/ElseLayout:
1851
- Description: 'Check for odd code arrangement in an else block.'
1884
+ Description: 'Checks for odd code arrangement in an else block.'
1852
1885
  Enabled: true
1853
1886
  VersionAdded: '0.17'
1854
1887
  VersionChanged: '1.2'
@@ -1871,10 +1904,9 @@ Lint/EmptyConditionalBody:
1871
1904
  Description: 'Checks for the presence of `if`, `elsif` and `unless` branches without a body.'
1872
1905
  Enabled: true
1873
1906
  AutoCorrect: contextual
1874
- SafeAutoCorrect: false
1875
1907
  AllowComments: true
1876
1908
  VersionAdded: '0.89'
1877
- VersionChanged: '1.61'
1909
+ VersionChanged: '1.73'
1878
1910
 
1879
1911
  Lint/EmptyEnsure:
1880
1912
  Description: 'Checks for empty ensure block.'
@@ -1905,7 +1937,7 @@ Lint/EmptyInterpolation:
1905
1937
  Enabled: true
1906
1938
  AutoCorrect: contextual
1907
1939
  VersionAdded: '0.20'
1908
- VersionChanged: '1.61'
1940
+ VersionChanged: '1.76'
1909
1941
 
1910
1942
  Lint/EmptyWhen:
1911
1943
  Description: 'Checks for `when` branches with empty bodies.'
@@ -2018,7 +2050,8 @@ Lint/InterpolationCheck:
2018
2050
 
2019
2051
  Lint/ItWithoutArgumentsInBlock:
2020
2052
  Description: 'Checks uses of `it` calls without arguments in block.'
2021
- Reference: 'https://bugs.ruby-lang.org/issues/18980'
2053
+ References:
2054
+ - 'https://bugs.ruby-lang.org/issues/18980'
2022
2055
  Enabled: pending
2023
2056
  VersionAdded: '1.59'
2024
2057
 
@@ -2030,6 +2063,7 @@ Lint/LambdaWithoutLiteralBlock:
2030
2063
  Lint/LiteralAsCondition:
2031
2064
  Description: 'Checks of literals used in conditions.'
2032
2065
  Enabled: true
2066
+ AutoCorrect: contextual
2033
2067
  VersionAdded: '0.51'
2034
2068
 
2035
2069
  Lint/LiteralAssignmentInCondition:
@@ -2243,14 +2277,14 @@ Lint/RedundantRegexpQuantifiers:
2243
2277
  Lint/RedundantRequireStatement:
2244
2278
  Description: 'Checks for unnecessary `require` statement.'
2245
2279
  Enabled: true
2246
- SafeAutoCorrect: false
2247
2280
  VersionAdded: '0.76'
2248
- VersionChanged: '1.57'
2281
+ VersionChanged: '1.73'
2249
2282
 
2250
2283
  Lint/RedundantSafeNavigation:
2251
2284
  Description: 'Checks for redundant safe navigation calls.'
2252
2285
  Enabled: true
2253
2286
  VersionAdded: '0.93'
2287
+ VersionChanged: '1.79'
2254
2288
  AllowedMethods:
2255
2289
  - instance_of?
2256
2290
  - kind_of?
@@ -2258,6 +2292,12 @@ Lint/RedundantSafeNavigation:
2258
2292
  - eql?
2259
2293
  - respond_to?
2260
2294
  - equal?
2295
+ InferNonNilReceiver: false
2296
+ AdditionalNilMethods:
2297
+ - present?
2298
+ - blank?
2299
+ - try
2300
+ - try!
2261
2301
  Safe: false
2262
2302
 
2263
2303
  Lint/RedundantSplatExpansion:
@@ -2274,6 +2314,11 @@ Lint/RedundantStringCoercion:
2274
2314
  VersionAdded: '0.19'
2275
2315
  VersionChanged: '0.77'
2276
2316
 
2317
+ Lint/RedundantTypeConversion:
2318
+ Description: 'Checks for redundantly converting a literal to the same type.'
2319
+ Enabled: pending
2320
+ VersionAdded: '1.72'
2321
+
2277
2322
  Lint/RedundantWithIndex:
2278
2323
  Description: 'Checks for redundant `with_index`.'
2279
2324
  Enabled: true
@@ -2376,6 +2421,7 @@ Lint/SelfAssignment:
2376
2421
  Description: 'Checks for self-assignments.'
2377
2422
  Enabled: true
2378
2423
  VersionAdded: '0.89'
2424
+ AllowRBSInlineAnnotation: false
2379
2425
 
2380
2426
  Lint/SendWithMixinArgument:
2381
2427
  Description: 'Checks for `send` method when using mixin.'
@@ -2399,8 +2445,15 @@ Lint/ShadowingOuterLocalVariable:
2399
2445
  Description: >-
2400
2446
  Do not use the same name as outer local variable
2401
2447
  for block arguments or block local variables.
2402
- Enabled: true
2448
+ Enabled: false
2403
2449
  VersionAdded: '0.9'
2450
+ VersionChanged: '1.76'
2451
+
2452
+ Lint/SharedMutableDefault:
2453
+ Description: 'Checks for mutable literals used as default arguments during Hash initialization.'
2454
+ StyleGuide: '#no-mutable-defaults'
2455
+ Enabled: pending
2456
+ VersionAdded: '1.70'
2404
2457
 
2405
2458
  Lint/StructNewOverride:
2406
2459
  Description: 'Disallow overriding the `Struct` built-in methods via `Struct.new`.'
@@ -2416,6 +2469,12 @@ Lint/SuppressedException:
2416
2469
  VersionAdded: '0.9'
2417
2470
  VersionChanged: '1.12'
2418
2471
 
2472
+ Lint/SuppressedExceptionInNumberConversion:
2473
+ Description: 'Checks for cases where exceptions unrelated to the numeric constructors may be unintentionally swallowed.'
2474
+ Enabled: pending
2475
+ SafeAutoCorrect: false
2476
+ VersionAdded: '1.72'
2477
+
2419
2478
  Lint/SymbolConversion:
2420
2479
  Description: 'Checks for unnecessary symbol conversions.'
2421
2480
  Enabled: pending
@@ -2571,6 +2630,18 @@ Lint/UselessAssignment:
2571
2630
  VersionAdded: '0.11'
2572
2631
  VersionChanged: '1.66'
2573
2632
 
2633
+ Lint/UselessConstantScoping:
2634
+ Description: 'Checks for useless constant scoping.'
2635
+ Enabled: pending
2636
+ VersionAdded: '1.72'
2637
+
2638
+ Lint/UselessDefaultValueArgument:
2639
+ Description: 'Checks for usage of `fetch` or `Array.new` with default value argument and block.'
2640
+ Enabled: pending
2641
+ VersionAdded: '1.76'
2642
+ Safe: false
2643
+ AllowedReceivers: []
2644
+
2574
2645
  Lint/UselessDefined:
2575
2646
  Description: 'Checks for calls to `defined?` with strings and symbols. The result of such a call will always be truthy.'
2576
2647
  Enabled: pending
@@ -2595,6 +2666,11 @@ Lint/UselessNumericOperation:
2595
2666
  Enabled: pending
2596
2667
  VersionAdded: '1.66'
2597
2668
 
2669
+ Lint/UselessOr:
2670
+ Description: 'Checks for useless OR expressions.'
2671
+ Enabled: pending
2672
+ VersionAdded: '1.76'
2673
+
2598
2674
  Lint/UselessRescue:
2599
2675
  Description: 'Checks for useless `rescue`s.'
2600
2676
  Enabled: pending
@@ -2634,8 +2710,8 @@ Metrics/AbcSize:
2634
2710
  Description: >-
2635
2711
  A calculated magnitude based on number of assignments,
2636
2712
  branches, and conditions.
2637
- Reference:
2638
- - http://c2.com/cgi/wiki?AbcMetric
2713
+ References:
2714
+ - https://wiki.c2.com/?AbcMetric
2639
2715
  - https://en.wikipedia.org/wiki/ABC_Software_Metric
2640
2716
  Enabled: true
2641
2717
  VersionAdded: '0.27'
@@ -2754,7 +2830,7 @@ Migration/DepartmentName:
2754
2830
  #################### Naming ##############################
2755
2831
 
2756
2832
  Naming/AccessorMethodName:
2757
- Description: Check the naming of accessor methods for get_/set_.
2833
+ Description: Checks the naming of accessor methods for get_/set_.
2758
2834
  StyleGuide: '#accessor_mutator_method_names'
2759
2835
  Enabled: true
2760
2836
  VersionAdded: '0.50'
@@ -2958,6 +3034,7 @@ Naming/MethodName:
2958
3034
  StyleGuide: '#snake-case-symbols-methods-vars'
2959
3035
  Enabled: true
2960
3036
  VersionAdded: '0.50'
3037
+ VersionChanged: '1.75'
2961
3038
  EnforcedStyle: snake_case
2962
3039
  SupportedStyles:
2963
3040
  - snake_case
@@ -2969,6 +3046,10 @@ Naming/MethodName:
2969
3046
  # - '\A\s*onSelectionCleared\s*'
2970
3047
  #
2971
3048
  AllowedPatterns: []
3049
+ ForbiddenIdentifiers:
3050
+ - __id__
3051
+ - __send__
3052
+ ForbiddenPatterns: []
2972
3053
 
2973
3054
  Naming/MethodParameterName:
2974
3055
  Description: >-
@@ -3000,22 +3081,42 @@ Naming/MethodParameterName:
3000
3081
  # Forbidden names that will register an offense
3001
3082
  ForbiddenNames: []
3002
3083
 
3003
- Naming/PredicateName:
3004
- Description: 'Check the names of predicate methods.'
3084
+ Naming/PredicateMethod:
3085
+ Description: 'Checks that predicate methods end with `?` and non-predicate methods do not.'
3086
+ Enabled: pending
3087
+ VersionAdded: '1.76'
3088
+ VersionChanged: '1.78'
3089
+ # In `aggressive` mode, the cop will register an offense for predicate methods that
3090
+ # may return a non-boolean value.
3091
+ # In `conservative` mode, the cop will *not* register an offense for predicate methods
3092
+ # that may return a non-boolean value.
3093
+ Mode: conservative
3094
+ AllowedMethods:
3095
+ - call
3096
+ AllowedPatterns: []
3097
+ AllowBangMethods: false
3098
+ # Methods that are known to not return a boolean value, despite ending in `?`.
3099
+ WaywardPredicates:
3100
+ - nonzero?
3101
+
3102
+ Naming/PredicatePrefix:
3103
+ Description: 'Predicate method names should not be prefixed and end with a `?`.'
3005
3104
  StyleGuide: '#bool-methods-qmark'
3006
3105
  Enabled: true
3007
3106
  VersionAdded: '0.50'
3008
- VersionChanged: '0.77'
3107
+ VersionChanged: '1.75'
3009
3108
  # Predicate name prefixes.
3010
3109
  NamePrefix:
3011
3110
  - is_
3012
3111
  - has_
3013
3112
  - have_
3113
+ - does_
3014
3114
  # Predicate name prefixes that should be removed.
3015
3115
  ForbiddenPrefixes:
3016
3116
  - is_
3017
3117
  - has_
3018
3118
  - have_
3119
+ - does_
3019
3120
  # Predicate names which, despite having a forbidden prefix, or no `?`,
3020
3121
  # should still be accepted
3021
3122
  AllowedMethods:
@@ -3024,6 +3125,8 @@ Naming/PredicateName:
3024
3125
  MethodDefinitionMacros:
3025
3126
  - define_method
3026
3127
  - define_singleton_method
3128
+ # Use Sorbet's T::Boolean return type to detect predicate methods.
3129
+ UseSorbetSigs: false
3027
3130
  # Exclude Rspec specs because there is a strong convention to write spec
3028
3131
  # helpers in the form of `have_something` or `be_something`.
3029
3132
  Exclude:
@@ -3041,13 +3144,15 @@ Naming/VariableName:
3041
3144
  StyleGuide: '#snake-case-symbols-methods-vars'
3042
3145
  Enabled: true
3043
3146
  VersionAdded: '0.50'
3044
- VersionChanged: '1.8'
3147
+ VersionChanged: '1.73'
3045
3148
  EnforcedStyle: snake_case
3046
3149
  SupportedStyles:
3047
3150
  - snake_case
3048
3151
  - camelCase
3049
3152
  AllowedIdentifiers: []
3050
3153
  AllowedPatterns: []
3154
+ ForbiddenIdentifiers: []
3155
+ ForbiddenPatterns: []
3051
3156
 
3052
3157
  Naming/VariableNumber:
3053
3158
  Description: 'Use the configured style when numbering symbols, methods and variables.'
@@ -3063,6 +3168,8 @@ Naming/VariableNumber:
3063
3168
  CheckMethodNames: true
3064
3169
  CheckSymbols: true
3065
3170
  AllowedIdentifiers:
3171
+ - TLS1_1 # OpenSSL::SSL::TLS1_1_VERSION
3172
+ - TLS1_2 # OpenSSL::SSL::TLS1_2_VERSION
3066
3173
  - capture3 # Open3.capture3
3067
3174
  - iso8601 # Time#iso8601
3068
3175
  - rfc1123_date # CGI.rfc1123_date
@@ -3098,7 +3205,8 @@ Security/JSONLoad:
3098
3205
  Description: >-
3099
3206
  Prefer usage of `JSON.parse` over `JSON.load` due to potential
3100
3207
  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'
3208
+ References:
3209
+ - 'https://ruby-doc.org/stdlib-2.7.0/libdoc/json/rdoc/JSON.html#method-i-load'
3102
3210
  Enabled: true
3103
3211
  VersionAdded: '0.43'
3104
3212
  VersionChanged: '1.22'
@@ -3110,7 +3218,8 @@ Security/MarshalLoad:
3110
3218
  Description: >-
3111
3219
  Avoid using of `Marshal.load` or `Marshal.restore` due to potential
3112
3220
  security issues. See reference for more information.
3113
- Reference: 'https://ruby-doc.org/core-2.7.0/Marshal.html#module-Marshal-label-Security+considerations'
3221
+ References:
3222
+ - 'https://ruby-doc.org/core-2.7.0/Marshal.html#module-Marshal-label-Security+considerations'
3114
3223
  Enabled: true
3115
3224
  VersionAdded: '0.47'
3116
3225
 
@@ -3125,7 +3234,8 @@ Security/YAMLLoad:
3125
3234
  Description: >-
3126
3235
  Prefer usage of `YAML.safe_load` over `YAML.load` due to potential
3127
3236
  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'
3237
+ References:
3238
+ - 'https://ruby-doc.org/stdlib-2.7.0/libdoc/yaml/rdoc/YAML.html#module-YAML-label-Security'
3129
3239
  Enabled: true
3130
3240
  VersionAdded: '0.47'
3131
3241
  SafeAutoCorrect: false
@@ -3136,13 +3246,14 @@ Style/AccessModifierDeclarations:
3136
3246
  Description: 'Checks style of how access modifiers are used.'
3137
3247
  Enabled: true
3138
3248
  VersionAdded: '0.57'
3139
- VersionChanged: '0.81'
3249
+ VersionChanged: '1.70'
3140
3250
  EnforcedStyle: group
3141
3251
  SupportedStyles:
3142
3252
  - inline
3143
3253
  - group
3144
3254
  AllowModifiersOnSymbols: true
3145
3255
  AllowModifiersOnAttrs: true
3256
+ AllowModifiersOnAliasMethod: true
3146
3257
  SafeAutoCorrect: false
3147
3258
 
3148
3259
  Style/AccessorGrouping:
@@ -3218,7 +3329,8 @@ Style/ArrayCoercion:
3218
3329
 
3219
3330
  Style/ArrayFirstLast:
3220
3331
  Description: 'Use `arr.first` and `arr.last` instead of `arr[0]` and `arr[-1]`.'
3221
- Reference: '#first-and-last'
3332
+ References:
3333
+ - '#first-and-last'
3222
3334
  Enabled: false
3223
3335
  VersionAdded: '1.58'
3224
3336
  Safe: false
@@ -3457,6 +3569,7 @@ Style/ClassAndModuleChildren:
3457
3569
  SafeAutoCorrect: false
3458
3570
  Enabled: true
3459
3571
  VersionAdded: '0.19'
3572
+ VersionChanged: '1.74'
3460
3573
  #
3461
3574
  # Basically there are two different styles:
3462
3575
  #
@@ -3472,7 +3585,21 @@ Style/ClassAndModuleChildren:
3472
3585
  #
3473
3586
  # The compact style is only forced, for classes or modules with one child.
3474
3587
  EnforcedStyle: nested
3475
- SupportedStyles:
3588
+ SupportedStyles: &supported_styles
3589
+ - nested
3590
+ - compact
3591
+ # Configure classes separately, if desired. If not set, or set to `nil`,
3592
+ # the `EnforcedStyle` value will be used.
3593
+ EnforcedStyleForClasses: ~
3594
+ SupportedStylesForClasses:
3595
+ - ~
3596
+ - nested
3597
+ - compact
3598
+ # Configure modules separately, if desired. If not set, or set to `nil`,
3599
+ # the `EnforcedStyle` value will be used.
3600
+ EnforcedStyleForModules: ~
3601
+ SupportedStylesForModules:
3602
+ - ~
3476
3603
  - nested
3477
3604
  - compact
3478
3605
 
@@ -3558,6 +3685,13 @@ Style/CollectionMethods:
3558
3685
  - inject
3559
3686
  - reduce
3560
3687
 
3688
+ Style/CollectionQuerying:
3689
+ Description: 'Prefer `Enumerable` predicate methods over expressions with `count`.'
3690
+ StyleGuide: '#collection-querying'
3691
+ Enabled: pending
3692
+ VersionAdded: '1.77'
3693
+ Safe: false
3694
+
3561
3695
  Style/ColonMethodCall:
3562
3696
  Description: 'Do not use :: for method call.'
3563
3697
  StyleGuide: '#double-colons'
@@ -3625,6 +3759,14 @@ Style/CommentedKeyword:
3625
3759
  VersionAdded: '0.51'
3626
3760
  VersionChanged: '1.19'
3627
3761
 
3762
+ Style/ComparableBetween:
3763
+ Description: 'Enforces the use of `Comparable#between?` instead of logical comparison.'
3764
+ Enabled: pending
3765
+ Safe: false
3766
+ VersionAdded: '1.74'
3767
+ VersionChanged: '1.75'
3768
+ StyleGuide: '#ranges-or-between'
3769
+
3628
3770
  Style/ComparableClamp:
3629
3771
  Description: 'Enforces the use of `Comparable#clamp` instead of comparison by minimum and maximum.'
3630
3772
  Enabled: pending
@@ -3857,6 +3999,16 @@ Style/EmptyMethod:
3857
3999
  - compact
3858
4000
  - expanded
3859
4001
 
4002
+ Style/EmptyStringInsideInterpolation:
4003
+ Description: 'Checks for empty strings being assigned inside string interpolation.'
4004
+ StyleGuide: '#empty-strings-in-interpolation'
4005
+ Enabled: pending
4006
+ EnforcedStyle: trailing_conditional
4007
+ SupportedStyles:
4008
+ - trailing_conditional
4009
+ - ternary
4010
+ VersionAdded: '1.76'
4011
+
3860
4012
  Style/Encoding:
3861
4013
  Description: 'Use UTF-8 as the source file encoding.'
3862
4014
  StyleGuide: '#utf-8'
@@ -3881,6 +4033,8 @@ Style/EndlessMethod:
3881
4033
  - allow_single_line
3882
4034
  - allow_always
3883
4035
  - disallow
4036
+ - require_single_line
4037
+ - require_always
3884
4038
 
3885
4039
  Style/EnvHome:
3886
4040
  Description: "Checks for consistent usage of `ENV['HOME']`."
@@ -3933,12 +4087,15 @@ Style/ExponentialNotation:
3933
4087
  Style/FetchEnvVar:
3934
4088
  Description: >-
3935
4089
  Suggests `ENV.fetch` for the replacement of `ENV[]`.
3936
- Reference:
4090
+ References:
3937
4091
  - https://rubystyle.guide/#hash-fetch-defaults
3938
4092
  Enabled: pending
3939
4093
  VersionAdded: '1.28'
3940
4094
  # Environment variables to be excluded from the inspection.
3941
4095
  AllowedVars: []
4096
+ # When `true`, autocorrects `ENV["key"]` to `ENV.fetch("key", nil)`.
4097
+ # When `false`, autocorrects `ENV["key"]` to `ENV.fetch("key")`.
4098
+ DefaultToNil: true
3942
4099
 
3943
4100
  Style/FileEmpty:
3944
4101
  Description: >-
@@ -3974,7 +4131,8 @@ Style/FileWrite:
3974
4131
  Style/FloatDivision:
3975
4132
  Description: 'For performing float division, coerce one side only.'
3976
4133
  StyleGuide: '#float-division'
3977
- Reference: 'https://blog.rubystyle.guide/ruby/2019/06/21/float-division.html'
4134
+ References:
4135
+ - 'https://blog.rubystyle.guide/ruby/2019/06/21/float-division.html'
3978
4136
  Enabled: true
3979
4137
  VersionAdded: '0.72'
3980
4138
  VersionChanged: '1.9'
@@ -4025,8 +4183,14 @@ Style/FormatStringToken:
4025
4183
  # style token in a format string to be allowed when enforced style is not
4026
4184
  # `unannotated`.
4027
4185
  MaxUnannotatedPlaceholdersAllowed: 1
4186
+ # The mode the cop operates in. Two values are allowed:
4187
+ # * aggressive (default): all strings are considered
4188
+ # * conservative:
4189
+ # only register offenses for strings given to `printf`, `sprintf`,
4190
+ # format` and `%` methods. Other strings are not considered.
4191
+ Mode: aggressive
4028
4192
  VersionAdded: '0.49'
4029
- VersionChanged: '1.0'
4193
+ VersionChanged: '1.74'
4030
4194
  AllowedMethods: []
4031
4195
  AllowedPatterns: []
4032
4196
 
@@ -4051,6 +4215,9 @@ Style/FrozenStringLiteralComment:
4051
4215
  # exist in a file.
4052
4216
  - never
4053
4217
  SafeAutoCorrect: false
4218
+ Exclude:
4219
+ # Prevent the Ruby warning: `'frozen_string_literal' is ignored after any tokens` when using Active Admin.
4220
+ - '**/*.arb'
4054
4221
 
4055
4222
  Style/GlobalStdStream:
4056
4223
  Description: 'Enforces the use of `$stdout/$stderr/$stdin` instead of `STDOUT/STDERR/STDIN`.'
@@ -4062,14 +4229,15 @@ Style/GlobalStdStream:
4062
4229
  Style/GlobalVars:
4063
4230
  Description: 'Do not introduce global variables.'
4064
4231
  StyleGuide: '#instance-vars'
4065
- Reference: 'https://www.zenspider.com/ruby/quickref.html'
4232
+ References:
4233
+ - 'https://www.zenspider.com/ruby/quickref.html'
4066
4234
  Enabled: true
4067
4235
  VersionAdded: '0.13'
4068
4236
  # Built-in global variables are allowed by default.
4069
4237
  AllowedVariables: []
4070
4238
 
4071
4239
  Style/GuardClause:
4072
- Description: 'Check for conditionals that can be replaced with guard clauses.'
4240
+ Description: 'Checks for conditionals that can be replaced with guard clauses.'
4073
4241
  StyleGuide: '#no-nested-conditionals'
4074
4242
  Enabled: true
4075
4243
  VersionAdded: '0.20'
@@ -4119,6 +4287,12 @@ Style/HashExcept:
4119
4287
  VersionAdded: '1.7'
4120
4288
  VersionChanged: '1.39'
4121
4289
 
4290
+ Style/HashFetchChain:
4291
+ Description: 'Use `Hash#dig` instead of chained `fetch` calls.'
4292
+ Enabled: pending
4293
+ Safe: false
4294
+ VersionAdded: '1.75'
4295
+
4122
4296
  Style/HashLikeCase:
4123
4297
  Description: >-
4124
4298
  Checks for places where `case-when` represents a simple 1:1
@@ -4129,6 +4303,14 @@ Style/HashLikeCase:
4129
4303
  # to trigger this cop
4130
4304
  MinBranchesCount: 3
4131
4305
 
4306
+ Style/HashSlice:
4307
+ Description: >-
4308
+ Checks for usages of `Hash#reject`, `Hash#select`, and `Hash#filter` methods
4309
+ that can be replaced with `Hash#slice` method.
4310
+ Enabled: pending
4311
+ Safe: false
4312
+ VersionAdded: '1.71'
4313
+
4132
4314
  Style/HashSyntax:
4133
4315
  Description: >-
4134
4316
  Prefer Ruby 1.9 hash syntax { a: 1, b: 2 } over 1.8 syntax
@@ -4316,6 +4498,23 @@ Style/IpAddresses:
4316
4498
  - '**/gems.rb'
4317
4499
  - '**/*.gemspec'
4318
4500
 
4501
+ Style/ItAssignment:
4502
+ Description: 'Checks for local variables and method parameters named `it`.'
4503
+ Enabled: pending
4504
+ VersionAdded: '1.70'
4505
+
4506
+ Style/ItBlockParameter:
4507
+ Description: 'Checks for blocks with one argument where `it` block parameter can be used.'
4508
+ Enabled: pending
4509
+ EnforcedStyle: allow_single_line
4510
+ SupportedStyles:
4511
+ - allow_single_line
4512
+ - only_numbered_parameters
4513
+ - always
4514
+ - disallow
4515
+ VersionAdded: '1.75'
4516
+ VersionChanged: '1.76'
4517
+
4319
4518
  Style/KeywordArgumentsMerging:
4320
4519
  Description: >-
4321
4520
  When passing an existing hash as keyword arguments, provide additional arguments
@@ -4704,7 +4903,7 @@ Style/Next:
4704
4903
  StyleGuide: '#no-nested-conditionals'
4705
4904
  Enabled: true
4706
4905
  VersionAdded: '0.22'
4707
- VersionChanged: '0.35'
4906
+ VersionChanged: '1.75'
4708
4907
  # With `always` all conditions at the end of an iteration needs to be
4709
4908
  # replaced by next - with `skip_modifier_ifs` the modifier if like this one
4710
4909
  # are ignored: [1, 2].each { |a| return 'yes' if a == 1 }
@@ -4712,6 +4911,7 @@ Style/Next:
4712
4911
  # `MinBodyLength` defines the number of lines of the a body of an `if` or `unless`
4713
4912
  # needs to have to trigger this cop
4714
4913
  MinBodyLength: 3
4914
+ AllowConsecutiveConditionals: false
4715
4915
  SupportedStyles:
4716
4916
  - skip_modifier_ifs
4717
4917
  - always
@@ -4843,8 +5043,8 @@ Style/OpenStructUse:
4843
5043
  Description: >-
4844
5044
  Avoid using OpenStruct. As of Ruby 3.0, use is officially discouraged due to performance,
4845
5045
  version compatibility, and potential security issues.
4846
- Reference:
4847
- - https://docs.ruby-lang.org/en/3.0.0/OpenStruct.html#class-OpenStruct-label-Caveats
5046
+ References:
5047
+ - https://docs.ruby-lang.org/en/3.0/OpenStruct.html#class-OpenStruct-label-Caveats
4848
5048
 
4849
5049
  Enabled: pending
4850
5050
  Safe: false
@@ -5000,7 +5200,7 @@ Style/RandomWithOffset:
5000
5200
  VersionAdded: '0.52'
5001
5201
 
5002
5202
  Style/RedundantArgument:
5003
- Description: 'Check for a redundant argument passed to certain methods.'
5203
+ Description: 'Checks for a redundant argument passed to certain methods.'
5004
5204
  Enabled: pending
5005
5205
  Safe: false
5006
5206
  VersionAdded: '1.4'
@@ -5026,6 +5226,12 @@ Style/RedundantArrayConstructor:
5026
5226
  Enabled: pending
5027
5227
  VersionAdded: '1.52'
5028
5228
 
5229
+ Style/RedundantArrayFlatten:
5230
+ Description: 'Checks for redundant calls of `Array#flatten`.'
5231
+ Enabled: pending
5232
+ Safe: false
5233
+ VersionAdded: '1.76'
5234
+
5029
5235
  Style/RedundantAssignment:
5030
5236
  Description: 'Checks for redundant assignment before returning.'
5031
5237
  Enabled: true
@@ -5047,6 +5253,9 @@ Style/RedundantCondition:
5047
5253
  Description: 'Checks for unnecessary conditional expressions.'
5048
5254
  Enabled: true
5049
5255
  VersionAdded: '0.76'
5256
+ VersionChanged: '1.73'
5257
+ AllowedMethods:
5258
+ - nonzero?
5050
5259
 
5051
5260
  Style/RedundantConditional:
5052
5261
  Description: "Don't return true/false from a conditional."
@@ -5059,7 +5268,7 @@ Style/RedundantConstantBase:
5059
5268
  VersionAdded: '1.40'
5060
5269
 
5061
5270
  Style/RedundantCurrentDirectoryInPath:
5062
- Description: 'Checks for uses a redundant current directory in path.'
5271
+ Description: 'Checks for a redundant current directory in a path given to `require_relative`.'
5063
5272
  Enabled: pending
5064
5273
  VersionAdded: '1.53'
5065
5274
 
@@ -5085,7 +5294,8 @@ Style/RedundantFetchBlock:
5085
5294
  Description: >-
5086
5295
  Use `fetch(key, value)` instead of `fetch(key) { value }`
5087
5296
  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'
5297
+ References:
5298
+ - 'https://github.com/fastruby/fast-ruby#hashfetch-with-argument-vs-hashfetch--block-code'
5089
5299
  Enabled: true
5090
5300
  Safe: false
5091
5301
  # If enabled, this cop will autocorrect usages of
@@ -5111,6 +5321,13 @@ Style/RedundantFilterChain:
5111
5321
  VersionAdded: '1.52'
5112
5322
  VersionChanged: '1.57'
5113
5323
 
5324
+ Style/RedundantFormat:
5325
+ Description: 'Checks for usages of `Kernel#format` or `Kernel#sprintf` with only a single argument.'
5326
+ Enabled: pending
5327
+ SafeAutoCorrect: false
5328
+ VersionAdded: '1.72'
5329
+ VersionChanged: '1.72'
5330
+
5114
5331
  Style/RedundantFreeze:
5115
5332
  Description: "Checks usages of Object#freeze on immutable objects."
5116
5333
  Enabled: true
@@ -5144,7 +5361,7 @@ Style/RedundantInterpolationUnfreeze:
5144
5361
  VersionAdded: '1.66'
5145
5362
 
5146
5363
  Style/RedundantLineContinuation:
5147
- Description: 'Check for redundant line continuation.'
5364
+ Description: 'Checks for redundant line continuation.'
5148
5365
  Enabled: pending
5149
5366
  VersionAdded: '1.49'
5150
5367
 
@@ -5320,7 +5537,8 @@ Style/Sample:
5320
5537
  Description: >-
5321
5538
  Use `sample` instead of `shuffle.first`,
5322
5539
  `shuffle.last`, and `shuffle[Integer]`.
5323
- Reference: 'https://github.com/fastruby/fast-ruby#arrayshufflefirst-vs-arraysample-code'
5540
+ References:
5541
+ - 'https://github.com/fastruby/fast-ruby#arrayshufflefirst-vs-arraysample-code'
5324
5542
  Enabled: true
5325
5543
  VersionAdded: '0.30'
5326
5544
 
@@ -5437,7 +5655,7 @@ Style/SpecialGlobalVars:
5437
5655
  - use_builtin_english_names
5438
5656
 
5439
5657
  Style/StabbyLambdaParentheses:
5440
- Description: 'Check for the usage of parentheses around stabby lambda arguments.'
5658
+ Description: 'Checks for the usage of parentheses around stabby lambda arguments.'
5441
5659
  StyleGuide: '#stabby-lambda-with-args'
5442
5660
  Enabled: true
5443
5661
  VersionAdded: '0.35'
@@ -5637,14 +5855,17 @@ Style/TrailingCommaInArrayLiteral:
5637
5855
  StyleGuide: '#no-trailing-array-commas'
5638
5856
  Enabled: true
5639
5857
  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.
5858
+ # If `comma`, the cop requires a comma after the last item in an array, but only when each item is
5859
+ # on its own line.
5860
+ # If `consistent_comma`, the cop requires a comma after the last item of all non-empty, multiline
5861
+ # array literals.
5862
+ # If `diff_comma`, the cop requires a comma after the last item of all non-empty, multiline array
5863
+ # literals, but only when that last item immediately precedes a newline.
5644
5864
  EnforcedStyleForMultiline: no_comma
5645
5865
  SupportedStylesForMultiline:
5646
5866
  - comma
5647
5867
  - consistent_comma
5868
+ - diff_comma
5648
5869
  - no_comma
5649
5870
 
5650
5871
  Style/TrailingCommaInBlockArgs:
@@ -5656,14 +5877,17 @@ Style/TrailingCommaInBlockArgs:
5656
5877
  Style/TrailingCommaInHashLiteral:
5657
5878
  Description: 'Checks for trailing comma in hash literals.'
5658
5879
  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.
5880
+ # If `comma`, the cop requires a comma after the last item in a hash, but only when each item is
5881
+ # on its own line.
5882
+ # If `consistent_comma`, the cop requires a comma after the last item of all non-empty, multiline
5883
+ # hash literals.
5884
+ # If `diff_comma`, the cop requires a comma after the last item of all non-empty, multiline hash
5885
+ # literals, but only when that last item immediately precedes a newline.
5663
5886
  EnforcedStyleForMultiline: no_comma
5664
5887
  SupportedStylesForMultiline:
5665
5888
  - comma
5666
5889
  - consistent_comma
5890
+ - diff_comma
5667
5891
  - no_comma
5668
5892
  VersionAdded: '0.53'
5669
5893
 
@@ -5809,7 +6033,8 @@ Style/YAMLFileRead:
5809
6033
 
5810
6034
  Style/YodaCondition:
5811
6035
  Description: 'Forbid or enforce yoda conditions.'
5812
- Reference: 'https://en.wikipedia.org/wiki/Yoda_conditions'
6036
+ References:
6037
+ - 'https://en.wikipedia.org/wiki/Yoda_conditions'
5813
6038
  Enabled: true
5814
6039
  EnforcedStyle: forbid_for_all_comparison_operators
5815
6040
  SupportedStyles: