rubocop 1.31.1 → 1.51.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (462) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +1 -1
  3. data/README.md +5 -5
  4. data/config/default.yml +342 -52
  5. data/config/obsoletion.yml +23 -1
  6. data/exe/rubocop +1 -1
  7. data/lib/rubocop/arguments_env.rb +17 -0
  8. data/lib/rubocop/arguments_file.rb +17 -0
  9. data/lib/rubocop/cache_config.rb +29 -0
  10. data/lib/rubocop/cli/command/{auto_genenerate_config.rb → auto_generate_config.rb} +9 -2
  11. data/lib/rubocop/cli/command/execute_runner.rb +14 -9
  12. data/lib/rubocop/cli/command/init_dotfile.rb +1 -1
  13. data/lib/rubocop/cli/command/suggest_extensions.rb +61 -16
  14. data/lib/rubocop/cli.rb +56 -9
  15. data/lib/rubocop/comment_config.rb +60 -1
  16. data/lib/rubocop/config.rb +48 -20
  17. data/lib/rubocop/config_finder.rb +68 -0
  18. data/lib/rubocop/config_loader.rb +46 -68
  19. data/lib/rubocop/config_loader_resolver.rb +11 -12
  20. data/lib/rubocop/config_obsoletion/changed_parameter.rb +5 -0
  21. data/lib/rubocop/config_obsoletion/parameter_rule.rb +4 -0
  22. data/lib/rubocop/config_obsoletion.rb +9 -4
  23. data/lib/rubocop/config_validator.rb +1 -1
  24. data/lib/rubocop/cop/autocorrect_logic.rb +29 -13
  25. data/lib/rubocop/cop/badge.rb +9 -4
  26. data/lib/rubocop/cop/base.rb +115 -83
  27. data/lib/rubocop/cop/bundler/gem_comment.rb +1 -1
  28. data/lib/rubocop/cop/commissioner.rb +19 -6
  29. data/lib/rubocop/cop/cop.rb +54 -34
  30. data/lib/rubocop/cop/corrector.rb +31 -11
  31. data/lib/rubocop/cop/correctors/alignment_corrector.rb +3 -3
  32. data/lib/rubocop/cop/correctors/each_to_for_corrector.rb +3 -3
  33. data/lib/rubocop/cop/correctors/for_to_each_corrector.rb +3 -3
  34. data/lib/rubocop/cop/correctors/line_break_corrector.rb +1 -1
  35. data/lib/rubocop/cop/correctors/multiline_literal_brace_corrector.rb +23 -7
  36. data/lib/rubocop/cop/correctors/ordered_gem_corrector.rb +2 -7
  37. data/lib/rubocop/cop/correctors/parentheses_corrector.rb +58 -0
  38. data/lib/rubocop/cop/correctors/percent_literal_corrector.rb +2 -2
  39. data/lib/rubocop/cop/gemspec/dependency_version.rb +17 -19
  40. data/lib/rubocop/cop/gemspec/deprecated_attribute_assignment.rb +1 -1
  41. data/lib/rubocop/cop/gemspec/development_dependencies.rb +107 -0
  42. data/lib/rubocop/cop/gemspec/require_mfa.rb +1 -1
  43. data/lib/rubocop/cop/generator/require_file_injector.rb +2 -2
  44. data/lib/rubocop/cop/generator.rb +5 -2
  45. data/lib/rubocop/cop/internal_affairs/cop_description.rb +8 -6
  46. data/lib/rubocop/cop/internal_affairs/create_empty_file.rb +37 -0
  47. data/lib/rubocop/cop/internal_affairs/example_heredoc_delimiter.rb +111 -0
  48. data/lib/rubocop/cop/internal_affairs/inherit_deprecated_cop_class.rb +1 -1
  49. data/lib/rubocop/cop/internal_affairs/lambda_or_proc.rb +46 -0
  50. data/lib/rubocop/cop/internal_affairs/location_expression.rb +37 -0
  51. data/lib/rubocop/cop/internal_affairs/node_matcher_directive.rb +3 -3
  52. data/lib/rubocop/cop/internal_affairs/node_type_predicate.rb +1 -1
  53. data/lib/rubocop/cop/internal_affairs/numblock_handler.rb +69 -0
  54. data/lib/rubocop/cop/internal_affairs/processed_source_buffer_name.rb +42 -0
  55. data/lib/rubocop/cop/internal_affairs/redundant_let_rubocop_config_new.rb +11 -3
  56. data/lib/rubocop/cop/internal_affairs/redundant_location_argument.rb +1 -1
  57. data/lib/rubocop/cop/internal_affairs/redundant_message_argument.rb +1 -1
  58. data/lib/rubocop/cop/internal_affairs/redundant_source_range.rb +66 -0
  59. data/lib/rubocop/cop/internal_affairs/single_line_comparison.rb +62 -0
  60. data/lib/rubocop/cop/internal_affairs/useless_restrict_on_send.rb +60 -0
  61. data/lib/rubocop/cop/internal_affairs.rb +9 -0
  62. data/lib/rubocop/cop/layout/array_alignment.rb +1 -1
  63. data/lib/rubocop/cop/layout/block_alignment.rb +16 -12
  64. data/lib/rubocop/cop/layout/block_end_newline.rb +31 -9
  65. data/lib/rubocop/cop/layout/class_structure.rb +37 -27
  66. data/lib/rubocop/cop/layout/closing_heredoc_indentation.rb +1 -1
  67. data/lib/rubocop/cop/layout/closing_parenthesis_indentation.rb +2 -6
  68. data/lib/rubocop/cop/layout/comment_indentation.rb +3 -1
  69. data/lib/rubocop/cop/layout/empty_comment.rb +3 -3
  70. data/lib/rubocop/cop/layout/empty_line_between_defs.rb +1 -1
  71. data/lib/rubocop/cop/layout/empty_lines.rb +3 -1
  72. data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +7 -2
  73. data/lib/rubocop/cop/layout/empty_lines_around_block_body.rb +2 -0
  74. data/lib/rubocop/cop/layout/end_alignment.rb +9 -1
  75. data/lib/rubocop/cop/layout/end_of_line.rb +4 -4
  76. data/lib/rubocop/cop/layout/extra_spacing.rb +15 -6
  77. data/lib/rubocop/cop/layout/first_argument_indentation.rb +15 -4
  78. data/lib/rubocop/cop/layout/first_array_element_indentation.rb +6 -5
  79. data/lib/rubocop/cop/layout/first_array_element_line_break.rb +35 -8
  80. data/lib/rubocop/cop/layout/first_hash_element_indentation.rb +5 -5
  81. data/lib/rubocop/cop/layout/first_hash_element_line_break.rb +36 -1
  82. data/lib/rubocop/cop/layout/first_method_argument_line_break.rb +57 -8
  83. data/lib/rubocop/cop/layout/first_method_parameter_line_break.rb +52 -19
  84. data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +10 -4
  85. data/lib/rubocop/cop/layout/heredoc_indentation.rb +8 -11
  86. data/lib/rubocop/cop/layout/indentation_style.rb +7 -2
  87. data/lib/rubocop/cop/layout/indentation_width.rb +6 -2
  88. data/lib/rubocop/cop/layout/initial_indentation.rb +1 -1
  89. data/lib/rubocop/cop/layout/leading_comment_space.rb +1 -1
  90. data/lib/rubocop/cop/layout/line_continuation_leading_space.rb +80 -12
  91. data/lib/rubocop/cop/layout/line_continuation_spacing.rb +18 -8
  92. data/lib/rubocop/cop/layout/line_length.rb +8 -1
  93. data/lib/rubocop/cop/layout/multiline_array_line_breaks.rb +31 -1
  94. data/lib/rubocop/cop/layout/multiline_assignment_layout.rb +1 -1
  95. data/lib/rubocop/cop/layout/multiline_block_layout.rb +3 -1
  96. data/lib/rubocop/cop/layout/multiline_hash_key_line_breaks.rb +29 -1
  97. data/lib/rubocop/cop/layout/multiline_method_argument_line_breaks.rb +39 -2
  98. data/lib/rubocop/cop/layout/multiline_method_parameter_line_breaks.rb +77 -0
  99. data/lib/rubocop/cop/layout/redundant_line_break.rb +9 -10
  100. data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +2 -2
  101. data/lib/rubocop/cop/layout/space_around_block_parameters.rb +1 -1
  102. data/lib/rubocop/cop/layout/space_around_keyword.rb +3 -3
  103. data/lib/rubocop/cop/layout/space_around_operators.rb +1 -1
  104. data/lib/rubocop/cop/layout/space_before_block_braces.rb +2 -0
  105. data/lib/rubocop/cop/layout/space_before_first_arg.rb +1 -1
  106. data/lib/rubocop/cop/layout/space_in_lambda_literal.rb +2 -2
  107. data/lib/rubocop/cop/layout/space_inside_array_literal_brackets.rb +22 -20
  108. data/lib/rubocop/cop/layout/space_inside_array_percent_literal.rb +3 -0
  109. data/lib/rubocop/cop/layout/space_inside_block_braces.rb +27 -9
  110. data/lib/rubocop/cop/layout/space_inside_hash_literal_braces.rb +30 -3
  111. data/lib/rubocop/cop/layout/space_inside_parens.rb +2 -2
  112. data/lib/rubocop/cop/layout/space_inside_percent_literal_delimiters.rb +34 -0
  113. data/lib/rubocop/cop/layout/space_inside_reference_brackets.rb +10 -6
  114. data/lib/rubocop/cop/layout/space_inside_string_interpolation.rb +5 -4
  115. data/lib/rubocop/cop/layout/trailing_empty_lines.rb +1 -1
  116. data/lib/rubocop/cop/layout/trailing_whitespace.rb +12 -5
  117. data/lib/rubocop/cop/legacy/corrections_proxy.rb +1 -1
  118. data/lib/rubocop/cop/legacy/corrector.rb +1 -1
  119. data/lib/rubocop/cop/lint/ambiguous_block_association.rb +39 -8
  120. data/lib/rubocop/cop/lint/ambiguous_operator.rb +4 -0
  121. data/lib/rubocop/cop/lint/assignment_in_condition.rb +11 -1
  122. data/lib/rubocop/cop/lint/constant_resolution.rb +5 -1
  123. data/lib/rubocop/cop/lint/debugger.rb +27 -31
  124. data/lib/rubocop/cop/lint/deprecated_class_methods.rb +66 -110
  125. data/lib/rubocop/cop/lint/deprecated_constants.rb +8 -1
  126. data/lib/rubocop/cop/lint/deprecated_open_ssl_constant.rb +1 -1
  127. data/lib/rubocop/cop/lint/duplicate_branch.rb +0 -2
  128. data/lib/rubocop/cop/lint/duplicate_magic_comment.rb +73 -0
  129. data/lib/rubocop/cop/lint/duplicate_match_pattern.rb +122 -0
  130. data/lib/rubocop/cop/lint/duplicate_methods.rb +48 -18
  131. data/lib/rubocop/cop/lint/duplicate_regexp_character_class_element.rb +26 -9
  132. data/lib/rubocop/cop/lint/duplicate_require.rb +1 -1
  133. data/lib/rubocop/cop/lint/else_layout.rb +3 -7
  134. data/lib/rubocop/cop/lint/empty_block.rb +3 -7
  135. data/lib/rubocop/cop/lint/empty_class.rb +3 -1
  136. data/lib/rubocop/cop/lint/empty_conditional_body.rb +110 -2
  137. data/lib/rubocop/cop/lint/empty_interpolation.rb +1 -1
  138. data/lib/rubocop/cop/lint/erb_new_arguments.rb +11 -11
  139. data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +14 -7
  140. data/lib/rubocop/cop/lint/heredoc_method_call_position.rb +15 -17
  141. data/lib/rubocop/cop/lint/implicit_string_concatenation.rb +1 -1
  142. data/lib/rubocop/cop/lint/incompatible_io_select_with_fiber_scheduler.rb +5 -2
  143. data/lib/rubocop/cop/lint/ineffective_access_modifier.rb +1 -1
  144. data/lib/rubocop/cop/lint/interpolation_check.rb +4 -3
  145. data/lib/rubocop/cop/lint/lambda_without_literal_block.rb +1 -1
  146. data/lib/rubocop/cop/lint/literal_in_interpolation.rb +48 -2
  147. data/lib/rubocop/cop/lint/missing_cop_enable_directive.rb +18 -3
  148. data/lib/rubocop/cop/lint/missing_super.rb +31 -2
  149. data/lib/rubocop/cop/lint/mixed_regexp_capture_types.rb +1 -0
  150. data/lib/rubocop/cop/lint/nested_method_definition.rb +53 -9
  151. data/lib/rubocop/cop/lint/next_without_accumulator.rb +25 -6
  152. data/lib/rubocop/cop/lint/non_atomic_file_operation.rb +68 -28
  153. data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +12 -0
  154. data/lib/rubocop/cop/lint/number_conversion.rb +28 -6
  155. data/lib/rubocop/cop/lint/numbered_parameter_assignment.rb +2 -2
  156. data/lib/rubocop/cop/lint/or_assignment_to_constant.rb +2 -0
  157. data/lib/rubocop/cop/lint/ordered_magic_comments.rb +4 -5
  158. data/lib/rubocop/cop/lint/out_of_range_regexp_ref.rb +17 -2
  159. data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +5 -0
  160. data/lib/rubocop/cop/lint/percent_string_array.rb +1 -1
  161. data/lib/rubocop/cop/lint/percent_symbol_array.rb +1 -1
  162. data/lib/rubocop/cop/lint/redundant_cop_disable_directive.rb +49 -9
  163. data/lib/rubocop/cop/lint/redundant_cop_enable_directive.rb +6 -6
  164. data/lib/rubocop/cop/lint/redundant_dir_glob_sort.rb +7 -0
  165. data/lib/rubocop/cop/lint/redundant_require_statement.rb +48 -10
  166. data/lib/rubocop/cop/lint/redundant_safe_navigation.rb +13 -0
  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/require_range_parentheses.rb +57 -0
  175. data/lib/rubocop/cop/lint/rescue_type.rb +3 -3
  176. data/lib/rubocop/cop/lint/safe_navigation_chain.rb +41 -8
  177. data/lib/rubocop/cop/lint/safe_navigation_consistency.rb +1 -1
  178. data/lib/rubocop/cop/lint/script_permission.rb +1 -1
  179. data/lib/rubocop/cop/lint/send_with_mixin_argument.rb +5 -4
  180. data/lib/rubocop/cop/lint/shadowed_exception.rb +16 -11
  181. data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +28 -3
  182. data/lib/rubocop/cop/lint/suppressed_exception.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 +56 -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 +92 -21
  195. data/lib/rubocop/cop/metrics/abc_size.rb +4 -2
  196. data/lib/rubocop/cop/metrics/block_length.rb +16 -11
  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 +17 -11
  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 +3 -6
  206. data/lib/rubocop/cop/metrics/utils/code_length_calculator.rb +9 -6
  207. data/lib/rubocop/cop/migration/department_name.rb +1 -1
  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 +23 -2
  211. data/lib/rubocop/cop/mixin/allowed_pattern.rb +17 -1
  212. data/lib/rubocop/cop/mixin/annotation_comment.rb +14 -7
  213. data/lib/rubocop/cop/mixin/check_line_breakable.rb +5 -1
  214. data/lib/rubocop/cop/mixin/code_length.rb +1 -1
  215. data/lib/rubocop/cop/mixin/comments_help.rb +29 -7
  216. data/lib/rubocop/cop/mixin/configurable_enforced_style.rb +21 -9
  217. data/lib/rubocop/cop/mixin/def_node.rb +2 -7
  218. data/lib/rubocop/cop/mixin/documentation_comment.rb +1 -1
  219. data/lib/rubocop/cop/mixin/enforce_superclass.rb +2 -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/line_length_help.rb +11 -2
  226. data/lib/rubocop/cop/mixin/method_complexity.rb +13 -16
  227. data/lib/rubocop/cop/mixin/min_branches_count.rb +40 -0
  228. data/lib/rubocop/cop/mixin/multiline_element_indentation.rb +7 -14
  229. data/lib/rubocop/cop/mixin/multiline_element_line_breaks.rb +5 -6
  230. data/lib/rubocop/cop/mixin/ordered_gem_node.rb +1 -1
  231. data/lib/rubocop/cop/mixin/percent_array.rb +58 -1
  232. data/lib/rubocop/cop/mixin/preceding_following_alignment.rb +1 -1
  233. data/lib/rubocop/cop/mixin/range_help.rb +22 -5
  234. data/lib/rubocop/cop/mixin/require_library.rb +2 -0
  235. data/lib/rubocop/cop/mixin/rescue_node.rb +5 -3
  236. data/lib/rubocop/cop/mixin/space_after_punctuation.rb +1 -1
  237. data/lib/rubocop/cop/mixin/statement_modifier.rb +18 -3
  238. data/lib/rubocop/cop/mixin/surrounding_space.rb +13 -11
  239. data/lib/rubocop/cop/mixin/trailing_comma.rb +2 -2
  240. data/lib/rubocop/cop/mixin/visibility_help.rb +40 -5
  241. data/lib/rubocop/cop/naming/ascii_identifiers.rb +1 -1
  242. data/lib/rubocop/cop/naming/block_forwarding.rb +5 -1
  243. data/lib/rubocop/cop/naming/block_parameter_name.rb +1 -1
  244. data/lib/rubocop/cop/naming/class_and_module_camel_case.rb +3 -1
  245. data/lib/rubocop/cop/naming/constant_name.rb +3 -3
  246. data/lib/rubocop/cop/naming/heredoc_delimiter_case.rb +1 -1
  247. data/lib/rubocop/cop/naming/inclusive_language.rb +28 -6
  248. data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +22 -7
  249. data/lib/rubocop/cop/naming/method_name.rb +3 -3
  250. data/lib/rubocop/cop/naming/predicate_name.rb +31 -2
  251. data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +12 -4
  252. data/lib/rubocop/cop/registry.rb +73 -45
  253. data/lib/rubocop/cop/security/compound_hash.rb +2 -1
  254. data/lib/rubocop/cop/style/access_modifier_declarations.rb +92 -3
  255. data/lib/rubocop/cop/style/accessor_grouping.rb +46 -20
  256. data/lib/rubocop/cop/style/alias.rb +9 -1
  257. data/lib/rubocop/cop/style/arguments_forwarding.rb +6 -5
  258. data/lib/rubocop/cop/style/array_intersect.rb +111 -0
  259. data/lib/rubocop/cop/style/ascii_comments.rb +1 -1
  260. data/lib/rubocop/cop/style/attr.rb +11 -1
  261. data/lib/rubocop/cop/style/bisected_attr_accessor.rb +1 -1
  262. data/lib/rubocop/cop/style/block_comments.rb +2 -2
  263. data/lib/rubocop/cop/style/block_delimiters.rb +44 -10
  264. data/lib/rubocop/cop/style/case_equality.rb +40 -10
  265. data/lib/rubocop/cop/style/case_like_if.rb +20 -3
  266. data/lib/rubocop/cop/style/character_literal.rb +1 -1
  267. data/lib/rubocop/cop/style/class_and_module_children.rb +8 -15
  268. data/lib/rubocop/cop/style/class_equality_comparison.rb +94 -12
  269. data/lib/rubocop/cop/style/class_methods_definitions.rb +2 -1
  270. data/lib/rubocop/cop/style/collection_compact.rb +21 -5
  271. data/lib/rubocop/cop/style/collection_methods.rb +2 -0
  272. data/lib/rubocop/cop/style/colon_method_call.rb +2 -2
  273. data/lib/rubocop/cop/style/combinable_loops.rb +29 -7
  274. data/lib/rubocop/cop/style/command_literal.rb +1 -1
  275. data/lib/rubocop/cop/style/comment_annotation.rb +1 -1
  276. data/lib/rubocop/cop/style/commented_keyword.rb +2 -2
  277. data/lib/rubocop/cop/style/comparable_clamp.rb +125 -0
  278. data/lib/rubocop/cop/style/concat_array_literals.rb +94 -0
  279. data/lib/rubocop/cop/style/conditional_assignment.rb +8 -14
  280. data/lib/rubocop/cop/style/copyright.rb +6 -3
  281. data/lib/rubocop/cop/style/data_inheritance.rb +75 -0
  282. data/lib/rubocop/cop/style/dir_empty.rb +60 -0
  283. data/lib/rubocop/cop/style/disable_cops_within_source_code_directive.rb +2 -2
  284. data/lib/rubocop/cop/style/document_dynamic_eval_definition.rb +2 -2
  285. data/lib/rubocop/cop/style/documentation.rb +22 -10
  286. data/lib/rubocop/cop/style/documentation_method.rb +10 -4
  287. data/lib/rubocop/cop/style/double_negation.rb +4 -2
  288. data/lib/rubocop/cop/style/each_for_simple_loop.rb +41 -6
  289. data/lib/rubocop/cop/style/each_with_object.rb +40 -9
  290. data/lib/rubocop/cop/style/empty_block_parameter.rb +2 -2
  291. data/lib/rubocop/cop/style/empty_else.rb +37 -0
  292. data/lib/rubocop/cop/style/empty_heredoc.rb +73 -0
  293. data/lib/rubocop/cop/style/empty_lambda_parameter.rb +2 -2
  294. data/lib/rubocop/cop/style/empty_method.rb +1 -1
  295. data/lib/rubocop/cop/style/endless_method.rb +1 -1
  296. data/lib/rubocop/cop/style/eval_with_location.rb +4 -4
  297. data/lib/rubocop/cop/style/exact_regexp_match.rb +62 -0
  298. data/lib/rubocop/cop/style/explicit_block_argument.rb +5 -1
  299. data/lib/rubocop/cop/style/fetch_env_var.rb +10 -177
  300. data/lib/rubocop/cop/style/file_empty.rb +71 -0
  301. data/lib/rubocop/cop/style/file_read.rb +1 -1
  302. data/lib/rubocop/cop/style/file_write.rb +1 -1
  303. data/lib/rubocop/cop/style/for.rb +2 -0
  304. data/lib/rubocop/cop/style/format_string_token.rb +25 -6
  305. data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +1 -1
  306. data/lib/rubocop/cop/style/guard_clause.rb +127 -38
  307. data/lib/rubocop/cop/style/hash_as_last_array_item.rb +1 -0
  308. data/lib/rubocop/cop/style/hash_each_methods.rb +48 -12
  309. data/lib/rubocop/cop/style/hash_except.rb +27 -16
  310. data/lib/rubocop/cop/style/hash_like_case.rb +3 -9
  311. data/lib/rubocop/cop/style/hash_syntax.rb +26 -2
  312. data/lib/rubocop/cop/style/identical_conditional_branches.rb +15 -0
  313. data/lib/rubocop/cop/style/if_inside_else.rb +6 -0
  314. data/lib/rubocop/cop/style/if_unless_modifier.rb +112 -16
  315. data/lib/rubocop/cop/style/if_with_boolean_literal_branches.rb +29 -2
  316. data/lib/rubocop/cop/style/if_with_semicolon.rb +4 -4
  317. data/lib/rubocop/cop/style/infinite_loop.rb +2 -5
  318. data/lib/rubocop/cop/style/inverse_methods.rb +15 -11
  319. data/lib/rubocop/cop/style/invertible_unless_condition.rb +118 -0
  320. data/lib/rubocop/cop/style/line_end_concatenation.rb +4 -1
  321. data/lib/rubocop/cop/style/magic_comment_format.rb +307 -0
  322. data/lib/rubocop/cop/style/map_compact_with_conditional_block.rb +2 -2
  323. data/lib/rubocop/cop/style/map_to_hash.rb +4 -1
  324. data/lib/rubocop/cop/style/map_to_set.rb +64 -0
  325. data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +40 -24
  326. data/lib/rubocop/cop/style/method_call_with_args_parentheses/require_parentheses.rb +5 -1
  327. data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +48 -41
  328. data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +21 -2
  329. data/lib/rubocop/cop/style/method_called_on_do_end_block.rb +4 -1
  330. data/lib/rubocop/cop/style/method_def_parentheses.rb +11 -4
  331. data/lib/rubocop/cop/style/min_max.rb +3 -3
  332. data/lib/rubocop/cop/style/min_max_comparison.rb +83 -0
  333. data/lib/rubocop/cop/style/missing_else.rb +13 -1
  334. data/lib/rubocop/cop/style/mixin_grouping.rb +4 -4
  335. data/lib/rubocop/cop/style/module_function.rb +30 -8
  336. data/lib/rubocop/cop/style/multiline_block_chain.rb +3 -1
  337. data/lib/rubocop/cop/style/multiline_if_modifier.rb +0 -4
  338. data/lib/rubocop/cop/style/multiline_in_pattern_then.rb +1 -1
  339. data/lib/rubocop/cop/style/multiline_memoization.rb +2 -2
  340. data/lib/rubocop/cop/style/multiline_method_signature.rb +7 -4
  341. data/lib/rubocop/cop/style/multiline_ternary_operator.rb +18 -3
  342. data/lib/rubocop/cop/style/negated_if_else_condition.rb +17 -10
  343. data/lib/rubocop/cop/style/nested_parenthesized_calls.rb +9 -0
  344. data/lib/rubocop/cop/style/next.rb +3 -5
  345. data/lib/rubocop/cop/style/nil_lambda.rb +4 -4
  346. data/lib/rubocop/cop/style/numbered_parameters_limit.rb +11 -3
  347. data/lib/rubocop/cop/style/numeric_literals.rb +16 -1
  348. data/lib/rubocop/cop/style/numeric_predicate.rb +43 -9
  349. data/lib/rubocop/cop/style/object_then.rb +5 -0
  350. data/lib/rubocop/cop/style/one_line_conditional.rb +3 -6
  351. data/lib/rubocop/cop/style/operator_method_call.rb +67 -0
  352. data/lib/rubocop/cop/style/parallel_assignment.rb +29 -19
  353. data/lib/rubocop/cop/style/percent_literal_delimiters.rb +2 -3
  354. data/lib/rubocop/cop/style/percent_q_literals.rb +1 -1
  355. data/lib/rubocop/cop/style/perl_backrefs.rb +22 -1
  356. data/lib/rubocop/cop/style/proc.rb +4 -1
  357. data/lib/rubocop/cop/style/quoted_symbols.rb +1 -1
  358. data/lib/rubocop/cop/style/redundant_argument.rb +3 -0
  359. data/lib/rubocop/cop/style/redundant_begin.rb +3 -0
  360. data/lib/rubocop/cop/style/redundant_condition.rb +41 -8
  361. data/lib/rubocop/cop/style/redundant_conditional.rb +0 -4
  362. data/lib/rubocop/cop/style/redundant_constant_base.rb +85 -0
  363. data/lib/rubocop/cop/style/redundant_double_splat_hash_braces.rb +45 -0
  364. data/lib/rubocop/cop/style/redundant_each.rb +116 -0
  365. data/lib/rubocop/cop/style/redundant_fetch_block.rb +7 -5
  366. data/lib/rubocop/cop/style/redundant_heredoc_delimiter_quotes.rb +58 -0
  367. data/lib/rubocop/cop/style/redundant_initialize.rb +3 -1
  368. data/lib/rubocop/cop/style/redundant_interpolation.rb +2 -2
  369. data/lib/rubocop/cop/style/redundant_line_continuation.rb +183 -0
  370. data/lib/rubocop/cop/style/redundant_parentheses.rb +22 -24
  371. data/lib/rubocop/cop/style/redundant_percent_q.rb +1 -1
  372. data/lib/rubocop/cop/style/redundant_regexp_character_class.rb +9 -3
  373. data/lib/rubocop/cop/style/redundant_regexp_escape.rb +21 -4
  374. data/lib/rubocop/cop/style/redundant_return.rb +7 -0
  375. data/lib/rubocop/cop/style/redundant_self.rb +2 -0
  376. data/lib/rubocop/cop/style/redundant_sort.rb +24 -9
  377. data/lib/rubocop/cop/style/redundant_sort_by.rb +24 -8
  378. data/lib/rubocop/cop/style/redundant_string_escape.rb +183 -0
  379. data/lib/rubocop/cop/style/regexp_literal.rb +11 -2
  380. data/lib/rubocop/cop/style/require_order.rb +138 -0
  381. data/lib/rubocop/cop/style/rescue_modifier.rb +1 -1
  382. data/lib/rubocop/cop/style/rescue_standard_error.rb +2 -2
  383. data/lib/rubocop/cop/style/safe_navigation.rb +41 -10
  384. data/lib/rubocop/cop/style/select_by_regexp.rb +13 -5
  385. data/lib/rubocop/cop/style/self_assignment.rb +2 -2
  386. data/lib/rubocop/cop/style/semicolon.rb +63 -5
  387. data/lib/rubocop/cop/style/signal_exception.rb +8 -6
  388. data/lib/rubocop/cop/style/single_line_block_params.rb +1 -1
  389. data/lib/rubocop/cop/style/slicing_with_range.rb +1 -1
  390. data/lib/rubocop/cop/style/sole_nested_conditional.rb +17 -8
  391. data/lib/rubocop/cop/style/special_global_vars.rb +2 -2
  392. data/lib/rubocop/cop/style/static_class.rb +32 -1
  393. data/lib/rubocop/cop/style/stderr_puts.rb +1 -1
  394. data/lib/rubocop/cop/style/string_hash_keys.rb +4 -1
  395. data/lib/rubocop/cop/style/string_literals.rb +1 -5
  396. data/lib/rubocop/cop/style/struct_inheritance.rb +1 -1
  397. data/lib/rubocop/cop/style/symbol_array.rb +6 -5
  398. data/lib/rubocop/cop/style/symbol_proc.rb +42 -10
  399. data/lib/rubocop/cop/style/ternary_parentheses.rb +1 -13
  400. data/lib/rubocop/cop/style/top_level_method_definition.rb +3 -1
  401. data/lib/rubocop/cop/style/trailing_body_on_class.rb +1 -0
  402. data/lib/rubocop/cop/style/trailing_comma_in_arguments.rb +4 -4
  403. data/lib/rubocop/cop/style/trailing_comma_in_block_args.rb +1 -1
  404. data/lib/rubocop/cop/style/trailing_underscore_variable.rb +1 -1
  405. data/lib/rubocop/cop/style/trivial_accessors.rb +4 -1
  406. data/lib/rubocop/cop/style/unless_logical_operators.rb +1 -0
  407. data/lib/rubocop/cop/style/unpack_first.rb +3 -3
  408. data/lib/rubocop/cop/style/word_array.rb +59 -5
  409. data/lib/rubocop/cop/style/yoda_condition.rb +13 -6
  410. data/lib/rubocop/cop/style/yoda_expression.rb +90 -0
  411. data/lib/rubocop/cop/style/zero_length_predicate.rb +40 -19
  412. data/lib/rubocop/cop/team.rb +63 -56
  413. data/lib/rubocop/cop/util.rb +44 -8
  414. data/lib/rubocop/cop/variable_force/assignment.rb +5 -1
  415. data/lib/rubocop/cop/variable_force/scope.rb +3 -3
  416. data/lib/rubocop/cop/variable_force/variable.rb +5 -3
  417. data/lib/rubocop/cop/variable_force/variable_table.rb +6 -4
  418. data/lib/rubocop/cop/variable_force.rb +18 -30
  419. data/lib/rubocop/cops_documentation_generator.rb +45 -15
  420. data/lib/rubocop/directive_comment.rb +4 -4
  421. data/lib/rubocop/ext/comment.rb +18 -0
  422. data/lib/rubocop/ext/processed_source.rb +2 -0
  423. data/lib/rubocop/ext/range.rb +15 -0
  424. data/lib/rubocop/ext/regexp_node.rb +1 -1
  425. data/lib/rubocop/ext/regexp_parser.rb +1 -1
  426. data/lib/rubocop/feature_loader.rb +94 -0
  427. data/lib/rubocop/file_patterns.rb +43 -0
  428. data/lib/rubocop/formatter/clang_style_formatter.rb +1 -1
  429. data/lib/rubocop/formatter/disabled_config_formatter.rb +26 -9
  430. data/lib/rubocop/formatter/html_formatter.rb +4 -4
  431. data/lib/rubocop/formatter/junit_formatter.rb +4 -1
  432. data/lib/rubocop/formatter/markdown_formatter.rb +1 -1
  433. data/lib/rubocop/formatter/offense_count_formatter.rb +8 -5
  434. data/lib/rubocop/formatter/simple_text_formatter.rb +1 -1
  435. data/lib/rubocop/formatter/tap_formatter.rb +1 -1
  436. data/lib/rubocop/formatter/worst_offenders_formatter.rb +6 -3
  437. data/lib/rubocop/formatter.rb +4 -1
  438. data/lib/rubocop/options.rb +55 -22
  439. data/lib/rubocop/path_util.rb +50 -22
  440. data/lib/rubocop/rake_task.rb +5 -1
  441. data/lib/rubocop/result_cache.rb +26 -24
  442. data/lib/rubocop/rspec/cop_helper.rb +26 -3
  443. data/lib/rubocop/rspec/expect_offense.rb +6 -4
  444. data/lib/rubocop/rspec/shared_contexts.rb +31 -14
  445. data/lib/rubocop/rspec/support.rb +17 -2
  446. data/lib/rubocop/runner.rb +73 -18
  447. data/lib/rubocop/server/cache.rb +48 -2
  448. data/lib/rubocop/server/cli.rb +62 -19
  449. data/lib/rubocop/server/client_command/base.rb +1 -1
  450. data/lib/rubocop/server/client_command/exec.rb +6 -1
  451. data/lib/rubocop/server/client_command/start.rb +6 -1
  452. data/lib/rubocop/server/core.rb +42 -10
  453. data/lib/rubocop/server/helper.rb +1 -1
  454. data/lib/rubocop/server/server_command/exec.rb +1 -1
  455. data/lib/rubocop/server/socket_reader.rb +5 -1
  456. data/lib/rubocop/server.rb +1 -1
  457. data/lib/rubocop/target_finder.rb +1 -1
  458. data/lib/rubocop/target_ruby.rb +5 -5
  459. data/lib/rubocop/version.rb +10 -4
  460. data/lib/rubocop.rb +45 -9
  461. metadata +58 -33
  462. data/lib/rubocop/cop/mixin/ignored_methods.rb +0 -52
