rubocop 1.34.1 → 1.54.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (474) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +1 -1
  3. data/README.md +4 -4
  4. data/config/default.yml +345 -54
  5. data/exe/rubocop +1 -1
  6. data/lib/rubocop/arguments_env.rb +17 -0
  7. data/lib/rubocop/arguments_file.rb +17 -0
  8. data/lib/rubocop/cli/command/{auto_genenerate_config.rb → auto_generate_config.rb} +7 -0
  9. data/lib/rubocop/cli/command/execute_runner.rb +14 -9
  10. data/lib/rubocop/cli/command/lsp.rb +19 -0
  11. data/lib/rubocop/cli/command/suggest_extensions.rb +8 -1
  12. data/lib/rubocop/cli.rb +58 -9
  13. data/lib/rubocop/comment_config.rb +60 -1
  14. data/lib/rubocop/config.rb +47 -19
  15. data/lib/rubocop/config_loader.rb +34 -28
  16. data/lib/rubocop/config_loader_resolver.rb +6 -2
  17. data/lib/rubocop/config_obsoletion.rb +2 -2
  18. data/lib/rubocop/config_validator.rb +1 -1
  19. data/lib/rubocop/cop/autocorrect_logic.rb +29 -13
  20. data/lib/rubocop/cop/badge.rb +9 -4
  21. data/lib/rubocop/cop/base.rb +115 -83
  22. data/lib/rubocop/cop/bundler/gem_comment.rb +2 -2
  23. data/lib/rubocop/cop/bundler/gem_version.rb +2 -2
  24. data/lib/rubocop/cop/commissioner.rb +19 -6
  25. data/lib/rubocop/cop/cop.rb +53 -33
  26. data/lib/rubocop/cop/corrector.rb +31 -11
  27. data/lib/rubocop/cop/correctors/alignment_corrector.rb +3 -3
  28. data/lib/rubocop/cop/correctors/each_to_for_corrector.rb +3 -3
  29. data/lib/rubocop/cop/correctors/for_to_each_corrector.rb +3 -3
  30. data/lib/rubocop/cop/correctors/line_break_corrector.rb +1 -1
  31. data/lib/rubocop/cop/correctors/multiline_literal_brace_corrector.rb +23 -7
  32. data/lib/rubocop/cop/correctors/ordered_gem_corrector.rb +2 -7
  33. data/lib/rubocop/cop/correctors/parentheses_corrector.rb +32 -2
  34. data/lib/rubocop/cop/correctors/percent_literal_corrector.rb +2 -2
  35. data/lib/rubocop/cop/gemspec/dependency_version.rb +19 -21
  36. data/lib/rubocop/cop/gemspec/deprecated_attribute_assignment.rb +1 -1
  37. data/lib/rubocop/cop/gemspec/development_dependencies.rb +107 -0
  38. data/lib/rubocop/cop/gemspec/require_mfa.rb +1 -1
  39. data/lib/rubocop/cop/generator/require_file_injector.rb +2 -2
  40. data/lib/rubocop/cop/generator.rb +1 -2
  41. data/lib/rubocop/cop/internal_affairs/cop_description.rb +38 -12
  42. data/lib/rubocop/cop/internal_affairs/create_empty_file.rb +37 -0
  43. data/lib/rubocop/cop/internal_affairs/example_heredoc_delimiter.rb +111 -0
  44. data/lib/rubocop/cop/internal_affairs/inherit_deprecated_cop_class.rb +1 -1
  45. data/lib/rubocop/cop/internal_affairs/lambda_or_proc.rb +46 -0
  46. data/lib/rubocop/cop/internal_affairs/location_expression.rb +37 -0
  47. data/lib/rubocop/cop/internal_affairs/node_matcher_directive.rb +6 -6
  48. data/lib/rubocop/cop/internal_affairs/node_type_predicate.rb +1 -1
  49. data/lib/rubocop/cop/internal_affairs/numblock_handler.rb +69 -0
  50. data/lib/rubocop/cop/internal_affairs/processed_source_buffer_name.rb +42 -0
  51. data/lib/rubocop/cop/internal_affairs/redundant_let_rubocop_config_new.rb +11 -3
  52. data/lib/rubocop/cop/internal_affairs/redundant_location_argument.rb +1 -1
  53. data/lib/rubocop/cop/internal_affairs/redundant_message_argument.rb +1 -1
  54. data/lib/rubocop/cop/internal_affairs/redundant_source_range.rb +66 -0
  55. data/lib/rubocop/cop/internal_affairs/single_line_comparison.rb +5 -4
  56. data/lib/rubocop/cop/internal_affairs.rb +7 -0
  57. data/lib/rubocop/cop/layout/array_alignment.rb +1 -1
  58. data/lib/rubocop/cop/layout/block_alignment.rb +16 -12
  59. data/lib/rubocop/cop/layout/block_end_newline.rb +9 -15
  60. data/lib/rubocop/cop/layout/class_structure.rb +44 -27
  61. data/lib/rubocop/cop/layout/closing_heredoc_indentation.rb +2 -3
  62. data/lib/rubocop/cop/layout/closing_parenthesis_indentation.rb +2 -6
  63. data/lib/rubocop/cop/layout/comment_indentation.rb +3 -1
  64. data/lib/rubocop/cop/layout/empty_comment.rb +3 -3
  65. data/lib/rubocop/cop/layout/empty_line_between_defs.rb +28 -5
  66. data/lib/rubocop/cop/layout/empty_lines.rb +3 -1
  67. data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +7 -2
  68. data/lib/rubocop/cop/layout/empty_lines_around_block_body.rb +2 -0
  69. data/lib/rubocop/cop/layout/empty_lines_around_exception_handling_keywords.rb +2 -0
  70. data/lib/rubocop/cop/layout/end_alignment.rb +9 -1
  71. data/lib/rubocop/cop/layout/end_of_line.rb +4 -4
  72. data/lib/rubocop/cop/layout/extra_spacing.rb +15 -6
  73. data/lib/rubocop/cop/layout/first_argument_indentation.rb +9 -3
  74. data/lib/rubocop/cop/layout/first_array_element_indentation.rb +2 -2
  75. data/lib/rubocop/cop/layout/first_array_element_line_break.rb +35 -8
  76. data/lib/rubocop/cop/layout/first_hash_element_indentation.rb +2 -2
  77. data/lib/rubocop/cop/layout/first_hash_element_line_break.rb +36 -1
  78. data/lib/rubocop/cop/layout/first_method_argument_line_break.rb +57 -8
  79. data/lib/rubocop/cop/layout/first_method_parameter_line_break.rb +52 -19
  80. data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +10 -4
  81. data/lib/rubocop/cop/layout/heredoc_indentation.rb +8 -11
  82. data/lib/rubocop/cop/layout/indentation_style.rb +8 -3
  83. data/lib/rubocop/cop/layout/indentation_width.rb +8 -4
  84. data/lib/rubocop/cop/layout/initial_indentation.rb +1 -1
  85. data/lib/rubocop/cop/layout/leading_comment_space.rb +1 -1
  86. data/lib/rubocop/cop/layout/line_continuation_leading_space.rb +33 -9
  87. data/lib/rubocop/cop/layout/line_continuation_spacing.rb +18 -8
  88. data/lib/rubocop/cop/layout/line_end_string_concatenation_indentation.rb +2 -0
  89. data/lib/rubocop/cop/layout/line_length.rb +6 -1
  90. data/lib/rubocop/cop/layout/multiline_array_line_breaks.rb +31 -1
  91. data/lib/rubocop/cop/layout/multiline_block_layout.rb +3 -1
  92. data/lib/rubocop/cop/layout/multiline_hash_key_line_breaks.rb +29 -1
  93. data/lib/rubocop/cop/layout/multiline_method_argument_line_breaks.rb +35 -1
  94. data/lib/rubocop/cop/layout/multiline_method_parameter_line_breaks.rb +33 -1
  95. data/lib/rubocop/cop/layout/redundant_line_break.rb +10 -11
  96. data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +2 -2
  97. data/lib/rubocop/cop/layout/space_around_block_parameters.rb +1 -1
  98. data/lib/rubocop/cop/layout/space_around_keyword.rb +3 -3
  99. data/lib/rubocop/cop/layout/space_around_operators.rb +4 -2
  100. data/lib/rubocop/cop/layout/space_before_block_braces.rb +2 -0
  101. data/lib/rubocop/cop/layout/space_before_first_arg.rb +1 -1
  102. data/lib/rubocop/cop/layout/space_in_lambda_literal.rb +2 -2
  103. data/lib/rubocop/cop/layout/space_inside_array_literal_brackets.rb +22 -20
  104. data/lib/rubocop/cop/layout/space_inside_array_percent_literal.rb +3 -0
  105. data/lib/rubocop/cop/layout/space_inside_block_braces.rb +27 -9
  106. data/lib/rubocop/cop/layout/space_inside_hash_literal_braces.rb +30 -3
  107. data/lib/rubocop/cop/layout/space_inside_parens.rb +2 -2
  108. data/lib/rubocop/cop/layout/space_inside_percent_literal_delimiters.rb +34 -0
  109. data/lib/rubocop/cop/layout/space_inside_range_literal.rb +1 -1
  110. data/lib/rubocop/cop/layout/space_inside_reference_brackets.rb +10 -6
  111. data/lib/rubocop/cop/layout/space_inside_string_interpolation.rb +5 -4
  112. data/lib/rubocop/cop/layout/trailing_empty_lines.rb +1 -1
  113. data/lib/rubocop/cop/layout/trailing_whitespace.rb +12 -5
  114. data/lib/rubocop/cop/lint/ambiguous_block_association.rb +16 -4
  115. data/lib/rubocop/cop/lint/ambiguous_operator.rb +4 -0
  116. data/lib/rubocop/cop/lint/assignment_in_condition.rb +11 -1
  117. data/lib/rubocop/cop/lint/constant_resolution.rb +5 -1
  118. data/lib/rubocop/cop/lint/debugger.rb +16 -26
  119. data/lib/rubocop/cop/lint/deprecated_class_methods.rb +62 -112
  120. data/lib/rubocop/cop/lint/deprecated_constants.rb +8 -1
  121. data/lib/rubocop/cop/lint/deprecated_open_ssl_constant.rb +1 -1
  122. data/lib/rubocop/cop/lint/duplicate_branch.rb +0 -2
  123. data/lib/rubocop/cop/lint/duplicate_hash_key.rb +2 -1
  124. data/lib/rubocop/cop/lint/duplicate_magic_comment.rb +73 -0
  125. data/lib/rubocop/cop/lint/duplicate_match_pattern.rb +122 -0
  126. data/lib/rubocop/cop/lint/duplicate_methods.rb +48 -18
  127. data/lib/rubocop/cop/lint/duplicate_regexp_character_class_element.rb +55 -11
  128. data/lib/rubocop/cop/lint/duplicate_require.rb +1 -1
  129. data/lib/rubocop/cop/lint/else_layout.rb +3 -7
  130. data/lib/rubocop/cop/lint/empty_block.rb +3 -7
  131. data/lib/rubocop/cop/lint/empty_class.rb +3 -1
  132. data/lib/rubocop/cop/lint/empty_conditional_body.rb +51 -7
  133. data/lib/rubocop/cop/lint/empty_interpolation.rb +1 -1
  134. data/lib/rubocop/cop/lint/erb_new_arguments.rb +12 -13
  135. data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +14 -7
  136. data/lib/rubocop/cop/lint/heredoc_method_call_position.rb +16 -18
  137. data/lib/rubocop/cop/lint/identity_comparison.rb +0 -1
  138. data/lib/rubocop/cop/lint/implicit_string_concatenation.rb +1 -1
  139. data/lib/rubocop/cop/lint/incompatible_io_select_with_fiber_scheduler.rb +5 -3
  140. data/lib/rubocop/cop/lint/ineffective_access_modifier.rb +1 -1
  141. data/lib/rubocop/cop/lint/inherit_exception.rb +9 -0
  142. data/lib/rubocop/cop/lint/interpolation_check.rb +4 -3
  143. data/lib/rubocop/cop/lint/lambda_without_literal_block.rb +1 -1
  144. data/lib/rubocop/cop/lint/literal_in_interpolation.rb +48 -2
  145. data/lib/rubocop/cop/lint/missing_cop_enable_directive.rb +18 -3
  146. data/lib/rubocop/cop/lint/missing_super.rb +63 -5
  147. data/lib/rubocop/cop/lint/mixed_case_range.rb +111 -0
  148. data/lib/rubocop/cop/lint/mixed_regexp_capture_types.rb +1 -0
  149. data/lib/rubocop/cop/lint/nested_method_definition.rb +53 -9
  150. data/lib/rubocop/cop/lint/next_without_accumulator.rb +25 -6
  151. data/lib/rubocop/cop/lint/non_atomic_file_operation.rb +15 -10
  152. data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +12 -0
  153. data/lib/rubocop/cop/lint/number_conversion.rb +6 -1
  154. data/lib/rubocop/cop/lint/numbered_parameter_assignment.rb +2 -2
  155. data/lib/rubocop/cop/lint/or_assignment_to_constant.rb +2 -0
  156. data/lib/rubocop/cop/lint/ordered_magic_comments.rb +4 -6
  157. data/lib/rubocop/cop/lint/out_of_range_regexp_ref.rb +17 -2
  158. data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +5 -0
  159. data/lib/rubocop/cop/lint/percent_string_array.rb +1 -1
  160. data/lib/rubocop/cop/lint/percent_symbol_array.rb +1 -1
  161. data/lib/rubocop/cop/lint/redundant_cop_disable_directive.rb +49 -9
  162. data/lib/rubocop/cop/lint/redundant_cop_enable_directive.rb +6 -6
  163. data/lib/rubocop/cop/lint/redundant_dir_glob_sort.rb +7 -0
  164. data/lib/rubocop/cop/lint/redundant_regexp_quantifiers.rb +120 -0
  165. data/lib/rubocop/cop/lint/redundant_require_statement.rb +53 -10
  166. data/lib/rubocop/cop/lint/redundant_safe_navigation.rb +9 -3
  167. data/lib/rubocop/cop/lint/redundant_splat_expansion.rb +1 -1
  168. data/lib/rubocop/cop/lint/redundant_string_coercion.rb +35 -15
  169. data/lib/rubocop/cop/lint/redundant_with_index.rb +14 -11
  170. data/lib/rubocop/cop/lint/redundant_with_object.rb +13 -12
  171. data/lib/rubocop/cop/lint/refinement_import_methods.rb +2 -1
  172. data/lib/rubocop/cop/lint/regexp_as_condition.rb +6 -0
  173. data/lib/rubocop/cop/lint/require_parentheses.rb +3 -1
  174. data/lib/rubocop/cop/lint/rescue_type.rb +3 -3
  175. data/lib/rubocop/cop/lint/safe_navigation_chain.rb +13 -14
  176. data/lib/rubocop/cop/lint/safe_navigation_consistency.rb +1 -1
  177. data/lib/rubocop/cop/lint/script_permission.rb +1 -1
  178. data/lib/rubocop/cop/lint/send_with_mixin_argument.rb +6 -6
  179. data/lib/rubocop/cop/lint/shadowed_exception.rb +7 -23
  180. data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +19 -2
  181. data/lib/rubocop/cop/lint/suppressed_exception.rb +2 -2
  182. data/lib/rubocop/cop/lint/symbol_conversion.rb +1 -1
  183. data/lib/rubocop/cop/lint/syntax.rb +4 -0
  184. data/lib/rubocop/cop/lint/to_enum_arguments.rb +13 -3
  185. data/lib/rubocop/cop/lint/top_level_return_with_argument.rb +23 -9
  186. data/lib/rubocop/cop/lint/unreachable_loop.rb +12 -6
  187. data/lib/rubocop/cop/lint/unused_method_argument.rb +6 -1
  188. data/lib/rubocop/cop/lint/useless_access_modifier.rb +17 -12
  189. data/lib/rubocop/cop/lint/useless_assignment.rb +59 -1
  190. data/lib/rubocop/cop/lint/useless_method_definition.rb +12 -4
  191. data/lib/rubocop/cop/lint/useless_rescue.rb +89 -0
  192. data/lib/rubocop/cop/lint/useless_ruby2_keywords.rb +15 -5
  193. data/lib/rubocop/cop/lint/useless_times.rb +1 -1
  194. data/lib/rubocop/cop/lint/void.rb +86 -21
  195. data/lib/rubocop/cop/metrics/abc_size.rb +1 -1
  196. data/lib/rubocop/cop/metrics/block_length.rb +10 -5
  197. data/lib/rubocop/cop/metrics/block_nesting.rb +2 -2
  198. data/lib/rubocop/cop/metrics/class_length.rb +11 -5
  199. data/lib/rubocop/cop/metrics/collection_literal_length.rb +76 -0
  200. data/lib/rubocop/cop/metrics/cyclomatic_complexity.rb +1 -1
  201. data/lib/rubocop/cop/metrics/method_length.rb +9 -4
  202. data/lib/rubocop/cop/metrics/module_length.rb +10 -5
  203. data/lib/rubocop/cop/metrics/parameter_lists.rb +27 -0
  204. data/lib/rubocop/cop/metrics/perceived_complexity.rb +1 -1
  205. data/lib/rubocop/cop/metrics/utils/abc_size_calculator.rb +4 -8
  206. data/lib/rubocop/cop/metrics/utils/code_length_calculator.rb +39 -8
  207. data/lib/rubocop/cop/migration/department_name.rb +3 -3
  208. data/lib/rubocop/cop/mixin/alignment.rb +2 -2
  209. data/lib/rubocop/cop/mixin/allowed_identifiers.rb +2 -2
  210. data/lib/rubocop/cop/mixin/allowed_methods.rb +13 -6
  211. data/lib/rubocop/cop/mixin/allowed_pattern.rb +13 -5
  212. data/lib/rubocop/cop/mixin/allowed_receivers.rb +34 -0
  213. data/lib/rubocop/cop/mixin/annotation_comment.rb +14 -7
  214. data/lib/rubocop/cop/mixin/check_line_breakable.rb +1 -1
  215. data/lib/rubocop/cop/mixin/code_length.rb +1 -1
  216. data/lib/rubocop/cop/mixin/comments_help.rb +24 -6
  217. data/lib/rubocop/cop/mixin/configurable_enforced_style.rb +21 -9
  218. data/lib/rubocop/cop/mixin/documentation_comment.rb +1 -1
  219. data/lib/rubocop/cop/mixin/end_keyword_alignment.rb +1 -1
  220. data/lib/rubocop/cop/mixin/first_element_line_break.rb +11 -7
  221. data/lib/rubocop/cop/mixin/frozen_string_literal.rb +4 -0
  222. data/lib/rubocop/cop/mixin/hash_alignment_styles.rb +1 -1
  223. data/lib/rubocop/cop/mixin/hash_shorthand_syntax.rb +152 -12
  224. data/lib/rubocop/cop/mixin/hash_transform_method.rb +13 -9
  225. data/lib/rubocop/cop/mixin/heredoc.rb +6 -2
  226. data/lib/rubocop/cop/mixin/line_length_help.rb +11 -2
  227. data/lib/rubocop/cop/mixin/method_complexity.rb +9 -7
  228. data/lib/rubocop/cop/mixin/min_branches_count.rb +40 -0
  229. data/lib/rubocop/cop/mixin/multiline_element_indentation.rb +1 -1
  230. data/lib/rubocop/cop/mixin/multiline_element_line_breaks.rb +5 -6
  231. data/lib/rubocop/cop/mixin/ordered_gem_node.rb +1 -1
  232. data/lib/rubocop/cop/mixin/percent_array.rb +3 -5
  233. data/lib/rubocop/cop/mixin/percent_literal.rb +1 -1
  234. data/lib/rubocop/cop/mixin/preceding_following_alignment.rb +1 -1
  235. data/lib/rubocop/cop/mixin/range_help.rb +20 -3
  236. data/lib/rubocop/cop/mixin/require_library.rb +2 -0
  237. data/lib/rubocop/cop/mixin/rescue_node.rb +5 -3
  238. data/lib/rubocop/cop/mixin/space_after_punctuation.rb +1 -1
  239. data/lib/rubocop/cop/mixin/statement_modifier.rb +18 -3
  240. data/lib/rubocop/cop/mixin/surrounding_space.rb +13 -11
  241. data/lib/rubocop/cop/mixin/trailing_comma.rb +2 -2
  242. data/lib/rubocop/cop/mixin/visibility_help.rb +40 -5
  243. data/lib/rubocop/cop/naming/ascii_identifiers.rb +1 -1
  244. data/lib/rubocop/cop/naming/block_forwarding.rb +6 -2
  245. data/lib/rubocop/cop/naming/block_parameter_name.rb +1 -1
  246. data/lib/rubocop/cop/naming/class_and_module_camel_case.rb +3 -1
  247. data/lib/rubocop/cop/naming/constant_name.rb +3 -3
  248. data/lib/rubocop/cop/naming/heredoc_delimiter_case.rb +1 -1
  249. data/lib/rubocop/cop/naming/inclusive_language.rb +28 -6
  250. data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +25 -10
  251. data/lib/rubocop/cop/naming/method_name.rb +3 -3
  252. data/lib/rubocop/cop/naming/predicate_name.rb +1 -1
  253. data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +12 -4
  254. data/lib/rubocop/cop/naming/variable_name.rb +6 -1
  255. data/lib/rubocop/cop/registry.rb +73 -45
  256. data/lib/rubocop/cop/security/compound_hash.rb +2 -1
  257. data/lib/rubocop/cop/style/access_modifier_declarations.rb +92 -3
  258. data/lib/rubocop/cop/style/accessor_grouping.rb +50 -20
  259. data/lib/rubocop/cop/style/alias.rb +9 -1
  260. data/lib/rubocop/cop/style/arguments_forwarding.rb +6 -5
  261. data/lib/rubocop/cop/style/array_intersect.rb +111 -0
  262. data/lib/rubocop/cop/style/ascii_comments.rb +1 -1
  263. data/lib/rubocop/cop/style/attr.rb +11 -1
  264. data/lib/rubocop/cop/style/begin_block.rb +1 -2
  265. data/lib/rubocop/cop/style/bisected_attr_accessor.rb +1 -1
  266. data/lib/rubocop/cop/style/block_comments.rb +3 -3
  267. data/lib/rubocop/cop/style/block_delimiters.rb +22 -7
  268. data/lib/rubocop/cop/style/case_equality.rb +40 -10
  269. data/lib/rubocop/cop/style/case_like_if.rb +20 -3
  270. data/lib/rubocop/cop/style/character_literal.rb +1 -1
  271. data/lib/rubocop/cop/style/class_and_module_children.rb +5 -12
  272. data/lib/rubocop/cop/style/class_equality_comparison.rb +58 -45
  273. data/lib/rubocop/cop/style/class_methods_definitions.rb +2 -1
  274. data/lib/rubocop/cop/style/collection_compact.rb +27 -5
  275. data/lib/rubocop/cop/style/collection_methods.rb +2 -0
  276. data/lib/rubocop/cop/style/colon_method_call.rb +2 -2
  277. data/lib/rubocop/cop/style/combinable_loops.rb +29 -7
  278. data/lib/rubocop/cop/style/command_literal.rb +1 -1
  279. data/lib/rubocop/cop/style/comment_annotation.rb +1 -1
  280. data/lib/rubocop/cop/style/commented_keyword.rb +2 -2
  281. data/lib/rubocop/cop/style/comparable_clamp.rb +125 -0
  282. data/lib/rubocop/cop/style/concat_array_literals.rb +94 -0
  283. data/lib/rubocop/cop/style/conditional_assignment.rb +11 -15
  284. data/lib/rubocop/cop/style/copyright.rb +6 -3
  285. data/lib/rubocop/cop/style/data_inheritance.rb +75 -0
  286. data/lib/rubocop/cop/style/dir.rb +1 -1
  287. data/lib/rubocop/cop/style/dir_empty.rb +54 -0
  288. data/lib/rubocop/cop/style/disable_cops_within_source_code_directive.rb +2 -2
  289. data/lib/rubocop/cop/style/document_dynamic_eval_definition.rb +3 -3
  290. data/lib/rubocop/cop/style/documentation.rb +22 -10
  291. data/lib/rubocop/cop/style/documentation_method.rb +10 -4
  292. data/lib/rubocop/cop/style/double_negation.rb +2 -2
  293. data/lib/rubocop/cop/style/each_for_simple_loop.rb +41 -6
  294. data/lib/rubocop/cop/style/each_with_object.rb +40 -9
  295. data/lib/rubocop/cop/style/empty_block_parameter.rb +2 -2
  296. data/lib/rubocop/cop/style/empty_lambda_parameter.rb +2 -2
  297. data/lib/rubocop/cop/style/empty_method.rb +1 -1
  298. data/lib/rubocop/cop/style/endless_method.rb +1 -1
  299. data/lib/rubocop/cop/style/eval_with_location.rb +8 -8
  300. data/lib/rubocop/cop/style/exact_regexp_match.rb +68 -0
  301. data/lib/rubocop/cop/style/explicit_block_argument.rb +5 -1
  302. data/lib/rubocop/cop/style/file_empty.rb +71 -0
  303. data/lib/rubocop/cop/style/file_read.rb +3 -3
  304. data/lib/rubocop/cop/style/file_write.rb +1 -1
  305. data/lib/rubocop/cop/style/for.rb +2 -0
  306. data/lib/rubocop/cop/style/format_string_token.rb +1 -1
  307. data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +1 -1
  308. data/lib/rubocop/cop/style/guard_clause.rb +127 -38
  309. data/lib/rubocop/cop/style/hash_as_last_array_item.rb +1 -0
  310. data/lib/rubocop/cop/style/hash_each_methods.rb +36 -21
  311. data/lib/rubocop/cop/style/hash_except.rb +27 -12
  312. data/lib/rubocop/cop/style/hash_like_case.rb +3 -9
  313. data/lib/rubocop/cop/style/hash_syntax.rb +26 -2
  314. data/lib/rubocop/cop/style/hash_transform_keys.rb +2 -2
  315. data/lib/rubocop/cop/style/hash_transform_values.rb +2 -2
  316. data/lib/rubocop/cop/style/identical_conditional_branches.rb +21 -2
  317. data/lib/rubocop/cop/style/if_inside_else.rb +6 -0
  318. data/lib/rubocop/cop/style/if_unless_modifier.rb +111 -15
  319. data/lib/rubocop/cop/style/if_with_boolean_literal_branches.rb +27 -2
  320. data/lib/rubocop/cop/style/if_with_semicolon.rb +6 -6
  321. data/lib/rubocop/cop/style/infinite_loop.rb +2 -5
  322. data/lib/rubocop/cop/style/inverse_methods.rb +15 -11
  323. data/lib/rubocop/cop/style/invertible_unless_condition.rb +118 -0
  324. data/lib/rubocop/cop/style/lambda.rb +3 -3
  325. data/lib/rubocop/cop/style/line_end_concatenation.rb +4 -1
  326. data/lib/rubocop/cop/style/magic_comment_format.rb +307 -0
  327. data/lib/rubocop/cop/style/map_compact_with_conditional_block.rb +2 -2
  328. data/lib/rubocop/cop/style/map_to_hash.rb +4 -1
  329. data/lib/rubocop/cop/style/map_to_set.rb +64 -0
  330. data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +41 -26
  331. data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +44 -37
  332. data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +2 -0
  333. data/lib/rubocop/cop/style/method_called_on_do_end_block.rb +4 -1
  334. data/lib/rubocop/cop/style/method_def_parentheses.rb +11 -4
  335. data/lib/rubocop/cop/style/min_max.rb +3 -3
  336. data/lib/rubocop/cop/style/min_max_comparison.rb +83 -0
  337. data/lib/rubocop/cop/style/missing_else.rb +13 -1
  338. data/lib/rubocop/cop/style/mixin_grouping.rb +4 -4
  339. data/lib/rubocop/cop/style/module_function.rb +28 -6
  340. data/lib/rubocop/cop/style/multiline_block_chain.rb +3 -1
  341. data/lib/rubocop/cop/style/multiline_if_modifier.rb +0 -4
  342. data/lib/rubocop/cop/style/multiline_in_pattern_then.rb +1 -1
  343. data/lib/rubocop/cop/style/multiline_memoization.rb +2 -2
  344. data/lib/rubocop/cop/style/multiline_method_signature.rb +7 -4
  345. data/lib/rubocop/cop/style/multiline_ternary_operator.rb +18 -3
  346. data/lib/rubocop/cop/style/multiple_comparison.rb +14 -0
  347. data/lib/rubocop/cop/style/negated_if_else_condition.rb +17 -10
  348. data/lib/rubocop/cop/style/next.rb +3 -5
  349. data/lib/rubocop/cop/style/nil_lambda.rb +4 -4
  350. data/lib/rubocop/cop/style/numbered_parameters_limit.rb +11 -3
  351. data/lib/rubocop/cop/style/numeric_literals.rb +1 -1
  352. data/lib/rubocop/cop/style/numeric_predicate.rb +1 -1
  353. data/lib/rubocop/cop/style/object_then.rb +5 -0
  354. data/lib/rubocop/cop/style/one_line_conditional.rb +3 -6
  355. data/lib/rubocop/cop/style/operator_method_call.rb +67 -0
  356. data/lib/rubocop/cop/style/parallel_assignment.rb +29 -19
  357. data/lib/rubocop/cop/style/percent_literal_delimiters.rb +2 -3
  358. data/lib/rubocop/cop/style/percent_q_literals.rb +1 -1
  359. data/lib/rubocop/cop/style/perl_backrefs.rb +22 -1
  360. data/lib/rubocop/cop/style/preferred_hash_methods.rb +1 -1
  361. data/lib/rubocop/cop/style/proc.rb +4 -1
  362. data/lib/rubocop/cop/style/quoted_symbols.rb +1 -1
  363. data/lib/rubocop/cop/style/redundant_argument.rb +3 -0
  364. data/lib/rubocop/cop/style/redundant_array_constructor.rb +77 -0
  365. data/lib/rubocop/cop/style/redundant_begin.rb +4 -1
  366. data/lib/rubocop/cop/style/redundant_condition.rb +22 -4
  367. data/lib/rubocop/cop/style/redundant_conditional.rb +1 -5
  368. data/lib/rubocop/cop/style/redundant_constant_base.rb +85 -0
  369. data/lib/rubocop/cop/style/redundant_current_directory_in_path.rb +38 -0
  370. data/lib/rubocop/cop/style/redundant_double_splat_hash_braces.rb +45 -0
  371. data/lib/rubocop/cop/style/redundant_each.rb +116 -0
  372. data/lib/rubocop/cop/style/redundant_fetch_block.rb +7 -5
  373. data/lib/rubocop/cop/style/redundant_filter_chain.rb +101 -0
  374. data/lib/rubocop/cop/style/redundant_heredoc_delimiter_quotes.rb +58 -0
  375. data/lib/rubocop/cop/style/redundant_initialize.rb +3 -1
  376. data/lib/rubocop/cop/style/redundant_interpolation.rb +2 -2
  377. data/lib/rubocop/cop/style/redundant_line_continuation.rb +183 -0
  378. data/lib/rubocop/cop/style/redundant_parentheses.rb +7 -3
  379. data/lib/rubocop/cop/style/redundant_percent_q.rb +1 -1
  380. data/lib/rubocop/cop/style/redundant_regexp_argument.rb +99 -0
  381. data/lib/rubocop/cop/style/redundant_regexp_character_class.rb +9 -3
  382. data/lib/rubocop/cop/style/redundant_regexp_constructor.rb +46 -0
  383. data/lib/rubocop/cop/style/redundant_regexp_escape.rb +22 -4
  384. data/lib/rubocop/cop/style/redundant_return.rb +7 -0
  385. data/lib/rubocop/cop/style/redundant_self.rb +2 -0
  386. data/lib/rubocop/cop/style/redundant_self_assignment_branch.rb +3 -1
  387. data/lib/rubocop/cop/style/redundant_sort.rb +5 -5
  388. data/lib/rubocop/cop/style/redundant_sort_by.rb +24 -8
  389. data/lib/rubocop/cop/style/redundant_string_escape.rb +185 -0
  390. data/lib/rubocop/cop/style/regexp_literal.rb +11 -2
  391. data/lib/rubocop/cop/style/require_order.rb +139 -0
  392. data/lib/rubocop/cop/style/rescue_modifier.rb +2 -4
  393. data/lib/rubocop/cop/style/rescue_standard_error.rb +2 -2
  394. data/lib/rubocop/cop/style/return_nil_in_predicate_method_definition.rb +81 -0
  395. data/lib/rubocop/cop/style/safe_navigation.rb +41 -10
  396. data/lib/rubocop/cop/style/select_by_regexp.rb +23 -5
  397. data/lib/rubocop/cop/style/self_assignment.rb +2 -2
  398. data/lib/rubocop/cop/style/semicolon.rb +37 -3
  399. data/lib/rubocop/cop/style/signal_exception.rb +9 -7
  400. data/lib/rubocop/cop/style/single_line_block_params.rb +1 -1
  401. data/lib/rubocop/cop/style/single_line_methods.rb +1 -1
  402. data/lib/rubocop/cop/style/slicing_with_range.rb +1 -1
  403. data/lib/rubocop/cop/style/sole_nested_conditional.rb +6 -6
  404. data/lib/rubocop/cop/style/special_global_vars.rb +3 -4
  405. data/lib/rubocop/cop/style/static_class.rb +32 -1
  406. data/lib/rubocop/cop/style/stderr_puts.rb +1 -1
  407. data/lib/rubocop/cop/style/string_hash_keys.rb +4 -1
  408. data/lib/rubocop/cop/style/string_literals.rb +1 -5
  409. data/lib/rubocop/cop/style/struct_inheritance.rb +1 -1
  410. data/lib/rubocop/cop/style/symbol_array.rb +4 -2
  411. data/lib/rubocop/cop/style/symbol_proc.rb +8 -9
  412. data/lib/rubocop/cop/style/top_level_method_definition.rb +3 -1
  413. data/lib/rubocop/cop/style/trailing_body_on_class.rb +1 -0
  414. data/lib/rubocop/cop/style/trailing_comma_in_arguments.rb +4 -4
  415. data/lib/rubocop/cop/style/trailing_comma_in_block_args.rb +1 -1
  416. data/lib/rubocop/cop/style/trailing_underscore_variable.rb +1 -1
  417. data/lib/rubocop/cop/style/trivial_accessors.rb +1 -1
  418. data/lib/rubocop/cop/style/unless_logical_operators.rb +1 -0
  419. data/lib/rubocop/cop/style/unpack_first.rb +3 -3
  420. data/lib/rubocop/cop/style/word_array.rb +57 -2
  421. data/lib/rubocop/cop/style/yaml_file_read.rb +66 -0
  422. data/lib/rubocop/cop/style/yoda_condition.rb +17 -8
  423. data/lib/rubocop/cop/style/yoda_expression.rb +90 -0
  424. data/lib/rubocop/cop/style/zero_length_predicate.rb +40 -19
  425. data/lib/rubocop/cop/team.rb +63 -56
  426. data/lib/rubocop/cop/util.rb +45 -9
  427. data/lib/rubocop/cop/utils/regexp_ranges.rb +100 -0
  428. data/lib/rubocop/cop/variable_force/assignment.rb +34 -2
  429. data/lib/rubocop/cop/variable_force/scope.rb +3 -3
  430. data/lib/rubocop/cop/variable_force/variable.rb +5 -3
  431. data/lib/rubocop/cop/variable_force/variable_table.rb +6 -4
  432. data/lib/rubocop/cop/variable_force.rb +19 -30
  433. data/lib/rubocop/cops_documentation_generator.rb +45 -15
  434. data/lib/rubocop/directive_comment.rb +4 -4
  435. data/lib/rubocop/ext/comment.rb +18 -0
  436. data/lib/rubocop/ext/processed_source.rb +2 -0
  437. data/lib/rubocop/ext/regexp_node.rb +1 -1
  438. data/lib/rubocop/ext/regexp_parser.rb +5 -2
  439. data/lib/rubocop/feature_loader.rb +6 -2
  440. data/lib/rubocop/file_patterns.rb +43 -0
  441. data/lib/rubocop/formatter/disabled_config_formatter.rb +25 -8
  442. data/lib/rubocop/formatter/html_formatter.rb +3 -3
  443. data/lib/rubocop/formatter/junit_formatter.rb +4 -1
  444. data/lib/rubocop/formatter/offense_count_formatter.rb +8 -5
  445. data/lib/rubocop/formatter/simple_text_formatter.rb +1 -1
  446. data/lib/rubocop/formatter/worst_offenders_formatter.rb +6 -3
  447. data/lib/rubocop/formatter.rb +4 -1
  448. data/lib/rubocop/lsp/logger.rb +22 -0
  449. data/lib/rubocop/lsp/routes.rb +231 -0
  450. data/lib/rubocop/lsp/runtime.rb +82 -0
  451. data/lib/rubocop/lsp/server.rb +66 -0
  452. data/lib/rubocop/lsp/severity.rb +27 -0
  453. data/lib/rubocop/options.rb +63 -17
  454. data/lib/rubocop/path_util.rb +50 -22
  455. data/lib/rubocop/result_cache.rb +4 -4
  456. data/lib/rubocop/rspec/cop_helper.rb +26 -3
  457. data/lib/rubocop/rspec/expect_offense.rb +6 -4
  458. data/lib/rubocop/rspec/shared_contexts.rb +18 -1
  459. data/lib/rubocop/rspec/support.rb +3 -2
  460. data/lib/rubocop/runner.rb +69 -18
  461. data/lib/rubocop/server/cache.rb +24 -10
  462. data/lib/rubocop/server/cli.rb +45 -19
  463. data/lib/rubocop/server/client_command/exec.rb +8 -2
  464. data/lib/rubocop/server/client_command/start.rb +6 -1
  465. data/lib/rubocop/server/core.rb +42 -10
  466. data/lib/rubocop/server/helper.rb +1 -1
  467. data/lib/rubocop/server/server_command/exec.rb +1 -1
  468. data/lib/rubocop/server/socket_reader.rb +5 -1
  469. data/lib/rubocop/server.rb +1 -1
  470. data/lib/rubocop/target_finder.rb +1 -1
  471. data/lib/rubocop/target_ruby.rb +5 -5
  472. data/lib/rubocop/version.rb +17 -7
  473. data/lib/rubocop.rb +52 -8
  474. metadata +80 -32
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,7 +142,7 @@ 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: ~
145
147
  # Determines if a notification for extension libraries should be shown when
