rubocop 1.67.0 → 1.77.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 (499) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +1 -1
  3. data/README.md +23 -17
  4. data/config/default.yml +337 -53
  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/parentheses_corrector.rb +5 -2
  31. data/lib/rubocop/cop/correctors/percent_literal_corrector.rb +10 -0
  32. data/lib/rubocop/cop/gemspec/attribute_assignment.rb +91 -0
  33. data/lib/rubocop/cop/gemspec/deprecated_attribute_assignment.rb +1 -2
  34. data/lib/rubocop/cop/gemspec/duplicated_assignment.rb +37 -15
  35. data/lib/rubocop/cop/gemspec/ordered_dependencies.rb +1 -1
  36. data/lib/rubocop/cop/gemspec/require_mfa.rb +15 -1
  37. data/lib/rubocop/cop/gemspec/required_ruby_version.rb +0 -2
  38. data/lib/rubocop/cop/generator.rb +6 -0
  39. data/lib/rubocop/cop/internal_affairs/cop_enabled.rb +85 -0
  40. data/lib/rubocop/cop/internal_affairs/example_description.rb +8 -4
  41. data/lib/rubocop/cop/internal_affairs/location_exists.rb +116 -0
  42. data/lib/rubocop/cop/internal_affairs/location_expression.rb +2 -1
  43. data/lib/rubocop/cop/internal_affairs/location_line_equality_comparison.rb +3 -4
  44. data/lib/rubocop/cop/internal_affairs/node_first_or_last_argument.rb +3 -2
  45. data/lib/rubocop/cop/internal_affairs/node_matcher_directive.rb +5 -5
  46. data/lib/rubocop/cop/internal_affairs/node_pattern_groups/ast_processor.rb +63 -0
  47. data/lib/rubocop/cop/internal_affairs/node_pattern_groups/ast_walker.rb +131 -0
  48. data/lib/rubocop/cop/internal_affairs/node_pattern_groups.rb +231 -0
  49. data/lib/rubocop/cop/internal_affairs/node_type_group.rb +91 -0
  50. data/lib/rubocop/cop/internal_affairs/node_type_multiple_predicates.rb +126 -0
  51. data/lib/rubocop/cop/internal_affairs/node_type_predicate.rb +4 -3
  52. data/lib/rubocop/cop/internal_affairs/numblock_handler.rb +1 -1
  53. data/lib/rubocop/cop/internal_affairs/on_send_without_on_csend.rb +90 -0
  54. data/lib/rubocop/cop/internal_affairs/operator_keyword.rb +48 -0
  55. data/lib/rubocop/cop/internal_affairs/plugin.rb +33 -0
  56. data/lib/rubocop/cop/internal_affairs/redundant_described_class_as_subject.rb +6 -5
  57. data/lib/rubocop/cop/internal_affairs/redundant_source_range.rb +3 -1
  58. data/lib/rubocop/cop/internal_affairs/single_line_comparison.rb +5 -4
  59. data/lib/rubocop/cop/internal_affairs/style_detected_api_use.rb +0 -2
  60. data/lib/rubocop/cop/internal_affairs/undefined_config.rb +13 -2
  61. data/lib/rubocop/cop/internal_affairs.rb +7 -16
  62. data/lib/rubocop/cop/layout/access_modifier_indentation.rb +1 -1
  63. data/lib/rubocop/cop/layout/argument_alignment.rb +2 -9
  64. data/lib/rubocop/cop/layout/array_alignment.rb +1 -1
  65. data/lib/rubocop/cop/layout/begin_end_alignment.rb +0 -1
  66. data/lib/rubocop/cop/layout/block_alignment.rb +3 -2
  67. data/lib/rubocop/cop/layout/block_end_newline.rb +1 -0
  68. data/lib/rubocop/cop/layout/class_structure.rb +44 -9
  69. data/lib/rubocop/cop/layout/closing_parenthesis_indentation.rb +5 -5
  70. data/lib/rubocop/cop/layout/def_end_alignment.rb +1 -1
  71. data/lib/rubocop/cop/layout/dot_position.rb +1 -1
  72. data/lib/rubocop/cop/layout/else_alignment.rb +2 -2
  73. data/lib/rubocop/cop/layout/empty_line_after_guard_clause.rb +3 -3
  74. data/lib/rubocop/cop/layout/empty_line_between_defs.rb +7 -11
  75. data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +37 -7
  76. data/lib/rubocop/cop/layout/empty_lines_around_begin_body.rb +5 -6
  77. data/lib/rubocop/cop/layout/empty_lines_around_block_body.rb +1 -0
  78. data/lib/rubocop/cop/layout/empty_lines_around_exception_handling_keywords.rb +4 -5
  79. data/lib/rubocop/cop/layout/empty_lines_around_method_body.rb +23 -1
  80. data/lib/rubocop/cop/layout/end_alignment.rb +1 -1
  81. data/lib/rubocop/cop/layout/extra_spacing.rb +1 -1
  82. data/lib/rubocop/cop/layout/first_argument_indentation.rb +4 -9
  83. data/lib/rubocop/cop/layout/first_array_element_indentation.rb +2 -7
  84. data/lib/rubocop/cop/layout/first_hash_element_indentation.rb +2 -7
  85. data/lib/rubocop/cop/layout/first_hash_element_line_break.rb +1 -1
  86. data/lib/rubocop/cop/layout/first_parameter_indentation.rb +2 -2
  87. data/lib/rubocop/cop/layout/hash_alignment.rb +8 -6
  88. data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +2 -1
  89. data/lib/rubocop/cop/layout/indentation_width.rb +8 -7
  90. data/lib/rubocop/cop/layout/leading_comment_space.rb +57 -2
  91. data/lib/rubocop/cop/layout/line_continuation_leading_space.rb +11 -2
  92. data/lib/rubocop/cop/layout/line_continuation_spacing.rb +7 -1
  93. data/lib/rubocop/cop/layout/line_end_string_concatenation_indentation.rb +2 -2
  94. data/lib/rubocop/cop/layout/line_length.rb +149 -9
  95. data/lib/rubocop/cop/layout/multiline_block_layout.rb +1 -0
  96. data/lib/rubocop/cop/layout/multiline_hash_key_line_breaks.rb +1 -1
  97. data/lib/rubocop/cop/layout/multiline_method_argument_line_breaks.rb +25 -0
  98. data/lib/rubocop/cop/layout/multiline_method_call_brace_layout.rb +2 -1
  99. data/lib/rubocop/cop/layout/multiline_method_call_indentation.rb +4 -4
  100. data/lib/rubocop/cop/layout/multiline_method_definition_brace_layout.rb +1 -1
  101. data/lib/rubocop/cop/layout/multiline_method_parameter_line_breaks.rb +1 -0
  102. data/lib/rubocop/cop/layout/multiline_operation_indentation.rb +3 -4
  103. data/lib/rubocop/cop/layout/parameter_alignment.rb +3 -4
  104. data/lib/rubocop/cop/layout/redundant_line_break.rb +19 -46
  105. data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +6 -7
  106. data/lib/rubocop/cop/layout/single_line_block_chain.rb +1 -1
  107. data/lib/rubocop/cop/layout/space_after_colon.rb +2 -2
  108. data/lib/rubocop/cop/layout/space_after_comma.rb +1 -1
  109. data/lib/rubocop/cop/layout/space_after_method_name.rb +1 -1
  110. data/lib/rubocop/cop/layout/space_after_semicolon.rb +11 -1
  111. data/lib/rubocop/cop/layout/space_around_keyword.rb +2 -1
  112. data/lib/rubocop/cop/layout/space_around_method_call_operator.rb +1 -1
  113. data/lib/rubocop/cop/layout/space_around_operators.rb +23 -21
  114. data/lib/rubocop/cop/layout/space_before_block_braces.rb +1 -0
  115. data/lib/rubocop/cop/layout/space_before_brackets.rb +7 -40
  116. data/lib/rubocop/cop/layout/space_before_comma.rb +1 -1
  117. data/lib/rubocop/cop/layout/space_before_semicolon.rb +1 -1
  118. data/lib/rubocop/cop/layout/space_inside_array_literal_brackets.rb +18 -3
  119. data/lib/rubocop/cop/layout/space_inside_block_braces.rb +5 -0
  120. data/lib/rubocop/cop/layout/space_inside_hash_literal_braces.rb +7 -0
  121. data/lib/rubocop/cop/layout/space_inside_string_interpolation.rb +0 -1
  122. data/lib/rubocop/cop/layout/trailing_whitespace.rb +5 -3
  123. data/lib/rubocop/cop/lint/ambiguous_block_association.rb +1 -1
  124. data/lib/rubocop/cop/lint/ambiguous_range.rb +5 -0
  125. data/lib/rubocop/cop/lint/array_literal_in_regexp.rb +118 -0
  126. data/lib/rubocop/cop/lint/assignment_in_condition.rb +1 -3
  127. data/lib/rubocop/cop/lint/binary_operator_with_identical_operands.rb +10 -12
  128. data/lib/rubocop/cop/lint/boolean_symbol.rb +1 -1
  129. data/lib/rubocop/cop/lint/circular_argument_reference.rb +4 -1
  130. data/lib/rubocop/cop/lint/constant_definition_in_block.rb +3 -3
  131. data/lib/rubocop/cop/lint/constant_reassignment.rb +148 -0
  132. data/lib/rubocop/cop/lint/cop_directive_syntax.rb +84 -0
  133. data/lib/rubocop/cop/lint/debugger.rb +3 -3
  134. data/lib/rubocop/cop/lint/deprecated_class_methods.rb +1 -1
  135. data/lib/rubocop/cop/lint/deprecated_open_ssl_constant.rb +3 -2
  136. data/lib/rubocop/cop/lint/duplicate_branch.rb +39 -4
  137. data/lib/rubocop/cop/lint/duplicate_match_pattern.rb +1 -1
  138. data/lib/rubocop/cop/lint/duplicate_methods.rb +86 -19
  139. data/lib/rubocop/cop/lint/duplicate_regexp_character_class_element.rb +1 -1
  140. data/lib/rubocop/cop/lint/duplicate_set_element.rb +20 -7
  141. data/lib/rubocop/cop/lint/empty_conditional_body.rb +14 -64
  142. data/lib/rubocop/cop/lint/empty_ensure.rb +1 -1
  143. data/lib/rubocop/cop/lint/empty_expression.rb +0 -2
  144. data/lib/rubocop/cop/lint/empty_file.rb +0 -2
  145. data/lib/rubocop/cop/lint/empty_interpolation.rb +3 -1
  146. data/lib/rubocop/cop/lint/ensure_return.rb +1 -1
  147. data/lib/rubocop/cop/lint/erb_new_arguments.rb +0 -6
  148. data/lib/rubocop/cop/lint/float_comparison.rb +51 -18
  149. data/lib/rubocop/cop/lint/float_out_of_range.rb +2 -4
  150. data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +2 -2
  151. data/lib/rubocop/cop/lint/hash_new_with_keyword_arguments_as_default.rb +55 -0
  152. data/lib/rubocop/cop/lint/identity_comparison.rb +19 -15
  153. data/lib/rubocop/cop/lint/implicit_string_concatenation.rb +1 -1
  154. data/lib/rubocop/cop/lint/interpolation_check.rb +9 -0
  155. data/lib/rubocop/cop/lint/it_without_arguments_in_block.rb +3 -0
  156. data/lib/rubocop/cop/lint/literal_as_condition.rb +110 -9
  157. data/lib/rubocop/cop/lint/literal_assignment_in_condition.rb +1 -1
  158. data/lib/rubocop/cop/lint/literal_in_interpolation.rb +24 -6
  159. data/lib/rubocop/cop/lint/missing_cop_enable_directive.rb +1 -1
  160. data/lib/rubocop/cop/lint/missing_super.rb +2 -2
  161. data/lib/rubocop/cop/lint/mixed_case_range.rb +5 -8
  162. data/lib/rubocop/cop/lint/mixed_regexp_capture_types.rb +1 -1
  163. data/lib/rubocop/cop/lint/nested_method_definition.rb +10 -6
  164. data/lib/rubocop/cop/lint/next_without_accumulator.rb +1 -1
  165. data/lib/rubocop/cop/lint/no_return_in_begin_end_blocks.rb +2 -2
  166. data/lib/rubocop/cop/lint/non_atomic_file_operation.rb +12 -3
  167. data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +3 -3
  168. data/lib/rubocop/cop/lint/non_local_exit_from_iterator.rb +3 -3
  169. data/lib/rubocop/cop/lint/number_conversion.rb +0 -1
  170. data/lib/rubocop/cop/lint/numbered_parameter_assignment.rb +1 -2
  171. data/lib/rubocop/cop/lint/numeric_operation_with_constant_result.rb +93 -0
  172. data/lib/rubocop/cop/lint/or_assignment_to_constant.rb +2 -3
  173. data/lib/rubocop/cop/lint/out_of_range_regexp_ref.rb +3 -2
  174. data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +1 -5
  175. data/lib/rubocop/cop/lint/raise_exception.rb +29 -10
  176. data/lib/rubocop/cop/lint/redundant_cop_enable_directive.rb +1 -1
  177. data/lib/rubocop/cop/lint/redundant_regexp_quantifiers.rb +2 -2
  178. data/lib/rubocop/cop/lint/redundant_require_statement.rb +0 -21
  179. data/lib/rubocop/cop/lint/redundant_safe_navigation.rb +12 -7
  180. data/lib/rubocop/cop/lint/redundant_splat_expansion.rb +8 -7
  181. data/lib/rubocop/cop/lint/redundant_string_coercion.rb +2 -2
  182. data/lib/rubocop/cop/lint/redundant_type_conversion.rb +261 -0
  183. data/lib/rubocop/cop/lint/redundant_with_index.rb +3 -0
  184. data/lib/rubocop/cop/lint/redundant_with_object.rb +3 -0
  185. data/lib/rubocop/cop/lint/refinement_import_methods.rb +1 -1
  186. data/lib/rubocop/cop/lint/regexp_as_condition.rb +0 -1
  187. data/lib/rubocop/cop/lint/rescue_exception.rb +1 -1
  188. data/lib/rubocop/cop/lint/rescue_type.rb +3 -7
  189. data/lib/rubocop/cop/lint/return_in_void_context.rb +9 -11
  190. data/lib/rubocop/cop/lint/safe_navigation_chain.rb +17 -1
  191. data/lib/rubocop/cop/lint/safe_navigation_consistency.rb +5 -1
  192. data/lib/rubocop/cop/lint/self_assignment.rb +33 -10
  193. data/lib/rubocop/cop/lint/shadowed_exception.rb +1 -1
  194. data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +13 -1
  195. data/lib/rubocop/cop/lint/shared_mutable_default.rb +76 -0
  196. data/lib/rubocop/cop/lint/suppressed_exception.rb +1 -1
  197. data/lib/rubocop/cop/lint/suppressed_exception_in_number_conversion.rb +111 -0
  198. data/lib/rubocop/cop/lint/symbol_conversion.rb +1 -1
  199. data/lib/rubocop/cop/lint/syntax.rb +4 -1
  200. data/lib/rubocop/cop/lint/to_enum_arguments.rb +1 -1
  201. data/lib/rubocop/cop/lint/top_level_return_with_argument.rb +1 -1
  202. data/lib/rubocop/cop/lint/unescaped_bracket_in_regexp.rb +88 -0
  203. data/lib/rubocop/cop/lint/unexpected_block_arity.rb +3 -1
  204. data/lib/rubocop/cop/lint/unmodified_reduce_accumulator.rb +1 -1
  205. data/lib/rubocop/cop/lint/unreachable_code.rb +52 -2
  206. data/lib/rubocop/cop/lint/unreachable_loop.rb +6 -6
  207. data/lib/rubocop/cop/lint/unused_method_argument.rb +18 -2
  208. data/lib/rubocop/cop/lint/useless_access_modifier.rb +34 -8
  209. data/lib/rubocop/cop/lint/useless_assignment.rb +3 -1
  210. data/lib/rubocop/cop/lint/useless_constant_scoping.rb +71 -0
  211. data/lib/rubocop/cop/lint/useless_default_value_argument.rb +90 -0
  212. data/lib/rubocop/cop/lint/useless_defined.rb +55 -0
  213. data/lib/rubocop/cop/lint/useless_else_without_rescue.rb +4 -0
  214. data/lib/rubocop/cop/lint/useless_method_definition.rb +1 -1
  215. data/lib/rubocop/cop/lint/useless_numeric_operation.rb +2 -1
  216. data/lib/rubocop/cop/lint/useless_or.rb +98 -0
  217. data/lib/rubocop/cop/lint/useless_rescue.rb +2 -2
  218. data/lib/rubocop/cop/lint/useless_ruby2_keywords.rb +5 -5
  219. data/lib/rubocop/cop/lint/useless_setter_call.rb +14 -25
  220. data/lib/rubocop/cop/lint/void.rb +16 -12
  221. data/lib/rubocop/cop/message_annotator.rb +7 -3
  222. data/lib/rubocop/cop/metrics/abc_size.rb +1 -1
  223. data/lib/rubocop/cop/metrics/block_length.rb +1 -0
  224. data/lib/rubocop/cop/metrics/block_nesting.rb +1 -1
  225. data/lib/rubocop/cop/metrics/class_length.rb +9 -9
  226. data/lib/rubocop/cop/metrics/collection_literal_length.rb +7 -0
  227. data/lib/rubocop/cop/metrics/cyclomatic_complexity.rb +5 -2
  228. data/lib/rubocop/cop/metrics/method_length.rb +9 -1
  229. data/lib/rubocop/cop/metrics/module_length.rb +1 -1
  230. data/lib/rubocop/cop/metrics/perceived_complexity.rb +1 -1
  231. data/lib/rubocop/cop/metrics/utils/abc_size_calculator.rb +1 -1
  232. data/lib/rubocop/cop/metrics/utils/code_length_calculator.rb +3 -4
  233. data/lib/rubocop/cop/metrics/utils/repeated_attribute_discount.rb +7 -7
  234. data/lib/rubocop/cop/mixin/alignment.rb +3 -3
  235. data/lib/rubocop/cop/mixin/allowed_pattern.rb +4 -4
  236. data/lib/rubocop/cop/mixin/check_assignment.rb +4 -12
  237. data/lib/rubocop/cop/mixin/check_line_breakable.rb +22 -12
  238. data/lib/rubocop/cop/mixin/check_single_line_suitability.rb +49 -0
  239. data/lib/rubocop/cop/mixin/comments_help.rb +8 -3
  240. data/lib/rubocop/cop/mixin/def_node.rb +1 -1
  241. data/lib/rubocop/cop/mixin/dig_help.rb +27 -0
  242. data/lib/rubocop/cop/mixin/empty_lines_around_body.rb +1 -1
  243. data/lib/rubocop/cop/mixin/endless_method_rewriter.rb +24 -0
  244. data/lib/rubocop/cop/mixin/forbidden_identifiers.rb +20 -0
  245. data/lib/rubocop/cop/mixin/forbidden_pattern.rb +16 -0
  246. data/lib/rubocop/cop/mixin/frozen_string_literal.rb +4 -3
  247. data/lib/rubocop/cop/mixin/gemspec_help.rb +22 -0
  248. data/lib/rubocop/cop/mixin/hash_alignment_styles.rb +15 -14
  249. data/lib/rubocop/cop/mixin/hash_shorthand_syntax.rb +22 -22
  250. data/lib/rubocop/cop/mixin/hash_subset.rb +203 -0
  251. data/lib/rubocop/cop/mixin/hash_transform_method.rb +74 -74
  252. data/lib/rubocop/cop/mixin/line_length_help.rb +27 -10
  253. data/lib/rubocop/cop/mixin/method_complexity.rb +2 -1
  254. data/lib/rubocop/cop/mixin/multiline_expression_indentation.rb +7 -9
  255. data/lib/rubocop/cop/mixin/ordered_gem_node.rb +1 -1
  256. data/lib/rubocop/cop/mixin/percent_literal.rb +1 -1
  257. data/lib/rubocop/cop/mixin/preceding_following_alignment.rb +68 -30
  258. data/lib/rubocop/cop/mixin/range_help.rb +15 -4
  259. data/lib/rubocop/cop/mixin/space_before_punctuation.rb +1 -1
  260. data/lib/rubocop/cop/mixin/statement_modifier.rb +8 -3
  261. data/lib/rubocop/cop/mixin/string_help.rb +2 -2
  262. data/lib/rubocop/cop/mixin/string_literals_help.rb +1 -1
  263. data/lib/rubocop/cop/mixin/target_ruby_version.rb +17 -1
  264. data/lib/rubocop/cop/mixin/trailing_comma.rb +21 -5
  265. data/lib/rubocop/cop/naming/accessor_method_name.rb +6 -6
  266. data/lib/rubocop/cop/naming/block_forwarding.rb +20 -16
  267. data/lib/rubocop/cop/naming/constant_name.rb +6 -7
  268. data/lib/rubocop/cop/naming/file_name.rb +2 -4
  269. data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +12 -13
  270. data/lib/rubocop/cop/naming/method_name.rb +64 -8
  271. data/lib/rubocop/cop/naming/predicate_method.rb +281 -0
  272. data/lib/rubocop/cop/naming/{predicate_name.rb → predicate_prefix.rb} +48 -4
  273. data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +6 -14
  274. data/lib/rubocop/cop/naming/variable_name.rb +50 -6
  275. data/lib/rubocop/cop/naming/variable_number.rb +2 -3
  276. data/lib/rubocop/cop/offense.rb +2 -3
  277. data/lib/rubocop/cop/registry.rb +9 -6
  278. data/lib/rubocop/cop/security/compound_hash.rb +2 -0
  279. data/lib/rubocop/cop/security/yaml_load.rb +3 -2
  280. data/lib/rubocop/cop/style/access_modifier_declarations.rb +114 -34
  281. data/lib/rubocop/cop/style/accessor_grouping.rb +19 -5
  282. data/lib/rubocop/cop/style/ambiguous_endless_method_definition.rb +79 -0
  283. data/lib/rubocop/cop/style/and_or.rb +1 -1
  284. data/lib/rubocop/cop/style/arguments_forwarding.rb +47 -28
  285. data/lib/rubocop/cop/style/array_first_last.rb +18 -2
  286. data/lib/rubocop/cop/style/array_intersect.rb +42 -30
  287. data/lib/rubocop/cop/style/bitwise_predicate.rb +100 -0
  288. data/lib/rubocop/cop/style/block_delimiters.rb +43 -25
  289. data/lib/rubocop/cop/style/case_like_if.rb +9 -12
  290. data/lib/rubocop/cop/style/class_and_module_children.rb +52 -11
  291. data/lib/rubocop/cop/style/class_equality_comparison.rb +1 -1
  292. data/lib/rubocop/cop/style/collection_methods.rb +2 -1
  293. data/lib/rubocop/cop/style/collection_querying.rb +167 -0
  294. data/lib/rubocop/cop/style/combinable_defined.rb +115 -0
  295. data/lib/rubocop/cop/style/combinable_loops.rb +3 -2
  296. data/lib/rubocop/cop/style/command_literal.rb +1 -1
  297. data/lib/rubocop/cop/style/commented_keyword.rb +20 -3
  298. data/lib/rubocop/cop/style/comparable_between.rb +78 -0
  299. data/lib/rubocop/cop/style/concat_array_literals.rb +1 -1
  300. data/lib/rubocop/cop/style/conditional_assignment.rb +41 -27
  301. data/lib/rubocop/cop/style/constant_visibility.rb +3 -12
  302. data/lib/rubocop/cop/style/data_inheritance.rb +7 -0
  303. data/lib/rubocop/cop/style/def_with_parentheses.rb +18 -5
  304. data/lib/rubocop/cop/style/dig_chain.rb +89 -0
  305. data/lib/rubocop/cop/style/documentation.rb +1 -1
  306. data/lib/rubocop/cop/style/double_negation.rb +4 -4
  307. data/lib/rubocop/cop/style/each_for_simple_loop.rb +4 -7
  308. data/lib/rubocop/cop/style/each_with_object.rb +2 -3
  309. data/lib/rubocop/cop/style/empty_else.rb +4 -2
  310. data/lib/rubocop/cop/style/empty_literal.rb +5 -1
  311. data/lib/rubocop/cop/style/empty_method.rb +1 -1
  312. data/lib/rubocop/cop/style/empty_string_inside_interpolation.rb +100 -0
  313. data/lib/rubocop/cop/style/endless_method.rb +150 -18
  314. data/lib/rubocop/cop/style/eval_with_location.rb +4 -4
  315. data/lib/rubocop/cop/style/exact_regexp_match.rb +2 -3
  316. data/lib/rubocop/cop/style/expand_path_arguments.rb +2 -7
  317. data/lib/rubocop/cop/style/explicit_block_argument.rb +16 -3
  318. data/lib/rubocop/cop/style/exponential_notation.rb +5 -5
  319. data/lib/rubocop/cop/style/fetch_env_var.rb +34 -7
  320. data/lib/rubocop/cop/style/file_null.rb +89 -0
  321. data/lib/rubocop/cop/style/file_touch.rb +75 -0
  322. data/lib/rubocop/cop/style/float_division.rb +8 -4
  323. data/lib/rubocop/cop/style/for.rb +1 -1
  324. data/lib/rubocop/cop/style/format_string_token.rb +38 -11
  325. data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +3 -2
  326. data/lib/rubocop/cop/style/global_std_stream.rb +3 -0
  327. data/lib/rubocop/cop/style/global_vars.rb +1 -3
  328. data/lib/rubocop/cop/style/guard_clause.rb +17 -3
  329. data/lib/rubocop/cop/style/hash_conversion.rb +12 -4
  330. data/lib/rubocop/cop/style/hash_each_methods.rb +6 -8
  331. data/lib/rubocop/cop/style/hash_except.rb +35 -147
  332. data/lib/rubocop/cop/style/hash_fetch_chain.rb +104 -0
  333. data/lib/rubocop/cop/style/hash_slice.rb +80 -0
  334. data/lib/rubocop/cop/style/hash_syntax.rb +9 -3
  335. data/lib/rubocop/cop/style/hash_transform_keys.rb +2 -2
  336. data/lib/rubocop/cop/style/hash_transform_values.rb +2 -2
  337. data/lib/rubocop/cop/style/identical_conditional_branches.rb +25 -6
  338. data/lib/rubocop/cop/style/if_inside_else.rb +10 -14
  339. data/lib/rubocop/cop/style/if_unless_modifier.rb +36 -9
  340. data/lib/rubocop/cop/style/if_unless_modifier_of_if_unless.rb +4 -7
  341. data/lib/rubocop/cop/style/if_with_boolean_literal_branches.rb +3 -4
  342. data/lib/rubocop/cop/style/if_with_semicolon.rb +20 -9
  343. data/lib/rubocop/cop/style/infinite_loop.rb +1 -1
  344. data/lib/rubocop/cop/style/inverse_methods.rb +15 -12
  345. data/lib/rubocop/cop/style/invertible_unless_condition.rb +2 -2
  346. data/lib/rubocop/cop/style/ip_addresses.rb +2 -2
  347. data/lib/rubocop/cop/style/it_assignment.rb +36 -0
  348. data/lib/rubocop/cop/style/it_block_parameter.rb +119 -0
  349. data/lib/rubocop/cop/style/keyword_arguments_merging.rb +67 -0
  350. data/lib/rubocop/cop/style/keyword_parameters_order.rb +14 -8
  351. data/lib/rubocop/cop/style/lambda.rb +1 -0
  352. data/lib/rubocop/cop/style/lambda_call.rb +10 -4
  353. data/lib/rubocop/cop/style/line_end_concatenation.rb +10 -4
  354. data/lib/rubocop/cop/style/map_into_array.rb +11 -3
  355. data/lib/rubocop/cop/style/map_to_hash.rb +12 -1
  356. data/lib/rubocop/cop/style/map_to_set.rb +3 -2
  357. data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +28 -18
  358. data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +2 -0
  359. data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +8 -11
  360. data/lib/rubocop/cop/style/method_called_on_do_end_block.rb +3 -4
  361. data/lib/rubocop/cop/style/method_def_parentheses.rb +1 -1
  362. data/lib/rubocop/cop/style/min_max_comparison.rb +13 -5
  363. data/lib/rubocop/cop/style/missing_else.rb +2 -0
  364. data/lib/rubocop/cop/style/missing_respond_to_missing.rb +33 -3
  365. data/lib/rubocop/cop/style/multiline_block_chain.rb +3 -2
  366. data/lib/rubocop/cop/style/multiline_if_modifier.rb +2 -0
  367. data/lib/rubocop/cop/style/multiline_memoization.rb +1 -1
  368. data/lib/rubocop/cop/style/multiline_method_signature.rb +1 -9
  369. data/lib/rubocop/cop/style/multiple_comparison.rb +52 -51
  370. data/lib/rubocop/cop/style/mutable_constant.rb +7 -8
  371. data/lib/rubocop/cop/style/negated_if_else_condition.rb +7 -5
  372. data/lib/rubocop/cop/style/nested_parenthesized_calls.rb +1 -1
  373. data/lib/rubocop/cop/style/nested_ternary_operator.rb +5 -4
  374. data/lib/rubocop/cop/style/next.rb +44 -0
  375. data/lib/rubocop/cop/style/not.rb +1 -1
  376. data/lib/rubocop/cop/style/object_then.rb +15 -15
  377. data/lib/rubocop/cop/style/one_line_conditional.rb +25 -4
  378. data/lib/rubocop/cop/style/open_struct_use.rb +5 -5
  379. data/lib/rubocop/cop/style/operator_method_call.rb +5 -6
  380. data/lib/rubocop/cop/style/or_assignment.rb +3 -6
  381. data/lib/rubocop/cop/style/parallel_assignment.rb +9 -18
  382. data/lib/rubocop/cop/style/parentheses_around_condition.rb +2 -2
  383. data/lib/rubocop/cop/style/percent_literal_delimiters.rb +1 -1
  384. data/lib/rubocop/cop/style/percent_q_literals.rb +1 -1
  385. data/lib/rubocop/cop/style/proc.rb +2 -2
  386. data/lib/rubocop/cop/style/quoted_symbols.rb +1 -1
  387. data/lib/rubocop/cop/style/raise_args.rb +15 -13
  388. data/lib/rubocop/cop/style/random_with_offset.rb +3 -3
  389. data/lib/rubocop/cop/style/redundant_argument.rb +3 -1
  390. data/lib/rubocop/cop/style/redundant_array_flatten.rb +50 -0
  391. data/lib/rubocop/cop/style/redundant_assignment.rb +1 -1
  392. data/lib/rubocop/cop/style/redundant_begin.rb +2 -1
  393. data/lib/rubocop/cop/style/redundant_condition.rb +95 -23
  394. data/lib/rubocop/cop/style/redundant_current_directory_in_path.rb +16 -5
  395. data/lib/rubocop/cop/style/redundant_double_splat_hash_braces.rb +6 -10
  396. data/lib/rubocop/cop/style/redundant_each.rb +1 -1
  397. data/lib/rubocop/cop/style/redundant_exception.rb +2 -2
  398. data/lib/rubocop/cop/style/redundant_format.rb +262 -0
  399. data/lib/rubocop/cop/style/redundant_freeze.rb +3 -3
  400. data/lib/rubocop/cop/style/redundant_initialize.rb +12 -3
  401. data/lib/rubocop/cop/style/redundant_interpolation.rb +1 -1
  402. data/lib/rubocop/cop/style/redundant_line_continuation.rb +54 -18
  403. data/lib/rubocop/cop/style/redundant_parentheses.rb +77 -26
  404. data/lib/rubocop/cop/style/redundant_regexp_argument.rb +4 -0
  405. data/lib/rubocop/cop/style/redundant_regexp_character_class.rb +1 -1
  406. data/lib/rubocop/cop/style/redundant_regexp_escape.rb +1 -1
  407. data/lib/rubocop/cop/style/redundant_return.rb +2 -2
  408. data/lib/rubocop/cop/style/redundant_self.rb +15 -18
  409. data/lib/rubocop/cop/style/redundant_self_assignment.rb +20 -32
  410. data/lib/rubocop/cop/style/redundant_self_assignment_branch.rb +4 -4
  411. data/lib/rubocop/cop/style/redundant_sort.rb +3 -3
  412. data/lib/rubocop/cop/style/redundant_sort_by.rb +17 -1
  413. data/lib/rubocop/cop/style/redundant_string_escape.rb +2 -2
  414. data/lib/rubocop/cop/style/regexp_literal.rb +1 -1
  415. data/lib/rubocop/cop/style/rescue_modifier.rb +5 -3
  416. data/lib/rubocop/cop/style/return_nil.rb +2 -2
  417. data/lib/rubocop/cop/style/safe_navigation.rb +56 -16
  418. data/lib/rubocop/cop/style/safe_navigation_chain_length.rb +52 -0
  419. data/lib/rubocop/cop/style/select_by_regexp.rb +5 -2
  420. data/lib/rubocop/cop/style/self_assignment.rb +11 -17
  421. data/lib/rubocop/cop/style/semicolon.rb +1 -1
  422. data/lib/rubocop/cop/style/send_with_literal_method_name.rb +2 -1
  423. data/lib/rubocop/cop/style/signal_exception.rb +2 -3
  424. data/lib/rubocop/cop/style/single_argument_dig.rb +9 -5
  425. data/lib/rubocop/cop/style/single_line_block_params.rb +1 -1
  426. data/lib/rubocop/cop/style/single_line_do_end_block.rb +15 -4
  427. data/lib/rubocop/cop/style/single_line_methods.rb +6 -7
  428. data/lib/rubocop/cop/style/slicing_with_range.rb +40 -11
  429. data/lib/rubocop/cop/style/sole_nested_conditional.rb +43 -106
  430. data/lib/rubocop/cop/style/special_global_vars.rb +1 -1
  431. data/lib/rubocop/cop/style/string_concatenation.rb +15 -15
  432. data/lib/rubocop/cop/style/string_literals.rb +1 -1
  433. data/lib/rubocop/cop/style/string_methods.rb +1 -1
  434. data/lib/rubocop/cop/style/struct_inheritance.rb +8 -1
  435. data/lib/rubocop/cop/style/super_arguments.rb +66 -19
  436. data/lib/rubocop/cop/style/swap_values.rb +4 -15
  437. data/lib/rubocop/cop/style/symbol_proc.rb +3 -1
  438. data/lib/rubocop/cop/style/ternary_parentheses.rb +25 -4
  439. data/lib/rubocop/cop/style/top_level_method_definition.rb +2 -1
  440. data/lib/rubocop/cop/style/trailing_comma_in_arguments.rb +11 -2
  441. data/lib/rubocop/cop/style/trailing_comma_in_array_literal.rb +47 -6
  442. data/lib/rubocop/cop/style/trailing_comma_in_block_args.rb +1 -1
  443. data/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb +48 -6
  444. data/lib/rubocop/cop/style/trailing_underscore_variable.rb +4 -4
  445. data/lib/rubocop/cop/style/trivial_accessors.rb +1 -1
  446. data/lib/rubocop/cop/style/variable_interpolation.rb +1 -2
  447. data/lib/rubocop/cop/style/while_until_modifier.rb +0 -1
  448. data/lib/rubocop/cop/style/yoda_condition.rb +8 -4
  449. data/lib/rubocop/cop/style/yoda_expression.rb +2 -1
  450. data/lib/rubocop/cop/team.rb +1 -1
  451. data/lib/rubocop/cop/util.rb +12 -5
  452. data/lib/rubocop/cop/utils/format_string.rb +10 -5
  453. data/lib/rubocop/cop/variable_force/assignment.rb +24 -5
  454. data/lib/rubocop/cop/variable_force/branch.rb +1 -1
  455. data/lib/rubocop/cop/variable_force/scope.rb +1 -1
  456. data/lib/rubocop/cop/variable_force/variable.rb +14 -3
  457. data/lib/rubocop/cop/variable_force/variable_table.rb +5 -5
  458. data/lib/rubocop/cop/variable_force.rb +5 -11
  459. data/lib/rubocop/cops_documentation_generator.rb +50 -25
  460. data/lib/rubocop/directive_comment.rb +45 -11
  461. data/lib/rubocop/ext/regexp_node.rb +0 -1
  462. data/lib/rubocop/formatter/disabled_config_formatter.rb +3 -2
  463. data/lib/rubocop/formatter/formatter_set.rb +1 -1
  464. data/lib/rubocop/formatter/fuubar_style_formatter.rb +1 -1
  465. data/lib/rubocop/formatter/html_formatter.rb +1 -1
  466. data/lib/rubocop/formatter/offense_count_formatter.rb +1 -1
  467. data/lib/rubocop/formatter/pacman_formatter.rb +1 -1
  468. data/lib/rubocop/lsp/diagnostic.rb +189 -0
  469. data/lib/rubocop/lsp/logger.rb +2 -2
  470. data/lib/rubocop/lsp/routes.rb +7 -23
  471. data/lib/rubocop/lsp/runtime.rb +18 -50
  472. data/lib/rubocop/lsp/server.rb +0 -2
  473. data/lib/rubocop/lsp/stdin_runner.rb +85 -0
  474. data/lib/rubocop/magic_comment.rb +11 -3
  475. data/lib/rubocop/options.rb +28 -12
  476. data/lib/rubocop/path_util.rb +15 -8
  477. data/lib/rubocop/plugin/configuration_integrator.rb +143 -0
  478. data/lib/rubocop/plugin/load_error.rb +26 -0
  479. data/lib/rubocop/plugin/loader.rb +100 -0
  480. data/lib/rubocop/plugin/not_supported_error.rb +29 -0
  481. data/lib/rubocop/plugin.rb +46 -0
  482. data/lib/rubocop/rake_task.rb +4 -1
  483. data/lib/rubocop/result_cache.rb +13 -13
  484. data/lib/rubocop/rspec/cop_helper.rb +13 -1
  485. data/lib/rubocop/rspec/expect_offense.rb +15 -5
  486. data/lib/rubocop/rspec/shared_contexts.rb +38 -1
  487. data/lib/rubocop/rspec/support.rb +4 -2
  488. data/lib/rubocop/runner.rb +26 -15
  489. data/lib/rubocop/server/cache.rb +47 -11
  490. data/lib/rubocop/server/cli.rb +2 -2
  491. data/lib/rubocop/target_finder.rb +7 -2
  492. data/lib/rubocop/target_ruby.rb +17 -2
  493. data/lib/rubocop/version.rb +53 -12
  494. data/lib/rubocop.rb +40 -2
  495. data/lib/ruby_lsp/rubocop/addon.rb +75 -0
  496. data/lib/ruby_lsp/rubocop/runtime_adapter.rb +65 -0
  497. metadata +87 -21
  498. data/lib/rubocop/cop/utils/regexp_ranges.rb +0 -113
  499. 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'