data/config/default.yml CHANGED
@@ -140,7 +140,7 @@ AllCops:
140
140
  # or gems.locked file. (Although the Ruby version is specified in the Gemfile
141
141
  # or gems.rb file, RuboCop reads the final value from the lock file.) If the
142
142
  # Ruby version is still unresolved, RuboCop will use the oldest officially
143
- # supported Ruby version (currently Ruby 2.6).
143
+ # supported Ruby version (currently Ruby 2.7).
144
144
  TargetRubyVersion: ~
145
145
  # Determines if a notification for extension libraries should be shown when
146
146
  # rubocop is run. Keys are the name of the extension, and values are an array
@@ -153,6 +153,8 @@ AllCops:
153
153
  rubocop-sequel: [sequel]
154
154
  rubocop-rake: [rake]
155
155
  rubocop-graphql: [graphql]
156
+ rubocop-capybara: [capybara]
157
+ rubocop-factory_bot: [factory_bot, factory_bot_rails]
156
158
  # Enable/Disable checking the methods extended by Active Support.
157
159
  ActiveSupportExtensionsEnabled: false
158
160
 
@@ -161,7 +163,9 @@ AllCops:
161
163
  Bundler/DuplicatedGem:
162
164
  Description: 'Checks for duplicate gem entries in Gemfile.'
