rubocop 1.42.0 → 1.64.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (498) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +1 -1
  3. data/README.md +7 -6
  4. data/assets/output.css.erb +159 -0
  5. data/assets/output.html.erb +1 -160
  6. data/config/default.yml +342 -64
  7. data/config/obsoletion.yml +5 -0
  8. data/lib/rubocop/cached_data.rb +11 -3
  9. data/lib/rubocop/cli/command/auto_generate_config.rb +27 -6
  10. data/lib/rubocop/cli/command/execute_runner.rb +7 -2
  11. data/lib/rubocop/cli/command/lsp.rb +19 -0
  12. data/lib/rubocop/cli/command/show_docs_url.rb +2 -2
  13. data/lib/rubocop/cli.rb +68 -10
  14. data/lib/rubocop/comment_config.rb +19 -0
  15. data/lib/rubocop/config.rb +43 -15
  16. data/lib/rubocop/config_finder.rb +14 -4
  17. data/lib/rubocop/config_loader.rb +20 -24
  18. data/lib/rubocop/config_obsoletion/parameter_rule.rb +9 -1
  19. data/lib/rubocop/config_obsoletion.rb +13 -10
  20. data/lib/rubocop/config_validator.rb +14 -7
  21. data/lib/rubocop/cop/autocorrect_logic.rb +37 -14
  22. data/lib/rubocop/cop/base.rb +97 -28
  23. data/lib/rubocop/cop/bundler/duplicated_gem.rb +1 -0
  24. data/lib/rubocop/cop/bundler/duplicated_group.rb +127 -0
  25. data/lib/rubocop/cop/bundler/gem_comment.rb +4 -4
  26. data/lib/rubocop/cop/bundler/gem_version.rb +5 -7
  27. data/lib/rubocop/cop/bundler/ordered_gems.rb +9 -1
  28. data/lib/rubocop/cop/commissioner.rb +8 -2
  29. data/lib/rubocop/cop/cop.rb +25 -5
  30. data/lib/rubocop/cop/corrector.rb +11 -3
  31. data/lib/rubocop/cop/correctors/alignment_corrector.rb +3 -3
  32. data/lib/rubocop/cop/correctors/each_to_for_corrector.rb +4 -8
  33. data/lib/rubocop/cop/correctors/for_to_each_corrector.rb +6 -14
  34. data/lib/rubocop/cop/correctors/lambda_literal_to_method_corrector.rb +7 -4
  35. data/lib/rubocop/cop/correctors/line_break_corrector.rb +1 -1
  36. data/lib/rubocop/cop/correctors/multiline_literal_brace_corrector.rb +2 -2
  37. data/lib/rubocop/cop/correctors/ordered_gem_corrector.rb +2 -7
  38. data/lib/rubocop/cop/correctors/parentheses_corrector.rb +1 -1
  39. data/lib/rubocop/cop/correctors/percent_literal_corrector.rb +2 -2
  40. data/lib/rubocop/cop/documentation.rb +16 -6
  41. data/lib/rubocop/cop/exclude_limit.rb +1 -1
  42. data/lib/rubocop/cop/force.rb +12 -0
  43. data/lib/rubocop/cop/gemspec/dependency_version.rb +6 -8
  44. data/lib/rubocop/cop/gemspec/deprecated_attribute_assignment.rb +3 -3
  45. data/lib/rubocop/cop/gemspec/development_dependencies.rb +107 -0
  46. data/lib/rubocop/cop/gemspec/ordered_dependencies.rb +9 -1
  47. data/lib/rubocop/cop/gemspec/required_ruby_version.rb +5 -1
  48. data/lib/rubocop/cop/generator/require_file_injector.rb +1 -1
  49. data/lib/rubocop/cop/internal_affairs/cop_description.rb +37 -13
  50. data/lib/rubocop/cop/internal_affairs/example_description.rb +46 -24
  51. data/lib/rubocop/cop/internal_affairs/example_heredoc_delimiter.rb +3 -3
  52. data/lib/rubocop/cop/internal_affairs/inherit_deprecated_cop_class.rb +1 -1
  53. data/lib/rubocop/cop/internal_affairs/location_expression.rb +37 -0
  54. data/lib/rubocop/cop/internal_affairs/location_line_equality_comparison.rb +3 -1
  55. data/lib/rubocop/cop/internal_affairs/method_name_end_with.rb +8 -6
  56. data/lib/rubocop/cop/internal_affairs/method_name_equal.rb +19 -20
  57. data/lib/rubocop/cop/internal_affairs/node_first_or_last_argument.rb +53 -0
  58. data/lib/rubocop/cop/internal_affairs/node_matcher_directive.rb +128 -34
  59. data/lib/rubocop/cop/internal_affairs/node_type_predicate.rb +1 -1
  60. data/lib/rubocop/cop/internal_affairs/processed_source_buffer_name.rb +42 -0
  61. data/lib/rubocop/cop/internal_affairs/redundant_expect_offense_arguments.rb +34 -0
  62. data/lib/rubocop/cop/internal_affairs/redundant_let_rubocop_config_new.rb +11 -3
  63. data/lib/rubocop/cop/internal_affairs/redundant_location_argument.rb +1 -1
  64. data/lib/rubocop/cop/internal_affairs/redundant_message_argument.rb +1 -1
  65. data/lib/rubocop/cop/internal_affairs/redundant_method_dispatch_node.rb +11 -2
  66. data/lib/rubocop/cop/internal_affairs/redundant_source_range.rb +66 -0
  67. data/lib/rubocop/cop/internal_affairs/useless_message_assertion.rb +2 -0
  68. data/lib/rubocop/cop/internal_affairs.rb +5 -0
  69. data/lib/rubocop/cop/layout/argument_alignment.rb +1 -1
  70. data/lib/rubocop/cop/layout/array_alignment.rb +1 -1
  71. data/lib/rubocop/cop/layout/block_end_newline.rb +7 -15
  72. data/lib/rubocop/cop/layout/class_structure.rb +15 -19
  73. data/lib/rubocop/cop/layout/closing_heredoc_indentation.rb +2 -3
  74. data/lib/rubocop/cop/layout/closing_parenthesis_indentation.rb +2 -6
  75. data/lib/rubocop/cop/layout/comment_indentation.rb +1 -1
  76. data/lib/rubocop/cop/layout/dot_position.rb +1 -5
  77. data/lib/rubocop/cop/layout/empty_comment.rb +6 -4
  78. data/lib/rubocop/cop/layout/empty_line_after_guard_clause.rb +42 -9
  79. data/lib/rubocop/cop/layout/empty_line_after_magic_comment.rb +14 -7
  80. data/lib/rubocop/cop/layout/empty_line_between_defs.rb +28 -5
  81. data/lib/rubocop/cop/layout/empty_lines.rb +1 -1
  82. data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +2 -0
  83. data/lib/rubocop/cop/layout/empty_lines_around_exception_handling_keywords.rb +2 -0
  84. data/lib/rubocop/cop/layout/end_alignment.rb +23 -3
  85. data/lib/rubocop/cop/layout/extra_spacing.rb +3 -4
  86. data/lib/rubocop/cop/layout/first_argument_indentation.rb +8 -3
  87. data/lib/rubocop/cop/layout/first_array_element_indentation.rb +24 -7
  88. data/lib/rubocop/cop/layout/first_array_element_line_break.rb +25 -34
  89. data/lib/rubocop/cop/layout/first_hash_element_line_break.rb +7 -19
  90. data/lib/rubocop/cop/layout/first_method_argument_line_break.rb +42 -52
  91. data/lib/rubocop/cop/layout/first_method_parameter_line_break.rb +38 -55
  92. data/lib/rubocop/cop/layout/first_parameter_indentation.rb +1 -1
  93. data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +12 -6
  94. data/lib/rubocop/cop/layout/heredoc_indentation.rb +12 -12
  95. data/lib/rubocop/cop/layout/indentation_style.rb +1 -1
  96. data/lib/rubocop/cop/layout/indentation_width.rb +3 -3
  97. data/lib/rubocop/cop/layout/initial_indentation.rb +1 -1
  98. data/lib/rubocop/cop/layout/leading_comment_space.rb +2 -2
  99. data/lib/rubocop/cop/layout/line_continuation_leading_space.rb +18 -12
  100. data/lib/rubocop/cop/layout/line_continuation_spacing.rb +12 -8
  101. data/lib/rubocop/cop/layout/line_end_string_concatenation_indentation.rb +2 -0
  102. data/lib/rubocop/cop/layout/multiline_array_line_breaks.rb +8 -27
  103. data/lib/rubocop/cop/layout/multiline_hash_key_line_breaks.rb +7 -26
  104. data/lib/rubocop/cop/layout/multiline_method_argument_line_breaks.rb +4 -21
  105. data/lib/rubocop/cop/layout/multiline_method_call_indentation.rb +18 -3
  106. data/lib/rubocop/cop/layout/multiline_method_parameter_line_breaks.rb +6 -30
  107. data/lib/rubocop/cop/layout/redundant_line_break.rb +33 -11
  108. data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +6 -6
  109. data/lib/rubocop/cop/layout/single_line_block_chain.rb +5 -0
  110. data/lib/rubocop/cop/layout/space_after_comma.rb +9 -1
  111. data/lib/rubocop/cop/layout/space_after_not.rb +1 -1
  112. data/lib/rubocop/cop/layout/space_around_keyword.rb +1 -1
  113. data/lib/rubocop/cop/layout/space_around_method_call_operator.rb +2 -2
  114. data/lib/rubocop/cop/layout/space_around_operators.rb +53 -21
  115. data/lib/rubocop/cop/layout/space_before_block_braces.rb +19 -10
  116. data/lib/rubocop/cop/layout/space_before_first_arg.rb +1 -1
  117. data/lib/rubocop/cop/layout/space_in_lambda_literal.rb +2 -2
  118. data/lib/rubocop/cop/layout/space_inside_array_literal_brackets.rb +11 -13
  119. data/lib/rubocop/cop/layout/space_inside_block_braces.rb +3 -1
  120. data/lib/rubocop/cop/layout/space_inside_hash_literal_braces.rb +1 -1
  121. data/lib/rubocop/cop/layout/space_inside_parens.rb +3 -3
  122. data/lib/rubocop/cop/layout/space_inside_percent_literal_delimiters.rb +1 -1
  123. data/lib/rubocop/cop/layout/space_inside_range_literal.rb +1 -1
  124. data/lib/rubocop/cop/layout/space_inside_reference_brackets.rb +4 -4
  125. data/lib/rubocop/cop/layout/space_inside_string_interpolation.rb +6 -6
  126. data/lib/rubocop/cop/layout/trailing_empty_lines.rb +5 -0
  127. data/lib/rubocop/cop/layout/trailing_whitespace.rb +1 -1
  128. data/lib/rubocop/cop/lint/ambiguous_block_association.rb +13 -1
  129. data/lib/rubocop/cop/lint/ambiguous_operator.rb +4 -0
  130. data/lib/rubocop/cop/lint/assignment_in_condition.rb +6 -6
  131. data/lib/rubocop/cop/lint/binary_operator_with_identical_operands.rb +2 -2
  132. data/lib/rubocop/cop/lint/constant_overwritten_in_rescue.rb +1 -1
  133. data/lib/rubocop/cop/lint/constant_resolution.rb +1 -1
  134. data/lib/rubocop/cop/lint/debugger.rb +49 -26
  135. data/lib/rubocop/cop/lint/deprecated_class_methods.rb +62 -112
  136. data/lib/rubocop/cop/lint/deprecated_open_ssl_constant.rb +1 -1
  137. data/lib/rubocop/cop/lint/duplicate_hash_key.rb +2 -1
  138. data/lib/rubocop/cop/lint/duplicate_match_pattern.rb +122 -0
  139. data/lib/rubocop/cop/lint/duplicate_methods.rb +3 -3
  140. data/lib/rubocop/cop/lint/duplicate_regexp_character_class_element.rb +47 -22
  141. data/lib/rubocop/cop/lint/else_layout.rb +3 -7
  142. data/lib/rubocop/cop/lint/empty_block.rb +2 -2
  143. data/lib/rubocop/cop/lint/empty_conditional_body.rb +6 -4
  144. data/lib/rubocop/cop/lint/empty_interpolation.rb +1 -1
  145. data/lib/rubocop/cop/lint/erb_new_arguments.rb +27 -21
  146. data/lib/rubocop/cop/lint/float_comparison.rb +10 -0
  147. data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +14 -7
  148. data/lib/rubocop/cop/lint/hash_compare_by_identity.rb +2 -1
  149. data/lib/rubocop/cop/lint/heredoc_method_call_position.rb +16 -18
  150. data/lib/rubocop/cop/lint/identity_comparison.rb +0 -1
  151. data/lib/rubocop/cop/lint/implicit_string_concatenation.rb +1 -1
  152. data/lib/rubocop/cop/lint/incompatible_io_select_with_fiber_scheduler.rb +5 -3
  153. data/lib/rubocop/cop/lint/ineffective_access_modifier.rb +1 -1
  154. data/lib/rubocop/cop/lint/inherit_exception.rb +9 -0
  155. data/lib/rubocop/cop/lint/it_without_arguments_in_block.rb +56 -0
  156. data/lib/rubocop/cop/lint/lambda_without_literal_block.rb +1 -1
  157. data/lib/rubocop/cop/lint/literal_assignment_in_condition.rb +85 -0
  158. data/lib/rubocop/cop/lint/literal_in_interpolation.rb +47 -5
  159. data/lib/rubocop/cop/lint/missing_super.rb +63 -5
  160. data/lib/rubocop/cop/lint/mixed_case_range.rb +116 -0
  161. data/lib/rubocop/cop/lint/mixed_regexp_capture_types.rb +1 -0
  162. data/lib/rubocop/cop/lint/nested_method_definition.rb +4 -9
  163. data/lib/rubocop/cop/lint/next_without_accumulator.rb +6 -21
  164. data/lib/rubocop/cop/lint/non_atomic_file_operation.rb +10 -7
  165. data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +3 -5
  166. data/lib/rubocop/cop/lint/number_conversion.rb +14 -4
  167. data/lib/rubocop/cop/lint/numbered_parameter_assignment.rb +2 -2
  168. data/lib/rubocop/cop/lint/or_assignment_to_constant.rb +2 -0
  169. data/lib/rubocop/cop/lint/ordered_magic_comments.rb +0 -1
  170. data/lib/rubocop/cop/lint/out_of_range_regexp_ref.rb +8 -12
  171. data/lib/rubocop/cop/lint/percent_string_array.rb +1 -1
  172. data/lib/rubocop/cop/lint/percent_symbol_array.rb +1 -1
  173. data/lib/rubocop/cop/lint/redundant_cop_disable_directive.rb +11 -5
  174. data/lib/rubocop/cop/lint/redundant_cop_enable_directive.rb +5 -5
  175. data/lib/rubocop/cop/lint/redundant_regexp_quantifiers.rb +130 -0
  176. data/lib/rubocop/cop/lint/redundant_require_statement.rb +21 -2
  177. data/lib/rubocop/cop/lint/redundant_safe_navigation.rb +72 -8
  178. data/lib/rubocop/cop/lint/redundant_splat_expansion.rb +1 -1
  179. data/lib/rubocop/cop/lint/redundant_string_coercion.rb +35 -15
  180. data/lib/rubocop/cop/lint/redundant_with_index.rb +7 -3
  181. data/lib/rubocop/cop/lint/redundant_with_object.rb +3 -3
  182. data/lib/rubocop/cop/lint/refinement_import_methods.rb +2 -1
  183. data/lib/rubocop/cop/lint/rescue_type.rb +2 -4
  184. data/lib/rubocop/cop/lint/safe_navigation_chain.rb +14 -8
  185. data/lib/rubocop/cop/lint/safe_navigation_consistency.rb +1 -1
  186. data/lib/rubocop/cop/lint/script_permission.rb +3 -3
  187. data/lib/rubocop/cop/lint/self_assignment.rb +38 -0
  188. data/lib/rubocop/cop/lint/send_with_mixin_argument.rb +1 -2
  189. data/lib/rubocop/cop/lint/shadowed_argument.rb +1 -0
  190. data/lib/rubocop/cop/lint/shadowed_exception.rb +6 -12
  191. data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +7 -1
  192. data/lib/rubocop/cop/lint/struct_new_override.rb +12 -12
  193. data/lib/rubocop/cop/lint/suppressed_exception.rb +2 -2
  194. data/lib/rubocop/cop/lint/symbol_conversion.rb +8 -3
  195. data/lib/rubocop/cop/lint/syntax.rb +10 -3
  196. data/lib/rubocop/cop/lint/to_enum_arguments.rb +23 -6
  197. data/lib/rubocop/cop/lint/top_level_return_with_argument.rb +23 -9
  198. data/lib/rubocop/cop/lint/trailing_comma_in_attribute_declaration.rb +1 -1
  199. data/lib/rubocop/cop/lint/unmodified_reduce_accumulator.rb +2 -2
  200. data/lib/rubocop/cop/lint/unreachable_code.rb +4 -2
  201. data/lib/rubocop/cop/lint/unreachable_loop.rb +11 -5
  202. data/lib/rubocop/cop/lint/useless_access_modifier.rb +12 -9
  203. data/lib/rubocop/cop/lint/useless_assignment.rb +94 -10
  204. data/lib/rubocop/cop/lint/useless_method_definition.rb +12 -4
  205. data/lib/rubocop/cop/lint/useless_rescue.rb +89 -0
  206. data/lib/rubocop/cop/lint/useless_ruby2_keywords.rb +9 -1
  207. data/lib/rubocop/cop/lint/useless_times.rb +3 -3
  208. data/lib/rubocop/cop/lint/void.rb +119 -20
  209. data/lib/rubocop/cop/metrics/abc_size.rb +3 -3
  210. data/lib/rubocop/cop/metrics/block_length.rb +2 -2
  211. data/lib/rubocop/cop/metrics/block_nesting.rb +2 -2
  212. data/lib/rubocop/cop/metrics/class_length.rb +8 -2
  213. data/lib/rubocop/cop/metrics/collection_literal_length.rb +76 -0
  214. data/lib/rubocop/cop/metrics/cyclomatic_complexity.rb +1 -1
  215. data/lib/rubocop/cop/metrics/method_length.rb +1 -1
  216. data/lib/rubocop/cop/metrics/parameter_lists.rb +27 -0
  217. data/lib/rubocop/cop/metrics/utils/abc_size_calculator.rb +3 -7
  218. data/lib/rubocop/cop/metrics/utils/code_length_calculator.rb +38 -10
  219. data/lib/rubocop/cop/migration/department_name.rb +3 -3
  220. data/lib/rubocop/cop/mixin/alignment.rb +1 -1
  221. data/lib/rubocop/cop/mixin/allowed_methods.rb +3 -1
  222. data/lib/rubocop/cop/mixin/allowed_receivers.rb +34 -0
  223. data/lib/rubocop/cop/mixin/annotation_comment.rb +1 -1
  224. data/lib/rubocop/cop/mixin/check_line_breakable.rb +1 -1
  225. data/lib/rubocop/cop/mixin/code_length.rb +12 -1
  226. data/lib/rubocop/cop/mixin/comments_help.rb +21 -11
  227. data/lib/rubocop/cop/mixin/configurable_formatting.rb +1 -0
  228. data/lib/rubocop/cop/mixin/def_node.rb +1 -1
  229. data/lib/rubocop/cop/mixin/documentation_comment.rb +1 -1
  230. data/lib/rubocop/cop/mixin/end_keyword_alignment.rb +1 -1
  231. data/lib/rubocop/cop/mixin/hash_alignment_styles.rb +1 -1
  232. data/lib/rubocop/cop/mixin/hash_shorthand_syntax.rb +78 -29
  233. data/lib/rubocop/cop/mixin/hash_transform_method.rb +3 -3
  234. data/lib/rubocop/cop/mixin/heredoc.rb +6 -2
  235. data/lib/rubocop/cop/mixin/line_length_help.rb +3 -1
  236. data/lib/rubocop/cop/mixin/method_complexity.rb +15 -6
  237. data/lib/rubocop/cop/mixin/min_branches_count.rb +40 -0
  238. data/lib/rubocop/cop/mixin/multiline_element_line_breaks.rb +0 -3
  239. data/lib/rubocop/cop/mixin/multiline_expression_indentation.rb +4 -3
  240. data/lib/rubocop/cop/mixin/ordered_gem_node.rb +1 -1
  241. data/lib/rubocop/cop/mixin/percent_literal.rb +1 -1
  242. data/lib/rubocop/cop/mixin/preceding_following_alignment.rb +6 -8
  243. data/lib/rubocop/cop/mixin/range_help.rb +1 -6
  244. data/lib/rubocop/cop/mixin/safe_assignment.rb +1 -1
  245. data/lib/rubocop/cop/mixin/space_after_punctuation.rb +1 -1
  246. data/lib/rubocop/cop/mixin/space_before_punctuation.rb +1 -1
  247. data/lib/rubocop/cop/mixin/statement_modifier.rb +4 -3
  248. data/lib/rubocop/cop/mixin/string_help.rb +4 -2
  249. data/lib/rubocop/cop/mixin/surrounding_space.rb +3 -3
  250. data/lib/rubocop/cop/mixin/trailing_comma.rb +3 -3
  251. data/lib/rubocop/cop/naming/ascii_identifiers.rb +1 -1
  252. data/lib/rubocop/cop/naming/block_forwarding.rb +38 -7
  253. data/lib/rubocop/cop/naming/class_and_module_camel_case.rb +1 -1
  254. data/lib/rubocop/cop/naming/constant_name.rb +2 -3
  255. data/lib/rubocop/cop/naming/file_name.rb +3 -3
  256. data/lib/rubocop/cop/naming/heredoc_delimiter_case.rb +1 -1
  257. data/lib/rubocop/cop/naming/heredoc_delimiter_naming.rb +3 -1
  258. data/lib/rubocop/cop/naming/inclusive_language.rb +24 -6
  259. data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +26 -11
  260. data/lib/rubocop/cop/naming/method_name.rb +3 -3
  261. data/lib/rubocop/cop/naming/predicate_name.rb +3 -3
  262. data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +12 -4
  263. data/lib/rubocop/cop/naming/variable_name.rb +6 -1
  264. data/lib/rubocop/cop/registry.rb +16 -9
  265. data/lib/rubocop/cop/security/compound_hash.rb +2 -2
  266. data/lib/rubocop/cop/security/open.rb +2 -2
  267. data/lib/rubocop/cop/style/access_modifier_declarations.rb +78 -13
  268. data/lib/rubocop/cop/style/accessor_grouping.rb +44 -18
  269. data/lib/rubocop/cop/style/alias.rb +10 -8
  270. data/lib/rubocop/cop/style/arguments_forwarding.rb +414 -62
  271. data/lib/rubocop/cop/style/array_first_last.rb +64 -0
  272. data/lib/rubocop/cop/style/array_intersect.rb +14 -6
  273. data/lib/rubocop/cop/style/ascii_comments.rb +1 -1
  274. data/lib/rubocop/cop/style/attr.rb +11 -1
  275. data/lib/rubocop/cop/style/auto_resource_cleanup.rb +21 -14
  276. data/lib/rubocop/cop/style/begin_block.rb +1 -2
  277. data/lib/rubocop/cop/style/bisected_attr_accessor.rb +3 -3
  278. data/lib/rubocop/cop/style/block_comments.rb +2 -2
  279. data/lib/rubocop/cop/style/block_delimiters.rb +22 -6
  280. data/lib/rubocop/cop/style/case_like_if.rb +25 -8
  281. data/lib/rubocop/cop/style/class_and_module_children.rb +5 -12
  282. data/lib/rubocop/cop/style/class_check.rb +1 -0
  283. data/lib/rubocop/cop/style/class_equality_comparison.rb +58 -40
  284. data/lib/rubocop/cop/style/class_vars.rb +3 -3
  285. data/lib/rubocop/cop/style/collection_compact.rb +37 -14
  286. data/lib/rubocop/cop/style/collection_methods.rb +2 -0
  287. data/lib/rubocop/cop/style/colon_method_call.rb +2 -2
  288. data/lib/rubocop/cop/style/combinable_loops.rb +36 -8
  289. data/lib/rubocop/cop/style/command_literal.rb +1 -1
  290. data/lib/rubocop/cop/style/comment_annotation.rb +1 -1
  291. data/lib/rubocop/cop/style/commented_keyword.rb +7 -4
  292. data/lib/rubocop/cop/style/comparable_clamp.rb +125 -0
  293. data/lib/rubocop/cop/style/concat_array_literals.rb +12 -3
  294. data/lib/rubocop/cop/style/conditional_assignment.rb +15 -20
  295. data/lib/rubocop/cop/style/copyright.rb +37 -24
  296. data/lib/rubocop/cop/style/data_inheritance.rb +75 -0
  297. data/lib/rubocop/cop/style/date_time.rb +5 -4
  298. data/lib/rubocop/cop/style/dir.rb +1 -1
  299. data/lib/rubocop/cop/style/dir_empty.rb +54 -0
  300. data/lib/rubocop/cop/style/disable_cops_within_source_code_directive.rb +2 -2
  301. data/lib/rubocop/cop/style/document_dynamic_eval_definition.rb +3 -3
  302. data/lib/rubocop/cop/style/documentation.rb +36 -30
  303. data/lib/rubocop/cop/style/documentation_method.rb +30 -4
  304. data/lib/rubocop/cop/style/double_negation.rb +2 -2
  305. data/lib/rubocop/cop/style/each_for_simple_loop.rb +7 -7
  306. data/lib/rubocop/cop/style/each_with_object.rb +3 -3
  307. data/lib/rubocop/cop/style/empty_block_parameter.rb +1 -1
  308. data/lib/rubocop/cop/style/empty_case_condition.rb +6 -1
  309. data/lib/rubocop/cop/style/empty_lambda_parameter.rb +1 -1
  310. data/lib/rubocop/cop/style/empty_literal.rb +1 -1
  311. data/lib/rubocop/cop/style/eval_with_location.rb +14 -23
  312. data/lib/rubocop/cop/style/exact_regexp_match.rb +70 -0
  313. data/lib/rubocop/cop/style/explicit_block_argument.rb +3 -3
  314. data/lib/rubocop/cop/style/file_empty.rb +71 -0
  315. data/lib/rubocop/cop/style/file_read.rb +3 -3
  316. data/lib/rubocop/cop/style/file_write.rb +1 -1
  317. data/lib/rubocop/cop/style/for.rb +3 -1
  318. data/lib/rubocop/cop/style/format_string.rb +33 -12
  319. data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +4 -2
  320. data/lib/rubocop/cop/style/guard_clause.rb +29 -1
  321. data/lib/rubocop/cop/style/hash_conversion.rb +10 -0
  322. data/lib/rubocop/cop/style/hash_each_methods.rb +106 -21
  323. data/lib/rubocop/cop/style/hash_except.rb +25 -13
  324. data/lib/rubocop/cop/style/hash_like_case.rb +3 -9
  325. data/lib/rubocop/cop/style/hash_syntax.rb +29 -3
  326. data/lib/rubocop/cop/style/hash_transform_keys.rb +2 -2
  327. data/lib/rubocop/cop/style/hash_transform_values.rb +2 -2
  328. data/lib/rubocop/cop/style/identical_conditional_branches.rb +34 -5
  329. data/lib/rubocop/cop/style/if_inside_else.rb +6 -0
  330. data/lib/rubocop/cop/style/if_unless_modifier.rb +111 -15
  331. data/lib/rubocop/cop/style/if_with_boolean_literal_branches.rb +7 -3
  332. data/lib/rubocop/cop/style/if_with_semicolon.rb +2 -2
  333. data/lib/rubocop/cop/style/infinite_loop.rb +2 -5
  334. data/lib/rubocop/cop/style/inverse_methods.rb +14 -13
  335. data/lib/rubocop/cop/style/invertible_unless_condition.rb +160 -0
  336. data/lib/rubocop/cop/style/lambda.rb +3 -3
  337. data/lib/rubocop/cop/style/lambda_call.rb +5 -0
  338. data/lib/rubocop/cop/style/map_compact_with_conditional_block.rb +8 -10
  339. data/lib/rubocop/cop/style/map_into_array.rb +175 -0
  340. data/lib/rubocop/cop/style/map_to_hash.rb +20 -7
  341. data/lib/rubocop/cop/style/map_to_set.rb +5 -2
  342. data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +48 -28
  343. data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +46 -41
  344. data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +22 -0
  345. data/lib/rubocop/cop/style/method_def_parentheses.rb +1 -1
  346. data/lib/rubocop/cop/style/min_max.rb +3 -3
  347. data/lib/rubocop/cop/style/min_max_comparison.rb +11 -1
  348. data/lib/rubocop/cop/style/missing_else.rb +13 -1
  349. data/lib/rubocop/cop/style/missing_respond_to_missing.rb +2 -2
  350. data/lib/rubocop/cop/style/mixin_grouping.rb +5 -5
  351. data/lib/rubocop/cop/style/multiline_block_chain.rb +1 -1
  352. data/lib/rubocop/cop/style/multiline_if_modifier.rb +0 -4
  353. data/lib/rubocop/cop/style/multiline_memoization.rb +2 -2
  354. data/lib/rubocop/cop/style/multiline_method_signature.rb +17 -5
  355. data/lib/rubocop/cop/style/multiline_ternary_operator.rb +21 -4
  356. data/lib/rubocop/cop/style/multiple_comparison.rb +14 -0
  357. data/lib/rubocop/cop/style/negated_if_else_condition.rb +13 -12
  358. data/lib/rubocop/cop/style/nested_ternary_operator.rb +3 -11
  359. data/lib/rubocop/cop/style/next.rb +1 -1
  360. data/lib/rubocop/cop/style/nil_comparison.rb +2 -0
  361. data/lib/rubocop/cop/style/nil_lambda.rb +2 -2
  362. data/lib/rubocop/cop/style/numbered_parameters_limit.rb +11 -3
  363. data/lib/rubocop/cop/style/numeric_literal_prefix.rb +1 -1
  364. data/lib/rubocop/cop/style/numeric_literals.rb +1 -1
  365. data/lib/rubocop/cop/style/numeric_predicate.rb +10 -2
  366. data/lib/rubocop/cop/style/object_then.rb +5 -3
  367. data/lib/rubocop/cop/style/one_line_conditional.rb +4 -7
  368. data/lib/rubocop/cop/style/open_struct_use.rb +1 -1
  369. data/lib/rubocop/cop/style/operator_method_call.rb +24 -4
  370. data/lib/rubocop/cop/style/parallel_assignment.rb +32 -24
  371. data/lib/rubocop/cop/style/parentheses_around_condition.rb +8 -0
  372. data/lib/rubocop/cop/style/percent_literal_delimiters.rb +2 -3
  373. data/lib/rubocop/cop/style/percent_q_literals.rb +1 -1
  374. data/lib/rubocop/cop/style/preferred_hash_methods.rb +1 -1
  375. data/lib/rubocop/cop/style/raise_args.rb +4 -1
  376. data/lib/rubocop/cop/style/redundant_argument.rb +33 -4
  377. data/lib/rubocop/cop/style/redundant_array_constructor.rb +77 -0
  378. data/lib/rubocop/cop/style/redundant_assignment.rb +10 -2
  379. data/lib/rubocop/cop/style/redundant_begin.rb +10 -2
  380. data/lib/rubocop/cop/style/redundant_condition.rb +18 -3
  381. data/lib/rubocop/cop/style/redundant_conditional.rb +2 -14
  382. data/lib/rubocop/cop/style/redundant_current_directory_in_path.rb +39 -0
  383. data/lib/rubocop/cop/style/redundant_double_splat_hash_braces.rb +103 -9
  384. data/lib/rubocop/cop/style/redundant_each.rb +7 -4
  385. data/lib/rubocop/cop/style/redundant_exception.rb +32 -12
  386. data/lib/rubocop/cop/style/redundant_fetch_block.rb +9 -7
  387. data/lib/rubocop/cop/style/redundant_filter_chain.rb +118 -0
  388. data/lib/rubocop/cop/style/redundant_heredoc_delimiter_quotes.rb +58 -0
  389. data/lib/rubocop/cop/style/redundant_interpolation.rb +2 -2
  390. data/lib/rubocop/cop/style/redundant_line_continuation.rb +200 -0
  391. data/lib/rubocop/cop/style/redundant_parentheses.rb +73 -24
  392. data/lib/rubocop/cop/style/redundant_percent_q.rb +2 -2
  393. data/lib/rubocop/cop/style/redundant_regexp_argument.rb +100 -0
  394. data/lib/rubocop/cop/style/redundant_regexp_character_class.rb +7 -8
  395. data/lib/rubocop/cop/style/redundant_regexp_constructor.rb +46 -0
  396. data/lib/rubocop/cop/style/redundant_regexp_escape.rb +13 -4
  397. data/lib/rubocop/cop/style/redundant_return.rb +14 -3
  398. data/lib/rubocop/cop/style/redundant_self.rb +17 -2
  399. data/lib/rubocop/cop/style/redundant_self_assignment_branch.rb +8 -1
  400. data/lib/rubocop/cop/style/redundant_sort.rb +13 -12
  401. data/lib/rubocop/cop/style/redundant_sort_by.rb +2 -2
  402. data/lib/rubocop/cop/style/redundant_string_escape.rb +6 -5
  403. data/lib/rubocop/cop/style/regexp_literal.rb +11 -2
  404. data/lib/rubocop/cop/style/require_order.rb +12 -15
  405. data/lib/rubocop/cop/style/rescue_modifier.rb +1 -3
  406. data/lib/rubocop/cop/style/rescue_standard_error.rb +2 -2
  407. data/lib/rubocop/cop/style/return_nil.rb +6 -2
  408. data/lib/rubocop/cop/style/return_nil_in_predicate_method_definition.rb +95 -0
  409. data/lib/rubocop/cop/style/safe_navigation.rb +2 -2
  410. data/lib/rubocop/cop/style/sample.rb +3 -4
  411. data/lib/rubocop/cop/style/select_by_regexp.rb +22 -11
  412. data/lib/rubocop/cop/style/self_assignment.rb +3 -3
  413. data/lib/rubocop/cop/style/semicolon.rb +43 -5
  414. data/lib/rubocop/cop/style/send.rb +4 -4
  415. data/lib/rubocop/cop/style/send_with_literal_method_name.rb +90 -0
  416. data/lib/rubocop/cop/style/signal_exception.rb +1 -1
  417. data/lib/rubocop/cop/style/single_argument_dig.rb +7 -3
  418. data/lib/rubocop/cop/style/single_line_do_end_block.rb +67 -0
  419. data/lib/rubocop/cop/style/single_line_methods.rb +1 -1
  420. data/lib/rubocop/cop/style/slicing_with_range.rb +77 -11
  421. data/lib/rubocop/cop/style/sole_nested_conditional.rb +9 -5
  422. data/lib/rubocop/cop/style/special_global_vars.rb +4 -6
  423. data/lib/rubocop/cop/style/stderr_puts.rb +1 -1
  424. data/lib/rubocop/cop/style/string_chars.rb +1 -0
  425. data/lib/rubocop/cop/style/string_hash_keys.rb +4 -1
  426. data/lib/rubocop/cop/style/string_literals_in_interpolation.rb +30 -5
  427. data/lib/rubocop/cop/style/strip.rb +7 -4
  428. data/lib/rubocop/cop/style/struct_inheritance.rb +1 -1
  429. data/lib/rubocop/cop/style/super_arguments.rb +156 -0
  430. data/lib/rubocop/cop/style/super_with_args_parentheses.rb +35 -0
  431. data/lib/rubocop/cop/style/symbol_array.rb +35 -15
  432. data/lib/rubocop/cop/style/symbol_proc.rb +68 -5
  433. data/lib/rubocop/cop/style/top_level_method_definition.rb +1 -1
  434. data/lib/rubocop/cop/style/trailing_body_on_class.rb +1 -0
  435. data/lib/rubocop/cop/style/trailing_underscore_variable.rb +1 -1
  436. data/lib/rubocop/cop/style/trivial_accessors.rb +1 -1
  437. data/lib/rubocop/cop/style/unless_logical_operators.rb +1 -0
  438. data/lib/rubocop/cop/style/unpack_first.rb +11 -14
  439. data/lib/rubocop/cop/style/word_array.rb +18 -6
  440. data/lib/rubocop/cop/style/yaml_file_read.rb +66 -0
  441. data/lib/rubocop/cop/style/yoda_condition.rb +17 -8
  442. data/lib/rubocop/cop/style/yoda_expression.rb +26 -9
  443. data/lib/rubocop/cop/style/zero_length_predicate.rb +9 -5
  444. data/lib/rubocop/cop/team.rb +36 -23
  445. data/lib/rubocop/cop/util.rb +14 -5
  446. data/lib/rubocop/cop/utils/regexp_ranges.rb +113 -0
  447. data/lib/rubocop/cop/variable_force/assignment.rb +45 -4
  448. data/lib/rubocop/cop/variable_force/scope.rb +3 -3
  449. data/lib/rubocop/cop/variable_force/variable.rb +5 -3
  450. data/lib/rubocop/cop/variable_force/variable_table.rb +5 -3
  451. data/lib/rubocop/cop/variable_force.rb +2 -1
  452. data/lib/rubocop/cops_documentation_generator.rb +26 -7
  453. data/lib/rubocop/directive_comment.rb +13 -11
  454. data/lib/rubocop/ext/comment.rb +18 -0
  455. data/lib/rubocop/ext/regexp_node.rb +10 -5
  456. data/lib/rubocop/ext/regexp_parser.rb +5 -2
  457. data/lib/rubocop/file_finder.rb +4 -7
  458. data/lib/rubocop/formatter/clang_style_formatter.rb +3 -7
  459. data/lib/rubocop/formatter/disabled_config_formatter.rb +23 -8
  460. data/lib/rubocop/formatter/formatter_set.rb +7 -1
  461. data/lib/rubocop/formatter/html_formatter.rb +35 -14
  462. data/lib/rubocop/formatter/json_formatter.rb +0 -1
  463. data/lib/rubocop/formatter/junit_formatter.rb +4 -1
  464. data/lib/rubocop/formatter/offense_count_formatter.rb +12 -2
  465. data/lib/rubocop/formatter/simple_text_formatter.rb +1 -1
  466. data/lib/rubocop/formatter/tap_formatter.rb +3 -7
  467. data/lib/rubocop/formatter.rb +1 -2
  468. data/lib/rubocop/lockfile.rb +56 -7
  469. data/lib/rubocop/lsp/logger.rb +22 -0
  470. data/lib/rubocop/lsp/routes.rb +243 -0
  471. data/lib/rubocop/lsp/runtime.rb +99 -0
  472. data/lib/rubocop/lsp/server.rb +73 -0
  473. data/lib/rubocop/lsp/severity.rb +27 -0
  474. data/lib/rubocop/lsp.rb +36 -0
  475. data/lib/rubocop/magic_comment.rb +13 -11
  476. data/lib/rubocop/options.rb +49 -12
  477. data/lib/rubocop/path_util.rb +17 -8
  478. data/lib/rubocop/rake_task.rb +1 -1
  479. data/lib/rubocop/result_cache.rb +6 -3
  480. data/lib/rubocop/rspec/cop_helper.rb +9 -3
  481. data/lib/rubocop/rspec/expect_offense.rb +18 -8
  482. data/lib/rubocop/rspec/shared_contexts.rb +59 -19
  483. data/lib/rubocop/rspec/support.rb +3 -0
  484. data/lib/rubocop/runner.rb +59 -10
  485. data/lib/rubocop/server/cache.rb +11 -4
  486. data/lib/rubocop/server/cli.rb +37 -18
  487. data/lib/rubocop/server/client_command/exec.rb +4 -4
  488. data/lib/rubocop/server/client_command/start.rb +6 -1
  489. data/lib/rubocop/server/core.rb +24 -9
  490. data/lib/rubocop/server/helper.rb +1 -1
  491. data/lib/rubocop/server/server_command/exec.rb +1 -2
  492. data/lib/rubocop/string_interpreter.rb +3 -3
  493. data/lib/rubocop/target_finder.rb +91 -81
  494. data/lib/rubocop/target_ruby.rb +85 -78
  495. data/lib/rubocop/version.rb +27 -8
  496. data/lib/rubocop.rb +35 -0
  497. metadata +76 -35
  498. /data/lib/rubocop/formatter/{git_hub_actions_formatter.rb → github_actions_formatter.rb} +0 -0