@@ -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:
@@ -637,7 +647,7 @@ Layout/EmptyLinesAroundAccessModifier:
637
647
  SupportedStyles:
638
648
  - around
639
649
  - only_before
640
- Reference:
650
+ References:
641
651
  # A reference to `EnforcedStyle: only_before`.
642
652
  - https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#follow-the-coding-conventions
643
653
 
@@ -994,7 +1004,7 @@ Layout/IndentationConsistency:
994
1004
  SupportedStyles:
995
1005
  - normal
996
1006
  - indented_internal_methods
997
- Reference:
1007
+ References:
998
1008
  # A reference to `EnforcedStyle: indented_internal_methods`.
999
1009
  - https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#follow-the-coding-conventions
1000
1010
 
@@ -1038,6 +1048,7 @@ Layout/LeadingCommentSpace:
1038
1048
  AllowDoxygenCommentStyle: false
1039
1049
  AllowGemfileRubyComment: false
1040
1050
  AllowRBSInlineAnnotation: false
1051
+ AllowSteepAnnotation: false
1041
1052
 
1042
1053
  Layout/LeadingEmptyLines:
1043
1054
  Description: Check for unnecessary blank lines at the beginning of a file.
@@ -1085,12 +1096,13 @@ Layout/LineLength:
1085
1096
  StyleGuide: '#max-line-length'