163
165
  Enabled: true
166
+ Severity: warning
164
167
  VersionAdded: '0.46'
168
+ VersionChanged: '1.40'
165
169
  Include:
166
170
  - '**/*.gemfile'
167
171
  - '**/Gemfile'
@@ -213,7 +217,9 @@ Bundler/InsecureProtocolSource:
213
217
  because HTTP requests are insecure. Please change your source to
214
218
  'https://rubygems.org' if possible, or 'http://rubygems.org' if not.
215
219
  Enabled: true
220
+ Severity: warning
216
221
  VersionAdded: '0.50'
222
+ VersionChanged: '1.40'
217
223
  AllowHttpProtocol: true
218
224
  Include:
219
225
  - '**/*.gemfile'
@@ -252,14 +258,33 @@ Gemspec/DependencyVersion:
252
258
  Gemspec/DeprecatedAttributeAssignment:
253
259
  Description: Checks that deprecated attribute assignments are not set in a gemspec file.
254
260
  Enabled: pending
261
+ Severity: warning
255
262
  VersionAdded: '1.30'
263
+ VersionChanged: '1.40'
264
+ Include:
265
+ - '**/*.gemspec'
266
+
267
+ Gemspec/DevelopmentDependencies:
268
+ Description: Checks that development dependencies are specified in Gemfile rather than gemspec.
269
+ Enabled: pending
270
+ VersionAdded: '1.44'
271
+ EnforcedStyle: Gemfile
272
+ SupportedStyles:
273
+ - Gemfile
274
+ - gems.rb
275
+ - gemspec
276
+ AllowedGems: []
256
277
  Include:
257
278
  - '**/*.gemspec'
279
+ - '**/Gemfile'
280
+ - '**/gems.rb'
258
281
 
259
282
  Gemspec/DuplicatedAssignment:
260
283
  Description: 'An attribute assignment method calls should be listed only once in a gemspec.'
261
284
  Enabled: true
285
+ Severity: warning
262
286
  VersionAdded: '0.52'
287
+ VersionChanged: '1.40'
263
288
  Include:
264
289
  - '**/*.gemspec'
265
290
 
@@ -278,7 +303,9 @@ Gemspec/OrderedDependencies:
278
303
  Gemspec/RequireMFA:
279
304
  Description: 'Checks that the gemspec has metadata to require Multi-Factor Authentication from RubyGems.'
280
305
  Enabled: pending
306
+ Severity: warning
281
307
  VersionAdded: '1.23'
308
+ VersionChanged: '1.40'
282
309
  Reference:
283
310
  - https://guides.rubygems.org/mfa-requirement-opt-in/
284
311
  Include:
@@ -287,8 +314,9 @@ Gemspec/RequireMFA:
287
314
  Gemspec/RequiredRubyVersion:
288
315
  Description: 'Checks that `required_ruby_version` of gemspec is specified and equal to `TargetRubyVersion` of .rubocop.yml.'
289
316
  Enabled: true
317
+ Severity: warning
290
318
  VersionAdded: '0.52'
291
- VersionChanged: '1.22'
319
+ VersionChanged: '1.40'
292
320
  Include:
293
321
  - '**/*.gemspec'
294
322
 
@@ -296,7 +324,9 @@ Gemspec/RubyVersionGlobalsUsage:
296
324
  Description: Checks usage of RUBY_VERSION in gemspec.
297
325
  StyleGuide: '#no-ruby-version-in-the-gemspec'
298
326
  Enabled: true
327
+ Severity: warning
299
328
  VersionAdded: '0.72'
329
+ VersionChanged: '1.40'
300
330
  Include:
301
331
  - '**/*.gemspec'
302
332
 
@@ -379,7 +409,7 @@ Layout/AssignmentIndentation:
379
409
  right-hand-side of a multi-line assignment.
380
410
  Enabled: true
381
411
  VersionAdded: '0.49'
382
- VersionChanged: '0.77'
412
+ VersionChanged: '1.45'
383
413
  # By default the indentation width from `Layout/IndentationWidth` is used,
384
414
  # but it can be overridden by setting this parameter.
385
415
  IndentationWidth: ~
@@ -748,6 +778,7 @@ Layout/FirstArrayElementLineBreak:
748
778
  multi-line array.
749
779
  Enabled: false
750
780
  VersionAdded: '0.49'
781
+ AllowMultilineFinalElement: false
751
782
 
752
783
  Layout/FirstHashElementIndentation:
753
784
  Description: 'Checks the indentation of the first key in a hash literal.'
@@ -780,6 +811,7 @@ Layout/FirstHashElementLineBreak:
780
811
  multi-line hash.
781
812
  Enabled: false
782
813
  VersionAdded: '0.49'
814
+ AllowMultilineFinalElement: false
783
815
 
784
816
  Layout/FirstMethodArgumentLineBreak:
785
817
  Description: >-
@@ -787,6 +819,7 @@ Layout/FirstMethodArgumentLineBreak:
787
819
  multi-line method call.
788
820
  Enabled: false
789
821
  VersionAdded: '0.49'
822
+ AllowMultilineFinalElement: false
790
823
 
791
824
  Layout/FirstMethodParameterLineBreak:
792
825
  Description: >-
@@ -794,6 +827,7 @@ Layout/FirstMethodParameterLineBreak:
794
827
  multi-line method parameter definition.
795
828
  Enabled: false
796
829
  VersionAdded: '0.49'
830
+ AllowMultilineFinalElement: false
797
831
 
798
832
  Layout/FirstParameterIndentation:
799
833
  Description: >-
@@ -946,7 +980,6 @@ Layout/IndentationWidth:
946
980
  # Number of spaces for each indentation level.
947
981
  Width: 2
948
982
  AllowedPatterns: []
949
- IgnoredPatterns: [] # deprecated
950
983
 
951
984
  Layout/InitialIndentation:
952
985
  Description: >-
@@ -974,15 +1007,16 @@ Layout/LineContinuationLeadingSpace:
974
1007
  Use trailing spaces instead of leading spaces in strings
975
1008
  broken over multiple lines (by a backslash).
976
1009
  Enabled: pending
977
- AutoCorrect: false
978
- SafeAutoCorrect: false
979
1010
  VersionAdded: '1.31'
1011
+ VersionChanged: '1.45'
1012
+ EnforcedStyle: trailing
1013
+ SupportedStyles:
1014
+ - leading
1015
+ - trailing
980
1016
 
981
1017
  Layout/LineContinuationSpacing:
982
1018
  Description: 'Checks the spacing in front of backslash in line continuations.'
983
1019
  Enabled: pending
984
- AutoCorrect: true
985
- SafeAutoCorrect: true
986
1020
  VersionAdded: '1.31'