data/config/default.yml CHANGED
@@ -30,6 +30,7 @@ AllCops:
30
30
  - '**/*.rbx'
31
31
  - '**/*.ru'
32
32
  - '**/*.ruby'
33
+ - '**/*.schema'
33
34
  - '**/*.spec'
34
35
  - '**/*.thor'
35
36
  - '**/*.watchr'
@@ -55,6 +56,7 @@ AllCops:
55
56
  - '**/Puppetfile'
56
57
  - '**/Rakefile'
57
58
  - '**/rakefile'
59
+ - '**/Schemafile'
58
60
  - '**/Snapfile'
59
61
  - '**/Steepfile'
60
62
  - '**/Thorfile'
@@ -140,8 +142,14 @@ AllCops:
140
142
  # or gems.locked file. (Although the Ruby version is specified in the Gemfile
141
143
  # or gems.rb file, RuboCop reads the final value from the lock file.) If the
142
144
  # Ruby version is still unresolved, RuboCop will use the oldest officially
143
- # supported Ruby version (currently Ruby 2.6).
145
+ # supported Ruby version (currently Ruby 2.7).
144
146
  TargetRubyVersion: ~
147
+ # You can specify the parser engine. There are two options available:
148
+ # - `parser_whitequark` ... https://github.com/whitequark/parser
149
+ # - `parser_prism` ... https://github.com/ruby/prism (`Prism::Translation::Parser`)
150
+ # By default, `parser` is used. For the `TargetRubyVersion` value, `parser` can be specified for versions `2.0` and above.
151
+ # `parser_prism` can be specified for versions `3.3` and above. `parser_prism` is faster but still considered experimental.
152
+ ParserEngine: parser_whitequark
145
153
  # Determines if a notification for extension libraries should be shown when