146
148
  # rubocop is run. Keys are the name of the extension, and values are an array
@@ -153,6 +155,8 @@ AllCops:
153
155
  rubocop-sequel: [sequel]
154
156
  rubocop-rake: [rake]
155
157
  rubocop-graphql: [graphql]
158
+ rubocop-capybara: [capybara]
159
+ rubocop-factory_bot: [factory_bot, factory_bot_rails]
156
160
  # Enable/Disable checking the methods extended by Active Support.
157
161
  ActiveSupportExtensionsEnabled: false
158
162
 
@@ -161,7 +165,9 @@ AllCops:
161
165
  Bundler/DuplicatedGem:
162
166
  Description: 'Checks for duplicate gem entries in Gemfile.'
163
167
  Enabled: true
168
+ Severity: warning
164
169
  VersionAdded: '0.46'
170
+ VersionChanged: '1.40'
165
171
  Include:
166
172
  - '**/*.gemfile'
167
173
  - '**/Gemfile'
@@ -213,7 +219,9 @@ Bundler/InsecureProtocolSource:
213
219
  because HTTP requests are insecure. Please change your source to
214
220
  'https://rubygems.org' if possible, or 'http://rubygems.org' if not.
215
221
  Enabled: true
222
+ Severity: warning
216
223
  VersionAdded: '0.50'