987
1021
  EnforcedStyle: space
988
1022
  SupportedStyles:
@@ -1024,7 +1058,6 @@ Layout/LineLength:
1024
1058
  # elements. Strings will be converted to Regexp objects. A line that matches
1025
1059
  # any regular expression listed in this option will be ignored by LineLength.
1026
1060
  AllowedPatterns: []
1027
- IgnoredPatterns: [] # deprecated
1028
1061
 
1029
1062
  Layout/MultilineArrayBraceLayout:
1030
1063
  Description: >-
@@ -1048,6 +1081,7 @@ Layout/MultilineArrayLineBreaks:
1048
1081
  starts on a separate line.
1049
1082
  Enabled: false
1050
1083
  VersionAdded: '0.67'
1084
+ AllowMultilineFinalElement: false
1051
1085
 
1052
1086
  Layout/MultilineAssignmentLayout:
1053
1087
  Description: 'Check for a newline after the assignment operator in multi-line assignments.'
@@ -1098,6 +1132,7 @@ Layout/MultilineHashKeyLineBreaks:
1098
1132
  starts on a separate line.
1099
1133
  Enabled: false
1100
1134
  VersionAdded: '0.67'
1135
+ AllowMultilineFinalElement: false
1101
1136
 
1102
1137
  Layout/MultilineMethodArgumentLineBreaks:
1103
1138
  Description: >-
@@ -1105,6 +1140,7 @@ Layout/MultilineMethodArgumentLineBreaks:
1105
1140
  starts on a separate line.
1106
1141
  Enabled: false
1107
1142
  VersionAdded: '0.67'
1143
+ AllowMultilineFinalElement: false
1108
1144
 
1109
1145
  Layout/MultilineMethodCallBraceLayout:
1110
1146
  Description: >-
@@ -1153,6 +1189,14 @@ Layout/MultilineMethodDefinitionBraceLayout:
1153
1189
  - new_line
1154
1190
  - same_line
1155
1191
 
1192
+ Layout/MultilineMethodParameterLineBreaks:
1193
+ Description: >-
1194
+ Checks that each parameter in a multi-line method definition
1195
+ starts on a separate line.
1196
+ Enabled: false
1197
+ VersionAdded: '1.32'
1198
+ AllowMultilineFinalElement: false
1199
+
1156
1200
  Layout/MultilineOperationIndentation:
1157
1201
  Description: >-
1158
1202
  Checks indentation of binary operations that span more than
@@ -1490,7 +1534,8 @@ Lint/AmbiguousBlockAssociation:
1490
1534
  Enabled: true
1491
1535
  VersionAdded: '0.48'
1492
1536
  VersionChanged: '1.13'
1493
- IgnoredMethods: []
1537
+ AllowedMethods: []
1538
+ AllowedPatterns: []
1494
1539
 
1495
1540
  Lint/AmbiguousOperator:
1496
1541
  Description: >-
@@ -1527,7 +1572,9 @@ Lint/AssignmentInCondition:
1527
1572
  Description: "Don't use assignment in conditions."
1528
1573
  StyleGuide: '#safe-assignment-in-condition'
1529
1574
  Enabled: true
1575
+ SafeAutoCorrect: false
1530
1576
  VersionAdded: '0.9'
1577
+ VersionChanged: '1.45'
1531
1578
  AllowSafeAssignment: true
1532
1579
 
1533
1580
  Lint/BigDecimalNew:
@@ -1583,13 +1630,13 @@ Lint/Debugger:
1583
1630
  Description: 'Check for debugger calls.'
1584
1631
  Enabled: true
1585
1632
  VersionAdded: '0.14'
1586
- VersionChanged: '1.10'
1587
- DebuggerReceivers: [] # deprecated
1633
+ VersionChanged: '1.46'
1588
1634
  DebuggerMethods:
1589
1635
  # Groups are available so that a specific group can be disabled in
1590
1636
  # a user's configuration, but are otherwise not significant.
1591
1637
  Kernel:
1592
1638
  - binding.irb
1639
+ - Kernel.binding.irb
1593
1640
  Byebug:
1594
1641
  - byebug
1595
1642
  - remote_byebug
@@ -1607,7 +1654,11 @@ Lint/Debugger:
1607
1654
  - binding.pry
1608
1655
  - binding.remote_pry
1609
1656
  - binding.pry_remote
1657
+ - Kernel.binding.pry
1658
+ - Kernel.binding.remote_pry
1659
+ - Kernel.binding.pry_remote
1610
1660
  - Pry.rescue
1661
+ - pry
1611
1662
  Rails:
1612
1663
  - debugger
1613
1664
  - Kernel.debugger
@@ -1625,7 +1676,7 @@ Lint/DeprecatedConstants:
1625
1676
  Description: 'Checks for deprecated constants.'
1626
1677
  Enabled: pending
1627
1678
  VersionAdded: '1.8'
1628
- VersionChanged: '1.22'
1679
+ VersionChanged: '1.40'
1629
1680
  # You can configure deprecated constants.
1630
1681
  # If there is an alternative method, you can set alternative value as `Alternative`.
1631
1682
  # And you can set the deprecated version as `DeprecatedVersion`.
@@ -1652,6 +1703,12 @@ Lint/DeprecatedConstants:
1652
1703
  'Random::DEFAULT':
1653
1704
  Alternative: 'Random.new'
1654
1705
  DeprecatedVersion: '3.0'
1706
+ 'Struct::Group':
1707
+ Alternative: 'Etc::Group'
1708
+ DeprecatedVersion: '3.0'
1709
+ 'Struct::Passwd':
1710
+ Alternative: 'Etc::Passwd'
1711
+ DeprecatedVersion: '3.0'
1655
1712
 
1656
1713
  Lint/DeprecatedOpenSSLConstant:
1657
1714
  Description: "Don't use algorithm constants for `OpenSSL::Cipher` and `OpenSSL::Digest`."
@@ -1689,6 +1746,16 @@ Lint/DuplicateHashKey:
1689
1746
  VersionAdded: '0.34'
1690
1747
  VersionChanged: '0.77'
1691
1748
 
1749
+ Lint/DuplicateMagicComment:
1750
+ Description: 'Check for duplicated magic comments.'
1751
+ Enabled: pending
1752
+ VersionAdded: '1.37'
1753
+
1754
+ Lint/DuplicateMatchPattern:
1755
+ Description: 'Do not repeat patterns in `in` keywords.'
1756
+ Enabled: pending
1757
+ VersionAdded: '1.50'
1758
+
1692
1759
  Lint/DuplicateMethods:
1693
1760
  Description: 'Check for duplicate method definitions.'
1694
1761
  Enabled: true
@@ -1739,8 +1806,10 @@ Lint/EmptyClass:
1739
1806
  Lint/EmptyConditionalBody:
1740
1807
  Description: 'Checks for the presence of `if`, `elsif` and `unless` branches without a body.'
1741
1808
  Enabled: true
1809
+ SafeAutoCorrect: false
1742
1810
  AllowComments: true
1743
1811
  VersionAdded: '0.89'
1812
+ VersionChanged: '1.34'
1744
1813
 
1745
1814
  Lint/EmptyEnsure:
1746
1815
  Description: 'Checks for empty ensure block.'
@@ -1869,11 +1938,11 @@ Lint/InheritException:
1869
1938
  - runtime_error
1870
1939
 
1871
1940
  Lint/InterpolationCheck:
1872
- Description: 'Raise warning for interpolation in single q strs.'
1941
+ Description: 'Checks for interpolation in a single quoted string.'
1873
1942
  Enabled: true
1874
- Safe: false
1943
+ SafeAutoCorrect: false
1875
1944
  VersionAdded: '0.50'
1876
- VersionChanged: '0.87'
1945
+ VersionChanged: '1.40'
1877
1946
 
1878
1947
  Lint/LambdaWithoutLiteralBlock:
1879
1948
  Description: 'Checks uses of lambda without a literal block.'
@@ -1937,6 +2006,8 @@ Lint/NestedMethodDefinition:
1937
2006
  Description: 'Do not use nested method definitions.'
1938
2007
  StyleGuide: '#no-nested-methods'
1939
2008
  Enabled: true
2009
+ AllowedMethods: []
2010
+ AllowedPatterns: []
1940
2011
  VersionAdded: '0.32'
1941
2012
 
1942
2013
  Lint/NestedPercentLiteral:
@@ -1958,6 +2029,7 @@ Lint/NoReturnInBeginEndBlocks:
1958
2029
 
1959
2030
  Lint/NonAtomicFileOperation:
1960
2031
  Description: Checks for non-atomic file operations.
2032
+ StyleGuide: '#atomic-file-operations'
1961
2033
  Enabled: pending
1962
2034
  VersionAdded: '1.31'
1963
2035
  SafeAutoCorrect: false
@@ -1979,7 +2051,8 @@ Lint/NumberConversion:
1979
2051
  VersionAdded: '0.53'
1980
2052
  VersionChanged: '1.1'
1981
2053
  SafeAutoCorrect: false
1982
- IgnoredMethods: []
2054
+ AllowedMethods: []
2055
+ AllowedPatterns: []
1983
2056
  IgnoredClasses:
1984
2057
  - Time
1985
2058
  - DateTime
@@ -1998,7 +2071,9 @@ Lint/OrAssignmentToConstant:
1998
2071
  Lint/OrderedMagicComments:
1999
2072
  Description: 'Checks the proper ordering of magic comments and whether a magic comment is not placed before a shebang.'
2000
2073
  Enabled: true
2074
+ SafeAutoCorrect: false
2001
2075
  VersionAdded: '0.53'
2076
+ VersionChanged: '1.37'
2002
2077
 
2003
2078
  Lint/OutOfRangeRegexpRef:
2004
2079
  Description: 'Checks for out of range reference for Regexp because it always returns nil.'
@@ -2128,6 +2203,11 @@ Lint/RequireParentheses:
2128
2203
  Enabled: true
2129
2204
  VersionAdded: '0.18'
2130
2205
 
2206
+ Lint/RequireRangeParentheses:
2207
+ Description: 'Checks that a range literal is enclosed in parentheses when the end of the range is at a line break.'
2208
+ Enabled: pending
2209
+ VersionAdded: '1.32'
2210
+
2131
2211
  Lint/RequireRelativeSelfPath:
2132
2212
  Description: 'Checks for uses a file requiring itself with `require_relative`.'
2133
2213
  Enabled: pending
@@ -2264,6 +2344,9 @@ Lint/TopLevelReturnWithArgument:
2264
2344
  Description: 'Detects top level return statements with argument.'
2265
2345
  Enabled: true
2266
2346
  VersionAdded: '0.89'