1086
1097
  Enabled: true
1087
1098
  VersionAdded: '0.25'
1088
- VersionChanged: '1.4'
1099
+ VersionChanged: '1.69'
1089
1100
  Max: 120
1101
+ AllowHeredoc: true
1090
1102
  # To make it possible to copy or click on URIs in the code, we allow lines
1091
1103
  # containing a URI to be longer than Max.
1092
- AllowHeredoc: true
1093
1104
  AllowURI: true
1105
+ AllowQualifiedName: true
1094
1106
  URISchemes:
1095
1107
  - http
1096
1108
  - https
@@ -1101,6 +1113,8 @@ Layout/LineLength:
1101
1113
  # elements. Strings will be converted to Regexp objects. A line that matches
1102
1114
  # any regular expression listed in this option will be ignored by LineLength.
1103
1115
  AllowedPatterns: []
1116
+ # If SplitStrings is true, long strings will be split using continuations
1117
+ SplitStrings: false
1104
1118
 
1105
1119
  Layout/MultilineArrayBraceLayout:
1106
1120
  Description: >-
@@ -1498,7 +1512,6 @@ Layout/SpaceInsideHashLiteralBraces:
1498
1512
  - space
1499
1513
  - no_space
1500
1514
 
1501
-
1502
1515
  Layout/SpaceInsideParens:
1503
1516
  Description: 'No spaces after ( or before ).'
1504
1517
  StyleGuide: '#spaces-braces'
@@ -1614,6 +1627,12 @@ Lint/AmbiguousRegexpLiteral:
1614
1627
  VersionAdded: '0.17'
1615
1628
  VersionChanged: '0.83'
1616
1629
 
1630
+ Lint/ArrayLiteralInRegexp:
1631
+ Description: 'Checks for an array literal interpolated inside a regexp.'
1632
+ Enabled: pending
1633
+ VersionAdded: '1.71'
1634
+ SafeAutoCorrect: false
1635
+
1617
1636
  Lint/AssignmentInCondition:
1618
1637
  Description: "Don't use assignment in conditions."
1619
1638
  StyleGuide: '#safe-assignment-in-condition'
@@ -1633,7 +1652,7 @@ Lint/BinaryOperatorWithIdenticalOperands:
1633
1652
  Enabled: true
1634
1653
  Safe: false
1635
1654
  VersionAdded: '0.89'
1636
- VersionChanged: '1.7'
1655
+ VersionChanged: '1.69'
1637
1656
 
1638
1657
  Lint/BooleanSymbol:
1639
1658
  Description: 'Check for `:true` and `:false` symbols.'
@@ -1663,6 +1682,11 @@ Lint/ConstantOverwrittenInRescue:
1663
1682
  Enabled: pending