146
154
  # rubocop is run. Keys are the name of the extension, and values are an array
147
155
  # of gems in the Gemfile that the extension is suggested for, if not already
@@ -153,6 +161,9 @@ AllCops:
153
161
  rubocop-sequel: [sequel]
154
162
  rubocop-rake: [rake]
155
163
  rubocop-graphql: [graphql]
164
+ rubocop-capybara: [capybara]
165
+ rubocop-factory_bot: [factory_bot, factory_bot_rails]
166
+ rubocop-rspec_rails: [rspec-rails]
156
167
  # Enable/Disable checking the methods extended by Active Support.
157
168
  ActiveSupportExtensionsEnabled: false
158
169
 
@@ -169,6 +180,16 @@ Bundler/DuplicatedGem:
169
180
  - '**/Gemfile'
170
181
  - '**/gems.rb'
171
182
 
183
+ Bundler/DuplicatedGroup:
184
+ Description: 'Checks for duplicate group entries in Gemfile.'
185
+ Enabled: true
186
+ Severity: warning
187
+ VersionAdded: '1.56'
188
+ Include:
189
+ - '**/*.gemfile'
190
+ - '**/Gemfile'
191
+ - '**/gems.rb'
192
+
172
193
  Bundler/GemComment:
173
194
  Description: 'Add a comment describing each gem.'