224
+ VersionChanged: '1.40'
217
225
  AllowHttpProtocol: true
218
226
  Include:
219
227
  - '**/*.gemfile'
@@ -252,14 +260,33 @@ Gemspec/DependencyVersion:
252
260
  Gemspec/DeprecatedAttributeAssignment:
253
261
  Description: Checks that deprecated attribute assignments are not set in a gemspec file.
254
262
  Enabled: pending
263
+ Severity: warning
255
264
  VersionAdded: '1.30'
265
+ VersionChanged: '1.40'
266
+ Include:
267
+ - '**/*.gemspec'
268
+
269
+ Gemspec/DevelopmentDependencies:
270
+ Description: Checks that development dependencies are specified in Gemfile rather than gemspec.
271
+ Enabled: pending
272
+ VersionAdded: '1.44'
273
+ EnforcedStyle: Gemfile
274
+ SupportedStyles:
275
+ - Gemfile
276
+ - gems.rb
277
+ - gemspec
278
+ AllowedGems: []
256
279
  Include:
257
280
  - '**/*.gemspec'
281
+ - '**/Gemfile'
282
+ - '**/gems.rb'
258
283
 
259
284
  Gemspec/DuplicatedAssignment:
260
285
  Description: 'An attribute assignment method calls should be listed only once in a gemspec.'