2347
+ # These codes are `eval`-ed in method and their return values may be used.
2348
+ Exclude:
2349
+ - '**/*.jb'
2267
2350
 
2268
2351
  Lint/TrailingCommaInAttributeDeclaration:
2269
2352
  Description: 'Checks for trailing commas in attribute declarations.'
@@ -2323,7 +2406,6 @@ Lint/UnreachableLoop:
2323
2406
  # RSpec uses `times` in its message expectations
2324
2407
  # eg. `exactly(2).times`
2325
2408
  - !ruby/regexp /(exactly|at_least|at_most)\(\d+\)\.times/
2326
- IgnoredPatterns: [] # deprecated
2327
2409
 
2328
2410
  Lint/UnusedBlockArgument:
2329
2411
  Description: 'Checks for unused block arguments.'
@@ -2373,6 +2455,8 @@ Lint/UselessAssignment:
2373
2455
  StyleGuide: '#underscore-unused-vars'
2374
2456
  Enabled: true
2375
2457
  VersionAdded: '0.11'
2458
+ VersionChanged: '1.51'
2459
+ SafeAutoCorrect: false
2376
2460
 
2377
2461
  Lint/UselessElseWithoutRescue:
2378
2462
  Description: 'Checks for useless `else` in `begin..end` without `rescue`.'
@@ -2387,6 +2471,11 @@ Lint/UselessMethodDefinition:
2387
2471
  VersionChanged: '0.91'
2388
2472
  Safe: false
2389
2473
 
2474
+ Lint/UselessRescue:
2475
+ Description: 'Checks for useless `rescue`s.'
2476
+ Enabled: pending
2477
+ VersionAdded: '1.43'
2478
+
2390
2479
  Lint/UselessRuby2Keywords:
2391
2480
  Description: 'Finds unnecessary uses of `ruby2_keywords`.'
2392
2481
  Enabled: pending
@@ -2426,7 +2515,8 @@ Metrics/AbcSize:
2426
2515
  VersionChanged: '1.5'
2427
2516
  # The ABC size is a calculated magnitude, so this number can be an Integer or
2428
2517
  # a Float.
2429
- IgnoredMethods: []
2518
+ AllowedMethods: []
2519
+ AllowedPatterns: []
2430
2520
  CountRepeatedAttributes: true
2431
2521
  Max: 17
2432
2522
 
@@ -2438,11 +2528,11 @@ Metrics/BlockLength:
2438
2528
  CountComments: false # count full line comments?
2439
2529
  Max: 25
2440
2530
  CountAsOne: []
2441
- ExcludedMethods: [] # deprecated, retained for backwards compatibility
2442
- IgnoredMethods:
2531
+ AllowedMethods:
2443
2532
  # By default, exclude the `#refine` method, as it tends to have larger
2444
2533
  # associated blocks.
2445
2534
  - refine
2535
+ AllowedPatterns: []
2446
2536
  Exclude:
2447
2537
  - '**/*.gemspec'
2448
2538
 
@@ -2464,6 +2554,12 @@ Metrics/ClassLength:
2464
2554
  Max: 100
2465
2555
  CountAsOne: []
2466
2556
 
2557
+ Metrics/CollectionLiteralLength:
2558
+ Description: 'Checks for `Array` or `Hash` literals with many entries.'
2559
+ Enabled: pending
2560
+ VersionAdded: '1.47'
2561
+ LengthThreshold: 250
2562
+
2467
2563
  # Avoid complex methods.
2468
2564
  Metrics/CyclomaticComplexity:
2469
2565
  Description: >-
@@ -2472,7 +2568,8 @@ Metrics/CyclomaticComplexity:
2472
2568
  Enabled: true
2473
2569
  VersionAdded: '0.25'
2474
2570
  VersionChanged: '0.81'
2475
- IgnoredMethods: []
2571
+ AllowedMethods: []
2572
+ AllowedPatterns: []
2476
2573
  Max: 7
2477
2574
 
2478
2575
  Metrics/MethodLength:
@@ -2484,8 +2581,8 @@ Metrics/MethodLength:
2484
2581
  CountComments: false # count full line comments?
2485
2582
  Max: 10
2486
2583
  CountAsOne: []
2487
- ExcludedMethods: [] # deprecated, retained for backwards compatibility
2488
- IgnoredMethods: []
2584
+ AllowedMethods: []
2585
+ AllowedPatterns: []
2489
2586
 
2490
2587
  Metrics/ModuleLength:
2491
2588
  Description: 'Avoid modules longer than 100 lines of code.'
@@ -2513,7 +2610,8 @@ Metrics/PerceivedComplexity:
2513
2610
  Enabled: true
2514
2611
  VersionAdded: '0.25'
2515
2612
  VersionChanged: '0.81'
2516
- IgnoredMethods: []
2613
+ AllowedMethods: []
2614
+ AllowedPatterns: []
2517
2615
  Max: 8
2518
2616
 
2519
2617
  ################## Migration #############################
@@ -2684,13 +2782,13 @@ Naming/HeredocDelimiterNaming:
2684
2782
  Enabled: true
2685
2783
  VersionAdded: '0.50'
2686
2784
  ForbiddenDelimiters:
2687
- - !ruby/regexp '/(^|\s)(EO[A-Z]{1}|END)(\s|$)/'
2785
+ - !ruby/regexp '/(^|\s)(EO[A-Z]{1}|END)(\s|$)/i'
2688
2786
 
2689
2787
  Naming/InclusiveLanguage:
2690
2788
  Description: 'Recommend the use of inclusive language instead of problematic terms.'
2691
2789
  Enabled: false
2692
2790
  VersionAdded: '1.18'
2693
- VersionChanged: '1.21'
2791
+ VersionChanged: '1.49'
2694
2792
  CheckIdentifiers: true
2695
2793
  CheckConstants: true
2696
2794
  CheckVariables: true
@@ -2742,7 +2840,6 @@ Naming/MethodName:
2742
2840
  # - '\A\s*onSelectionCleared\s*'
2743
2841
  #
2744
2842
  AllowedPatterns: []
2745
- IgnoredPatterns: [] # deprecated
2746
2843
 
2747
2844
  Naming/MethodParameterName:
2748
2845
  Description: >-
@@ -2756,10 +2853,13 @@ Naming/MethodParameterName:
2756
2853
  AllowNamesEndingInNumbers: true
2757
2854
  # Allowed names that will not register an offense
2758
2855
  AllowedNames:
2856
+ - as
2759
2857
  - at
2760
2858
  - by
2859
+ - cc
2761
2860
  - db
2762
2861
  - id
2862
+ - if
2763
2863
  - in
2764
2864
  - io
2765
2865
  - ip
@@ -2840,6 +2940,7 @@ Naming/VariableNumber:
2840
2940
  - rfc822 # Time#rfc822
2841
2941
  - rfc2822 # Time#rfc2822
2842
2942
  - rfc3339 # DateTime.rfc3339
2943
+ - x86_64 # Allowed by default as an underscore separated CPU architecture name
2843
2944
  AllowedPatterns: []
2844
2945
 
2845
2946
  #################### Security ##############################
@@ -2847,7 +2948,9 @@ Naming/VariableNumber:
2847
2948
  Security/CompoundHash:
2848
2949
  Description: 'When overwriting Object#hash to combine values, prefer delegating to Array#hash over writing a custom implementation.'
2849
2950
  Enabled: pending
2951
+ Safe: false
2850
2952
  VersionAdded: '1.28'
2953
+ VersionChanged: '1.51'
2851
2954
 
2852
2955
  Security/Eval:
2853
2956
  Description: 'The use of eval represents a serious security risk.'
@@ -2910,6 +3013,7 @@ Style/AccessModifierDeclarations:
2910
3013
  - inline
2911
3014
  - group
2912
3015
  AllowModifiersOnSymbols: true
3016
+ SafeAutoCorrect: false
2913
3017
 
2914
3018
  Style/AccessorGrouping:
2915
3019
  Description: 'Checks for grouping of accessors in `class` and `module` bodies.'
@@ -2963,6 +3067,12 @@ Style/ArrayCoercion:
2963
3067
  Enabled: false
2964
3068
  VersionAdded: '0.88'
2965
3069
 
3070
+ Style/ArrayIntersect:
3071
+ Description: 'Use `array1.intersect?(array2)` instead of `(array1 & array2).any?`.'
3072
+ Enabled: 'pending'
3073
+ Safe: false
3074
+ VersionAdded: '1.40'
3075
+
2966
3076
  Style/ArrayJoin:
2967
3077
  Description: 'Use Array#join instead of Array#*.'
2968
3078
  StyleGuide: '#array-join'
@@ -3044,7 +3154,7 @@ Style/BlockDelimiters:
3044
3154
  # This looks at the usage of a block's method to determine its type (e.g. is
3045
3155
  # the result of a `map` assigned to a variable or passed to another
3046
3156
  # method) but exceptions are permitted in the `ProceduralMethods`,
3047
- # `FunctionalMethods` and `IgnoredMethods` sections below.
3157
+ # `FunctionalMethods` and `AllowedMethods` sections below.
3048
3158
  - semantic
3049
3159
  # The `braces_for_chaining` style enforces braces around single line blocks
3050
3160
  # and do..end around multi-line blocks, except for multi-line blocks whose
@@ -3085,7 +3195,7 @@ Style/BlockDelimiters:
3085
3195
  - let!
3086
3196
  - subject
3087
3197
  - watch
3088
- IgnoredMethods:
3198
+ AllowedMethods:
3089
3199
  # Methods that can be either procedural or functional and cannot be
3090
3200
  # categorised from their usage alone, e.g.
3091
3201
  #
@@ -3102,6 +3212,7 @@ Style/BlockDelimiters:
3102
3212
  - lambda
3103
3213
  - proc
3104
3214
  - it
3215
+ AllowedPatterns: []
3105
3216
  # The AllowBracesOnProceduralOneLiners option is ignored unless the
3106
3217
  # EnforcedStyle is set to `semantic`. If so:
3107
3218
  #
@@ -3125,7 +3236,7 @@ Style/BlockDelimiters:
3125
3236
  # collection.each do |element| puts element end
3126
3237
  AllowBracesOnProceduralOneLiners: false
3127
3238
  # The BracesRequiredMethods overrides all other configurations except
3128
- # IgnoredMethods. It can be used to enforce that all blocks for specific
3239
+ # AllowedMethods. It can be used to enforce that all blocks for specific
3129
3240
  # methods use braces. For example, you can use this to enforce Sorbet
3130
3241
  # signatures use braces even when the rest of your codebase enforces
3131
3242
  # the `line_count_based` style.
@@ -3146,6 +3257,15 @@ Style/CaseEquality:
3146
3257
  # # good