174
195
  Enabled: false
@@ -262,6 +283,21 @@ Gemspec/DeprecatedAttributeAssignment:
262
283
  Include:
263
284
  - '**/*.gemspec'
264
285
 
286
+ Gemspec/DevelopmentDependencies:
287
+ Description: Checks that development dependencies are specified in Gemfile rather than gemspec.
288
+ Enabled: pending
289
+ VersionAdded: '1.44'
290
+ EnforcedStyle: Gemfile
291
+ SupportedStyles:
292
+ - Gemfile
293
+ - gems.rb
294
+ - gemspec
295
+ AllowedGems: []
296
+ Include:
297
+ - '**/*.gemspec'
298
+ - '**/Gemfile'
299
+ - '**/gems.rb'
300
+
265
301
  Gemspec/DuplicatedAssignment:
266
302
  Description: 'An attribute assignment method calls should be listed only once in a gemspec.'
267
303
  Enabled: true
@@ -391,9 +427,8 @@ Layout/AssignmentIndentation:
391
427
  Checks the indentation of the first line of the
392
428
  right-hand-side of a multi-line assignment.
393
429
  Enabled: true
394
- SafeAutoCorrect: false
395
430
  VersionAdded: '0.49'
396
- VersionChanged: '1.40'
431
+ VersionChanged: '1.45'
397
432
  # By default the indentation width from `Layout/IndentationWidth` is used,
398
433
  # but it can be overridden by setting this parameter.
399
434
  IndentationWidth: ~
@@ -451,7 +486,9 @@ Layout/ClassStructure:
451
486
  Description: 'Enforces a configured order of definitions within a class body.'
452
487
  StyleGuide: '#consistent-classes'
453
488
  Enabled: false
489
+ SafeAutoCorrect: false
454
490
  VersionAdded: '0.52'
491
+ VersionChanged: '1.53'
455
492
  Categories:
456
493
  module_inclusion:
457
494
  - include
@@ -526,7 +563,9 @@ Layout/ElseAlignment:
526
563
  Layout/EmptyComment:
527
564
  Description: 'Checks empty comment.'
528
565
  Enabled: true
566
+ AutoCorrect: contextual
529
567
  VersionAdded: '0.53'
568
+ VersionChanged: '1.61'
530
569
  AllowBorderComment: true
531
570
  AllowMarginComment: true
532
571
 
@@ -559,6 +598,8 @@ Layout/EmptyLineBetweenDefs:
559
598
  EmptyLineBetweenMethodDefs: true
560
599
  EmptyLineBetweenClassDefs: true
561
600
  EmptyLineBetweenModuleDefs: true
601
+ # `DefLikeMacros` takes the name of any macro that you want to treat like a def.
602
+ DefLikeMacros: []
562
603
  # `AllowAdjacentOneLineDefs` means that single line method definitions don't
563
604
  # need an empty line between them. `true` by default.
564
605
  AllowAdjacentOneLineDefs: true
@@ -964,7 +1005,6 @@ Layout/IndentationWidth:
964
1005
  # Number of spaces for each indentation level.
965
1006
  Width: 2
966
1007
  AllowedPatterns: []
967
- IgnoredPatterns: [] # deprecated
968
1008
 
969
1009
  Layout/InitialIndentation:
970
1010
  Description: >-
@@ -992,10 +1032,8 @@ Layout/LineContinuationLeadingSpace:
992
1032
  Use trailing spaces instead of leading spaces in strings
993
1033
  broken over multiple lines (by a backslash).
994
1034
  Enabled: pending
995
- AutoCorrect: false
996
- SafeAutoCorrect: false
997
1035
  VersionAdded: '1.31'
998
- VersionChanged: '1.32'
1036
+ VersionChanged: '1.45'
999
1037
  EnforcedStyle: trailing
1000
1038
  SupportedStyles:
1001
1039
  - leading
@@ -1004,8 +1042,6 @@ Layout/LineContinuationLeadingSpace:
1004
1042
  Layout/LineContinuationSpacing:
1005
1043
  Description: 'Checks the spacing in front of backslash in line continuations.'
1006
1044
  Enabled: pending
1007
- AutoCorrect: true
1008
- SafeAutoCorrect: true
1009
1045
  VersionAdded: '1.31'
1010
1046
  EnforcedStyle: space
1011
1047
  SupportedStyles:
@@ -1047,7 +1083,6 @@ Layout/LineLength:
1047
1083
  # elements. Strings will be converted to Regexp objects. A line that matches
1048
1084
  # any regular expression listed in this option will be ignored by LineLength.
1049
1085
  AllowedPatterns: []
1050
- IgnoredPatterns: [] # deprecated
1051
1086
 
1052
1087
  Layout/MultilineArrayBraceLayout:
1053
1088
  Description: >-
@@ -1325,6 +1360,10 @@ Layout/SpaceAroundOperators:
1325
1360
  SupportedStylesForExponentOperator:
1326
1361
  - space
1327
1362
  - no_space
1363
+ EnforcedStyleForRationalLiterals: no_space
1364
+ SupportedStylesForRationalLiterals:
1365
+ - space
1366
+ - no_space
1328
1367
 
1329
1368
  Layout/SpaceBeforeBlockBraces:
1330
1369
  Description: >-
@@ -1520,13 +1559,11 @@ Lint/AmbiguousBlockAssociation:
1520
1559
  Description: >-
1521
1560
  Checks for ambiguous block association with method when param passed without
1522
1561
  parentheses.
1523
- StyleGuide: '#syntax'
1524
1562
  Enabled: true
1525
1563
  VersionAdded: '0.48'
1526
1564
  VersionChanged: '1.13'
1527
1565
  AllowedMethods: []
1528
1566
  AllowedPatterns: []
1529
- IgnoredMethods: [] # deprecated
1530
1567
 
1531
1568
  Lint/AmbiguousOperator:
1532
1569
  Description: >-
@@ -1563,7 +1600,9 @@ Lint/AssignmentInCondition:
1563
1600
  Description: "Don't use assignment in conditions."
1564
1601
  StyleGuide: '#safe-assignment-in-condition'
1565
1602
  Enabled: true
1603
+ SafeAutoCorrect: false
1566
1604
  VersionAdded: '0.9'
1605
+ VersionChanged: '1.45'
1567
1606
  AllowSafeAssignment: true
1568
1607
 
1569
1608
  Lint/BigDecimalNew:
@@ -1619,8 +1658,7 @@ Lint/Debugger:
1619
1658
  Description: 'Check for debugger calls.'
1620
1659
  Enabled: true
1621
1660
  VersionAdded: '0.14'
1622
- VersionChanged: '1.10'
1623
- DebuggerReceivers: [] # deprecated
1661
+ VersionChanged: '1.63'
1624
1662
  DebuggerMethods:
1625
1663
  # Groups are available so that a specific group can be disabled in
1626
1664
  # a user's configuration, but are otherwise not significant.
@@ -1633,8 +1671,14 @@ Lint/Debugger:
1633
1671
  - Kernel.byebug
1634
1672
  - Kernel.remote_byebug
1635
1673
  Capybara:
1674
+ - page.save_and_open_page
1675
+ - page.save_and_open_screenshot
1676
+ - page.save_page
1677
+ - page.save_screenshot
1636
1678
  - save_and_open_page
1637
1679
  - save_and_open_screenshot
1680
+ - save_page
1681
+ - save_screenshot
1638
1682
  debug.rb:
1639
1683
  - binding.b
1640
1684
  - binding.break
@@ -1648,6 +1692,7 @@ Lint/Debugger:
1648
1692
  - Kernel.binding.remote_pry
1649
1693
  - Kernel.binding.pry_remote
1650
1694
  - Pry.rescue
1695
+ - pry
1651
1696
  Rails:
1652
1697
  - debugger
1653
1698
  - Kernel.debugger
@@ -1655,6 +1700,10 @@ Lint/Debugger:
1655
1700
  - jard
1656
1701
  WebConsole:
1657
1702
  - binding.console
1703
+ DebuggerRequires:
1704
+ debug.rb:
1705
+ - debug/open
1706
+ - debug/start
1658
1707
 
1659
1708
  Lint/DeprecatedClassMethods:
1660
1709
  Description: 'Check for deprecated class method calls.'
@@ -1740,6 +1789,11 @@ Lint/DuplicateMagicComment:
1740
1789
  Enabled: pending
1741
1790
  VersionAdded: '1.37'
1742
1791
 
1792
+ Lint/DuplicateMatchPattern:
1793
+ Description: 'Do not repeat patterns in `in` keywords.'
1794
+ Enabled: pending
1795
+ VersionAdded: '1.50'
1796
+
1743
1797
  Lint/DuplicateMethods:
1744
1798
  Description: 'Check for duplicate method definitions.'
1745
1799
  Enabled: true
@@ -1790,16 +1844,18 @@ Lint/EmptyClass:
1790
1844
  Lint/EmptyConditionalBody:
1791
1845
  Description: 'Checks for the presence of `if`, `elsif` and `unless` branches without a body.'
1792
1846
  Enabled: true
1847
+ AutoCorrect: contextual
1793
1848
  SafeAutoCorrect: false
1794
1849
  AllowComments: true
1795
1850
  VersionAdded: '0.89'
1796
- VersionChanged: '1.34'
1851
+ VersionChanged: '1.61'
1797
1852
 
1798
1853
  Lint/EmptyEnsure:
1799
1854
  Description: 'Checks for empty ensure block.'
1800
1855
  Enabled: true
1856
+ AutoCorrect: contextual
1801
1857
  VersionAdded: '0.10'
1802
- VersionChanged: '0.48'
1858
+ VersionChanged: '1.61'
1803
1859
 
1804
1860
  Lint/EmptyExpression:
1805
1861
  Description: 'Checks for empty expressions.'
@@ -1821,8 +1877,9 @@ Lint/EmptyInPattern:
1821
1877
  Lint/EmptyInterpolation:
1822
1878
  Description: 'Checks for empty string interpolation.'
1823
1879
  Enabled: true
1880
+ AutoCorrect: contextual
1824
1881
  VersionAdded: '0.20'
1825
- VersionChanged: '0.45'
1882
+ VersionChanged: '1.61'
1826
1883
 
1827
1884
  Lint/EmptyWhen:
1828
1885
  Description: 'Checks for `when` branches with empty bodies.'
@@ -1928,6 +1985,12 @@ Lint/InterpolationCheck:
1928
1985
  VersionAdded: '0.50'
1929
1986
  VersionChanged: '1.40'
1930
1987
 
1988
+ Lint/ItWithoutArgumentsInBlock:
1989
+ Description: 'Checks uses of `it` calls without arguments in block.'
1990
+ Reference: 'https://bugs.ruby-lang.org/issues/18980'
1991
+ Enabled: pending
1992
+ VersionAdded: '1.59'
1993
+
1931
1994
  Lint/LambdaWithoutLiteralBlock:
1932
1995
  Description: 'Checks uses of lambda without a literal block.'
1933
1996
  Enabled: pending
@@ -1938,6 +2001,11 @@ Lint/LiteralAsCondition:
1938
2001
  Enabled: true
1939
2002
  VersionAdded: '0.51'
1940
2003
 
2004
+ Lint/LiteralAssignmentInCondition:
2005
+ Description: 'Checks for literal assignments in the conditions.'
2006
+ Enabled: pending
2007
+ VersionAdded: '1.58'
2008
+
1941
2009
  Lint/LiteralInInterpolation:
1942
2010
  Description: 'Checks for literals used in interpolation.'
1943
2011
  Enabled: true
@@ -1972,9 +2040,16 @@ Lint/MissingSuper:
1972
2040
  Checks for the presence of constructors and lifecycle callbacks
1973
2041
  without calls to `super`.
1974
2042
  Enabled: true
2043
+ AllowedParentClasses: []
1975
2044
  VersionAdded: '0.89'
1976
2045
  VersionChanged: '1.4'
1977
2046
 
2047
+ Lint/MixedCaseRange:
2048
+ Description: 'Checks for mixed-case character ranges since they include likely unintended characters.'
2049
+ Enabled: pending
2050
+ SafeAutoCorrect: false
2051
+ VersionAdded: '1.53'
2052
+
1978
2053
  Lint/MixedRegexpCaptureTypes:
1979
2054
  Description: 'Do not mix named captures and numbered captures in a Regexp literal.'
1980
2055
  Enabled: true
@@ -2037,7 +2112,6 @@ Lint/NumberConversion:
2037
2112
  SafeAutoCorrect: false
2038
2113
  AllowedMethods: []
2039
2114
  AllowedPatterns: []
2040
- IgnoredMethods: [] # deprecated
2041
2115
  IgnoredClasses:
2042
2116
  - Time
2043
2117
  - DateTime
@@ -2125,10 +2199,17 @@ Lint/RedundantDirGlobSort:
2125
2199
  VersionChanged: '1.26'
2126
2200
  SafeAutoCorrect: false
2127
2201
 
2202
+ Lint/RedundantRegexpQuantifiers:
2203
+ Description: 'Checks for redundant quantifiers in Regexps.'
2204
+ Enabled: pending
2205
+ VersionAdded: '1.53'
2206
+
2128
2207
  Lint/RedundantRequireStatement:
2129
2208
  Description: 'Checks for unnecessary `require` statement.'
2130
2209
  Enabled: true
2210
+ SafeAutoCorrect: false
2131
2211
  VersionAdded: '0.76'
2212
+ VersionChanged: '1.57'
2132
2213
 
2133
2214
  Lint/RedundantSafeNavigation:
2134
2215
  Description: 'Checks for redundant safe navigation calls.'
@@ -2329,11 +2410,16 @@ Lint/TopLevelReturnWithArgument:
2329
2410
  Description: 'Detects top level return statements with argument.'
2330
2411
  Enabled: true
2331
2412
  VersionAdded: '0.89'
2413
+ # These codes are `eval`-ed in method and their return values may be used.
2414
+ Exclude:
2415
+ - '**/*.jb'
2332
2416
 
2333
2417
  Lint/TrailingCommaInAttributeDeclaration:
2334
2418
  Description: 'Checks for trailing commas in attribute declarations.'
2335
2419
  Enabled: true
2420
+ AutoCorrect: contextual
2336
2421
  VersionAdded: '0.90'
2422
+ VersionChanged: '1.61'
2337
2423
 
2338
2424
  Lint/TripleQuotes:
2339
2425
  Description: 'Checks for useless triple quote constructs.'
@@ -2388,14 +2474,14 @@ Lint/UnreachableLoop:
2388
2474
  # RSpec uses `times` in its message expectations
2389
2475
  # eg. `exactly(2).times`
2390
2476
  - !ruby/regexp /(exactly|at_least|at_most)\(\d+\)\.times/
2391
- IgnoredPatterns: [] # deprecated
2392
2477
 
2393
2478
  Lint/UnusedBlockArgument:
2394
2479
  Description: 'Checks for unused block arguments.'
2395
2480
  StyleGuide: '#underscore-unused-vars'
2396
2481
  Enabled: true
2482
+ AutoCorrect: contextual
2397
2483
  VersionAdded: '0.21'
2398
- VersionChanged: '0.22'
2484
+ VersionChanged: '1.61'
2399
2485
  IgnoreEmptyBlocks: true
2400
2486
  AllowUnusedKeywordArguments: false
2401
2487
 
@@ -2403,8 +2489,9 @@ Lint/UnusedMethodArgument:
2403
2489
  Description: 'Checks for unused method arguments.'
2404
2490
  StyleGuide: '#underscore-unused-vars'
2405
2491
  Enabled: true
2492
+ AutoCorrect: contextual
2406
2493
  VersionAdded: '0.21'
2407
- VersionChanged: '0.81'
2494
+ VersionChanged: '1.61'
2408
2495
  AllowUnusedKeywordArguments: false
2409
2496
  IgnoreEmptyMethods: true
2410
2497
  IgnoreNotImplementedMethods: true
@@ -2428,8 +2515,9 @@ Lint/UriRegexp:
2428
2515
  Lint/UselessAccessModifier:
2429
2516
  Description: 'Checks for useless access modifiers.'
2430
2517
  Enabled: true
2518
+ AutoCorrect: contextual
2431
2519
  VersionAdded: '0.20'
2432
- VersionChanged: '0.83'
2520
+ VersionChanged: '1.61'
2433
2521
  ContextCreatingMethods: []
2434
2522
  MethodCreatingMethods: []
2435
2523
 
@@ -2437,7 +2525,10 @@ Lint/UselessAssignment:
2437
2525
  Description: 'Checks for useless assignment to a local variable.'
2438
2526
  StyleGuide: '#underscore-unused-vars'
2439
2527
  Enabled: true
2528
+ AutoCorrect: contextual
2440
2529
  VersionAdded: '0.11'
2530
+ VersionChanged: '1.61'
2531
+ SafeAutoCorrect: false
2441
2532
 
2442
2533
  Lint/UselessElseWithoutRescue:
2443
2534
  Description: 'Checks for useless `else` in `begin..end` without `rescue`.'
@@ -2448,10 +2539,16 @@ Lint/UselessElseWithoutRescue:
2448
2539
  Lint/UselessMethodDefinition:
2449
2540
  Description: 'Checks for useless method definitions.'
2450
2541
  Enabled: true
2542
+ AutoCorrect: contextual
2451
2543
  VersionAdded: '0.90'
2452
- VersionChanged: '0.91'
2544
+ VersionChanged: '1.61'
2453
2545
  Safe: false
2454
2546
 
2547
+ Lint/UselessRescue:
2548
+ Description: 'Checks for useless `rescue`s.'
2549
+ Enabled: pending
2550
+ VersionAdded: '1.43'
2551
+
2455
2552
  Lint/UselessRuby2Keywords:
2456
2553
  Description: 'Finds unnecessary uses of `ruby2_keywords`.'
2457
2554
  Enabled: pending
@@ -2460,21 +2557,24 @@ Lint/UselessRuby2Keywords:
2460
2557
  Lint/UselessSetterCall:
2461
2558
  Description: 'Checks for useless setter call to a local variable.'
2462
2559
  Enabled: true
2463
- SafeAutoCorrect: false
2560
+ Safe: false
2464
2561
  VersionAdded: '0.13'