261
286
  Enabled: true
287
+ Severity: warning
262
288
  VersionAdded: '0.52'
289
+ VersionChanged: '1.40'
263
290
  Include:
264
291
  - '**/*.gemspec'
265
292
 
@@ -278,7 +305,9 @@ Gemspec/OrderedDependencies:
278
305
  Gemspec/RequireMFA:
279
306
  Description: 'Checks that the gemspec has metadata to require Multi-Factor Authentication from RubyGems.'
280
307
  Enabled: pending
308
+ Severity: warning
281
309
  VersionAdded: '1.23'
310
+ VersionChanged: '1.40'
282
311
  Reference:
283
312
  - https://guides.rubygems.org/mfa-requirement-opt-in/
284
313
  Include:
@@ -287,8 +316,9 @@ Gemspec/RequireMFA:
287
316
  Gemspec/RequiredRubyVersion:
288
317
  Description: 'Checks that `required_ruby_version` of gemspec is specified and equal to `TargetRubyVersion` of .rubocop.yml.'
289
318
  Enabled: true
319
+ Severity: warning
290
320
  VersionAdded: '0.52'
291
- VersionChanged: '1.22'
321
+ VersionChanged: '1.40'
292
322
  Include:
293
323
  - '**/*.gemspec'
294
324
 
@@ -296,7 +326,9 @@ Gemspec/RubyVersionGlobalsUsage:
296
326
  Description: Checks usage of RUBY_VERSION in gemspec.
297
327
  StyleGuide: '#no-ruby-version-in-the-gemspec'
298
328
  Enabled: true
329
+ Severity: warning
299
330
  VersionAdded: '0.72'
331
+ VersionChanged: '1.40'
300
332
  Include:
301
333
  - '**/*.gemspec'
302
334
 
@@ -379,7 +411,7 @@ Layout/AssignmentIndentation:
379
411
  right-hand-side of a multi-line assignment.
380
412
  Enabled: true
381
413
  VersionAdded: '0.49'
382
- VersionChanged: '0.77'
414
+ VersionChanged: '1.45'
383
415
  # By default the indentation width from `Layout/IndentationWidth` is used,
384
416
  # but it can be overridden by setting this parameter.
385
417
  IndentationWidth: ~
@@ -437,7 +469,9 @@ Layout/ClassStructure:
437
469
  Description: 'Enforces a configured order of definitions within a class body.'
438
470
  StyleGuide: '#consistent-classes'
439
471
  Enabled: false
472
+ SafeAutoCorrect: false
440
473
  VersionAdded: '0.52'
474
+ VersionChanged: '1.53'
441
475
  Categories:
442
476
  module_inclusion:
443
477
  - include
@@ -545,6 +579,8 @@ Layout/EmptyLineBetweenDefs:
545
579
  EmptyLineBetweenMethodDefs: true
546
580
  EmptyLineBetweenClassDefs: true
547
581
  EmptyLineBetweenModuleDefs: true
582
+ # `DefLikeMacros` takes the name of any macro that you want to treat like a def.
583
+ DefLikeMacros: []
548
584
  # `AllowAdjacentOneLineDefs` means that single line method definitions don't
549
585
  # need an empty line between them. `true` by default.
550
586
  AllowAdjacentOneLineDefs: true
@@ -748,6 +784,7 @@ Layout/FirstArrayElementLineBreak:
748
784
  multi-line array.
749
785
  Enabled: false
750
786
  VersionAdded: '0.49'
787
+ AllowMultilineFinalElement: false
751
788
 
752
789
  Layout/FirstHashElementIndentation:
753
790
  Description: 'Checks the indentation of the first key in a hash literal.'
@@ -780,6 +817,7 @@ Layout/FirstHashElementLineBreak:
780
817
  multi-line hash.
781
818
  Enabled: false
782
819
  VersionAdded: '0.49'
820
+ AllowMultilineFinalElement: false
783
821
 
784
822
  Layout/FirstMethodArgumentLineBreak:
785
823
  Description: >-
@@ -787,6 +825,7 @@ Layout/FirstMethodArgumentLineBreak:
787
825
  multi-line method call.
788
826
  Enabled: false
789
827
  VersionAdded: '0.49'
828
+ AllowMultilineFinalElement: false
790
829
 
791
830
  Layout/FirstMethodParameterLineBreak:
792
831
  Description: >-
@@ -794,6 +833,7 @@ Layout/FirstMethodParameterLineBreak:
794
833
  multi-line method parameter definition.
795
834
  Enabled: false
796
835
  VersionAdded: '0.49'