1664
1683
  VersionAdded: '1.31'
1665
1684
 
1685
+ Lint/ConstantReassignment:
1686
+ Description: 'Checks for constant reassignments.'
1687
+ Enabled: pending
1688
+ VersionAdded: '1.70'
1689
+
1666
1690
  Lint/ConstantResolution:
1667
1691
  Description: 'Check that constants are fully qualified with `::`.'
1668
1692
  Enabled: false
@@ -1672,6 +1696,11 @@ Lint/ConstantResolution:
1672
1696
  # Restrict this cop from only looking at certain names
1673
1697
  Ignore: []
1674
1698
 
1699
+ Lint/CopDirectiveSyntax:
1700
+ Description: 'Checks that `# rubocop:` directives are strictly formatted.'
1701
+ Enabled: pending
1702
+ VersionAdded: '1.72'
1703
+
1675
1704
  Lint/Debugger:
1676
1705
  Description: 'Check for debugger calls.'
1677
1706
  Enabled: true
@@ -1785,6 +1814,7 @@ Lint/DuplicateBranch:
1785
1814
  VersionChanged: '1.7'
1786
1815
  IgnoreLiteralBranches: false
1787
1816
  IgnoreConstantBranches: false
1817
+ IgnoreDuplicateElseBranch: false
1788
1818
 
1789
1819
  Lint/DuplicateCaseCondition:
1790
1820
  Description: 'Do not repeat values in case conditionals.'
@@ -1868,10 +1898,9 @@ Lint/EmptyConditionalBody:
1868
1898
  Description: 'Checks for the presence of `if`, `elsif` and `unless` branches without a body.'
1869
1899
  Enabled: true
1870
1900
  AutoCorrect: contextual
1871
- SafeAutoCorrect: false
1872
1901
  AllowComments: true
1873
1902
  VersionAdded: '0.89'
1874
- VersionChanged: '1.61'
1903
+ VersionChanged: '1.73'
1875
1904
 
1876
1905
  Lint/EmptyEnsure:
1877
1906
  Description: 'Checks for empty ensure block.'
@@ -1902,7 +1931,7 @@ Lint/EmptyInterpolation:
1902
1931
  Enabled: true
1903
1932
  AutoCorrect: contextual
1904
1933
  VersionAdded: '0.20'
1905
- VersionChanged: '1.61'
1934
+ VersionChanged: '1.76'
1906
1935
 
1907
1936
  Lint/EmptyWhen:
1908
1937
  Description: 'Checks for `when` branches with empty bodies.'
@@ -1954,6 +1983,11 @@ Lint/HashCompareByIdentity:
1954
1983
  Safe: false
1955
1984
  VersionAdded: '0.93'
1956
1985
 
1986
+ Lint/HashNewWithKeywordArgumentsAsDefault:
1987
+ Description: 'Checks for the deprecated use of keyword arguments for hash default in `Hash.new`.'
1988
+ Enabled: pending
1989
+ VersionAdded: '1.69'
1990
+
1957
1991
  Lint/HeredocMethodCallPosition:
1958
1992
  Description: >-
1959
1993
  Checks for the ordering of a method call where
@@ -2010,7 +2044,8 @@ Lint/InterpolationCheck:
2010
2044
 
2011
2045
  Lint/ItWithoutArgumentsInBlock:
2012
2046
  Description: 'Checks uses of `it` calls without arguments in block.'
2013
- Reference: 'https://bugs.ruby-lang.org/issues/18980'
2047
+ References:
2048
+ - 'https://bugs.ruby-lang.org/issues/18980'
2014
2049
  Enabled: pending
2015
2050
  VersionAdded: '1.59'
2016
2051
 
@@ -2022,6 +2057,7 @@ Lint/LambdaWithoutLiteralBlock:
2022
2057
  Lint/LiteralAsCondition:
2023
2058
  Description: 'Checks of literals used in conditions.'
2024
2059
  Enabled: true
2060
+ AutoCorrect: contextual
2025
2061
  VersionAdded: '0.51'
2026
2062
 
2027
2063
  Lint/LiteralAssignmentInCondition:
@@ -2144,6 +2180,11 @@ Lint/NumberedParameterAssignment:
2144
2180
  Enabled: pending
2145
2181
  VersionAdded: '1.9'
2146
2182
 
2183
+ Lint/NumericOperationWithConstantResult:
2184
+ Description: 'Checks for numeric operations with constant results.'
2185
+ Enabled: pending
2186
+ VersionAdded: '1.69'
2187
+
2147
2188
  Lint/OrAssignmentToConstant:
2148
2189
  Description: 'Checks unintended or-assignment to constant.'
2149
2190
  Enabled: pending
@@ -2230,9 +2271,8 @@ Lint/RedundantRegexpQuantifiers:
2230
2271
  Lint/RedundantRequireStatement:
2231
2272
  Description: 'Checks for unnecessary `require` statement.'
2232
2273
  Enabled: true
2233
- SafeAutoCorrect: false
2234
2274
  VersionAdded: '0.76'
2235
- VersionChanged: '1.57'
2275
+ VersionChanged: '1.73'
2236
2276
 
2237
2277
  Lint/RedundantSafeNavigation:
2238
2278
  Description: 'Checks for redundant safe navigation calls.'
@@ -2261,6 +2301,11 @@ Lint/RedundantStringCoercion:
2261
2301
  VersionAdded: '0.19'
2262
2302
  VersionChanged: '0.77'
2263
2303
 
2304
+ Lint/RedundantTypeConversion:
2305
+ Description: 'Checks for redundantly converting a literal to the same type.'
2306
+ Enabled: pending
2307
+ VersionAdded: '1.72'
2308
+
2264
2309
  Lint/RedundantWithIndex:
2265
2310
  Description: 'Checks for redundant `with_index`.'
2266
2311
  Enabled: true
@@ -2363,6 +2408,7 @@ Lint/SelfAssignment:
2363
2408
  Description: 'Checks for self-assignments.'
2364
2409
  Enabled: true
2365
2410
  VersionAdded: '0.89'
2411
+ AllowRBSInlineAnnotation: false
2366
2412
 
2367
2413
  Lint/SendWithMixinArgument:
2368
2414
  Description: 'Checks for `send` method when using mixin.'
@@ -2375,7 +2421,6 @@ Lint/ShadowedArgument:
2375
2421
  VersionAdded: '0.52'
2376
2422
  IgnoreImplicitReferences: false
2377
2423
 
2378
-
2379
2424
  Lint/ShadowedException:
2380
2425
  Description: >-
2381
2426
  Avoid rescuing a higher level exception
@@ -2387,8 +2432,15 @@ Lint/ShadowingOuterLocalVariable:
2387
2432
  Description: >-
2388
2433
  Do not use the same name as outer local variable
2389
2434
  for block arguments or block local variables.
2390
- Enabled: true
2435
+ Enabled: false
2391
2436
  VersionAdded: '0.9'
2437
+ VersionChanged: '1.76'
2438
+
2439
+ Lint/SharedMutableDefault:
2440
+ Description: 'Checks for mutable literals used as default arguments during Hash initialization.'
2441
+ StyleGuide: '#no-mutable-defaults'
2442
+ Enabled: pending
2443
+ VersionAdded: '1.70'
2392
2444
 
2393
2445
  Lint/StructNewOverride:
2394
2446
  Description: 'Disallow overriding the `Struct` built-in methods via `Struct.new`.'
@@ -2404,6 +2456,12 @@ Lint/SuppressedException:
2404
2456
  VersionAdded: '0.9'
2405
2457
  VersionChanged: '1.12'
2406
2458
 
2459
+ Lint/SuppressedExceptionInNumberConversion:
2460
+ Description: 'Checks for cases where exceptions unrelated to the numeric constructors may be unintentionally swallowed.'
2461
+ Enabled: pending
2462
+ SafeAutoCorrect: false
2463
+ VersionAdded: '1.72'
2464
+
2407
2465
  Lint/SymbolConversion:
2408
2466
  Description: 'Checks for unnecessary symbol conversions.'
2409
2467
  Enabled: pending
@@ -2455,6 +2513,11 @@ Lint/UnderscorePrefixedVariableName:
2455
2513
  VersionAdded: '0.21'
2456
2514
  AllowKeywordBlockArguments: false
2457
2515
 
2516
+ Lint/UnescapedBracketInRegexp:
2517
+ Description: 'Checks for unescaped literal `]` in Regexp.'
2518
+ Enabled: pending
2519
+ VersionAdded: '1.68'
2520
+
2458
2521
  Lint/UnexpectedBlockArity:
2459
2522
  Description: 'Looks for blocks that have fewer arguments that the calling method expects.'
2460
2523
  Enabled: pending
@@ -2514,10 +2577,12 @@ Lint/UnusedMethodArgument:
2514
2577
  Enabled: true
2515
2578
  AutoCorrect: contextual
2516
2579
  VersionAdded: '0.21'