2465
2562
  VersionChanged: '1.2'
2466
- Safe: false
2467
2563
 
2468
2564
  Lint/UselessTimes:
2469
2565
  Description: 'Checks for useless `Integer#times` calls.'
2470
2566
  Enabled: true
2471
- VersionAdded: '0.91'
2472
2567
  Safe: false
2568
+ AutoCorrect: contextual
2569
+ VersionAdded: '0.91'
2570
+ VersionChanged: '1.61'
2473
2571
 
2474
2572
  Lint/Void:
2475
2573
  Description: 'Possible use of operator/literal/variable in void context.'
2476
2574
  Enabled: true
2575
+ AutoCorrect: contextual
2477
2576
  VersionAdded: '0.9'
2577
+ VersionChanged: '1.61'
2478
2578
  CheckForMethodsWithNoSideEffects: false
2479
2579
 
2480
2580
  #################### Metrics ###############################
@@ -2493,7 +2593,6 @@ Metrics/AbcSize:
2493
2593
  # a Float.
2494
2594
  AllowedMethods: []
2495
2595
  AllowedPatterns: []
2496
- IgnoredMethods: [] # deprecated
2497
2596
  CountRepeatedAttributes: true
2498
2597
  Max: 17
2499
2598
 
@@ -2505,13 +2604,11 @@ Metrics/BlockLength:
2505
2604
  CountComments: false # count full line comments?
2506
2605
  Max: 25
2507
2606
  CountAsOne: []
2508
- ExcludedMethods: [] # deprecated, retained for backwards compatibility
2509
2607
  AllowedMethods:
2510
2608
  # By default, exclude the `#refine` method, as it tends to have larger
2511
2609
  # associated blocks.
2512
2610
  - refine
2513
2611
  AllowedPatterns: []
2514
- IgnoredMethods: [] # deprecated
2515
2612
  Exclude:
2516
2613
  - '**/*.gemspec'
2517
2614
 
@@ -2533,6 +2630,12 @@ Metrics/ClassLength:
2533
2630
  Max: 100
2534
2631
  CountAsOne: []
2535
2632
 
2633
+ Metrics/CollectionLiteralLength:
2634
+ Description: 'Checks for `Array` or `Hash` literals with many entries.'
2635
+ Enabled: pending
2636
+ VersionAdded: '1.47'
2637
+ LengthThreshold: 250
2638
+
2536
2639
  # Avoid complex methods.
2537
2640
  Metrics/CyclomaticComplexity:
2538
2641
  Description: >-
@@ -2543,7 +2646,6 @@ Metrics/CyclomaticComplexity:
2543
2646
  VersionChanged: '0.81'
2544
2647
  AllowedMethods: []
2545
2648
  AllowedPatterns: []
2546
- IgnoredMethods: [] # deprecated
2547
2649
  Max: 7
2548
2650
 
2549
2651
  Metrics/MethodLength:
@@ -2555,10 +2657,8 @@ Metrics/MethodLength:
2555
2657
  CountComments: false # count full line comments?
2556
2658
  Max: 10
2557
2659
  CountAsOne: []
2558
- ExcludedMethods: [] # deprecated, retained for backwards compatibility
2559
2660
  AllowedMethods: []
2560
2661
  AllowedPatterns: []
2561
- IgnoredMethods: [] # deprecated
2562
2662
 
2563
2663
  Metrics/ModuleLength:
2564
2664
  Description: 'Avoid modules longer than 100 lines of code.'
@@ -2588,7 +2688,6 @@ Metrics/PerceivedComplexity:
2588
2688
  VersionChanged: '0.81'
2589
2689
  AllowedMethods: []
2590
2690
  AllowedPatterns: []
2591
- IgnoredMethods: [] # deprecated
2592
2691
  Max: 8
2593
2692
 
2594
2693
  ################## Migration #############################
@@ -2674,7 +2773,8 @@ Naming/FileName:
2674
2773
  VersionChanged: '1.23'
2675
2774
  # Camel case file names listed in `AllCops:Include` and all file names listed
2676
2775
  # in `AllCops:Exclude` are excluded by default. Add extra excludes here.
2677
- Exclude: []
2776
+ Exclude:
2777
+ - Rakefile.rb
2678
2778
  # When `true`, requires that each source file should define a class or module
2679
2779
  # with a name which matches the file name (converted to ... case).
2680
2780
  # It further expects it to be nested inside modules which match the names
@@ -2759,13 +2859,13 @@ Naming/HeredocDelimiterNaming:
2759
2859
  Enabled: true
2760
2860
  VersionAdded: '0.50'
2761
2861
  ForbiddenDelimiters:
2762
- - !ruby/regexp '/(^|\s)(EO[A-Z]{1}|END)(\s|$)/'
2862
+ - !ruby/regexp '/(^|\s)(EO[A-Z]{1}|END)(\s|$)/i'
2763
2863
 
2764
2864
  Naming/InclusiveLanguage:
2765
2865
  Description: 'Recommend the use of inclusive language instead of problematic terms.'
2766
2866
  Enabled: false
2767
2867
  VersionAdded: '1.18'
2768
- VersionChanged: '1.21'
2868
+ VersionChanged: '1.49'
2769
2869
  CheckIdentifiers: true
2770
2870
  CheckConstants: true
2771
2871
  CheckVariables: true
@@ -2817,7 +2917,6 @@ Naming/MethodName:
2817
2917
  # - '\A\s*onSelectionCleared\s*'
2818
2918
  #
2819
2919
  AllowedPatterns: []
2820
- IgnoredPatterns: [] # deprecated
2821
2920
 
2822
2921
  Naming/MethodParameterName:
2823
2922
  Description: >-
@@ -2918,6 +3017,7 @@ Naming/VariableNumber:
2918
3017
  - rfc822 # Time#rfc822
2919
3018
  - rfc2822 # Time#rfc2822
2920
3019
  - rfc3339 # DateTime.rfc3339
3020
+ - x86_64 # Allowed by default as an underscore separated CPU architecture name
2921
3021
  AllowedPatterns: []
2922
3022
 
2923
3023
  #################### Security ##############################
@@ -2925,7 +3025,9 @@ Naming/VariableNumber:
2925
3025
  Security/CompoundHash:
2926
3026
  Description: 'When overwriting Object#hash to combine values, prefer delegating to Array#hash over writing a custom implementation.'
2927
3027
  Enabled: pending
3028
+ Safe: false
2928
3029
  VersionAdded: '1.28'
3030
+ VersionChanged: '1.51'
2929
3031
 
2930
3032
  Security/Eval:
2931
3033
  Description: 'The use of eval represents a serious security risk.'
@@ -2988,6 +3090,7 @@ Style/AccessModifierDeclarations:
2988
3090
  - inline
2989
3091
  - group
2990
3092
  AllowModifiersOnSymbols: true
3093
+ AllowModifiersOnAttrs: true
2991
3094
  SafeAutoCorrect: false
2992
3095
 
2993
3096
  Style/AccessorGrouping:
@@ -3031,7 +3134,20 @@ Style/ArgumentsForwarding:
3031
3134
  StyleGuide: '#arguments-forwarding'
3032
3135
  Enabled: pending
3033
3136
  AllowOnlyRestArgument: true
3137
+ UseAnonymousForwarding: true
3138
+ RedundantRestArgumentNames:
3139
+ - args
3140
+ - arguments
3141
+ RedundantKeywordRestArgumentNames:
3142
+ - kwargs
3143
+ - options
3144
+ - opts
3145
+ RedundantBlockArgumentNames:
3146
+ - blk
3147
+ - block
3148
+ - proc
3034
3149
  VersionAdded: '1.1'
3150
+ VersionChanged: '1.58'
3035
3151
 
3036
3152
  Style/ArrayCoercion:
3037
3153
  Description: >-
@@ -3042,9 +3158,17 @@ Style/ArrayCoercion:
3042
3158
  Enabled: false
3043
3159
  VersionAdded: '0.88'
3044
3160
 
3161
+ Style/ArrayFirstLast:
3162
+ Description: 'Use `arr.first` and `arr.last` instead of `arr[0]` and `arr[-1]`.'
3163
+ Reference: '#first-and-last'
3164
+ Enabled: false
3165
+ VersionAdded: '1.58'
3166
+ Safe: false
3167
+
3045
3168
  Style/ArrayIntersect:
3046
3169
  Description: 'Use `array1.intersect?(array2)` instead of `(array1 & array2).any?`.'
3047
3170
  Enabled: 'pending'
3171
+ Safe: false
3048
3172
  VersionAdded: '1.40'
3049
3173
 
3050
3174
  Style/ArrayJoin:
@@ -3187,7 +3311,6 @@ Style/BlockDelimiters:
3187
3311
  - proc
3188
3312
  - it
3189
3313
  AllowedPatterns: []
3190
- IgnoredMethods: [] # deprecated
3191
3314
  # The AllowBracesOnProceduralOneLiners option is ignored unless the
3192
3315
  # EnforcedStyle is set to `semantic`. If so:
3193
3316
  #
@@ -3211,7 +3334,7 @@ Style/BlockDelimiters:
3211
3334
  # collection.each do |element| puts element end
3212
3335
  AllowBracesOnProceduralOneLiners: false
3213
3336
  # The BracesRequiredMethods overrides all other configurations except
3214
- # IgnoredMethods. It can be used to enforce that all blocks for specific
3337
+ # AllowedMethods. It can be used to enforce that all blocks for specific
3215
3338
  # methods use braces. For example, you can use this to enforce Sorbet
3216
3339
  # signatures use braces even when the rest of your codebase enforces
3217
3340
  # the `line_count_based` style.
@@ -3248,6 +3371,9 @@ Style/CaseLikeIf:
3248
3371
  Enabled: true
3249
3372
  Safe: false
3250
3373
  VersionAdded: '0.88'
3374
+ VersionChanged: '1.48'
3375
+ # `MinBranchesCount` defines the number of branches `if` needs to have to trigger this cop.
3376
+ MinBranchesCount: 3
3251
3377
 
3252
3378
  Style/CharacterLiteral:
3253
3379
  Description: 'Checks for uses of character literals.'
@@ -3260,7 +3386,7 @@ Style/ClassAndModuleChildren:
3260
3386
  StyleGuide: '#namespace-definition'
3261
3387
  # Moving from compact to nested children requires knowledge of whether the
3262
3388
  # outer parent is a module or a class. Moving from nested to compact requires
3263
- # verification that the outer parent is defined elsewhere. Rubocop does not
3389
+ # verification that the outer parent is defined elsewhere. RuboCop does not
3264
3390
  # have the knowledge to perform either operation safely and thus requires
3265
3391
  # manual oversight.
3266
3392
  SafeAutoCorrect: false
@@ -3299,13 +3425,14 @@ Style/ClassEqualityComparison:
3299
3425
  Description: 'Enforces the use of `Object#instance_of?` instead of class comparison for equality.'
3300
3426
  StyleGuide: '#instance-of-vs-class-comparison'
3301
3427
  Enabled: true
3428
+ SafeAutoCorrect: false
3302
3429
  VersionAdded: '0.93'
3430
+ VersionChanged: '1.57'
3303
3431
  AllowedMethods:
3304
3432
  - ==
3305
3433
  - equal?
3306
3434
  - eql?
3307
3435
  AllowedPatterns: []
3308
- IgnoredMethods: [] # deprecated
3309
3436
 
3310
3437
  Style/ClassMethods:
3311
3438
  Description: 'Use self when defining module/class methods.'
@@ -3336,6 +3463,7 @@ Style/CollectionCompact:
3336
3463
  Safe: false
3337
3464
  VersionAdded: '1.2'
3338
3465
  VersionChanged: '1.3'
3466
+ AllowedReceivers: []
3339
3467
 
3340
3468
  # Align with the style guide.
3341
3469
  Style/CollectionMethods:
@@ -3354,6 +3482,7 @@ Style/CollectionMethods:
3354
3482
  PreferredMethods:
3355
3483
  collect: 'map'
3356
3484
  collect!: 'map!'
3485
+ collect_concat: 'flat_map'
3357
3486
  inject: 'reduce'
3358
3487
  detect: 'find'
3359
3488
  find_all: 'select'
@@ -3426,6 +3555,11 @@ Style/CommentedKeyword:
3426
3555
  VersionAdded: '0.51'
3427
3556
  VersionChanged: '1.19'
3428
3557
 