836
+ AllowMultilineFinalElement: false
797
837
 
798
838
  Layout/FirstParameterIndentation:
799
839
  Description: >-
@@ -946,7 +986,6 @@ Layout/IndentationWidth:
946
986
  # Number of spaces for each indentation level.
947
987
  Width: 2
948
988
  AllowedPatterns: []
949
- IgnoredPatterns: [] # deprecated
950
989
 
951
990
  Layout/InitialIndentation:
952
991
  Description: >-
@@ -974,10 +1013,8 @@ Layout/LineContinuationLeadingSpace:
974
1013
  Use trailing spaces instead of leading spaces in strings
975
1014
  broken over multiple lines (by a backslash).
976
1015
  Enabled: pending
977
- AutoCorrect: false
978
- SafeAutoCorrect: false
979
1016
  VersionAdded: '1.31'
980
- VersionChanged: '1.32'
1017
+ VersionChanged: '1.45'
981
1018
  EnforcedStyle: trailing
982
1019
  SupportedStyles:
983
1020
  - leading
@@ -986,8 +1023,6 @@ Layout/LineContinuationLeadingSpace:
986
1023
  Layout/LineContinuationSpacing:
987
1024
  Description: 'Checks the spacing in front of backslash in line continuations.'
988
1025
  Enabled: pending
989
- AutoCorrect: true
990
- SafeAutoCorrect: true
991
1026
  VersionAdded: '1.31'
992
1027
  EnforcedStyle: space
993
1028
  SupportedStyles:
@@ -1029,7 +1064,6 @@ Layout/LineLength:
1029
1064
  # elements. Strings will be converted to Regexp objects. A line that matches
1030
1065
  # any regular expression listed in this option will be ignored by LineLength.
1031
1066
  AllowedPatterns: []
1032
- IgnoredPatterns: [] # deprecated
1033
1067
 
1034
1068
  Layout/MultilineArrayBraceLayout:
1035
1069
  Description: >-
@@ -1053,6 +1087,7 @@ Layout/MultilineArrayLineBreaks:
1053
1087
  starts on a separate line.
1054
1088
  Enabled: false
1055
1089
  VersionAdded: '0.67'
1090
+ AllowMultilineFinalElement: false
1056
1091
 
1057
1092
  Layout/MultilineAssignmentLayout:
1058
1093
  Description: 'Check for a newline after the assignment operator in multi-line assignments.'
@@ -1103,6 +1138,7 @@ Layout/MultilineHashKeyLineBreaks:
1103
1138
  starts on a separate line.
1104
1139
  Enabled: false
1105
1140
  VersionAdded: '0.67'
1141
+ AllowMultilineFinalElement: false
1106
1142
 
1107
1143
  Layout/MultilineMethodArgumentLineBreaks:
1108
1144
  Description: >-
@@ -1110,6 +1146,7 @@ Layout/MultilineMethodArgumentLineBreaks:
1110
1146
  starts on a separate line.
1111
1147
  Enabled: false
1112
1148
  VersionAdded: '0.67'
1149
+ AllowMultilineFinalElement: false
1113
1150
 
1114
1151
  Layout/MultilineMethodCallBraceLayout:
1115
1152
  Description: >-
@@ -1164,6 +1201,7 @@ Layout/MultilineMethodParameterLineBreaks:
1164
1201
  starts on a separate line.
1165
1202
  Enabled: false
1166
1203
  VersionAdded: '1.32'
1204
+ AllowMultilineFinalElement: false
1167
1205
 
1168
1206
  Layout/MultilineOperationIndentation:
1169
1207
  Description: >-
@@ -1498,13 +1536,11 @@ Lint/AmbiguousBlockAssociation:
1498
1536
  Description: >-
1499
1537
  Checks for ambiguous block association with method when param passed without
1500
1538
  parentheses.
1501
- StyleGuide: '#syntax'
1502
1539
  Enabled: true
1503
1540
  VersionAdded: '0.48'
1504
1541
  VersionChanged: '1.13'
1505
1542
  AllowedMethods: []
1506
1543
  AllowedPatterns: []
1507
- IgnoredMethods: [] # deprecated
1508
1544
 
1509
1545
  Lint/AmbiguousOperator:
1510
1546
  Description: >-
@@ -1541,7 +1577,9 @@ Lint/AssignmentInCondition:
1541
1577
  Description: "Don't use assignment in conditions."
1542
1578
  StyleGuide: '#safe-assignment-in-condition'
1543
1579
  Enabled: true
1580
+ SafeAutoCorrect: false
1544
1581
  VersionAdded: '0.9'
1582
+ VersionChanged: '1.45'
1545
1583
  AllowSafeAssignment: true
1546
1584
 
1547
1585
  Lint/BigDecimalNew:
@@ -1597,8 +1635,7 @@ Lint/Debugger:
1597
1635
  Description: 'Check for debugger calls.'
1598
1636
  Enabled: true
1599
1637
  VersionAdded: '0.14'
1600
- VersionChanged: '1.10'
1601
- DebuggerReceivers: [] # deprecated
1638
+ VersionChanged: '1.46'
1602
1639
  DebuggerMethods:
1603
1640
  # Groups are available so that a specific group can be disabled in
1604
1641
  # a user's configuration, but are otherwise not significant.
@@ -1626,6 +1663,7 @@ Lint/Debugger:
1626
1663
  - Kernel.binding.remote_pry
1627
1664
  - Kernel.binding.pry_remote
1628
1665
  - Pry.rescue
1666
+ - pry
1629
1667
  Rails:
1630
1668
  - debugger
1631
1669
  - Kernel.debugger
@@ -1643,7 +1681,7 @@ Lint/DeprecatedConstants:
1643
1681
  Description: 'Checks for deprecated constants.'
1644
1682
  Enabled: pending
1645
1683
  VersionAdded: '1.8'
1646
- VersionChanged: '1.22'
1684
+ VersionChanged: '1.40'
1647
1685
  # You can configure deprecated constants.
1648
1686
  # If there is an alternative method, you can set alternative value as `Alternative`.
1649
1687
  # And you can set the deprecated version as `DeprecatedVersion`.
@@ -1670,6 +1708,12 @@ Lint/DeprecatedConstants:
1670
1708
  'Random::DEFAULT':
1671
1709
  Alternative: 'Random.new'
1672
1710
  DeprecatedVersion: '3.0'
1711
+ 'Struct::Group':
1712
+ Alternative: 'Etc::Group'
1713
+ DeprecatedVersion: '3.0'
1714
+ 'Struct::Passwd':
1715
+ Alternative: 'Etc::Passwd'
1716
+ DeprecatedVersion: '3.0'
1673
1717
 
1674
1718
  Lint/DeprecatedOpenSSLConstant:
1675
1719
  Description: "Don't use algorithm constants for `OpenSSL::Cipher` and `OpenSSL::Digest`."
@@ -1707,6 +1751,16 @@ Lint/DuplicateHashKey:
1707
1751
  VersionAdded: '0.34'
1708
1752
  VersionChanged: '0.77'
1709
1753
 
1754
+ Lint/DuplicateMagicComment:
1755
+ Description: 'Check for duplicated magic comments.'
1756
+ Enabled: pending
1757
+ VersionAdded: '1.37'
1758
+
1759
+ Lint/DuplicateMatchPattern:
1760
+ Description: 'Do not repeat patterns in `in` keywords.'
1761
+ Enabled: pending
1762
+ VersionAdded: '1.50'
1763
+
1710
1764
  Lint/DuplicateMethods:
1711
1765
  Description: 'Check for duplicate method definitions.'
1712
1766
  Enabled: true
@@ -1889,11 +1943,11 @@ Lint/InheritException:
1889
1943
  - runtime_error
1890
1944
 
1891
1945
  Lint/InterpolationCheck:
1892
- Description: 'Raise warning for interpolation in single q strs.'
1946
+ Description: 'Checks for interpolation in a single quoted string.'
1893
1947
  Enabled: true
1894
- Safe: false
1948
+ SafeAutoCorrect: false
1895
1949
  VersionAdded: '0.50'
1896
- VersionChanged: '0.87'
1950
+ VersionChanged: '1.40'
1897
1951
 
1898
1952
  Lint/LambdaWithoutLiteralBlock:
1899
1953
  Description: 'Checks uses of lambda without a literal block.'
@@ -1939,9 +1993,16 @@ Lint/MissingSuper:
1939
1993
  Checks for the presence of constructors and lifecycle callbacks
1940
1994
  without calls to `super`.
1941
1995
  Enabled: true
1996
+ AllowedParentClasses: []
1942
1997
  VersionAdded: '0.89'
1943
1998
  VersionChanged: '1.4'
1944
1999
 
2000
+ Lint/MixedCaseRange:
2001
+ Description: 'Checks for mixed-case character ranges since they include likely unintended characters.'
2002
+ Enabled: pending
2003
+ SafeAutoCorrect: false
2004
+ VersionAdded: '1.53'
2005
+
1945
2006
  Lint/MixedRegexpCaptureTypes:
1946
2007
  Description: 'Do not mix named captures and numbered captures in a Regexp literal.'
1947
2008
  Enabled: true
@@ -1957,6 +2018,8 @@ Lint/NestedMethodDefinition:
1957
2018
  Description: 'Do not use nested method definitions.'
1958
2019
  StyleGuide: '#no-nested-methods'
1959
2020
  Enabled: true
2021
+ AllowedMethods: []
2022
+ AllowedPatterns: []
1960
2023
  VersionAdded: '0.32'
1961
2024
 
1962
2025
  Lint/NestedPercentLiteral:
@@ -2002,7 +2065,6 @@ Lint/NumberConversion:
2002
2065
  SafeAutoCorrect: false
2003
2066
  AllowedMethods: []
2004
2067
  AllowedPatterns: []
2005
- IgnoredMethods: [] # deprecated
2006
2068
  IgnoredClasses:
2007
2069
  - Time
2008
2070
  - DateTime
@@ -2021,7 +2083,9 @@ Lint/OrAssignmentToConstant:
2021
2083
  Lint/OrderedMagicComments:
2022
2084
  Description: 'Checks the proper ordering of magic comments and whether a magic comment is not placed before a shebang.'
2023
2085
  Enabled: true
2086
+ SafeAutoCorrect: false
2024
2087
  VersionAdded: '0.53'
2088
+ VersionChanged: '1.37'
2025
2089
 
2026
2090
  Lint/OutOfRangeRegexpRef:
2027
2091
  Description: 'Checks for out of range reference for Regexp because it always returns nil.'
@@ -2088,6 +2152,11 @@ Lint/RedundantDirGlobSort:
2088
2152
  VersionChanged: '1.26'
2089
2153
  SafeAutoCorrect: false
2090
2154
 
2155
+ Lint/RedundantRegexpQuantifiers:
2156
+ Description: 'Checks for redundant quantifiers in Regexps.'
2157
+ Enabled: pending
2158
+ VersionAdded: '1.53'
2159
+
2091
2160
  Lint/RedundantRequireStatement:
2092
2161
  Description: 'Checks for unnecessary `require` statement.'
2093
2162
  Enabled: true
@@ -2292,6 +2361,9 @@ Lint/TopLevelReturnWithArgument:
2292
2361
  Description: 'Detects top level return statements with argument.'
2293
2362
  Enabled: true
2294
2363
  VersionAdded: '0.89'
2364
+ # These codes are `eval`-ed in method and their return values may be used.
2365
+ Exclude:
2366
+ - '**/*.jb'
2295
2367
 
2296
2368
  Lint/TrailingCommaInAttributeDeclaration:
2297
2369
  Description: 'Checks for trailing commas in attribute declarations.'
@@ -2351,7 +2423,6 @@ Lint/UnreachableLoop:
2351
2423
  # RSpec uses `times` in its message expectations
2352
2424
  # eg. `exactly(2).times`
2353
2425
  - !ruby/regexp /(exactly|at_least|at_most)\(\d+\)\.times/
2354
- IgnoredPatterns: [] # deprecated
2355
2426
 
2356
2427
  Lint/UnusedBlockArgument:
2357
2428
  Description: 'Checks for unused block arguments.'
@@ -2401,6 +2472,8 @@ Lint/UselessAssignment:
2401
2472
  StyleGuide: '#underscore-unused-vars'
2402
2473
  Enabled: true
2403
2474
  VersionAdded: '0.11'
2475
+ VersionChanged: '1.51'
2476
+ SafeAutoCorrect: false
2404
2477
 
2405
2478
  Lint/UselessElseWithoutRescue:
2406
2479
  Description: 'Checks for useless `else` in `begin..end` without `rescue`.'
@@ -2415,6 +2488,11 @@ Lint/UselessMethodDefinition:
2415
2488
  VersionChanged: '0.91'
2416
2489
  Safe: false
2417
2490
 
2491
+ Lint/UselessRescue:
2492
+ Description: 'Checks for useless `rescue`s.'
2493
+ Enabled: pending
2494
+ VersionAdded: '1.43'
2495
+
2418
2496
  Lint/UselessRuby2Keywords:
2419
2497
  Description: 'Finds unnecessary uses of `ruby2_keywords`.'
2420
2498
  Enabled: pending
@@ -2423,10 +2501,9 @@ Lint/UselessRuby2Keywords:
2423
2501
  Lint/UselessSetterCall:
2424
2502
  Description: 'Checks for useless setter call to a local variable.'
2425
2503
  Enabled: true
2426
- SafeAutoCorrect: false
2504
+ Safe: false
2427
2505
  VersionAdded: '0.13'
2428
2506
  VersionChanged: '1.2'
2429
- Safe: false
2430
2507
 
2431
2508
  Lint/UselessTimes:
2432
2509
  Description: 'Checks for useless `Integer#times` calls.'
@@ -2456,7 +2533,6 @@ Metrics/AbcSize:
2456
2533
  # a Float.
2457
2534
  AllowedMethods: []
2458
2535
  AllowedPatterns: []
2459
- IgnoredMethods: [] # deprecated
2460
2536
  CountRepeatedAttributes: true
2461
2537
  Max: 17
2462
2538
 
@@ -2468,13 +2544,11 @@ Metrics/BlockLength:
2468
2544
  CountComments: false # count full line comments?
2469
2545
  Max: 25
2470
2546
  CountAsOne: []
2471
- ExcludedMethods: [] # deprecated, retained for backwards compatibility
2472
2547
  AllowedMethods:
2473
2548
  # By default, exclude the `#refine` method, as it tends to have larger
2474
2549
  # associated blocks.
2475
2550
  - refine
2476
2551
  AllowedPatterns: []
2477
- IgnoredMethods: [] # deprecated
2478
2552
  Exclude:
2479
2553
  - '**/*.gemspec'
2480
2554
 
@@ -2496,6 +2570,12 @@ Metrics/ClassLength:
2496
2570
  Max: 100
2497
2571
  CountAsOne: []
2498
2572
 
2573
+ Metrics/CollectionLiteralLength:
2574
+ Description: 'Checks for `Array` or `Hash` literals with many entries.'
2575
+ Enabled: pending
2576
+ VersionAdded: '1.47'
2577
+ LengthThreshold: 250
2578
+
2499
2579
  # Avoid complex methods.
2500
2580
  Metrics/CyclomaticComplexity:
2501
2581
  Description: >-
@@ -2506,7 +2586,6 @@ Metrics/CyclomaticComplexity:
2506
2586
  VersionChanged: '0.81'
2507
2587
  AllowedMethods: []
2508
2588
  AllowedPatterns: []
2509
- IgnoredMethods: [] # deprecated
2510
2589
  Max: 7
2511
2590
 
2512
2591
  Metrics/MethodLength:
@@ -2518,10 +2597,8 @@ Metrics/MethodLength:
2518
2597
  CountComments: false # count full line comments?
2519
2598
  Max: 10
2520
2599
  CountAsOne: []
2521
- ExcludedMethods: [] # deprecated, retained for backwards compatibility
2522
2600
  AllowedMethods: []
2523
2601
  AllowedPatterns: []
2524
- IgnoredMethods: [] # deprecated
2525
2602
 
2526
2603
  Metrics/ModuleLength:
2527
2604
  Description: 'Avoid modules longer than 100 lines of code.'
@@ -2551,7 +2628,6 @@ Metrics/PerceivedComplexity:
2551
2628
  VersionChanged: '0.81'
2552
2629
  AllowedMethods: []
2553
2630
  AllowedPatterns: []
2554
- IgnoredMethods: [] # deprecated
2555
2631
  Max: 8
2556
2632
 
2557
2633
  ################## Migration #############################
@@ -2722,13 +2798,13 @@ Naming/HeredocDelimiterNaming:
2722
2798
  Enabled: true
2723
2799
  VersionAdded: '0.50'
2724
2800
  ForbiddenDelimiters:
2725
- - !ruby/regexp '/(^|\s)(EO[A-Z]{1}|END)(\s|$)/'
2801
+ - !ruby/regexp '/(^|\s)(EO[A-Z]{1}|END)(\s|$)/i'
2726
2802
 
2727
2803
  Naming/InclusiveLanguage:
2728
2804
  Description: 'Recommend the use of inclusive language instead of problematic terms.'
2729
2805
  Enabled: false
2730
2806
  VersionAdded: '1.18'
2731
- VersionChanged: '1.21'
2807
+ VersionChanged: '1.49'
2732
2808
  CheckIdentifiers: true
2733
2809
  CheckConstants: true
2734
2810
  CheckVariables: true
@@ -2780,7 +2856,6 @@ Naming/MethodName:
2780
2856
  # - '\A\s*onSelectionCleared\s*'
2781
2857
  #
2782
2858
  AllowedPatterns: []
2783
- IgnoredPatterns: [] # deprecated
2784
2859
 
2785
2860
  Naming/MethodParameterName:
2786
2861
  Description: >-
@@ -2794,10 +2869,13 @@ Naming/MethodParameterName:
2794
2869
  AllowNamesEndingInNumbers: true
2795
2870
  # Allowed names that will not register an offense
2796
2871
  AllowedNames:
2872
+ - as
2797
2873
  - at
2798
2874
  - by
2875
+ - cc
2799
2876
  - db
2800
2877
  - id
2878
+ - if
2801
2879
  - in
2802
2880
  - io
2803
2881
  - ip
@@ -2878,6 +2956,7 @@ Naming/VariableNumber:
2878
2956
  - rfc822 # Time#rfc822
2879
2957
  - rfc2822 # Time#rfc2822
2880
2958
  - rfc3339 # DateTime.rfc3339
2959
+ - x86_64 # Allowed by default as an underscore separated CPU architecture name
2881
2960
  AllowedPatterns: []
2882
2961
 
2883
2962
  #################### Security ##############################
@@ -2885,7 +2964,9 @@ Naming/VariableNumber:
2885
2964
  Security/CompoundHash:
2886
2965
  Description: 'When overwriting Object#hash to combine values, prefer delegating to Array#hash over writing a custom implementation.'
2887
2966
  Enabled: pending
2967
+ Safe: false
2888
2968
  VersionAdded: '1.28'
2969
+ VersionChanged: '1.51'
2889
2970
 
2890
2971
  Security/Eval:
2891
2972
  Description: 'The use of eval represents a serious security risk.'
@@ -2948,6 +3029,7 @@ Style/AccessModifierDeclarations:
2948
3029
  - inline
2949
3030
  - group
2950
3031
  AllowModifiersOnSymbols: true
3032
+ SafeAutoCorrect: false
2951
3033
 
2952
3034
  Style/AccessorGrouping:
2953
3035
  Description: 'Checks for grouping of accessors in `class` and `module` bodies.'
@@ -3001,6 +3083,12 @@ Style/ArrayCoercion:
3001
3083
  Enabled: false
3002
3084
  VersionAdded: '0.88'
3003
3085
 
3086
+ Style/ArrayIntersect:
3087
+ Description: 'Use `array1.intersect?(array2)` instead of `(array1 & array2).any?`.'
3088
+ Enabled: 'pending'
3089
+ Safe: false
3090
+ VersionAdded: '1.40'
3091
+
3004
3092
  Style/ArrayJoin:
3005
3093
  Description: 'Use Array#join instead of Array#*.'
3006
3094
  StyleGuide: '#array-join'
@@ -3141,7 +3229,6 @@ Style/BlockDelimiters:
3141
3229
  - proc
3142
3230
  - it
3143
3231
  AllowedPatterns: []
3144
- IgnoredMethods: [] # deprecated
3145
3232
  # The AllowBracesOnProceduralOneLiners option is ignored unless the
3146
3233
  # EnforcedStyle is set to `semantic`. If so:
3147
3234
  #
@@ -3165,7 +3252,7 @@ Style/BlockDelimiters:
3165
3252
  # collection.each do |element| puts element end
3166
3253
  AllowBracesOnProceduralOneLiners: false
3167
3254
  # The BracesRequiredMethods overrides all other configurations except
3168
- # IgnoredMethods. It can be used to enforce that all blocks for specific
3255
+ # AllowedMethods. It can be used to enforce that all blocks for specific
3169
3256
  # methods use braces. For example, you can use this to enforce Sorbet
3170
3257
  # signatures use braces even when the rest of your codebase enforces
3171
3258
  # the `line_count_based` style.
@@ -3186,6 +3273,15 @@ Style/CaseEquality:
3186
3273
  # # good
3187
3274
  # String === "string"
3188
3275
  AllowOnConstant: false
3276
+ # If `AllowOnSelfClass` option is enabled, the cop will ignore violations when the receiver of
3277
+ # the case equality operator is `self.class`.
3278
+ #
3279
+ # # bad
3280
+ # some_class === object
3281
+ #
3282
+ # # good
3283
+ # self.class === object
3284
+ AllowOnSelfClass: false
3189
3285
 
3190
3286
  Style/CaseLikeIf:
3191
3287
  Description: 'Identifies places where `if-elsif` constructions can be replaced with `case-when`.'
@@ -3193,6 +3289,9 @@ Style/CaseLikeIf:
3193
3289
  Enabled: true
3194
3290
  Safe: false
3195
3291
  VersionAdded: '0.88'
3292
+ VersionChanged: '1.48'
3293
+ # `MinBranchesCount` defines the number of branches `if` needs to have to trigger this cop.
3294
+ MinBranchesCount: 3
3196
3295
 
3197
3296
  Style/CharacterLiteral:
3198
3297
  Description: 'Checks for uses of character literals.'
@@ -3205,7 +3304,7 @@ Style/ClassAndModuleChildren:
3205
3304
  StyleGuide: '#namespace-definition'
3206
3305
  # Moving from compact to nested children requires knowledge of whether the
3207
3306
  # outer parent is a module or a class. Moving from nested to compact requires
3208
- # verification that the outer parent is defined elsewhere. Rubocop does not
3307
+ # verification that the outer parent is defined elsewhere. RuboCop does not
3209
3308
  # have the knowledge to perform either operation safely and thus requires
3210
3309
  # manual oversight.