3147
3258
  # String === "string"
3148
3259
  AllowOnConstant: false
3260
+ # If `AllowOnSelfClass` option is enabled, the cop will ignore violations when the receiver of
3261
+ # the case equality operator is `self.class`.
3262
+ #
3263
+ # # bad
3264
+ # some_class === object
3265
+ #
3266
+ # # good
3267
+ # self.class === object
3268
+ AllowOnSelfClass: false
3149
3269
 
3150
3270
  Style/CaseLikeIf:
3151
3271
  Description: 'Identifies places where `if-elsif` constructions can be replaced with `case-when`.'
@@ -3153,6 +3273,9 @@ Style/CaseLikeIf:
3153
3273
  Enabled: true
3154
3274
  Safe: false
3155
3275
  VersionAdded: '0.88'
3276
+ VersionChanged: '1.48'
3277
+ # `MinBranchesCount` defines the number of branches `if` needs to have to trigger this cop.
3278
+ MinBranchesCount: 3
3156
3279
 
3157
3280
  Style/CharacterLiteral:
3158
3281
  Description: 'Checks for uses of character literals.'
@@ -3165,7 +3288,7 @@ Style/ClassAndModuleChildren:
3165
3288
  StyleGuide: '#namespace-definition'
3166
3289
  # Moving from compact to nested children requires knowledge of whether the
3167
3290
  # outer parent is a module or a class. Moving from nested to compact requires
3168
- # verification that the outer parent is defined elsewhere. Rubocop does not
3291
+ # verification that the outer parent is defined elsewhere. RuboCop does not
3169
3292
  # have the knowledge to perform either operation safely and thus requires
3170
3293
  # manual oversight.
3171
3294
  SafeAutoCorrect: false
@@ -3205,10 +3328,11 @@ Style/ClassEqualityComparison:
3205
3328
  StyleGuide: '#instance-of-vs-class-comparison'
3206
3329
  Enabled: true
3207
3330
  VersionAdded: '0.93'
3208
- IgnoredMethods:
3331
+ AllowedMethods:
3209
3332
  - ==
3210
3333
  - equal?
3211
3334
  - eql?
3335
+ AllowedPatterns: []
3212
3336
 
3213
3337
  Style/ClassMethods:
3214
3338
  Description: 'Use self when defining module/class methods.'
@@ -3329,6 +3453,17 @@ Style/CommentedKeyword:
3329
3453
  VersionAdded: '0.51'
3330
3454
  VersionChanged: '1.19'
3331
3455
 
3456
+ Style/ComparableClamp:
3457
+ Description: 'Enforces the use of `Comparable#clamp` instead of comparison by minimum and maximum.'
3458
+ Enabled: pending
3459
+ VersionAdded: '1.44'
3460
+
3461
+ Style/ConcatArrayLiterals:
3462
+ Description: 'Enforces the use of `Array#push(item)` instead of `Array#concat([item])` to avoid redundant array literals.'
3463
+ Enabled: pending
3464
+ Safe: false
3465
+ VersionAdded: '1.41'
3466
+
3332
3467
  Style/ConditionalAssignment:
3333
3468
  Description: >-
3334
3469
  Use the return value of `if` and `case` statements for
@@ -3384,9 +3519,17 @@ Style/Copyright:
3384
3519
  Notice: '^Copyright (\(c\) )?2[0-9]{3} .+'
3385
3520
  AutocorrectNotice: ''
3386
3521
 
3522
+ Style/DataInheritance:
3523
+ Description: 'Checks for inheritance from Data.define.'
3524
+ StyleGuide: '#no-extend-data-define'
3525
+ Enabled: pending
3526
+ SafeAutoCorrect: false
3527
+ VersionAdded: '1.49'
3528
+ VersionChanged: '1.51'
3529
+
3387
3530
  Style/DateTime:
3388
3531
  Description: 'Use Time over DateTime.'
3389
- StyleGuide: '#date--time'
3532
+ StyleGuide: '#date-time'
3390
3533
  Enabled: false
3391
3534
  VersionAdded: '0.51'
3392
3535
  VersionChanged: '0.92'
@@ -3407,6 +3550,12 @@ Style/Dir:
3407
3550
  Enabled: true
3408
3551
  VersionAdded: '0.50'
3409
3552
 
3553
+ Style/DirEmpty:
3554
+ Description: >-
3555
+ Prefer to use `Dir.empty?('path/to/dir')` when checking if a directory is empty.
3556
+ Enabled: pending
3557
+ VersionAdded: '1.48'
3558
+
3410
3559
  Style/DisableCopsWithinSourceCodeDirective:
3411
3560
  Description: >-
3412
3561
  Forbids disabling/enabling cops within source code.
@@ -3495,6 +3644,12 @@ Style/EmptyElse:
3495
3644
  - empty
3496
3645
  - nil
3497
3646
  - both
3647
+ AllowComments: false
3648
+
3649
+ Style/EmptyHeredoc:
3650
+ Description: 'Checks for using empty heredoc to reduce redundancy.'
3651
+ Enabled: pending
3652
+ VersionAdded: '1.32'
3498
3653
 
3499
3654
  Style/EmptyLambdaParameter:
3500
3655
  Description: 'Omit parens for empty lambda parameters.'
@@ -3561,6 +3716,11 @@ Style/EvenOdd:
3561
3716
  VersionAdded: '0.12'
3562
3717
  VersionChanged: '0.29'
3563
3718
 
3719
+ Style/ExactRegexpMatch:
3720
+ Description: 'Checks for exact regexp match inside Regexp literals.'
3721
+ Enabled: pending
3722
+ VersionAdded: '1.51'
3723
+
3564
3724
  Style/ExpandPathArguments:
3565
3725
  Description: "Use `expand_path(__dir__)` instead of `expand_path('..', __FILE__)`."
3566
3726
  Enabled: true
@@ -3596,6 +3756,13 @@ Style/FetchEnvVar:
3596
3756
  # Environment variables to be excluded from the inspection.
3597
3757
  AllowedVars: []
3598
3758
 
3759
+ Style/FileEmpty:
3760
+ Description: >-
3761
+ Prefer to use `File.empty?('path/to/file')` when checking if a file is empty.
3762
+ Enabled: pending
3763
+ Safe: false
3764
+ VersionAdded: '1.48'
3765
+
3599
3766
  Style/FileRead:
3600
3767
  Description: 'Favor `File.(bin)read` convenience methods.'
3601
3768
  StyleGuide: '#file-read'
@@ -3664,7 +3831,8 @@ Style/FormatStringToken:
3664
3831
  MaxUnannotatedPlaceholdersAllowed: 1
3665
3832
  VersionAdded: '0.49'
3666
3833
  VersionChanged: '1.0'
3667
- IgnoredMethods: []
3834
+ AllowedMethods: []
3835
+ AllowedPatterns: []
3668
3836
 
3669
3837
  Style/FrozenStringLiteralComment:
3670
3838
  Description: >-
@@ -3742,15 +3910,17 @@ Style/HashEachMethods:
3742
3910
  Safe: false
3743
3911
  VersionAdded: '0.80'
3744
3912
  VersionChanged: '1.16'
3745
- AllowedReceivers: []
3913
+ AllowedReceivers:
3914
+ - Thread.current
3746
3915
 
3747
3916
  Style/HashExcept:
3748
3917
  Description: >-
3749
3918
  Checks for usages of `Hash#reject`, `Hash#select`, and `Hash#filter` methods
3750
3919
  that can be replaced with `Hash#except` method.
3751
3920
  Enabled: pending
3921
+ Safe: false
3752
3922
  VersionAdded: '1.7'
3753
- VersionChanged: '1.31'
3923
+ VersionChanged: '1.39'
3754
3924
 
3755
3925
  Style/HashLikeCase:
3756
3926
  Description: >-
@@ -3789,6 +3959,8 @@ Style/HashSyntax:
3789
3959
  - never
3790
3960
  # accepts both shorthand and explicit use of hash literal value.
3791
3961
  - either
3962
+ # forces use of the 3.1 syntax only if all values can be omitted in the hash.
3963
+ - consistent
3792
3964
  # Force hashes that have a symbol value to use hash rockets
3793
3965
  UseHashRocketsWithSymbolValues: false
3794
3966
  # Do not suggest { a?: 1 } over { :a? => 1 } in ruby19 style
@@ -3901,16 +4073,41 @@ Style/InverseMethods:
3901
4073
  :=~: :!~
3902
4074
  :<: :>=
3903
4075
  :>: :<=
3904
- # `ActiveSupport` defines some common inverse methods. They are listed below,
3905
- # and not enabled by default.
3906
- # :present?: :blank?,
3907
- # :include?: :exclude?
3908
4076
  # `InverseBlocks` are methods that are inverted by inverting the return
3909
4077
  # of the block that is passed to the method
3910
4078
  InverseBlocks:
3911
4079
  :select: :reject
3912
4080
  :select!: :reject!
3913
4081
 
4082
+ Style/InvertibleUnlessCondition:
4083
+ Description: 'Favor `if` with inverted condition over `unless`.'
4084
+ Enabled: false
4085
+ Safe: false
4086
+ VersionAdded: '1.44'
4087
+ VersionChanged: '1.50'
4088
+ # `InverseMethods` are methods that can be inverted in a `unless` condition.
4089
+ # The relationship of inverse methods needs to be defined in both directions.
4090
+ # Keys and values both need to be defined as symbols.
4091
+ InverseMethods:
4092
+ :!=: :==
4093
+ :>: :<=
4094
+ :<=: :>
4095
+ :<: :>=
4096
+ :>=: :<
4097
+ :!~: :=~
4098
+ :zero?: :nonzero?
4099
+ :nonzero?: :zero?
4100
+ :any?: :none?
4101
+ :none?: :any?
4102
+ :even?: :odd?
4103
+ :odd?: :even?
4104
+ # `ActiveSupport` defines some common inverse methods. They are listed below,
4105
+ # and not enabled by default.
4106
+ # :present?: :blank?
4107
+ # :blank?: :present?
4108
+ # :include?: :exclude?
4109
+ # :exclude?: :include?
4110
+
3914
4111
  Style/IpAddresses:
3915
4112
  Description: "Don't include literal IP addresses in code."
3916
4113
  Enabled: false
@@ -3965,6 +4162,26 @@ Style/LineEndConcatenation:
3965
4162
  VersionAdded: '0.18'
3966
4163
  VersionChanged: '0.64'
3967
4164
 