3558
+ Style/ComparableClamp:
3559
+ Description: 'Enforces the use of `Comparable#clamp` instead of comparison by minimum and maximum.'
3560
+ Enabled: pending
3561
+ VersionAdded: '1.44'
3562
+
3429
3563
  Style/ConcatArrayLiterals:
3430
3564
  Description: 'Enforces the use of `Array#push(item)` instead of `Array#concat([item])` to avoid redundant array literals.'
3431
3565
  Enabled: pending
@@ -3487,6 +3621,14 @@ Style/Copyright:
3487
3621
  Notice: '^Copyright (\(c\) )?2[0-9]{3} .+'
3488
3622
  AutocorrectNotice: ''
3489
3623
 
3624
+ Style/DataInheritance:
3625
+ Description: 'Checks for inheritance from Data.define.'
3626
+ StyleGuide: '#no-extend-data-define'
3627
+ Enabled: pending
3628
+ SafeAutoCorrect: false
3629
+ VersionAdded: '1.49'
3630
+ VersionChanged: '1.51'
3631
+
3490
3632
  Style/DateTime:
3491
3633
  Description: 'Use Time over DateTime.'
3492
3634
  StyleGuide: '#date-time'
@@ -3510,6 +3652,12 @@ Style/Dir:
3510
3652
  Enabled: true
3511
3653
  VersionAdded: '0.50'
3512
3654
 
3655
+ Style/DirEmpty:
3656
+ Description: >-
3657
+ Prefer to use `Dir.empty?('path/to/dir')` when checking if a directory is empty.
3658
+ Enabled: pending
3659
+ VersionAdded: '1.48'
3660
+
3513
3661
  Style/DisableCopsWithinSourceCodeDirective:
3514
3662
  Description: >-
3515
3663
  Forbids disabling/enabling cops within source code.
@@ -3540,6 +3688,7 @@ Style/DocumentationMethod:
3540
3688
  Description: 'Checks for missing documentation comment for public methods.'
3541
3689
  Enabled: false
3542
3690
  VersionAdded: '0.43'
3691
+ AllowedMethods: []
3543
3692
  Exclude:
3544
3693
  - 'spec/**/*'
3545
3694
  - 'test/**/*'
@@ -3588,8 +3737,9 @@ Style/EmptyCaseCondition:
3588
3737
  Style/EmptyElse:
3589
3738
  Description: 'Avoid empty else-clauses.'
3590
3739
  Enabled: true
3740
+ AutoCorrect: contextual
3591
3741
  VersionAdded: '0.28'
3592
- VersionChanged: '0.32'
3742
+ VersionChanged: '1.61'
3593
3743
  EnforcedStyle: both
3594
3744
  # empty - warn only on empty `else`
3595
3745
  # nil - warn on `else` with nil in it
@@ -3603,7 +3753,9 @@ Style/EmptyElse:
3603
3753
  Style/EmptyHeredoc:
3604
3754
  Description: 'Checks for using empty heredoc to reduce redundancy.'
3605
3755
  Enabled: pending
3756
+ AutoCorrect: contextual
3606
3757
  VersionAdded: '1.32'
3758
+ VersionChanged: '1.61'
3607
3759
 
3608
3760
  Style/EmptyLambdaParameter:
3609
3761
  Description: 'Omit parens for empty lambda parameters.'
@@ -3621,7 +3773,9 @@ Style/EmptyMethod:
3621
3773
  Description: 'Checks the formatting of empty method definitions.'
3622
3774
  StyleGuide: '#no-single-line-methods'
3623
3775
  Enabled: true
3776
+ AutoCorrect: contextual
3624
3777
  VersionAdded: '0.46'
3778
+ VersionChanged: '1.61'
3625
3779
  EnforcedStyle: compact
3626
3780
  SupportedStyles:
3627
3781
  - compact
@@ -3670,6 +3824,11 @@ Style/EvenOdd:
3670
3824
  VersionAdded: '0.12'
3671
3825
  VersionChanged: '0.29'
3672
3826
 
3827
+ Style/ExactRegexpMatch:
3828
+ Description: 'Checks for exact regexp match inside Regexp literals.'
3829
+ Enabled: pending
3830
+ VersionAdded: '1.51'
3831
+
3673
3832
  Style/ExpandPathArguments:
3674
3833
  Description: "Use `expand_path(__dir__)` instead of `expand_path('..', __FILE__)`."
3675
3834
  Enabled: true
@@ -3705,6 +3864,13 @@ Style/FetchEnvVar:
3705
3864
  # Environment variables to be excluded from the inspection.
3706
3865
  AllowedVars: []
3707
3866
 
3867
+ Style/FileEmpty:
3868
+ Description: >-
3869
+ Prefer to use `File.empty?('path/to/file')` when checking if a file is empty.
3870
+ Enabled: pending
3871
+ Safe: false
3872
+ VersionAdded: '1.48'
3873
+
3708
3874
  Style/FileRead:
3709
3875
  Description: 'Favor `File.(bin)read` convenience methods.'
3710
3876
  StyleGuide: '#file-read'
@@ -3775,7 +3941,6 @@ Style/FormatStringToken:
3775
3941
  VersionChanged: '1.0'
3776
3942
  AllowedMethods: []
3777
3943
  AllowedPatterns: []
3778
- IgnoredMethods: [] # deprecated
3779
3944
 
3780
3945
  Style/FrozenStringLiteralComment:
3781
3946
  Description: >-
@@ -3842,8 +4007,9 @@ Style/HashConversion:
3842
4007
  Description: 'Avoid Hash[] in favor of ary.to_h or literal hashes.'
3843
4008
  StyleGuide: '#avoid-hash-constructor'
3844
4009
  Enabled: pending
4010
+ SafeAutoCorrect: false
3845
4011
  VersionAdded: '1.10'
3846
- VersionChanged: '1.11'
4012
+ VersionChanged: '1.55'
3847
4013
  AllowSplatArgument: true
3848
4014
 
3849
4015
  Style/HashEachMethods:
@@ -3853,7 +4019,8 @@ Style/HashEachMethods:
3853
4019
  Safe: false
3854
4020
  VersionAdded: '0.80'
3855
4021
  VersionChanged: '1.16'
3856
- AllowedReceivers: []
4022
+ AllowedReceivers:
4023
+ - Thread.current
3857
4024
 
3858
4025
  Style/HashExcept:
3859
4026
  Description: >-
@@ -3903,6 +4070,8 @@ Style/HashSyntax:
3903
4070
  - either
3904
4071
  # forces use of the 3.1 syntax only if all values can be omitted in the hash.
3905
4072
  - consistent
4073
+ # allow either (implicit or explicit) syntax but enforce consistency within a single hash
4074
+ - either_consistent
3906
4075
  # Force hashes that have a symbol value to use hash rockets
3907
4076
  UseHashRocketsWithSymbolValues: false
3908
4077
  # Do not suggest { a?: 1 } over { :a? => 1 } in ruby19 style
@@ -4015,16 +4184,35 @@ Style/InverseMethods:
4015
4184
  :=~: :!~
4016
4185
  :<: :>=
4017
4186
  :>: :<=
4018
- # `ActiveSupport` defines some common inverse methods. They are listed below,
4019
- # and not enabled by default.
4020
- # :present?: :blank?,
4021
- # :include?: :exclude?
4022
4187
  # `InverseBlocks` are methods that are inverted by inverting the return
4023
4188
  # of the block that is passed to the method
4024
4189
  InverseBlocks:
4025
4190
  :select: :reject
4026
4191
  :select!: :reject!
4027
4192
 
4193
+ Style/InvertibleUnlessCondition:
4194
+ Description: 'Favor `if` with inverted condition over `unless`.'
4195
+ Enabled: false
4196
+ Safe: false
4197
+ VersionAdded: '1.44'
4198
+ VersionChanged: '1.50'
4199
+ # `InverseMethods` are methods that can be inverted in a `unless` condition.
4200
+ # The relationship of inverse methods needs to be defined in both directions.
4201
+ # Keys and values both need to be defined as symbols.
4202
+ InverseMethods:
4203
+ :!=: :==
4204
+ :>: :<=
4205
+ :<=: :>
4206
+ :<: :>=
4207
+ :>=: :<
4208
+ :!~: :=~
4209
+ :zero?: :nonzero?
4210
+ :nonzero?: :zero?
4211
+ :any?: :none?
4212
+ :none?: :any?
4213
+ :even?: :odd?
4214
+ :odd?: :even?
4215
+
4028
4216
  Style/IpAddresses:
4029
4217
  Description: "Don't include literal IP addresses in code."
4030
4218
  Enabled: false
@@ -4104,6 +4292,13 @@ Style/MapCompactWithConditionalBlock:
4104
4292
  Enabled: pending
4105
4293
  VersionAdded: '1.30'
4106
4294
 
4295
+ Style/MapIntoArray:
4296
+ Description: 'Checks for usages of `each` with `<<`, `push`, or `append` which can be replaced by `map`.'
4297
+ StyleGuide: '#functional-code'
4298
+ Enabled: pending
4299
+ VersionAdded: '1.63'
4300
+ Safe: false
4301
+
4107
4302
  Style/MapToHash:
4108
4303
  Description: 'Prefer `to_h` with a block over `map.to_h`.'
4109
4304
  Enabled: pending
@@ -4124,9 +4319,7 @@ Style/MethodCallWithArgsParentheses:
4124
4319
  VersionChanged: '1.7'
4125
4320
  IgnoreMacros: true
4126
4321
  AllowedMethods: []
4127
- IgnoredMethods: [] # deprecated
4128
4322
  AllowedPatterns: []
4129
- IgnoredPatterns: [] # deprecated
4130
4323
  IncludedMacros: []
4131
4324
  AllowParenthesesInMultilineCall: false
4132
4325
  AllowParenthesesInChaining: false
@@ -4143,7 +4336,6 @@ Style/MethodCallWithoutArgsParentheses:
4143
4336
  Enabled: true
4144
4337
  AllowedMethods: []
4145
4338
  AllowedPatterns: []
4146
- IgnoredMethods: [] # deprecated
4147
4339
  VersionAdded: '0.47'
4148
4340
  VersionChanged: '0.55'
4149
4341
 
@@ -4303,6 +4495,7 @@ Style/MultipleComparison:
4303
4495
  VersionAdded: '0.49'
4304
4496
  VersionChanged: '1.1'
4305
4497
  AllowMethodComparison: true
4498
+ ComparisonsThreshold: 2
4306
4499
 
4307
4500
  Style/MutableConstant:
4308
4501
  Description: 'Do not assign mutable objects to constants.'
@@ -4508,11 +4701,10 @@ Style/NumericPredicate:
4508
4701
  Checks for the use of predicate- or comparison methods for
4509
4702
  numeric comparisons.
4510
4703
  StyleGuide: '#predicate-methods'
4511
- Safe: false
4512
4704
  # This will change to a new method call which isn't guaranteed to be on the
4513
4705
  # object. Switching these methods has to be done with knowledge of the types
4514
4706
  # of the variables which rubocop doesn't have.
4515
- SafeAutoCorrect: false
4707
+ Safe: false
4516
4708
  Enabled: true
4517
4709
  VersionAdded: '0.42'
4518
4710
  VersionChanged: '0.59'
@@ -4522,7 +4714,6 @@ Style/NumericPredicate:
4522
4714
  - comparison
4523
4715
  AllowedMethods: []
4524
4716
  AllowedPatterns: []
4525
- IgnoredMethods: [] # deprecated
4526
4717
  # Exclude RSpec specs because assertions like `expect(1).to be > 0` cause
4527
4718
  # false positives.
4528
4719
  Exclude:
@@ -4559,7 +4750,9 @@ Style/OpenStructUse:
4559
4750
  - https://docs.ruby-lang.org/en/3.0.0/OpenStruct.html#class-OpenStruct-label-Caveats
4560
4751
 
4561
4752
  Enabled: pending
4753
+ Safe: false
4562
4754
  VersionAdded: '1.23'
4755
+ VersionChanged: '1.51'
4563
4756
 
4564
4757
  Style/OperatorMethodCall:
4565
4758
  Description: 'Checks for redundant dot before operator method call.'
@@ -4569,6 +4762,7 @@ Style/OperatorMethodCall:
4569
4762
 
4570
4763
  Style/OptionHash:
4571
4764
  Description: "Don't use option hashes when you can use keyword arguments."
4765
+ StyleGuide: '#keyword-arguments-vs-option-hashes'
4572
4766
  Enabled: false
4573
4767
  VersionAdded: '0.33'