3211
3310
  SafeAutoCorrect: false
@@ -3250,7 +3349,6 @@ Style/ClassEqualityComparison:
3250
3349
  - equal?
3251
3350
  - eql?
3252
3351
  AllowedPatterns: []
3253
- IgnoredMethods: [] # deprecated
3254
3352
 
3255
3353
  Style/ClassMethods:
3256
3354
  Description: 'Use self when defining module/class methods.'
@@ -3281,6 +3379,7 @@ Style/CollectionCompact:
3281
3379
  Safe: false
3282
3380
  VersionAdded: '1.2'
3283
3381
  VersionChanged: '1.3'
3382
+ AllowedReceivers: []
3284
3383
 
3285
3384
  # Align with the style guide.
3286
3385
  Style/CollectionMethods:
@@ -3371,6 +3470,17 @@ Style/CommentedKeyword:
3371
3470
  VersionAdded: '0.51'
3372
3471
  VersionChanged: '1.19'
3373
3472
 
3473
+ Style/ComparableClamp:
3474
+ Description: 'Enforces the use of `Comparable#clamp` instead of comparison by minimum and maximum.'
3475
+ Enabled: pending
3476
+ VersionAdded: '1.44'
3477
+
3478
+ Style/ConcatArrayLiterals:
3479
+ Description: 'Enforces the use of `Array#push(item)` instead of `Array#concat([item])` to avoid redundant array literals.'
3480
+ Enabled: pending
3481
+ Safe: false
3482
+ VersionAdded: '1.41'
3483
+
3374
3484
  Style/ConditionalAssignment:
3375
3485
  Description: >-
3376
3486
  Use the return value of `if` and `case` statements for
@@ -3426,9 +3536,17 @@ Style/Copyright:
3426
3536
  Notice: '^Copyright (\(c\) )?2[0-9]{3} .+'
3427
3537
  AutocorrectNotice: ''
3428
3538
 
3539
+ Style/DataInheritance:
3540
+ Description: 'Checks for inheritance from Data.define.'
3541
+ StyleGuide: '#no-extend-data-define'
3542
+ Enabled: pending
3543
+ SafeAutoCorrect: false
3544
+ VersionAdded: '1.49'
3545
+ VersionChanged: '1.51'
3546
+
3429
3547
  Style/DateTime:
3430
3548
  Description: 'Use Time over DateTime.'
3431
- StyleGuide: '#date--time'
3549
+ StyleGuide: '#date-time'
3432
3550
  Enabled: false
3433
3551
  VersionAdded: '0.51'
3434
3552
  VersionChanged: '0.92'
@@ -3449,6 +3567,12 @@ Style/Dir:
3449
3567
  Enabled: true
3450
3568
  VersionAdded: '0.50'
3451
3569
 
3570
+ Style/DirEmpty:
3571
+ Description: >-
3572
+ Prefer to use `Dir.empty?('path/to/dir')` when checking if a directory is empty.
3573
+ Enabled: pending
3574
+ VersionAdded: '1.48'
3575
+
3452
3576
  Style/DisableCopsWithinSourceCodeDirective:
3453
3577
  Description: >-
3454
3578
  Forbids disabling/enabling cops within source code.
@@ -3609,6 +3733,11 @@ Style/EvenOdd:
3609
3733
  VersionAdded: '0.12'
3610
3734
  VersionChanged: '0.29'
3611
3735
 
3736
+ Style/ExactRegexpMatch:
3737
+ Description: 'Checks for exact regexp match inside Regexp literals.'
3738
+ Enabled: pending
3739
+ VersionAdded: '1.51'
3740
+
3612
3741
  Style/ExpandPathArguments:
3613
3742
  Description: "Use `expand_path(__dir__)` instead of `expand_path('..', __FILE__)`."
3614
3743
  Enabled: true
@@ -3644,6 +3773,13 @@ Style/FetchEnvVar:
3644
3773
  # Environment variables to be excluded from the inspection.
3645
3774
  AllowedVars: []
3646
3775
 
3776
+ Style/FileEmpty:
3777
+ Description: >-
3778
+ Prefer to use `File.empty?('path/to/file')` when checking if a file is empty.
3779
+ Enabled: pending
3780
+ Safe: false
3781
+ VersionAdded: '1.48'
3782
+
3647
3783
  Style/FileRead:
3648
3784
  Description: 'Favor `File.(bin)read` convenience methods.'
3649
3785
  StyleGuide: '#file-read'
@@ -3714,7 +3850,6 @@ Style/FormatStringToken:
3714
3850
  VersionChanged: '1.0'
3715
3851
  AllowedMethods: []
3716
3852
  AllowedPatterns: []
3717
- IgnoredMethods: [] # deprecated
3718
3853
 
3719
3854
  Style/FrozenStringLiteralComment:
3720
3855
  Description: >-
@@ -3792,15 +3927,17 @@ Style/HashEachMethods:
3792
3927
  Safe: false
3793
3928
  VersionAdded: '0.80'
3794
3929
  VersionChanged: '1.16'
3795
- AllowedReceivers: []
3930
+ AllowedReceivers:
3931
+ - Thread.current
3796
3932
 
3797
3933
  Style/HashExcept:
3798
3934
  Description: >-
3799
3935
  Checks for usages of `Hash#reject`, `Hash#select`, and `Hash#filter` methods
3800
3936
  that can be replaced with `Hash#except` method.
3801
3937
  Enabled: pending
3938
+ Safe: false
3802
3939
  VersionAdded: '1.7'
3803
- VersionChanged: '1.31'
3940
+ VersionChanged: '1.39'
3804
3941
 
3805
3942
  Style/HashLikeCase:
3806
3943
  Description: >-
@@ -3839,6 +3976,8 @@ Style/HashSyntax:
3839
3976
  - never
3840
3977
  # accepts both shorthand and explicit use of hash literal value.
3841
3978
  - either
3979
+ # forces use of the 3.1 syntax only if all values can be omitted in the hash.
3980
+ - consistent
3842
3981
  # Force hashes that have a symbol value to use hash rockets
3843
3982
  UseHashRocketsWithSymbolValues: false
3844
3983
  # Do not suggest { a?: 1 } over { :a? => 1 } in ruby19 style
@@ -3951,16 +4090,41 @@ Style/InverseMethods:
3951
4090
  :=~: :!~
3952
4091
  :<: :>=
3953
4092
  :>: :<=
3954
- # `ActiveSupport` defines some common inverse methods. They are listed below,
3955
- # and not enabled by default.
3956
- # :present?: :blank?,
3957
- # :include?: :exclude?
3958
4093
  # `InverseBlocks` are methods that are inverted by inverting the return
3959
4094
  # of the block that is passed to the method
3960
4095
  InverseBlocks:
3961
4096
  :select: :reject
3962
4097
  :select!: :reject!
3963
4098
 
4099
+ Style/InvertibleUnlessCondition:
4100
+ Description: 'Favor `if` with inverted condition over `unless`.'
4101
+ Enabled: false
4102
+ Safe: false
4103
+ VersionAdded: '1.44'
4104
+ VersionChanged: '1.50'
4105
+ # `InverseMethods` are methods that can be inverted in a `unless` condition.
4106
+ # The relationship of inverse methods needs to be defined in both directions.
4107
+ # Keys and values both need to be defined as symbols.
4108
+ InverseMethods:
4109
+ :!=: :==
4110
+ :>: :<=
4111
+ :<=: :>
4112
+ :<: :>=
4113
+ :>=: :<
4114
+ :!~: :=~
4115
+ :zero?: :nonzero?
4116
+ :nonzero?: :zero?
4117
+ :any?: :none?
4118
+ :none?: :any?
4119
+ :even?: :odd?
4120
+ :odd?: :even?
4121
+ # `ActiveSupport` defines some common inverse methods. They are listed below,
4122
+ # and not enabled by default.
4123
+ # :present?: :blank?
4124
+ # :blank?: :present?
4125
+ # :include?: :exclude?
4126
+ # :exclude?: :include?
4127
+
3964
4128
  Style/IpAddresses:
3965
4129
  Description: "Don't include literal IP addresses in code."
3966
4130
  Enabled: false
@@ -4015,6 +4179,26 @@ Style/LineEndConcatenation:
4015
4179
  VersionAdded: '0.18'
4016
4180
  VersionChanged: '0.64'
4017
4181
 
4182
+ Style/MagicCommentFormat:
4183
+ Description: 'Use a consistent style for magic comments.'
4184
+ Enabled: pending
4185
+ VersionAdded: '1.35'
4186
+ EnforcedStyle: snake_case
4187
+ SupportedStyles:
4188
+ # `snake` will enforce the magic comment is written
4189
+ # in snake case (words separated by underscores).
4190
+ # Eg: froze_string_literal: true
4191
+ - snake_case
4192
+ # `kebab` will enforce the magic comment is written
4193
+ # in kebab case (words separated by hyphens).
4194
+ # Eg: froze-string-literal: true
4195
+ - kebab_case
4196
+ DirectiveCapitalization: lowercase
4197
+ ValueCapitalization: ~
4198
+ SupportedCapitalizations:
4199
+ - lowercase
4200
+ - uppercase
4201
+
4018
4202
  Style/MapCompactWithConditionalBlock:
4019
4203
  Description: 'Prefer `select` or `reject` over `map { ... }.compact`.'
4020
4204
  Enabled: pending
@@ -4026,6 +4210,12 @@ Style/MapToHash:
4026
4210
  VersionAdded: '1.24'
4027
4211
  Safe: false
4028
4212
 
4213
+ Style/MapToSet:
4214
+ Description: 'Prefer `to_set` with a block over `map.to_set`.'
4215
+ Enabled: pending
4216
+ Safe: false
4217
+ VersionAdded: '1.42'
4218
+
4029
4219
  Style/MethodCallWithArgsParentheses:
4030
4220
  Description: 'Use parentheses for method calls with arguments.'
4031
4221
  StyleGuide: '#method-invocation-parens'
@@ -4034,9 +4224,7 @@ Style/MethodCallWithArgsParentheses:
4034
4224
  VersionChanged: '1.7'
4035
4225
  IgnoreMacros: true
4036
4226
  AllowedMethods: []
4037
- IgnoredMethods: [] # deprecated
4038
4227
  AllowedPatterns: []
4039
- IgnoredPatterns: [] # deprecated
4040
4228
  IncludedMacros: []
4041
4229
  AllowParenthesesInMultilineCall: false
4042
4230
  AllowParenthesesInChaining: false
@@ -4053,7 +4241,6 @@ Style/MethodCallWithoutArgsParentheses:
4053
4241
  Enabled: true
4054
4242
  AllowedMethods: []
4055
4243
  AllowedPatterns: []
4056
- IgnoredMethods: [] # deprecated
4057
4244
  VersionAdded: '0.47'
4058
4245
  VersionChanged: '0.55'
4059
4246
 
@@ -4084,6 +4271,12 @@ Style/MinMax:
4084
4271
  Enabled: true
4085
4272
  VersionAdded: '0.50'
4086
4273
 
4274
+ Style/MinMaxComparison:
4275
+ Description: 'Enforces the use of `max` or `min` instead of comparison for greater or less.'
4276
+ Enabled: pending
4277
+ Safe: false
4278
+ VersionAdded: '1.42'
4279
+
4087
4280
  Style/MissingElse:
4088
4281
  Description: >-
4089
4282
  Require if/case expressions to have an else branches.
@@ -4207,6 +4400,7 @@ Style/MultipleComparison:
4207
4400
  VersionAdded: '0.49'
4208
4401
  VersionChanged: '1.1'
4209
4402
  AllowMethodComparison: true
4403
+ ComparisonsThreshold: 2
4210
4404
 
4211
4405
  Style/MutableConstant:
4212
4406
  Description: 'Do not assign mutable objects to constants.'
@@ -4412,11 +4606,10 @@ Style/NumericPredicate:
4412
4606
  Checks for the use of predicate- or comparison methods for
4413
4607
  numeric comparisons.
4414
4608
  StyleGuide: '#predicate-methods'
4415
- Safe: false
4416
4609
  # This will change to a new method call which isn't guaranteed to be on the
4417
4610
  # object. Switching these methods has to be done with knowledge of the types
4418
4611
  # of the variables which rubocop doesn't have.
4419
- SafeAutoCorrect: false
4612
+ Safe: false
4420
4613
  Enabled: true
4421
4614
  VersionAdded: '0.42'
4422
4615
  VersionChanged: '0.59'
@@ -4426,7 +4619,6 @@ Style/NumericPredicate:
4426
4619
  - comparison
4427
4620
  AllowedMethods: []
4428
4621
  AllowedPatterns: []
4429
- IgnoredMethods: [] # deprecated
4430
4622
  # Exclude RSpec specs because assertions like `expect(1).to be > 0` cause
4431
4623
  # false positives.
4432
4624
  Exclude:
@@ -4463,7 +4655,15 @@ Style/OpenStructUse:
4463
4655
  - https://docs.ruby-lang.org/en/3.0.0/OpenStruct.html#class-OpenStruct-label-Caveats
4464
4656
 
4465
4657
  Enabled: pending
4658
+ Safe: false
4466
4659
  VersionAdded: '1.23'
4660
+ VersionChanged: '1.51'
4661
+
4662
+ Style/OperatorMethodCall:
4663
+ Description: 'Checks for redundant dot before operator method call.'
4664
+ StyleGuide: '#operator-method-call'
4665
+ Enabled: pending
4666
+ VersionAdded: '1.37'
4467
4667
 
4468
4668
  Style/OptionHash:
4469
4669
  Description: "Don't use option hashes when you can use keyword arguments."
@@ -4610,10 +4810,12 @@ Style/RedundantArgument:
4610
4810
  Enabled: pending
4611
4811
  Safe: false
4612
4812
  VersionAdded: '1.4'
4613
- VersionChanged: '1.7'
4813
+ VersionChanged: '1.40'
4614
4814
  Methods:
4615
4815
  # Array#join
4616
4816
  join: ''
4817
+ # Array#sum
4818
+ sum: 0
4617
4819
  # String#split
4618
4820
  split: ' '
4619
4821
  # String#chomp
@@ -4621,6 +4823,11 @@ Style/RedundantArgument:
4621
4823
  # String#chomp!
4622
4824
  chomp!: "\n"
4623
4825
 
4826
+ Style/RedundantArrayConstructor:
4827
+ Description: 'Checks for the instantiation of array using redundant `Array` constructor.'
4828
+ Enabled: pending
4829
+ VersionAdded: '1.52'
4830
+
4624
4831
  Style/RedundantAssignment:
4625
4832
  Description: 'Checks for redundant assignment before returning.'
4626
4833
  Enabled: true
@@ -4648,6 +4855,27 @@ Style/RedundantConditional:
4648
4855
  Enabled: true
4649
4856
  VersionAdded: '0.50'
4650
4857
 
4858
+ Style/RedundantConstantBase:
4859
+ Description: Avoid redundant `::` prefix on constant.
4860
+ Enabled: pending
4861
+ VersionAdded: '1.40'
4862
+
4863
+ Style/RedundantCurrentDirectoryInPath:
4864
+ Description: 'Checks for uses a redundant current directory in path.'
4865
+ Enabled: pending
4866
+ VersionAdded: '1.53'
4867
+
4868
+ Style/RedundantDoubleSplatHashBraces:
4869
+ Description: 'Checks for redundant uses of double splat hash braces.'
4870
+ Enabled: pending
4871
+ VersionAdded: '1.41'
4872
+
4873
+ Style/RedundantEach:
4874
+ Description: 'Checks for redundant `each`.'
4875
+ Enabled: pending
4876
+ Safe: false
4877
+ VersionAdded: '1.38'
4878
+
4651
4879
  Style/RedundantException:
4652
4880
  Description: "Checks for an obsolete RuntimeException argument in raise/fail."
4653
4881
  StyleGuide: '#no-explicit-runtimeerror'
@@ -4676,12 +4904,24 @@ Style/RedundantFileExtensionInRequire:
4676
4904
  Enabled: true
4677
4905
  VersionAdded: '0.88'
4678
4906
 
4907
+ Style/RedundantFilterChain:
4908
+ Description: >-
4909
+ Identifies usages of `any?`, `empty?`, `none?` or `one?` predicate methods chained to
4910
+ `select`/`filter`/`find_all` and change them to use predicate method instead.
4911
+ Enabled: pending
4912
+ VersionAdded: '1.52'
4913
+
4679
4914
  Style/RedundantFreeze:
4680
4915
  Description: "Checks usages of Object#freeze on immutable objects."
4681
4916
  Enabled: true
4682
4917
  VersionAdded: '0.34'
4683
4918
  VersionChanged: '0.66'
4684
4919
 
4920
+ Style/RedundantHeredocDelimiterQuotes:
4921
+ Description: 'Checks for redundant heredoc delimiter quotes.'
4922
+ Enabled: pending
4923
+ VersionAdded: '1.45'
4924
+
4685
4925
  Style/RedundantInitialize:
4686
4926
  Description: 'Checks for redundant `initialize` methods.'
4687
4927
  Enabled: pending
@@ -4697,6 +4937,11 @@ Style/RedundantInterpolation:
4697
4937
  VersionAdded: '0.76'
4698
4938
  VersionChanged: '1.30'
4699
4939
 
4940
+ Style/RedundantLineContinuation:
4941
+ Description: 'Check for redundant line continuation.'
4942
+ Enabled: pending
4943
+ VersionAdded: '1.49'
4944
+
4700
4945
  Style/RedundantParentheses:
4701
4946
  Description: "Checks for parentheses that seem not to serve any purpose."
4702
4947
  Enabled: true
@@ -4708,11 +4953,21 @@ Style/RedundantPercentQ:
4708
4953
  Enabled: true
4709
4954
  VersionAdded: '0.76'
4710
4955
 
4956
+ Style/RedundantRegexpArgument:
4957
+ Description: 'Identifies places where argument can be replaced from a deterministic regexp to a string.'
4958
+ Enabled: pending
4959
+ VersionAdded: '1.53'
4960
+
4711
4961
  Style/RedundantRegexpCharacterClass:
4712
4962
  Description: 'Checks for unnecessary single-element Regexp character classes.'
4713
4963
  Enabled: true
4714
4964
  VersionAdded: '0.85'
4715
4965
 
4966
+ Style/RedundantRegexpConstructor:
4967
+ Description: 'Checks for the instantiation of regexp using redundant `Regexp.new` or `Regexp.compile`.'
4968
+ Enabled: pending
4969
+ VersionAdded: '1.52'
4970
+
4716
4971
  Style/RedundantRegexpEscape:
4717
4972
  Description: 'Checks for redundant escapes in Regexps.'
4718
4973
  Enabled: true
@@ -4759,6 +5014,11 @@ Style/RedundantSortBy:
4759
5014
  Enabled: true
4760
5015
  VersionAdded: '0.36'
4761
5016
 
5017
+ Style/RedundantStringEscape:
5018
+ Description: 'Checks for redundant escapes in string literals.'
5019
+ Enabled: pending
5020
+ VersionAdded: '1.37'
5021
+
4762
5022
  Style/RegexpLiteral:
4763
5023
  Description: 'Use / or %r around regular expressions.'
4764
5024
  StyleGuide: '#percent-r'
@@ -4777,6 +5037,12 @@ Style/RegexpLiteral:
4777
5037
  # are found in the regexp string.
4778
5038
  AllowInnerSlashes: false
4779
5039
 
5040
+ Style/RequireOrder:
5041
+ Description: Sort `require` and `require_relative` in alphabetical order.
5042
+ Enabled: false
5043
+ SafeAutoCorrect: false
5044
+ VersionAdded: '1.40'
5045
+
4780
5046
  Style/RescueModifier:
4781
5047
  Description: 'Avoid using rescue in its modifier form.'
4782
5048
  StyleGuide: '#no-rescue-modifiers'
@@ -4804,6 +5070,15 @@ Style/ReturnNil:
4804
5070
  - return_nil
4805
5071
  VersionAdded: '0.50'
4806
5072
 
5073
+ Style/ReturnNilInPredicateMethodDefinition:
5074
+ Description: 'Checks if uses of `return` or `return nil` in predicate method definition.'
5075
+ StyleGuide: '#bool-methods-qmark'
5076
+ Enabled: pending
5077
+ SafeAutoCorrect: false
5078
+ AllowedMethods: []
5079
+ AllowedPatterns: []
5080
+ VersionAdded: '1.53'
5081
+
4807
5082
  Style/SafeNavigation:
4808
5083
  Description: >-
4809
5084
  Transforms usages of a method call safeguarded by
@@ -5061,15 +5336,13 @@ Style/SymbolProc:
5061
5336
  Enabled: true
5062
5337
  Safe: false
5063
5338
  VersionAdded: '0.26'
5064
- VersionChanged: '1.28'
5339
+ VersionChanged: '1.40'
5065
5340
  AllowMethodsWithArguments: false
5066
5341
  # A list of method names to be always allowed by the check.
5067
5342
  # The names should be fairly unique, otherwise you'll end up ignoring lots of code.
5068
5343
  AllowedMethods:
5069
- - respond_to
5070
5344
  - define_method
5071
5345
  AllowedPatterns: []
5072
- IgnoredMethods: [] # deprecated
5073
5346
  AllowComments: false
5074
5347
 
5075
5348
  Style/TernaryParentheses:
@@ -5290,6 +5563,11 @@ Style/WordArray:
5290
5563
  # The regular expression `WordRegex` decides what is considered a word.
5291
5564
  WordRegex: !ruby/regexp '/\A(?:\p{Word}|\p{Word}-\p{Word}|\n|\t)+\z/'
5292
5565
 
5566
+ Style/YAMLFileRead:
5567
+ Description: 'Checks for the use of `YAML.load`, `YAML.safe_load`, and `YAML.parse` with `File.read` argument.'
5568
+ Enabled: pending
5569
+ VersionAdded: '1.53'
5570
+
5293
5571
  Style/YodaCondition:
5294
5572
  Description: 'Forbid or enforce yoda conditions.'
5295
5573
  Reference: 'https://en.wikipedia.org/wiki/Yoda_conditions'
@@ -5308,6 +5586,19 @@ Style/YodaCondition:
5308
5586
  VersionAdded: '0.49'
5309
5587
  VersionChanged: '0.75'
5310
5588
 
5589
+ Style/YodaExpression:
5590
+ Description: 'Forbid the use of yoda expressions.'
5591
+ Enabled: false
5592
+ Safe: false
5593
+ VersionAdded: '1.42'
5594
+ VersionChanged: '1.43'
5595
+ SupportedOperators:
5596
+ - '*'
5597
+ - '+'
5598
+ - '&'
5599
+ - '|'
5600
+ - '^'
5601
+
5311
5602
  Style/ZeroLengthPredicate:
5312
5603
  Description: 'Use #empty? when testing for objects of length 0.'
5313
5604
  Enabled: true