4165
+ Style/MagicCommentFormat:
4166
+ Description: 'Use a consistent style for magic comments.'
4167
+ Enabled: pending
4168
+ VersionAdded: '1.35'
4169
+ EnforcedStyle: snake_case
4170
+ SupportedStyles:
4171
+ # `snake` will enforce the magic comment is written
4172
+ # in snake case (words separated by underscores).
4173
+ # Eg: froze_string_literal: true
4174
+ - snake_case
4175
+ # `kebab` will enforce the magic comment is written
4176
+ # in kebab case (words separated by hyphens).
4177
+ # Eg: froze-string-literal: true
4178
+ - kebab_case
4179
+ DirectiveCapitalization: lowercase
4180
+ ValueCapitalization: ~
4181
+ SupportedCapitalizations:
4182
+ - lowercase
4183
+ - uppercase
4184
+
3968
4185
  Style/MapCompactWithConditionalBlock:
3969
4186
  Description: 'Prefer `select` or `reject` over `map { ... }.compact`.'
3970
4187
  Enabled: pending
@@ -3976,6 +4193,12 @@ Style/MapToHash:
3976
4193
  VersionAdded: '1.24'
3977
4194
  Safe: false
3978
4195
 
4196
+ Style/MapToSet:
4197
+ Description: 'Prefer `to_set` with a block over `map.to_set`.'
4198
+ Enabled: pending
4199
+ Safe: false
4200
+ VersionAdded: '1.42'
4201
+
3979
4202
  Style/MethodCallWithArgsParentheses:
3980
4203
  Description: 'Use parentheses for method calls with arguments.'
3981
4204
  StyleGuide: '#method-invocation-parens'
@@ -3983,9 +4206,8 @@ Style/MethodCallWithArgsParentheses:
3983
4206
  VersionAdded: '0.47'
3984
4207
  VersionChanged: '1.7'
3985
4208
  IgnoreMacros: true
3986
- IgnoredMethods: []
4209
+ AllowedMethods: []
3987
4210
  AllowedPatterns: []
3988
- IgnoredPatterns: [] # deprecated
3989
4211
  IncludedMacros: []
3990
4212
  AllowParenthesesInMultilineCall: false
3991
4213
  AllowParenthesesInChaining: false
@@ -4000,7 +4222,8 @@ Style/MethodCallWithoutArgsParentheses:
4000
4222
  Description: 'Do not use parentheses for method calls with no arguments.'
4001
4223
  StyleGuide: '#method-invocation-parens'
4002
4224
  Enabled: true
4003
- IgnoredMethods: []
4225
+ AllowedMethods: []
4226
+ AllowedPatterns: []
4004
4227
  VersionAdded: '0.47'
4005
4228
  VersionChanged: '0.55'
4006
4229
 
@@ -4031,6 +4254,12 @@ Style/MinMax:
4031
4254
  Enabled: true
4032
4255
  VersionAdded: '0.50'
4033
4256
 
4257
+ Style/MinMaxComparison:
4258
+ Description: 'Enforces the use of `max` or `min` instead of comparison for greater or less.'
4259
+ Enabled: pending
4260
+ Safe: false
4261
+ VersionAdded: '1.42'
4262
+
4034
4263
  Style/MissingElse:
4035
4264
  Description: >-
4036
4265
  Require if/case expressions to have an else branches.
@@ -4352,17 +4581,17 @@ Style/NumericLiterals:
4352
4581
  Strict: false
4353
4582
  # You can specify allowed numbers. (e.g. port number 3000, 8080, and etc)
4354
4583
  AllowedNumbers: []
4584
+ AllowedPatterns: []
4355
4585
 
4356
4586
  Style/NumericPredicate:
4357
4587
  Description: >-
4358
4588
  Checks for the use of predicate- or comparison methods for
4359
4589
  numeric comparisons.
4360
4590
  StyleGuide: '#predicate-methods'
4361
- Safe: false
4362
4591
  # This will change to a new method call which isn't guaranteed to be on the
4363
4592
  # object. Switching these methods has to be done with knowledge of the types
4364
4593
  # of the variables which rubocop doesn't have.
4365
- SafeAutoCorrect: false
4594
+ Safe: false
4366
4595
  Enabled: true
4367
4596
  VersionAdded: '0.42'
4368
4597
  VersionChanged: '0.59'
@@ -4370,7 +4599,8 @@ Style/NumericPredicate:
4370
4599
  SupportedStyles:
4371
4600
  - predicate
4372
4601
  - comparison
4373
- IgnoredMethods: []
4602
+ AllowedMethods: []
4603
+ AllowedPatterns: []
4374
4604
  # Exclude RSpec specs because assertions like `expect(1).to be > 0` cause
4375
4605
  # false positives.
4376
4606
  Exclude:
@@ -4407,7 +4637,15 @@ Style/OpenStructUse:
4407
4637
  - https://docs.ruby-lang.org/en/3.0.0/OpenStruct.html#class-OpenStruct-label-Caveats
4408
4638
 
4409
4639
  Enabled: pending
4640
+ Safe: false
4410
4641
  VersionAdded: '1.23'
4642
+ VersionChanged: '1.51'
4643
+
4644
+ Style/OperatorMethodCall:
4645
+ Description: 'Checks for redundant dot before operator method call.'
4646
+ StyleGuide: '#operator-method-call'
4647
+ Enabled: pending
4648
+ VersionAdded: '1.37'
4411
4649
 
4412
4650
  Style/OptionHash:
4413
4651
  Description: "Don't use option hashes when you can use keyword arguments."
@@ -4554,10 +4792,12 @@ Style/RedundantArgument:
4554
4792
  Enabled: pending
4555
4793
  Safe: false
4556
4794
  VersionAdded: '1.4'
4557
- VersionChanged: '1.7'
4795
+ VersionChanged: '1.40'
4558
4796
  Methods:
4559
4797
  # Array#join
4560
4798
  join: ''
4799
+ # Array#sum
4800
+ sum: 0
4561
4801
  # String#split
4562
4802
  split: ' '
4563
4803
  # String#chomp
@@ -4592,6 +4832,22 @@ Style/RedundantConditional:
4592
4832
  Enabled: true
4593
4833
  VersionAdded: '0.50'
4594
4834
 
4835
+ Style/RedundantConstantBase:
4836
+ Description: Avoid redundant `::` prefix on constant.
4837
+ Enabled: pending
4838
+ VersionAdded: '1.40'
4839
+
4840
+ Style/RedundantDoubleSplatHashBraces:
4841
+ Description: 'Checks for redundant uses of double splat hash braces.'
4842
+ Enabled: pending
4843
+ VersionAdded: '1.41'
4844
+
4845
+ Style/RedundantEach:
4846
+ Description: 'Checks for redundant `each`.'
4847
+ Enabled: pending
4848
+ Safe: false
4849
+ VersionAdded: '1.38'
4850
+
4595
4851
  Style/RedundantException:
4596
4852
  Description: "Checks for an obsolete RuntimeException argument in raise/fail."
4597
4853
  StyleGuide: '#no-explicit-runtimeerror'
@@ -4626,6 +4882,11 @@ Style/RedundantFreeze:
4626
4882
  VersionAdded: '0.34'
4627
4883
  VersionChanged: '0.66'
4628
4884
 
4885
+ Style/RedundantHeredocDelimiterQuotes:
4886
+ Description: 'Checks for redundant heredoc delimiter quotes.'
4887
+ Enabled: pending
4888
+ VersionAdded: '1.45'
4889
+
4629
4890
  Style/RedundantInitialize:
4630
4891
  Description: 'Checks for redundant `initialize` methods.'
4631
4892
  Enabled: pending
@@ -4641,6 +4902,11 @@ Style/RedundantInterpolation:
4641
4902
  VersionAdded: '0.76'
4642
4903
  VersionChanged: '1.30'
4643
4904
 
4905
+ Style/RedundantLineContinuation:
4906
+ Description: 'Check for redundant line continuation.'
4907
+ Enabled: pending
4908
+ VersionAdded: '1.49'
4909
+
4644
4910
  Style/RedundantParentheses:
4645
4911
  Description: "Checks for parentheses that seem not to serve any purpose."
4646
4912
  Enabled: true
@@ -4703,6 +4969,11 @@ Style/RedundantSortBy:
4703
4969
  Enabled: true
4704
4970
  VersionAdded: '0.36'
4705
4971
 
4972
+ Style/RedundantStringEscape:
4973
+ Description: 'Checks for redundant escapes in string literals.'
4974
+ Enabled: pending
4975
+ VersionAdded: '1.37'
4976
+
4706
4977
  Style/RegexpLiteral:
4707
4978
  Description: 'Use / or %r around regular expressions.'
4708
4979
  StyleGuide: '#percent-r'
@@ -4721,6 +4992,12 @@ Style/RegexpLiteral:
4721
4992
  # are found in the regexp string.
4722
4993
  AllowInnerSlashes: false
4723
4994
 
4995
+ Style/RequireOrder:
4996
+ Description: Sort `require` and `require_relative` in alphabetical order.
4997
+ Enabled: false
4998
+ SafeAutoCorrect: false
4999
+ VersionAdded: '1.40'
5000
+
4724
5001
  Style/RescueModifier:
4725
5002
  Description: 'Avoid using rescue in its modifier form.'
4726
5003
  StyleGuide: '#no-rescue-modifiers'
@@ -5005,13 +5282,13 @@ Style/SymbolProc:
5005
5282
  Enabled: true
5006
5283
  Safe: false
5007
5284
  VersionAdded: '0.26'
5008
- VersionChanged: '1.28'
5285
+ VersionChanged: '1.40'
5009
5286
  AllowMethodsWithArguments: false
5010
- # A list of method names to be ignored by the check.
5287
+ # A list of method names to be always allowed by the check.
5011
5288
  # The names should be fairly unique, otherwise you'll end up ignoring lots of code.
5012
- IgnoredMethods:
5013
- - respond_to
5289
+ AllowedMethods:
5014
5290
  - define_method
5291
+ AllowedPatterns: []
5015
5292
  AllowComments: false
5016
5293
 
5017
5294
  Style/TernaryParentheses:
@@ -5250,6 +5527,19 @@ Style/YodaCondition:
5250
5527
  VersionAdded: '0.49'
5251
5528
  VersionChanged: '0.75'
5252
5529
 
5530
+ Style/YodaExpression:
5531
+ Description: 'Forbid the use of yoda expressions.'
5532
+ Enabled: false
5533
+ Safe: false
5534
+ VersionAdded: '1.42'
5535
+ VersionChanged: '1.43'
5536
+ SupportedOperators:
5537
+ - '*'
5538
+ - '+'
5539
+ - '&'
5540
+ - '|'
5541
+ - '^'
5542
+
5253
5543
  Style/ZeroLengthPredicate:
5254
5544
  Description: 'Use #empty? when testing for objects of length 0.'
5255
5545
  Enabled: true