2517
- VersionChanged: '1.61'
2580
+ VersionChanged: '1.69'
2518
2581
  AllowUnusedKeywordArguments: false
2519
2582
  IgnoreEmptyMethods: true
2520
2583
  IgnoreNotImplementedMethods: true
2584
+ NotImplementedExceptions:
2585
+ - NotImplementedError
2521
2586
 
2522
2587
  Lint/UriEscapeUnescape:
2523
2588
  Description: >-
@@ -2552,6 +2617,23 @@ Lint/UselessAssignment:
2552
2617
  VersionAdded: '0.11'
2553
2618
  VersionChanged: '1.66'
2554
2619
 
2620
+ Lint/UselessConstantScoping:
2621
+ Description: 'Checks for useless constant scoping.'
2622
+ Enabled: pending
2623
+ VersionAdded: '1.72'
2624
+
2625
+ Lint/UselessDefaultValueArgument:
2626
+ Description: 'Checks for usage of `fetch` or `Array.new` with default value argument and block.'
2627
+ Enabled: pending
2628
+ VersionAdded: '1.76'
2629
+ Safe: false
2630
+ AllowedReceivers: []
2631
+
2632
+ Lint/UselessDefined:
2633
+ Description: 'Checks for calls to `defined?` with strings and symbols. The result of such a call will always be truthy.'
2634
+ Enabled: pending
2635
+ VersionAdded: '1.69'
2636
+
2555
2637
  Lint/UselessElseWithoutRescue:
2556
2638
  Description: 'Checks for useless `else` in `begin..end` without `rescue`.'
2557
2639
  Enabled: true
@@ -2571,6 +2653,11 @@ Lint/UselessNumericOperation:
2571
2653
  Enabled: pending
2572
2654
  VersionAdded: '1.66'
2573
2655
 
2656
+ Lint/UselessOr:
2657
+ Description: 'Checks for useless OR expressions.'
2658
+ Enabled: pending
2659
+ VersionAdded: '1.76'
2660
+
2574
2661
  Lint/UselessRescue:
2575
2662
  Description: 'Checks for useless `rescue`s.'
2576
2663
  Enabled: pending
@@ -2610,8 +2697,8 @@ Metrics/AbcSize:
2610
2697
  Description: >-
2611
2698
  A calculated magnitude based on number of assignments,
2612
2699
  branches, and conditions.
2613
- Reference:
2614
- - http://c2.com/cgi/wiki?AbcMetric
2700
+ References:
2701
+ - https://wiki.c2.com/?AbcMetric
2615
2702
  - https://en.wikipedia.org/wiki/ABC_Software_Metric
2616
2703
  Enabled: true
2617
2704
  VersionAdded: '0.27'
@@ -2934,6 +3021,7 @@ Naming/MethodName:
2934
3021
  StyleGuide: '#snake-case-symbols-methods-vars'
2935
3022
  Enabled: true
2936
3023
  VersionAdded: '0.50'
3024
+ VersionChanged: '1.75'
2937
3025
  EnforcedStyle: snake_case
2938
3026
  SupportedStyles:
2939
3027
  - snake_case
@@ -2945,6 +3033,10 @@ Naming/MethodName:
2945
3033
  # - '\A\s*onSelectionCleared\s*'
2946
3034
  #
2947
3035
  AllowedPatterns: []
3036
+ ForbiddenIdentifiers:
3037
+ - __id__
3038
+ - __send__
3039
+ ForbiddenPatterns: []
2948
3040
 
2949
3041
  Naming/MethodParameterName:
2950
3042
  Description: >-
@@ -2976,22 +3068,39 @@ Naming/MethodParameterName:
2976
3068
  # Forbidden names that will register an offense
2977
3069
  ForbiddenNames: []
2978
3070
 
2979
- Naming/PredicateName:
2980
- Description: 'Check the names of predicate methods.'
3071
+ Naming/PredicateMethod:
3072
+ Description: 'Checks that predicate methods end with `?` and non-predicate methods do not.'
3073
+ Enabled: pending
3074
+ VersionAdded: '1.76'
3075
+ VersionChanged: '1.76'
3076
+ # In `aggressive` mode, the cop will register an offense for predicate methods that
3077
+ # may return a non-boolean value.
3078
+ # In `conservative` mode, the cop will *not* register an offense for predicate methods
3079
+ # that may return a non-boolean value.
3080
+ Mode: conservative
3081
+ AllowedMethods:
3082
+ - call
3083
+ AllowedPatterns: []
3084
+ AllowBangMethods: false
3085
+
3086
+ Naming/PredicatePrefix:
3087
+ Description: 'Predicate method names should not be prefixed and end with a `?`.'
2981
3088
  StyleGuide: '#bool-methods-qmark'
2982
3089
  Enabled: true
2983
3090
  VersionAdded: '0.50'
2984
- VersionChanged: '0.77'
3091
+ VersionChanged: '1.75'
2985
3092
  # Predicate name prefixes.
2986
3093
  NamePrefix:
2987
3094
  - is_
2988
3095
  - has_
2989
3096
  - have_
3097
+ - does_
2990
3098
  # Predicate name prefixes that should be removed.
2991
3099
  ForbiddenPrefixes:
2992
3100
  - is_
2993
3101
  - has_
2994
3102
  - have_
3103
+ - does_
2995
3104
  # Predicate names which, despite having a forbidden prefix, or no `?`,
2996
3105
  # should still be accepted
2997
3106
  AllowedMethods:
@@ -3000,6 +3109,8 @@ Naming/PredicateName:
3000
3109
  MethodDefinitionMacros:
3001
3110
  - define_method
3002
3111
  - define_singleton_method
3112
+ # Use Sorbet's T::Boolean return type to detect predicate methods.
3113
+ UseSorbetSigs: false
3003
3114
  # Exclude Rspec specs because there is a strong convention to write spec
3004
3115
  # helpers in the form of `have_something` or `be_something`.
3005
3116
  Exclude:
@@ -3017,13 +3128,15 @@ Naming/VariableName:
3017
3128
  StyleGuide: '#snake-case-symbols-methods-vars'
3018
3129
  Enabled: true
3019
3130
  VersionAdded: '0.50'
3020
- VersionChanged: '1.8'
3131
+ VersionChanged: '1.73'
3021
3132
  EnforcedStyle: snake_case
3022
3133
  SupportedStyles:
3023
3134
  - snake_case
3024
3135
  - camelCase
3025
3136
  AllowedIdentifiers: []
3026
3137
  AllowedPatterns: []
3138
+ ForbiddenIdentifiers: []
3139
+ ForbiddenPatterns: []
3027
3140
 
3028
3141
  Naming/VariableNumber:
3029
3142
  Description: 'Use the configured style when numbering symbols, methods and variables.'
@@ -3039,6 +3152,8 @@ Naming/VariableNumber:
3039
3152
  CheckMethodNames: true
3040
3153
  CheckSymbols: true
3041
3154
  AllowedIdentifiers:
3155
+ - TLS1_1 # OpenSSL::SSL::TLS1_1_VERSION
3156
+ - TLS1_2 # OpenSSL::SSL::TLS1_2_VERSION
3042
3157
  - capture3 # Open3.capture3
3043
3158
  - iso8601 # Time#iso8601
3044
3159
  - rfc1123_date # CGI.rfc1123_date
@@ -3074,7 +3189,8 @@ Security/JSONLoad:
3074
3189
  Description: >-
3075
3190
  Prefer usage of `JSON.parse` over `JSON.load` due to potential
3076
3191
  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'
3192
+ References:
3193
+ - 'https://ruby-doc.org/stdlib-2.7.0/libdoc/json/rdoc/JSON.html#method-i-load'
3078
3194
  Enabled: true
3079
3195
  VersionAdded: '0.43'
3080
3196
  VersionChanged: '1.22'
@@ -3086,7 +3202,8 @@ Security/MarshalLoad:
3086
3202
  Description: >-
3087
3203
  Avoid using of `Marshal.load` or `Marshal.restore` due to potential
3088
3204
  security issues. See reference for more information.
3089
- Reference: 'https://ruby-doc.org/core-2.7.0/Marshal.html#module-Marshal-label-Security+considerations'
3205
+ References:
3206
+ - 'https://ruby-doc.org/core-2.7.0/Marshal.html#module-Marshal-label-Security+considerations'
3090
3207
  Enabled: true
3091
3208
  VersionAdded: '0.47'
3092
3209
 
@@ -3101,7 +3218,8 @@ Security/YAMLLoad:
3101
3218
  Description: >-
3102
3219
  Prefer usage of `YAML.safe_load` over `YAML.load` due to potential
3103
3220
  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'
3221
+ References:
3222
+ - 'https://ruby-doc.org/stdlib-2.7.0/libdoc/yaml/rdoc/YAML.html#module-YAML-label-Security'
3105
3223
  Enabled: true
3106
3224
  VersionAdded: '0.47'
3107
3225
  SafeAutoCorrect: false
@@ -3112,13 +3230,14 @@ Style/AccessModifierDeclarations:
3112
3230
  Description: 'Checks style of how access modifiers are used.'
3113
3231
  Enabled: true
3114
3232
  VersionAdded: '0.57'
3115
- VersionChanged: '0.81'
3233
+ VersionChanged: '1.70'
3116
3234
  EnforcedStyle: group
3117
3235
  SupportedStyles:
3118
3236
  - inline
3119
3237
  - group
3120
3238
  AllowModifiersOnSymbols: true
3121
3239
  AllowModifiersOnAttrs: true
3240
+ AllowModifiersOnAliasMethod: true
3122
3241
  SafeAutoCorrect: false
3123
3242
 
3124
3243
  Style/AccessorGrouping:
@@ -3143,6 +3262,12 @@ Style/Alias:
3143
3262
  - prefer_alias
3144
3263
  - prefer_alias_method
3145
3264
 
3265
+ Style/AmbiguousEndlessMethodDefinition:
3266
+ Description: 'Checks for endless methods inside operators of lower precedence.'
3267
+ StyleGuide: '#ambiguous-endless-method-defintions'
3268
+ Enabled: pending
3269
+ VersionAdded: '1.68'
3270
+
3146
3271
  Style/AndOr:
3147
3272
  Description: 'Use &&/|| instead of and/or.'
3148
3273
  StyleGuide: '#no-and-or-or'
@@ -3188,7 +3313,8 @@ Style/ArrayCoercion:
3188
3313
 
3189
3314
  Style/ArrayFirstLast:
3190
3315
  Description: 'Use `arr.first` and `arr.last` instead of `arr[0]` and `arr[-1]`.'
3191
- Reference: '#first-and-last'
3316
+ References:
3317
+ - '#first-and-last'
3192
3318
  Enabled: false
3193
3319
  VersionAdded: '1.58'
3194
3320
  Safe: false
@@ -3250,6 +3376,13 @@ Style/BisectedAttrAccessor:
3250
3376
  Enabled: true
3251
3377
  VersionAdded: '0.87'
3252
3378
 
3379
+ Style/BitwisePredicate:
3380
+ Description: 'Prefer bitwise predicate methods over direct comparison operations.'
3381
+ StyleGuide: '#bitwise-predicate-methods'
3382
+ Enabled: pending
3383
+ Safe: false
3384
+ VersionAdded: '1.68'
3385
+
3253
3386
  Style/BlockComments:
3254
3387
  Description: 'Do not use block comments.'
3255
3388
  StyleGuide: '#no-block-comments'
@@ -3420,6 +3553,7 @@ Style/ClassAndModuleChildren:
3420
3553
  SafeAutoCorrect: false
3421
3554
  Enabled: true
3422
3555
  VersionAdded: '0.19'
3556
+ VersionChanged: '1.74'
3423
3557
  #
3424
3558
  # Basically there are two different styles:
3425
3559
  #
@@ -3435,7 +3569,21 @@ Style/ClassAndModuleChildren:
3435
3569
  #
3436
3570
  # The compact style is only forced, for classes or modules with one child.
3437
3571
  EnforcedStyle: nested
3438
- SupportedStyles:
3572
+ SupportedStyles: &supported_styles
3573
+ - nested
3574
+ - compact
3575
+ # Configure classes separately, if desired. If not set, or set to `nil`,
3576
+ # the `EnforcedStyle` value will be used.
3577
+ EnforcedStyleForClasses: ~
3578
+ SupportedStylesForClasses:
3579
+ - ~
3580
+ - nested
3581
+ - compact
3582
+ # Configure modules separately, if desired. If not set, or set to `nil`,
3583
+ # the `EnforcedStyle` value will be used.
3584
+ EnforcedStyleForModules: ~
3585
+ SupportedStylesForModules:
3586
+ - ~
3439
3587
  - nested
3440
3588
  - compact
3441
3589
 
@@ -3521,6 +3669,13 @@ Style/CollectionMethods:
3521
3669
  - inject
3522
3670
  - reduce
3523
3671
 
3672
+ Style/CollectionQuerying:
3673
+ Description: 'Prefer `Enumerable` predicate methods over expressions with `count`.'
3674
+ StyleGuide: '#collection-querying'
3675
+ Enabled: pending
3676
+ VersionAdded: '1.77'
3677
+ Safe: false
3678
+
3524
3679
  Style/ColonMethodCall:
3525
3680
  Description: 'Do not use :: for method call.'
3526
3681
  StyleGuide: '#double-colons'
@@ -3533,6 +3688,11 @@ Style/ColonMethodDefinition:
3533
3688
  Enabled: true
3534
3689
  VersionAdded: '0.52'
3535
3690
 
3691
+ Style/CombinableDefined:
3692
+ Description: 'Checks successive `defined?` calls that can be combined into a single call.'
3693
+ Enabled: pending
3694
+ VersionAdded: '1.68'
3695
+
3536
3696
  Style/CombinableLoops:
3537
3697
  Description: >-
3538
3698
  Checks for places where multiple consecutive loops over the same data
@@ -3583,6 +3743,14 @@ Style/CommentedKeyword:
3583
3743
  VersionAdded: '0.51'
3584
3744
  VersionChanged: '1.19'
3585
3745
 
3746
+ Style/ComparableBetween:
3747
+ Description: 'Enforces the use of `Comparable#between?` instead of logical comparison.'
3748
+ Enabled: pending
3749
+ Safe: false
3750
+ VersionAdded: '1.74'
3751
+ VersionChanged: '1.75'
3752
+ StyleGuide: '#ranges-or-between'
3753
+
3586
3754
  Style/ComparableClamp:
3587
3755
  Description: 'Enforces the use of `Comparable#clamp` instead of comparison by minimum and maximum.'
3588
3756
  Enabled: pending
@@ -3673,6 +3841,12 @@ Style/DefWithParentheses:
3673
3841
  VersionAdded: '0.9'
3674
3842
  VersionChanged: '0.12'
3675
3843
 
3844
+ Style/DigChain:
3845
+ Description: 'Use `dig` with multiple parameters instead of chaining multiple calls.'
3846
+ Enabled: pending
3847
+ Safe: false
3848
+ VersionAdded: '1.69'
3849
+
3676
3850
  Style/Dir:
3677
3851
  Description: >-
3678
3852
  Use the `__dir__` method to retrieve the canonicalized
@@ -3809,6 +3983,16 @@ Style/EmptyMethod:
3809
3983
  - compact
3810
3984
  - expanded
3811
3985
 
3986
+ Style/EmptyStringInsideInterpolation:
3987
+ Description: 'Checks for empty strings being assigned inside string interpolation.'
3988
+ StyleGuide: '#empty-strings-in-interpolation'
3989
+ Enabled: pending
3990
+ EnforcedStyle: trailing_conditional
3991
+ SupportedStyles:
3992
+ - trailing_conditional
3993
+ - ternary
3994
+ VersionAdded: '1.76'
3995
+
3812
3996
  Style/Encoding:
3813
3997
  Description: 'Use UTF-8 as the source file encoding.'
3814
3998
  StyleGuide: '#utf-8'
@@ -3833,6 +4017,8 @@ Style/EndlessMethod:
3833
4017
  - allow_single_line
3834
4018
  - allow_always
3835
4019
  - disallow
4020
+ - require_single_line
4021
+ - require_always
3836
4022
 
3837
4023
  Style/EnvHome:
3838
4024
  Description: "Checks for consistent usage of `ENV['HOME']`."
@@ -3885,12 +4071,15 @@ Style/ExponentialNotation:
3885
4071
  Style/FetchEnvVar:
3886
4072
  Description: >-
3887
4073
  Suggests `ENV.fetch` for the replacement of `ENV[]`.
3888
- Reference:
4074
+ References:
3889
4075
  - https://rubystyle.guide/#hash-fetch-defaults
3890
4076
  Enabled: pending
3891
4077
  VersionAdded: '1.28'
3892
4078
  # Environment variables to be excluded from the inspection.
3893
4079
  AllowedVars: []
4080
+ # When `true`, autocorrects `ENV["key"]` to `ENV.fetch("key", nil)`.
4081
+ # When `false`, autocorrects `ENV["key"]` to `ENV.fetch("key")`.
4082
+ DefaultToNil: true
3894
4083
 
3895
4084
  Style/FileEmpty:
3896
4085
  Description: >-
@@ -3899,12 +4088,24 @@ Style/FileEmpty:
3899
4088
  Safe: false
3900
4089
  VersionAdded: '1.48'
3901
4090
 
4091
+ Style/FileNull:
4092
+ Description: 'Use `File::NULL` instead of hardcoding "dev/null".'
4093
+ Enabled: pending
4094
+ SafeAutoCorrect: false
4095
+ VersionAdded: '1.69'
4096
+
3902
4097
  Style/FileRead:
3903
4098
  Description: 'Favor `File.(bin)read` convenience methods.'
3904
4099
  StyleGuide: '#file-read'
3905
4100
  Enabled: pending
3906
4101
  VersionAdded: '1.24'
3907
4102
 
4103
+ Style/FileTouch:
4104
+ Description: 'Favor `FileUtils.touch` for touching files.'
4105
+ Enabled: pending
4106
+ VersionAdded: '1.69'
4107
+ SafeAutoCorrect: false
4108
+
3908
4109
  Style/FileWrite:
3909
4110
  Description: 'Favor `File.(bin)write` convenience methods.'
3910
4111
  StyleGuide: '#file-write'
@@ -3914,7 +4115,8 @@ Style/FileWrite:
3914
4115
  Style/FloatDivision:
3915
4116
  Description: 'For performing float division, coerce one side only.'
3916
4117
  StyleGuide: '#float-division'
3917
- Reference: 'https://blog.rubystyle.guide/ruby/2019/06/21/float-division.html'
4118
+ References:
4119
+ - 'https://blog.rubystyle.guide/ruby/2019/06/21/float-division.html'
3918
4120
  Enabled: true
3919
4121
  VersionAdded: '0.72'
3920
4122
  VersionChanged: '1.9'
@@ -3965,8 +4167,14 @@ Style/FormatStringToken:
3965
4167
  # style token in a format string to be allowed when enforced style is not
3966
4168
  # `unannotated`.
3967
4169
  MaxUnannotatedPlaceholdersAllowed: 1
4170
+ # The mode the cop operates in. Two values are allowed:
4171
+ # * aggressive (default): all strings are considered
4172
+ # * conservative:
4173
+ # only register offenses for strings given to `printf`, `sprintf`,
4174
+ # format` and `%` methods. Other strings are not considered.
4175
+ Mode: aggressive
3968
4176
  VersionAdded: '0.49'
3969
- VersionChanged: '1.0'
4177
+ VersionChanged: '1.74'
3970
4178
  AllowedMethods: []
3971
4179
  AllowedPatterns: []
3972
4180
 
@@ -3991,6 +4199,9 @@ Style/FrozenStringLiteralComment:
3991
4199
  # exist in a file.
3992
4200
  - never
3993
4201
  SafeAutoCorrect: false
4202
+ Exclude:
4203
+ # Prevent the Ruby warning: `'frozen_string_literal' is ignored after any tokens` when using Active Admin.
4204
+ - '**/*.arb'
3994
4205
 
3995
4206
  Style/GlobalStdStream:
3996
4207
  Description: 'Enforces the use of `$stdout/$stderr/$stdin` instead of `STDOUT/STDERR/STDIN`.'
@@ -4002,7 +4213,8 @@ Style/GlobalStdStream:
4002
4213
  Style/GlobalVars:
4003
4214
  Description: 'Do not introduce global variables.'
4004
4215
  StyleGuide: '#instance-vars'
4005
- Reference: 'https://www.zenspider.com/ruby/quickref.html'
4216
+ References:
4217
+ - 'https://www.zenspider.com/ruby/quickref.html'
4006
4218
  Enabled: true
4007
4219
  VersionAdded: '0.13'
4008
4220
  # Built-in global variables are allowed by default.