4574
4768
  VersionChanged: '0.34'
@@ -4691,8 +4885,9 @@ Style/RaiseArgs:
4691
4885
  Description: 'Checks the arguments passed to raise/fail.'
4692
4886
  StyleGuide: '#exception-class-messages'
4693
4887
  Enabled: true
4888
+ Safe: false
4694
4889
  VersionAdded: '0.14'
4695
- VersionChanged: '1.2'
4890
+ VersionChanged: '1.61'
4696
4891
  EnforcedStyle: exploded
4697
4892
  SupportedStyles:
4698
4893
  - compact # raise Exception.new(msg)
@@ -4712,12 +4907,16 @@ Style/RedundantArgument:
4712
4907
  Enabled: pending
4713
4908
  Safe: false
4714
4909
  VersionAdded: '1.4'
4715
- VersionChanged: '1.40'
4910
+ VersionChanged: '1.55'
4716
4911
  Methods:
4717
4912
  # Array#join
4718
4913
  join: ''
4719
4914
  # Array#sum
4720
4915
  sum: 0
4916
+ # Kernel.#exit
4917
+ exit: true
4918
+ # Kernel.#exit!
4919
+ exit!: false
4721
4920
  # String#split
4722
4921
  split: ' '
4723
4922
  # String#chomp
@@ -4725,6 +4924,11 @@ Style/RedundantArgument:
4725
4924
  # String#chomp!
4726
4925
  chomp!: "\n"
4727
4926
 
4927
+ Style/RedundantArrayConstructor:
4928
+ Description: 'Checks for the instantiation of array using redundant `Array` constructor.'
4929
+ Enabled: pending
4930
+ VersionAdded: '1.52'
4931
+
4728
4932
  Style/RedundantAssignment:
4729
4933
  Description: 'Checks for redundant assignment before returning.'
4730
4934
  Enabled: true
@@ -4757,6 +4961,11 @@ Style/RedundantConstantBase:
4757
4961
  Enabled: pending
4758
4962
  VersionAdded: '1.40'
4759
4963
 
4964
+ Style/RedundantCurrentDirectoryInPath:
4965
+ Description: 'Checks for uses a redundant current directory in path.'
4966
+ Enabled: pending
4967
+ VersionAdded: '1.53'
4968
+
4760
4969
  Style/RedundantDoubleSplatHashBraces:
4761
4970
  Description: 'Checks for redundant uses of double splat hash braces.'
4762
4971
  Enabled: pending
@@ -4779,7 +4988,7 @@ Style/RedundantFetchBlock:
4779
4988
  Description: >-
4780
4989
  Use `fetch(key, value)` instead of `fetch(key) { value }`
4781
4990
  when value has Numeric, Rational, Complex, Symbol or String type, `false`, `true`, `nil` or is a constant.
4782
- Reference: 'https://github.com/JuanitoFatas/fast-ruby#hashfetch-with-argument-vs-hashfetch--block-code'
4991
+ Reference: 'https://github.com/fastruby/fast-ruby#hashfetch-with-argument-vs-hashfetch--block-code'
4783
4992
  Enabled: true
4784
4993
  Safe: false
4785
4994
  # If enabled, this cop will autocorrect usages of
@@ -4796,19 +5005,34 @@ Style/RedundantFileExtensionInRequire:
4796
5005
  Enabled: true
4797
5006
  VersionAdded: '0.88'
4798
5007
 
5008
+ Style/RedundantFilterChain:
5009
+ Description: >-
5010
+ Identifies usages of `any?`, `empty?`, `none?` or `one?` predicate methods chained to
5011
+ `select`/`filter`/`find_all` and change them to use predicate method instead.
5012
+ Enabled: pending
5013
+ SafeAutoCorrect: false
5014
+ VersionAdded: '1.52'
5015
+ VersionChanged: '1.57'
5016
+
4799
5017
  Style/RedundantFreeze:
4800
5018
  Description: "Checks usages of Object#freeze on immutable objects."
4801
5019
  Enabled: true
4802
5020
  VersionAdded: '0.34'
4803
5021
  VersionChanged: '0.66'
4804
5022
 
5023
+ Style/RedundantHeredocDelimiterQuotes:
5024
+ Description: 'Checks for redundant heredoc delimiter quotes.'
5025
+ Enabled: pending
5026
+ VersionAdded: '1.45'
5027
+
4805
5028
  Style/RedundantInitialize:
4806
5029
  Description: 'Checks for redundant `initialize` methods.'
4807
5030
  Enabled: pending
5031
+ AutoCorrect: contextual
4808
5032
  Safe: false
4809
5033
  AllowComments: true
4810
5034
  VersionAdded: '1.27'
4811
- VersionChanged: '1.28'
5035
+ VersionChanged: '1.61'
4812
5036
 
4813
5037
  Style/RedundantInterpolation:
4814
5038
  Description: 'Checks for strings that are just an interpolated expression.'
@@ -4817,6 +5041,11 @@ Style/RedundantInterpolation:
4817
5041
  VersionAdded: '0.76'
4818
5042
  VersionChanged: '1.30'
4819
5043
 
5044
+ Style/RedundantLineContinuation:
5045
+ Description: 'Check for redundant line continuation.'
5046
+ Enabled: pending
5047
+ VersionAdded: '1.49'
5048
+
4820
5049
  Style/RedundantParentheses:
4821
5050
  Description: "Checks for parentheses that seem not to serve any purpose."
4822
5051
  Enabled: true
@@ -4828,11 +5057,21 @@ Style/RedundantPercentQ:
4828
5057
  Enabled: true
4829
5058
  VersionAdded: '0.76'
4830
5059
 
5060
+ Style/RedundantRegexpArgument:
5061
+ Description: 'Identifies places where argument can be replaced from a deterministic regexp to a string.'
5062
+ Enabled: pending
5063
+ VersionAdded: '1.53'
5064
+
4831
5065
  Style/RedundantRegexpCharacterClass:
4832
5066
  Description: 'Checks for unnecessary single-element Regexp character classes.'
4833
5067
  Enabled: true
4834
5068
  VersionAdded: '0.85'
4835
5069
 
5070
+ Style/RedundantRegexpConstructor:
5071
+ Description: 'Checks for the instantiation of regexp using redundant `Regexp.new` or `Regexp.compile`.'
5072
+ Enabled: pending
5073
+ VersionAdded: '1.52'
5074
+
4836
5075
  Style/RedundantRegexpEscape:
4837
5076
  Description: 'Checks for redundant escapes in Regexps.'
4838
5077
  Enabled: true
@@ -4935,6 +5174,15 @@ Style/ReturnNil:
4935
5174
  - return_nil
4936
5175
  VersionAdded: '0.50'
4937
5176
 
5177
+ Style/ReturnNilInPredicateMethodDefinition:
5178
+ Description: 'Checks if uses of `return` or `return nil` in predicate method definition.'
5179
+ StyleGuide: '#bool-methods-qmark'
5180
+ Enabled: pending
5181
+ SafeAutoCorrect: false
5182
+ AllowedMethods: []
5183
+ AllowedPatterns: []
5184
+ VersionAdded: '1.53'
5185
+
4938
5186
  Style/SafeNavigation:
4939
5187
  Description: >-
4940
5188
  Transforms usages of a method call safeguarded by
@@ -4962,7 +5210,7 @@ Style/Sample:
4962
5210
  Description: >-
4963
5211
  Use `sample` instead of `shuffle.first`,
4964
5212
  `shuffle.last`, and `shuffle[Integer]`.
4965
- Reference: 'https://github.com/JuanitoFatas/fast-ruby#arrayshufflefirst-vs-arraysample-code'
5213
+ Reference: 'https://github.com/fastruby/fast-ruby#arrayshufflefirst-vs-arraysample-code'
4966
5214
  Enabled: true
4967
5215
  VersionAdded: '0.30'
4968
5216
 
@@ -4996,6 +5244,13 @@ Style/Send:
4996
5244
  Enabled: false
4997
5245
  VersionAdded: '0.33'
4998
5246
 
5247
+ Style/SendWithLiteralMethodName:
5248
+ Description: 'Detects the use of the `public_send` method with a static method name argument.'
5249
+ Enabled: pending
5250
+ Safe: false
5251
+ AllowSend: true
5252
+ VersionAdded: '1.64'
5253
+
4999
5254
  Style/SignalException:
5000
5255
  Description: 'Checks for proper usage of fail and raise.'
5001
5256
  StyleGuide: '#prefer-raise-over-fail'
@@ -5027,6 +5282,12 @@ Style/SingleLineBlockParams:
5027
5282
  - acc
5028
5283
  - elem
5029
5284
 
5285
+ Style/SingleLineDoEndBlock:
5286
+ Description: 'Checks for single-line `do`...`end` blocks.'
5287
+ StyleGuide: '#single-line-do-end-block'
5288
+ Enabled: pending
5289
+ VersionAdded: '1.57'
5290
+
5030
5291
  Style/SingleLineMethods:
5031
5292
  Description: 'Avoid single-line methods.'
5032
5293
  StyleGuide: '#no-single-line-methods'
@@ -5036,7 +5297,8 @@ Style/SingleLineMethods:
5036
5297
  AllowIfMethodIsEmpty: true
5037
5298
 
5038
5299
  Style/SlicingWithRange:
5039
- Description: 'Checks array slicing is done with endless ranges when suitable.'
5300
+ Description: 'Checks array slicing is done with redundant, endless, and beginless ranges when suitable.'
5301
+ StyleGuide: '#slicing-with-ranges'
5040
5302
  Enabled: true
5041
5303
  VersionAdded: '0.83'
5042
5304
  Safe: false
@@ -5163,6 +5425,17 @@ Style/StructInheritance:
5163
5425
  VersionAdded: '0.29'
5164
5426
  VersionChanged: '1.20'
5165
5427
 
5428
+ Style/SuperArguments:
5429
+ Description: 'Call `super` without arguments and parentheses when the signature is identical.'
5430
+ Enabled: pending
5431
+ VersionAdded: '1.64'
5432
+
5433
+ Style/SuperWithArgsParentheses:
5434
+ Description: 'Use parentheses for `super` with arguments.'
5435
+ StyleGuide: '#super-with-args'
5436
+ Enabled: pending
5437
+ VersionAdded: '1.58'
5438
+
5166
5439
  Style/SwapValues:
5167
5440
  Description: 'Enforces the use of shorthand-style swapping of 2 variables.'
5168
5441
  StyleGuide: '#values-swapping'
@@ -5192,14 +5465,13 @@ Style/SymbolProc:
5192
5465
  Enabled: true
5193
5466
  Safe: false
5194
5467
  VersionAdded: '0.26'
5195
- VersionChanged: '1.40'
5468
+ VersionChanged: '1.64'
5196
5469
  AllowMethodsWithArguments: false
5197
5470
  # A list of method names to be always allowed by the check.
5198
5471
  # The names should be fairly unique, otherwise you'll end up ignoring lots of code.
5199
5472
  AllowedMethods:
5200
5473
  - define_method
5201
5474
  AllowedPatterns: []
5202
- IgnoredMethods: [] # deprecated
5203
5475
  AllowComments: false
5204
5476
 
5205
5477
  Style/TernaryParentheses:
@@ -5420,6 +5692,11 @@ Style/WordArray:
5420
5692
  # The regular expression `WordRegex` decides what is considered a word.
5421
5693
  WordRegex: !ruby/regexp '/\A(?:\p{Word}|\p{Word}-\p{Word}|\n|\t)+\z/'
5422
5694
 
5695
+ Style/YAMLFileRead:
5696
+ Description: 'Checks for the use of `YAML.load`, `YAML.safe_load`, and `YAML.parse` with `File.read` argument.'
5697
+ Enabled: pending
5698
+ VersionAdded: '1.53'
5699
+
5423
5700
  Style/YodaCondition:
5424
5701
  Description: 'Forbid or enforce yoda conditions.'
5425
5702
  Reference: 'https://en.wikipedia.org/wiki/Yoda_conditions'
@@ -5440,9 +5717,10 @@ Style/YodaCondition:
5440
5717
 
5441
5718
  Style/YodaExpression:
5442
5719
  Description: 'Forbid the use of yoda expressions.'
5443
- Enabled: pending
5720
+ Enabled: false
5444
5721
  Safe: false
5445
5722
  VersionAdded: '1.42'
5723
+ VersionChanged: '1.43'
5446
5724
  SupportedOperators:
5447
5725
  - '*'
5448
5726
  - '+'