@@ -4059,6 +4271,12 @@ Style/HashExcept:
4059
4271
  VersionAdded: '1.7'
4060
4272
  VersionChanged: '1.39'
4061
4273
 
4274
+ Style/HashFetchChain:
4275
+ Description: 'Use `Hash#dig` instead of chained `fetch` calls.'
4276
+ Enabled: pending
4277
+ Safe: false
4278
+ VersionAdded: '1.75'
4279
+
4062
4280
  Style/HashLikeCase:
4063
4281
  Description: >-
4064
4282
  Checks for places where `case-when` represents a simple 1:1
@@ -4069,6 +4287,14 @@ Style/HashLikeCase:
4069
4287
  # to trigger this cop
4070
4288
  MinBranchesCount: 3
4071
4289
 
4290
+ Style/HashSlice:
4291
+ Description: >-
4292
+ Checks for usages of `Hash#reject`, `Hash#select`, and `Hash#filter` methods
4293
+ that can be replaced with `Hash#slice` method.
4294
+ Enabled: pending
4295
+ Safe: false
4296
+ VersionAdded: '1.71'
4297
+
4072
4298
  Style/HashSyntax:
4073
4299
  Description: >-
4074
4300
  Prefer Ruby 1.9 hash syntax { a: 1, b: 2 } over 1.8 syntax
@@ -4256,6 +4482,31 @@ Style/IpAddresses:
4256
4482
  - '**/gems.rb'
4257
4483
  - '**/*.gemspec'
4258
4484
 
4485
+ Style/ItAssignment:
4486
+ Description: 'Checks for assignment to `it` inside a block.'
4487
+ Enabled: pending
4488
+ VersionAdded: '1.70'
4489
+
4490
+ Style/ItBlockParameter:
4491
+ Description: 'Checks for blocks with one argument where `it` block parameter can be used.'
4492
+ Enabled: pending
4493
+ EnforcedStyle: allow_single_line
4494
+ SupportedStyles:
4495
+ - allow_single_line
4496
+ - only_numbered_parameters
4497
+ - always
4498
+ - disallow
4499
+ VersionAdded: '1.75'
4500
+ VersionChanged: '1.76'
4501
+
4502
+ Style/KeywordArgumentsMerging:
4503
+ Description: >-
4504
+ When passing an existing hash as keyword arguments, provide additional arguments
4505
+ directly rather than using `merge`.
4506
+ StyleGuide: '#merging-keyword-arguments'
4507
+ Enabled: pending
4508
+ VersionAdded: '1.68'
4509
+
4259
4510
  Style/KeywordParametersOrder:
4260
4511
  Description: 'Enforces that optional keyword parameters are placed at the end of the parameters list.'
4261
4512
  StyleGuide: '#keyword-parameters-order'
@@ -4636,7 +4887,7 @@ Style/Next:
4636
4887
  StyleGuide: '#no-nested-conditionals'
4637
4888
  Enabled: true
4638
4889
  VersionAdded: '0.22'
4639
- VersionChanged: '0.35'
4890
+ VersionChanged: '1.75'
4640
4891
  # With `always` all conditions at the end of an iteration needs to be
4641
4892
  # replaced by next - with `skip_modifier_ifs` the modifier if like this one
4642
4893
  # are ignored: [1, 2].each { |a| return 'yes' if a == 1 }
@@ -4644,6 +4895,7 @@ Style/Next:
4644
4895
  # `MinBodyLength` defines the number of lines of the a body of an `if` or `unless`
4645
4896
  # needs to have to trigger this cop
4646
4897
  MinBodyLength: 3
4898
+ AllowConsecutiveConditionals: false
4647
4899
  SupportedStyles:
4648
4900
  - skip_modifier_ifs
4649
4901
  - always
@@ -4775,8 +5027,8 @@ Style/OpenStructUse:
4775
5027
  Description: >-
4776
5028
  Avoid using OpenStruct. As of Ruby 3.0, use is officially discouraged due to performance,
4777
5029
  version compatibility, and potential security issues.
4778
- Reference:
4779
- - https://docs.ruby-lang.org/en/3.0.0/OpenStruct.html#class-OpenStruct-label-Caveats
5030
+ References:
5031
+ - https://docs.ruby-lang.org/en/3.0/OpenStruct.html#class-OpenStruct-label-Caveats
4780
5032
 
4781
5033
  Enabled: pending
4782
5034
  Safe: false
@@ -4958,6 +5210,12 @@ Style/RedundantArrayConstructor:
4958
5210
  Enabled: pending
4959
5211
  VersionAdded: '1.52'
4960
5212
 
5213
+ Style/RedundantArrayFlatten:
5214
+ Description: 'Checks for redundant calls of `Array#flatten`.'
5215
+ Enabled: pending
5216
+ Safe: false
5217
+ VersionAdded: '1.76'
5218
+
4961
5219
  Style/RedundantAssignment:
4962
5220
  Description: 'Checks for redundant assignment before returning.'
4963
5221
  Enabled: true
@@ -4979,6 +5237,9 @@ Style/RedundantCondition:
4979
5237
  Description: 'Checks for unnecessary conditional expressions.'
4980
5238
  Enabled: true
4981
5239
  VersionAdded: '0.76'
5240
+ VersionChanged: '1.73'
5241
+ AllowedMethods:
5242
+ - nonzero?
4982
5243
 
4983
5244
  Style/RedundantConditional:
4984
5245
  Description: "Don't return true/false from a conditional."
@@ -4991,7 +5252,7 @@ Style/RedundantConstantBase:
4991
5252
  VersionAdded: '1.40'
4992
5253
 
4993
5254
  Style/RedundantCurrentDirectoryInPath:
4994
- Description: 'Checks for uses a redundant current directory in path.'
5255
+ Description: 'Checks for a redundant current directory in a path given to `require_relative`.'
4995
5256
  Enabled: pending
4996
5257
  VersionAdded: '1.53'
4997
5258
 
@@ -5017,7 +5278,8 @@ Style/RedundantFetchBlock:
5017
5278
  Description: >-
5018
5279
  Use `fetch(key, value)` instead of `fetch(key) { value }`
5019
5280
  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'
5281
+ References:
5282
+ - 'https://github.com/fastruby/fast-ruby#hashfetch-with-argument-vs-hashfetch--block-code'
5021
5283
  Enabled: true
5022
5284
  Safe: false
5023
5285
  # If enabled, this cop will autocorrect usages of
@@ -5043,6 +5305,13 @@ Style/RedundantFilterChain:
5043
5305
  VersionAdded: '1.52'
5044
5306
  VersionChanged: '1.57'
5045
5307
 
5308
+ Style/RedundantFormat:
5309
+ Description: 'Checks for usages of `Kernel#format` or `Kernel#sprintf` with only a single argument.'
5310
+ Enabled: pending
5311
+ SafeAutoCorrect: false
5312
+ VersionAdded: '1.72'
5313
+ VersionChanged: '1.72'
5314
+
5046
5315
  Style/RedundantFreeze:
5047
5316
  Description: "Checks usages of Object#freeze on immutable objects."
5048
5317
  Enabled: true
@@ -5241,11 +5510,19 @@ Style/SafeNavigation:
5241
5510
  # Maximum length of method chains for register an offense.
5242
5511
  MaxChainLength: 2
5243
5512
 
5513
+ Style/SafeNavigationChainLength:
5514
+ Description: 'Enforces safe navigation chains length to not exceed the configured maximum.'
5515
+ StyleGuide: '#safe-navigation'
5516
+ Enabled: pending
5517
+ VersionAdded: '1.68'
5518
+ Max: 2
5519
+
5244
5520
  Style/Sample:
5245
5521
  Description: >-
5246
5522
  Use `sample` instead of `shuffle.first`,
5247
5523
  `shuffle.last`, and `shuffle[Integer]`.
5248
- Reference: 'https://github.com/fastruby/fast-ruby#arrayshufflefirst-vs-arraysample-code'
5524
+ References:
5525
+ - 'https://github.com/fastruby/fast-ruby#arrayshufflefirst-vs-arraysample-code'
5249
5526
  Enabled: true
5250
5527
  VersionAdded: '0.30'
5251
5528
 
@@ -5562,14 +5839,17 @@ Style/TrailingCommaInArrayLiteral:
5562
5839
  StyleGuide: '#no-trailing-array-commas'
5563
5840
  Enabled: true
5564
5841
  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.
5842
+ # If `comma`, the cop requires a comma after the last item in an array, 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
+ # array literals.
5846
+ # If `diff_comma`, the cop requires a comma after the last item of all non-empty, multiline array
5847
+ # literals, but only when that last item immediately precedes a newline.
5569
5848
  EnforcedStyleForMultiline: no_comma
5570
5849
  SupportedStylesForMultiline:
5571
5850
  - comma
5572
5851
  - consistent_comma
5852
+ - diff_comma
5573
5853
  - no_comma
5574
5854
 
5575
5855
  Style/TrailingCommaInBlockArgs:
@@ -5581,14 +5861,17 @@ Style/TrailingCommaInBlockArgs:
5581
5861
  Style/TrailingCommaInHashLiteral:
5582
5862
  Description: 'Checks for trailing comma in hash literals.'
5583
5863
  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.
5864
+ # If `comma`, the cop requires a comma after the last item in a hash, but only when each item is
5865
+ # on its own line.
5866
+ # If `consistent_comma`, the cop requires a comma after the last item of all non-empty, multiline
5867
+ # hash literals.
5868
+ # If `diff_comma`, the cop requires a comma after the last item of all non-empty, multiline hash
5869
+ # literals, but only when that last item immediately precedes a newline.
5588
5870
  EnforcedStyleForMultiline: no_comma
5589
5871
  SupportedStylesForMultiline:
5590
5872
  - comma
5591
5873
  - consistent_comma
5874
+ - diff_comma
5592
5875
  - no_comma
5593
5876
  VersionAdded: '0.53'
5594
5877
 
@@ -5734,7 +6017,8 @@ Style/YAMLFileRead:
5734
6017
 
5735
6018
  Style/YodaCondition:
5736
6019
  Description: 'Forbid or enforce yoda conditions.'
5737
- Reference: 'https://en.wikipedia.org/wiki/Yoda_conditions'
6020
+ References:
6021
+ - 'https://en.wikipedia.org/wiki/Yoda_conditions'
5738
6022
  Enabled: true
5739
6023
  EnforcedStyle: forbid_for_all_comparison_operators
5740
6024
  SupportedStyles: