rubocop 1.89.0 → 1.91.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 (248) hide show
  1. checksums.yaml +4 -4
  2. data/config/default.yml +309 -14
  3. data/config/obsoletion.yml +9 -0
  4. data/exe/rubocop +1 -1
  5. data/lib/rubocop/cached_data.rb +7 -2
  6. data/lib/rubocop/changed_files.rb +112 -0
  7. data/lib/rubocop/cli/command/execute_runner.rb +52 -1
  8. data/lib/rubocop/cli.rb +11 -7
  9. data/lib/rubocop/comment_config/directive_range.rb +34 -0
  10. data/lib/rubocop/comment_config/disable_next.rb +143 -0
  11. data/lib/rubocop/comment_config/push_pop.rb +55 -0
  12. data/lib/rubocop/comment_config.rb +50 -64
  13. data/lib/rubocop/config.rb +33 -5
  14. data/lib/rubocop/config_loader.rb +13 -6
  15. data/lib/rubocop/config_loader_resolver.rb +50 -9
  16. data/lib/rubocop/config_obsoletion/cop_rule.rb +2 -1
  17. data/lib/rubocop/config_obsoletion/removed_cop.rb +8 -0
  18. data/lib/rubocop/config_obsoletion.rb +1 -1
  19. data/lib/rubocop/config_validator.rb +19 -5
  20. data/lib/rubocop/cop/autocorrect_logic.rb +8 -0
  21. data/lib/rubocop/cop/badge.rb +1 -1
  22. data/lib/rubocop/cop/base.rb +49 -5
  23. data/lib/rubocop/cop/corrector.rb +3 -3
  24. data/lib/rubocop/cop/correctors.rb +2 -2
  25. data/lib/rubocop/cop/gemspec/require_mfa.rb +1 -1
  26. data/lib/rubocop/cop/generator.rb +1 -1
  27. data/lib/rubocop/cop/internal_affairs/node_matcher_directive.rb +1 -2
  28. data/lib/rubocop/cop/internal_affairs/node_pattern_groups/ast_walker.rb +1 -2
  29. data/lib/rubocop/cop/internal_affairs/on_send_without_on_csend.rb +1 -1
  30. data/lib/rubocop/cop/layout/argument_alignment.rb +2 -0
  31. data/lib/rubocop/cop/layout/block_alignment.rb +1 -2
  32. data/lib/rubocop/cop/layout/class_structure.rb +102 -26
  33. data/lib/rubocop/cop/layout/comment_indentation.rb +8 -5
  34. data/lib/rubocop/cop/layout/else_alignment.rb +1 -0
  35. data/lib/rubocop/cop/layout/empty_line_after_guard_clause.rb +1 -2
  36. data/lib/rubocop/cop/layout/empty_line_after_magic_comment.rb +63 -5
  37. data/lib/rubocop/cop/layout/empty_lines_after_module_inclusion.rb +1 -1
  38. data/lib/rubocop/cop/layout/end_alignment.rb +1 -2
  39. data/lib/rubocop/cop/layout/extra_spacing.rb +105 -3
  40. data/lib/rubocop/cop/layout/first_argument_indentation.rb +21 -1
  41. data/lib/rubocop/cop/layout/first_array_element_indentation.rb +17 -4
  42. data/lib/rubocop/cop/layout/first_parameter_indentation.rb +11 -0
  43. data/lib/rubocop/cop/layout/hash_alignment.rb +6 -5
  44. data/lib/rubocop/cop/layout/indentation_width.rb +2 -2
  45. data/lib/rubocop/cop/layout/line_continuation_spacing.rb +1 -2
  46. data/lib/rubocop/cop/layout/line_length.rb +20 -3
  47. data/lib/rubocop/cop/layout/multiline_assignment_layout.rb +1 -2
  48. data/lib/rubocop/cop/layout/multiline_method_call_indentation.rb +5 -5
  49. data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +1 -2
  50. data/lib/rubocop/cop/layout/space_around_block_parameters.rb +14 -3
  51. data/lib/rubocop/cop/layout/space_around_operators.rb +12 -1
  52. data/lib/rubocop/cop/layout/space_inside_array_literal_brackets.rb +2 -4
  53. data/lib/rubocop/cop/lint/ambiguous_range.rb +1 -2
  54. data/lib/rubocop/cop/lint/argument_mismatch.rb +99 -0
  55. data/lib/rubocop/cop/lint/assignment_in_condition.rb +2 -0
  56. data/lib/rubocop/cop/lint/constant_reassignment.rb +17 -11
  57. data/lib/rubocop/cop/lint/cop_directive_syntax.rb +165 -15
  58. data/lib/rubocop/cop/lint/deprecated_reference.rb +11 -2
  59. data/lib/rubocop/cop/lint/duplicate_methods.rb +113 -15
  60. data/lib/rubocop/cop/lint/empty_block.rb +1 -1
  61. data/lib/rubocop/cop/lint/implicit_string_concatenation.rb +1 -2
  62. data/lib/rubocop/cop/lint/ineffective_access_modifier.rb +1 -2
  63. data/lib/rubocop/cop/lint/interpolation_check.rb +1 -2
  64. data/lib/rubocop/cop/lint/literal_as_condition.rb +11 -8
  65. data/lib/rubocop/cop/lint/literal_in_interpolation.rb +3 -6
  66. data/lib/rubocop/cop/lint/misplaced_magic_comment.rb +185 -0
  67. data/lib/rubocop/cop/lint/missing_cop_enable_directive.rb +25 -12
  68. data/lib/rubocop/cop/lint/name_typo.rb +53 -6
  69. data/lib/rubocop/cop/lint/nested_method_definition.rb +1 -1
  70. data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +1 -1
  71. data/lib/rubocop/cop/lint/out_of_range_regexp_ref.rb +15 -0
  72. data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +17 -1
  73. data/lib/rubocop/cop/lint/redundant_cop_disable_directive.rb +122 -29
  74. data/lib/rubocop/cop/lint/redundant_cop_enable_directive.rb +47 -7
  75. data/lib/rubocop/cop/lint/redundant_require_statement.rb +1 -2
  76. data/lib/rubocop/cop/lint/redundant_safe_navigation.rb +1 -2
  77. data/lib/rubocop/cop/lint/redundant_splat_expansion.rb +1 -2
  78. data/lib/rubocop/cop/lint/redundant_type_conversion.rb +1 -2
  79. data/lib/rubocop/cop/lint/redundant_with_index.rb +1 -2
  80. data/lib/rubocop/cop/lint/safe_navigation_chain.rb +1 -2
  81. data/lib/rubocop/cop/lint/safe_navigation_consistency.rb +2 -4
  82. data/lib/rubocop/cop/lint/super_argument_mismatch.rb +179 -0
  83. data/lib/rubocop/cop/lint/suppressed_exception_in_number_conversion.rb +1 -2
  84. data/lib/rubocop/cop/lint/to_enum_arguments.rb +1 -2
  85. data/lib/rubocop/cop/lint/unreachable_code.rb +1 -2
  86. data/lib/rubocop/cop/lint/unused_private_method.rb +94 -17
  87. data/lib/rubocop/cop/lint/useless_access_modifier.rb +1 -2
  88. data/lib/rubocop/cop/lint/useless_assignment.rb +1 -2
  89. data/lib/rubocop/cop/lint/useless_constant_scoping.rb +36 -0
  90. data/lib/rubocop/cop/lint/useless_method_definition.rb +1 -1
  91. data/lib/rubocop/cop/lint/useless_rescue.rb +1 -2
  92. data/lib/rubocop/cop/lint/utils/nil_receiver_checker.rb +61 -7
  93. data/lib/rubocop/cop/lint/void.rb +1 -2
  94. data/lib/rubocop/cop/lint.rb +3 -0
  95. data/lib/rubocop/cop/metrics/perceived_complexity.rb +1 -2
  96. data/lib/rubocop/cop/migration/department_name.rb +1 -2
  97. data/lib/rubocop/cop/mixin/alignment.rb +1 -1
  98. data/lib/rubocop/cop/mixin/annotation_comment.rb +1 -1
  99. data/lib/rubocop/cop/mixin/comments_help.rb +1 -2
  100. data/lib/rubocop/cop/mixin/configurable_enforced_style.rb +1 -2
  101. data/lib/rubocop/cop/mixin/hash_alignment_styles.rb +11 -1
  102. data/lib/rubocop/cop/mixin/hash_shorthand_syntax.rb +7 -4
  103. data/lib/rubocop/cop/mixin/hash_subset.rb +1 -2
  104. data/lib/rubocop/cop/mixin/hash_transform_method.rb +1 -1
  105. data/lib/rubocop/cop/mixin/indexed_method_arity.rb +94 -0
  106. data/lib/rubocop/cop/mixin/line_length_help.rb +7 -1
  107. data/lib/rubocop/cop/mixin/preceding_following_alignment.rb +62 -6
  108. data/lib/rubocop/cop/mixin/range_help.rb +1 -2
  109. data/lib/rubocop/cop/mixin/statement_modifier.rb +13 -7
  110. data/lib/rubocop/cop/mixin/trailing_comma.rb +2 -4
  111. data/lib/rubocop/cop/mixin.rb +6 -2
  112. data/lib/rubocop/cop/naming/binary_operator_parameter_name.rb +16 -0
  113. data/lib/rubocop/cop/naming/block_forwarding.rb +4 -1
  114. data/lib/rubocop/cop/naming/block_parameter_name.rb +1 -1
  115. data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +2 -4
  116. data/lib/rubocop/cop/naming/method_name.rb +5 -2
  117. data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +1 -2
  118. data/lib/rubocop/cop/offense.rb +27 -4
  119. data/lib/rubocop/cop/registry.rb +43 -11
  120. data/lib/rubocop/cop/severity.rb +12 -0
  121. data/lib/rubocop/cop/style/access_modifier_declarations.rb +3 -2
  122. data/lib/rubocop/cop/style/accessor_grouping.rb +1 -2
  123. data/lib/rubocop/cop/style/arguments_forwarding.rb +5 -8
  124. data/lib/rubocop/cop/style/array_first_last.rb +1 -2
  125. data/lib/rubocop/cop/style/bitwise_predicate.rb +1 -2
  126. data/lib/rubocop/cop/style/block_delimiters.rb +3 -6
  127. data/lib/rubocop/cop/style/case_like_if.rb +5 -7
  128. data/lib/rubocop/cop/style/class_and_module_children.rb +1 -2
  129. data/lib/rubocop/cop/style/combinable_loops.rb +1 -2
  130. data/lib/rubocop/cop/style/concat_array_literals.rb +1 -2
  131. data/lib/rubocop/cop/style/conditional_assignment.rb +1 -2
  132. data/lib/rubocop/cop/style/constant_visibility.rb +6 -3
  133. data/lib/rubocop/cop/style/copyright.rb +1 -2
  134. data/lib/rubocop/cop/style/data_inheritance.rb +14 -0
  135. data/lib/rubocop/cop/style/directive_scope.rb +304 -0
  136. data/lib/rubocop/cop/style/disable_cops_within_source_code_directive.rb +83 -13
  137. data/lib/rubocop/cop/style/documentation_method.rb +1 -9
  138. data/lib/rubocop/cop/style/each_for_simple_loop.rb +1 -1
  139. data/lib/rubocop/cop/style/empty_block_parameter.rb +1 -1
  140. data/lib/rubocop/cop/style/empty_case_condition.rb +1 -2
  141. data/lib/rubocop/cop/style/empty_lambda_parameter.rb +1 -1
  142. data/lib/rubocop/cop/style/empty_method.rb +12 -2
  143. data/lib/rubocop/cop/style/endless_method.rb +31 -12
  144. data/lib/rubocop/cop/style/file_null.rb +2 -2
  145. data/lib/rubocop/cop/style/float_division.rb +10 -16
  146. data/lib/rubocop/cop/style/for.rb +5 -0
  147. data/lib/rubocop/cop/style/format_string_token.rb +1 -2
  148. data/lib/rubocop/cop/style/guard_clause.rb +5 -2
  149. data/lib/rubocop/cop/style/hash_each_methods.rb +1 -2
  150. data/lib/rubocop/cop/style/hash_lookup_method.rb +3 -0
  151. data/lib/rubocop/cop/style/hash_syntax.rb +1 -2
  152. data/lib/rubocop/cop/style/identical_conditional_branches.rb +2 -4
  153. data/lib/rubocop/cop/style/if_inside_else.rb +1 -2
  154. data/lib/rubocop/cop/style/if_unless_modifier.rb +1 -2
  155. data/lib/rubocop/cop/style/if_unless_modifier_of_if_unless.rb +1 -2
  156. data/lib/rubocop/cop/style/magic_comment_format.rb +1 -1
  157. data/lib/rubocop/cop/style/map_to_hash.rb +1 -2
  158. data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +2 -4
  159. data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +1 -1
  160. data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +1 -2
  161. data/lib/rubocop/cop/style/multiline_method_signature.rb +1 -2
  162. data/lib/rubocop/cop/style/negated_if_else_condition.rb +1 -2
  163. data/lib/rubocop/cop/style/negative_array_index.rb +2 -4
  164. data/lib/rubocop/cop/style/nested_modifier.rb +9 -4
  165. data/lib/rubocop/cop/style/nil_comparison.rb +36 -9
  166. data/lib/rubocop/cop/style/nil_lambda.rb +1 -1
  167. data/lib/rubocop/cop/style/non_nil_check.rb +18 -2
  168. data/lib/rubocop/cop/style/not.rb +3 -1
  169. data/lib/rubocop/cop/style/numeric_literal_prefix.rb +11 -1
  170. data/lib/rubocop/cop/style/one_line_conditional.rb +1 -1
  171. data/lib/rubocop/cop/style/operator_method_call.rb +1 -2
  172. data/lib/rubocop/cop/style/parallel_assignment.rb +1 -2
  173. data/lib/rubocop/cop/style/parentheses_around_condition.rb +6 -1
  174. data/lib/rubocop/cop/style/redundant_assignment.rb +1 -2
  175. data/lib/rubocop/cop/style/redundant_condition.rb +6 -8
  176. data/lib/rubocop/cop/style/redundant_double_splat_hash_braces.rb +11 -3
  177. data/lib/rubocop/cop/style/redundant_each.rb +1 -2
  178. data/lib/rubocop/cop/style/redundant_fetch_block.rb +1 -1
  179. data/lib/rubocop/cop/style/redundant_format.rb +2 -4
  180. data/lib/rubocop/cop/style/redundant_parentheses.rb +13 -5
  181. data/lib/rubocop/cop/style/redundant_regexp_argument.rb +1 -2
  182. data/lib/rubocop/cop/style/redundant_regexp_character_class.rb +6 -5
  183. data/lib/rubocop/cop/style/redundant_regexp_constructor.rb +6 -6
  184. data/lib/rubocop/cop/style/redundant_return.rb +1 -2
  185. data/lib/rubocop/cop/style/redundant_self_assignment.rb +1 -2
  186. data/lib/rubocop/cop/style/redundant_string_escape.rb +1 -2
  187. data/lib/rubocop/cop/style/rescue_modifier.rb +1 -2
  188. data/lib/rubocop/cop/style/safe_navigation.rb +1 -2
  189. data/lib/rubocop/cop/style/sample.rb +11 -6
  190. data/lib/rubocop/cop/style/select_by_regexp.rb +1 -2
  191. data/lib/rubocop/cop/style/semicolon.rb +2 -4
  192. data/lib/rubocop/cop/style/single_line_block_params.rb +1 -1
  193. data/lib/rubocop/cop/style/single_line_do_end_block.rb +1 -2
  194. data/lib/rubocop/cop/style/sole_nested_conditional.rb +1 -2
  195. data/lib/rubocop/cop/style/special_global_vars.rb +1 -1
  196. data/lib/rubocop/cop/style/stabby_lambda_parentheses.rb +2 -0
  197. data/lib/rubocop/cop/style/string_concatenation.rb +18 -5
  198. data/lib/rubocop/cop/style/struct_inheritance.rb +14 -0
  199. data/lib/rubocop/cop/style/super_arguments.rb +1 -2
  200. data/lib/rubocop/cop/style/symbol_proc.rb +1 -2
  201. data/lib/rubocop/cop/style/time_now.rb +41 -0
  202. data/lib/rubocop/cop/style/trailing_comma_in_block_args.rb +1 -1
  203. data/lib/rubocop/cop/style/yoda_condition.rb +1 -2
  204. data/lib/rubocop/cop/style.rb +2 -1
  205. data/lib/rubocop/cop/team.rb +11 -3
  206. data/lib/rubocop/cop/util.rb +3 -5
  207. data/lib/rubocop/cop/variable_force/variable.rb +1 -2
  208. data/lib/rubocop/cops_documentation_generator.rb +26 -8
  209. data/lib/rubocop/directive_comment.rb +73 -10
  210. data/lib/rubocop/formatter/disabled_config_formatter.rb +19 -1
  211. data/lib/rubocop/formatter/emacs_style_formatter.rb +3 -1
  212. data/lib/rubocop/formatter/formatter_set.rb +2 -1
  213. data/lib/rubocop/formatter/github_actions_formatter.rb +6 -5
  214. data/lib/rubocop/formatter/html_formatter.rb +2 -4
  215. data/lib/rubocop/formatter/json_formatter.rb +11 -6
  216. data/lib/rubocop/formatter/junit_formatter.rb +26 -9
  217. data/lib/rubocop/formatter/offense_count_formatter.rb +1 -2
  218. data/lib/rubocop/formatter/sarif_formatter.rb +181 -0
  219. data/lib/rubocop/formatter/simple_text_formatter.rb +4 -3
  220. data/lib/rubocop/formatter/tap_formatter.rb +3 -1
  221. data/lib/rubocop/formatter/worst_offenders_formatter.rb +1 -2
  222. data/lib/rubocop/formatter.rb +1 -0
  223. data/lib/rubocop/lockfile.rb +18 -0
  224. data/lib/rubocop/lsp/diagnostic.rb +4 -8
  225. data/lib/rubocop/lsp/routes.rb +48 -19
  226. data/lib/rubocop/magic_comment.rb +27 -0
  227. data/lib/rubocop/mcp/server.rb +1 -2
  228. data/lib/rubocop/options.rb +69 -7
  229. data/lib/rubocop/path_util.rb +2 -3
  230. data/lib/rubocop/plugin/configuration_integrator.rb +6 -3
  231. data/lib/rubocop/plugin/loader.rb +1 -1
  232. data/lib/rubocop/rake_task.rb +1 -2
  233. data/lib/rubocop/remote_config.rb +4 -4
  234. data/lib/rubocop/result_cache.rb +16 -5
  235. data/lib/rubocop/rspec/expect_offense.rb +2 -4
  236. data/lib/rubocop/rspec/shared_contexts.rb +4 -2
  237. data/lib/rubocop/runner.rb +90 -44
  238. data/lib/rubocop/server/cache.rb +1 -2
  239. data/lib/rubocop/server/cli.rb +2 -4
  240. data/lib/rubocop/server.rb +14 -0
  241. data/lib/rubocop/target_finder.rb +4 -1
  242. data/lib/rubocop/todo_audit.rb +111 -0
  243. data/lib/rubocop/unified_diff.rb +257 -0
  244. data/lib/rubocop/version.rb +3 -5
  245. data/lib/rubocop.rb +7 -1
  246. data/lib/ruby_lsp/rubocop/addon.rb +1 -2
  247. metadata +18 -6
  248. data/lib/rubocop/cop/style/double_cop_disable_directive.rb +0 -46
data/config/default.yml CHANGED
@@ -60,6 +60,9 @@ AllCops:
60
60
  - '.git/**/*'
61
61
  # Default formatter will be used if no `-f/--format` option is given.
62
62
  DefaultFormatter: progress
63
+ # The lowest severity that makes a run fail. Offenses below it are still
64
+ # reported. Can be overridden by the `--fail-level` command line option.
65
+ FailLevel: refactor
63
66
  # Cop names are displayed in offense messages by default. Change behavior
64
67
  # by overriding DisplayCopNames, or by giving the `--no-display-cop-names`
65
68
  # option.
@@ -116,6 +119,15 @@ AllCops:
116
119
  # of extra memory proportional to the bundle's size. Has no effect when
117
120
  # `UseProjectIndex` is `false` or when RuboCop does not run inside Bundler.
118
121
  ProjectIndexIncludesGems: false
122
+ # Projects opt in to preview with `Preview: true` here, or with the `--preview`
123
+ # command line option. In this file the key instead holds the `AllCops`
124
+ # settings expected to change in the next major release: they apply under
125
+ # preview and are dropped otherwise, exactly like a cop's `Preview` section.
126
+ Preview:
127
+ # Style offenses are reported but stop failing the build; `Lint` and
128
+ # `Security` offenses still do.
129
+ FailLevel: warning
130
+
119
131
  # Enables the result cache if `true`. Can be overridden by the `--cache` command
120
132
  # line option.
121
133
  UseCache: true
@@ -262,6 +274,10 @@ Bundler/OrderedGems:
262
274
  Description: >-
263
275
  Gems within groups in the Gemfile should be alphabetically sorted.
264
276
  Enabled: true
277
+ # Expected to be disabled by default in the next major release.
278
+ # Alphabetical Gemfiles are a preference; grouping gems by purpose is as common.
279
+ Preview:
280
+ Enabled: false
265
281
  VersionAdded: '0.46'
266
282
  VersionChanged: '0.47'
267
283
  TreatCommentsAsGroupSeparators: true
@@ -416,6 +432,10 @@ Layout/ArgumentAlignment:
416
432
  # method_call(a,
417
433
  # b)
418
434
  EnforcedStyle: with_first_argument
435
+ # Expected to become the default in the next major release.
436
+ # Same preference as `ParameterAlignment`.
437
+ Preview:
438
+ EnforcedStyle: with_fixed_indentation
419
439
  SupportedStyles:
420
440
  - with_first_argument
421
441
  - with_fixed_indentation
@@ -427,7 +447,7 @@ Layout/ArrayAlignment:
427
447
  Description: >-
428
448
  Align the elements of an array literal if they span more than
429
449
  one line.
430
- StyleGuide: '#no-double-indent'
450
+ StyleGuide: '#align-multiline-arrays'
431
451
  Enabled: true
432
452
  VersionAdded: '0.49'
433
453
  VersionChanged: '0.77'
@@ -474,6 +494,7 @@ Layout/BeginEndAlignment:
474
494
  SupportedStylesAlignWith:
475
495
  - start_of_line
476
496
  - begin
497
+ # A misaligned `end` usually means a structural mistake, so this reports as a lint would.
477
498
  Severity: warning
478
499
 
479
500
  Layout/BlockAlignment:
@@ -503,6 +524,10 @@ Layout/CaseIndentation:
503
524
  VersionAdded: '0.49'
504
525
  VersionChanged: '1.16'
505
526
  EnforcedStyle: case
527
+ # Expected to become the default in the next major release.
528
+ # `when` aligned with `end` is the pick of nearly every project that sets this.
529
+ Preview:
530
+ EnforcedStyle: end
506
531
  SupportedStyles:
507
532
  - case
508
533
  - end
@@ -581,6 +606,7 @@ Layout/DefEndAlignment:
581
606
  SupportedStylesAlignWith:
582
607
  - start_of_line
583
608
  - def
609
+ # A misaligned `end` usually means a structural mistake, so this reports as a lint would.
584
610
  Severity: warning
585
611
 
586
612
  Layout/DotPosition:
@@ -610,6 +636,10 @@ Layout/EmptyComment:
610
636
  Layout/EmptyLineAfterGuardClause:
611
637
  Description: 'Add empty line after guard clause.'
612
638
  Enabled: true
639
+ # Expected to be disabled by default in the next major release.
640
+ # Goes with `GuardClause`; a blank line after a guard is a preference.
641
+ Preview:
642
+ Enabled: false
613
643
  VersionAdded: '0.56'
614
644
  VersionChanged: '0.59'
615
645
 
@@ -618,6 +648,12 @@ Layout/EmptyLineAfterMagicComment:
618
648
  StyleGuide: '#separate-magic-comments-from-code'
619
649
  Enabled: true
620
650
  VersionAdded: '0.49'
651
+ VersionChanged: '1.91'
652
+ # The minimum number of empty lines required after the last magic comment. Set this
653
+ # to `2` when using YARD, which otherwise treats the magic comments as documentation
654
+ # for the first module or class in the file. `Layout/EmptyLines` has to be disabled
655
+ # for values greater than `1`.
656
+ NumberOfEmptyLines: 1
621
657
 
622
658
  Layout/EmptyLineAfterMultilineCondition:
623
659
  Description: 'Enforces empty line after multiline condition.'
@@ -754,10 +790,15 @@ Layout/EndAlignment:
754
790
  # The value `start_of_line` means that `end` should be aligned with the start
755
791
  # of the line which the matching keyword appears on.
756
792
  EnforcedStyleAlignWith: keyword
793
+ # Expected to become the default in the next major release.
794
+ # Aligning `end` with the variable is the pick of most projects that set this.
795
+ Preview:
796
+ EnforcedStyleAlignWith: variable
757
797
  SupportedStylesAlignWith:
758
798
  - keyword
759
799
  - variable
760
800
  - start_of_line
801
+ # A misaligned `end` usually means a structural mistake, so this reports as a lint would.
761
802
  Severity: warning
762
803
 
763
804
  Layout/EndOfLine:
@@ -833,6 +874,10 @@ Layout/FirstArrayElementIndentation:
833
874
  # The value `align_brackets` means that the indentation of the first element
834
875
  # shall always be relative to the position of the opening bracket.
835
876
  EnforcedStyle: special_inside_parentheses
877
+ # Expected to become the default in the next major release.
878
+ # Same preference as `FirstHashElementIndentation`.
879
+ Preview:
880
+ EnforcedStyle: consistent
836
881
  SupportedStyles:
837
882
  - special_inside_parentheses
838
883
  - consistent
@@ -867,6 +912,10 @@ Layout/FirstHashElementIndentation:
867
912
  # The value `align_braces` means that the indentation of the first key shall
868
913
  # always be relative to the position of the opening brace.
869
914
  EnforcedStyle: special_inside_parentheses
915
+ # Expected to become the default in the next major release.
916
+ # A consistent indent wins over the parentheses-sensitive rule by a wide margin.
917
+ Preview:
918
+ EnforcedStyle: consistent
870
919
  SupportedStyles:
871
920
  - special_inside_parentheses
872
921
  - consistent
@@ -1254,6 +1303,10 @@ Layout/MultilineMethodCallIndentation:
1254
1303
  Enabled: true
1255
1304
  VersionAdded: '0.49'
1256
1305
  EnforcedStyle: aligned
1306
+ # Expected to become the default in the next major release.
1307
+ # Indenting continuation lines wins over aligning them by a wide margin.
1308
+ Preview:
1309
+ EnforcedStyle: indented
1257
1310
  SupportedStyles:
1258
1311
  - aligned
1259
1312
  - indented
@@ -1293,6 +1346,10 @@ Layout/MultilineOperationIndentation:
1293
1346
  Enabled: true
1294
1347
  VersionAdded: '0.49'
1295
1348
  EnforcedStyle: aligned
1349
+ # Expected to become the default in the next major release.
1350
+ # Same preference as `MultilineMethodCallIndentation`.
1351
+ Preview:
1352
+ EnforcedStyle: indented
1296
1353
  SupportedStyles:
1297
1354
  - aligned
1298
1355
  - indented
@@ -1322,6 +1379,10 @@ Layout/ParameterAlignment:
1322
1379
  # def method_foo(a,
1323
1380
  # b)
1324
1381
  EnforcedStyle: with_first_parameter
1382
+ # Expected to become the default in the next major release.
1383
+ # A fixed indent wins over aligning with the first parameter.
1384
+ Preview:
1385
+ EnforcedStyle: with_fixed_indentation
1325
1386
  SupportedStyles:
1326
1387
  - with_first_parameter
1327
1388
  - with_fixed_indentation
@@ -1416,6 +1477,7 @@ Layout/SpaceAroundOperators:
1416
1477
  StyleGuide: '#spaces-operators'
1417
1478
  Enabled: true
1418
1479
  VersionAdded: '0.49'
1480
+ VersionChanged: '1.90'
1419
1481
  # When `true`, allows most uses of extra spacing if the intent is to align
1420
1482
  # with an operator on the previous or next line, not counting empty lines
1421
1483
  # or comment lines.
@@ -1659,6 +1721,13 @@ Lint/AmbiguousRegexpLiteral:
1659
1721
  VersionAdded: '0.17'
1660
1722
  VersionChanged: '0.83'
1661
1723
 
1724
+ Lint/ArgumentMismatch:
1725
+ Description: >-
1726
+ Checks for calls that pass the wrong number of positional arguments
1727
+ to a method, using the project index.
1728
+ Enabled: pending
1729
+ VersionAdded: '1.90'
1730
+
1662
1731
  Lint/ArrayLiteralInRegexp:
1663
1732
  Description: 'Checks for an array literal interpolated inside a regexp.'
1664
1733
  Enabled: pending
@@ -1732,8 +1801,9 @@ Lint/ConstantResolution:
1732
1801
 
1733
1802
  Lint/CopDirectiveSyntax:
1734
1803
  Description: 'Checks that `# rubocop:` directives are strictly formatted.'
1735
- Enabled: pending
1804
+ Enabled: true
1736
1805
  VersionAdded: '1.72'
1806
+ VersionChanged: '1.91'
1737
1807
 
1738
1808
  Lint/DataDefineOverride:
1739
1809
  Description: 'Disallow overriding the `Data` built-in methods via `Data.define`.'
@@ -1849,6 +1919,7 @@ Lint/DeprecatedReference:
1849
1919
 
1850
1920
  Lint/DisjunctiveAssignmentInConstructor:
1851
1921
  Description: 'In constructor, plain assignment is preferred over disjunctive.'
1922
+ StyleGuide: '#disjunctive-assignment-in-constructor'
1852
1923
  Enabled: true
1853
1924
  Safe: false
1854
1925
  VersionAdded: '0.62'
@@ -1893,7 +1964,7 @@ Lint/DuplicateMethods:
1893
1964
  Description: 'Checks for duplicate method definitions.'
1894
1965
  Enabled: true
1895
1966
  VersionAdded: '0.29'
1896
- VersionChanged: '1.89'
1967
+ VersionChanged: '1.90'
1897
1968
  # Methods that define instance methods by delegation, in the style of
1898
1969
  # Active Support's `delegate` (`delegate :foo, :bar, to: :target`). Register
1899
1970
  # a project's own `delegate`-shaped macros here so the cop recognizes the
@@ -1901,6 +1972,14 @@ Lint/DuplicateMethods:
1901
1972
  # is `true`.
1902
1973
  DelegatingMethods:
1903
1974
  - delegate
1975
+ # Cross-file duplicates (detected with `AllCops/UseProjectIndex`) whose other
1976
+ # definition lives in a file matching one of these patterns are not reported.
1977
+ # Useful for files that redefine application methods but are never loaded
1978
+ # together with them, such as standalone scripts. Patterns follow the same
1979
+ # glob (or regexp) semantics as `Exclude` and are matched against the other
1980
+ # file's path relative to the directory of the config file; absolute patterns
1981
+ # are matched against the absolute path.
1982
+ AllowedCrossFilePaths: []
1904
1983
 
1905
1984
  Lint/DuplicateRegexpCharacterClassElement:
1906
1985
  Description: 'Checks for duplicate elements in Regexp character classes.'
@@ -2136,11 +2215,18 @@ Lint/Loop:
2136
2215
  VersionChanged: '1.3'
2137
2216
  Safe: false
2138
2217
 
2218
+ Lint/MisplacedMagicComment:
2219
+ Description: 'Checks for magic comments placed where Ruby silently ignores them.'
2220
+ StyleGuide: '#magic-comments-first'
2221
+ Enabled: pending
2222
+ SafeAutoCorrect: false
2223
+ VersionAdded: '1.91'
2224
+
2139
2225
  Lint/MissingCopEnableDirective:
2140
2226
  Description: 'Checks for a `# rubocop:enable` after `# rubocop:disable`.'
2141
2227
  Enabled: true
2142
2228
  VersionAdded: '0.52'
2143
- VersionChanged: '1.88'
2229
+ VersionChanged: '1.90'
2144
2230
  # Maximum number of consecutive lines the cop can be disabled for.
2145
2231
  # 0 allows only single-line disables
2146
2232
  # 1 would mean the maximum allowed is the following:
@@ -2167,6 +2253,7 @@ Lint/MixedCaseRange:
2167
2253
 
2168
2254
  Lint/MixedRegexpCaptureTypes:
2169
2255
  Description: 'Do not mix named captures and numbered captures in a Regexp literal.'
2256
+ StyleGuide: '#do-not-mix-named-and-numbered-captures'
2170
2257
  Enabled: true
2171
2258
  VersionAdded: '0.85'
2172
2259
 
@@ -2264,7 +2351,7 @@ Lint/OrderedMagicComments:
2264
2351
  Enabled: true
2265
2352
  SafeAutoCorrect: false
2266
2353
  VersionAdded: '0.53'
2267
- VersionChanged: '1.37'
2354
+ VersionChanged: '1.91'
2268
2355
 
2269
2356
  Lint/OutOfRangeRegexpRef:
2270
2357
  Description: 'Checks for out of range reference for Regexp because it always returns nil.'
@@ -2323,6 +2410,7 @@ Lint/RedundantCopEnableDirective:
2323
2410
  Description: Checks for rubocop:enable comments that can be removed.
2324
2411
  Enabled: true
2325
2412
  VersionAdded: '0.76'
2413
+ VersionChanged: '1.90'
2326
2414
 
2327
2415
  Lint/RedundantDirGlobSort:
2328
2416
  Description: 'Checks for redundant `sort` method to `Dir.glob` and `Dir[]`.'
@@ -2505,6 +2593,7 @@ Lint/ShadowedException:
2505
2593
  Description: >-
2506
2594
  Avoid rescuing a higher level exception
2507
2595
  before a lower level exception.
2596
+ StyleGuide: '#exception-ordering'
2508
2597
  Enabled: true
2509
2598
  VersionAdded: '0.41'
2510
2599
 
@@ -2527,6 +2616,13 @@ Lint/StructNewOverride:
2527
2616
  Enabled: true
2528
2617
  VersionAdded: '0.81'
2529
2618
 
2619
+ Lint/SuperArgumentMismatch:
2620
+ Description: >-
2621
+ Checks for `super` calls that pass the wrong number of positional
2622
+ arguments to the overridden implementation, using the project index.
2623
+ Enabled: pending
2624
+ VersionAdded: '1.90'
2625
+
2530
2626
  Lint/SuppressedException:
2531
2627
  Description: "Don't suppress exceptions."
2532
2628
  StyleGuide: '#dont-hide-exceptions'
@@ -2617,6 +2713,7 @@ Lint/UnexpectedBlockArity:
2617
2713
 
2618
2714
  Lint/UnifiedInteger:
2619
2715
  Description: 'Use Integer instead of Fixnum or Bignum.'
2716
+ StyleGuide: '#integer-type-checking'
2620
2717
  Enabled: true
2621
2718
  VersionAdded: '0.43'
2622
2719
 
@@ -2679,7 +2776,10 @@ Lint/UnusedPrivateMethod:
2679
2776
  # would be reported as false positives. It is intended for occasional
2680
2777
  # dead-code sweeps rather than permanent enforcement.
2681
2778
  Enabled: false
2779
+ AllowedNames: []
2780
+ AllowedPatterns: []
2682
2781
  VersionAdded: '1.89'
2782
+ VersionChanged: '1.90'
2683
2783
 
2684
2784
  Lint/UriEscapeUnescape:
2685
2785
  Description: >-
@@ -2718,6 +2818,7 @@ Lint/UselessConstantScoping:
2718
2818
  Description: 'Checks for useless constant scoping.'
2719
2819
  Enabled: pending
2720
2820
  VersionAdded: '1.72'
2821
+ VersionChanged: '1.90'
2721
2822
 
2722
2823
  Lint/UselessDefaultValueArgument:
2723
2824
  Description: 'Checks for usage of `fetch` or `Array.new` with default value argument and block.'
@@ -2799,6 +2900,10 @@ Metrics/AbcSize:
2799
2900
  - https://wiki.c2.com/?AbcMetric
2800
2901
  - https://en.wikipedia.org/wiki/ABC_Software_Metric
2801
2902
  Enabled: true
2903
+ # Expected to be disabled by default in the next major release.
2904
+ # Rejected by more than a third of projects; those that keep it split evenly between 20 and 30.
2905
+ Preview:
2906
+ Enabled: false
2802
2907
  VersionAdded: '0.27'
2803
2908
  VersionChanged: '1.5'
2804
2909
  # The ABC size is a calculated magnitude, so this number can be an Integer or
@@ -2811,6 +2916,10 @@ Metrics/AbcSize:
2811
2916
  Metrics/BlockLength:
2812
2917
  Description: 'Avoid long blocks with many lines.'
2813
2918
  Enabled: true
2919
+ # Expected to be disabled by default in the next major release.
2920
+ # Rejected by nearly a third of projects; the raised limits range from 30 to 300.
2921
+ Preview:
2922
+ Enabled: false
2814
2923
  VersionAdded: '0.44'
2815
2924
  VersionChanged: '1.5'
2816
2925
  CountComments: false # count full line comments?
@@ -2828,6 +2937,10 @@ Metrics/BlockNesting:
2828
2937
  Description: 'Avoid excessive block nesting.'
2829
2938
  StyleGuide: '#three-is-the-number-thou-shalt-count'
2830
2939
  Enabled: true
2940
+ # Expected to be disabled by default in the next major release.
2941
+ # Rejected by a fifth of projects; almost nobody adjusts the limit instead.
2942
+ Preview:
2943
+ Enabled: false
2831
2944
  VersionAdded: '0.25'
2832
2945
  VersionChanged: '1.65'
2833
2946
  CountBlocks: false
@@ -2837,6 +2950,10 @@ Metrics/BlockNesting:
2837
2950
  Metrics/ClassLength:
2838
2951
  Description: 'Avoid classes longer than 100 lines of code.'
2839
2952
  Enabled: true
2953
+ # Expected to be disabled by default in the next major release.
2954
+ # Rejected by a third of projects; those that keep it set the limit three times higher.
2955
+ Preview:
2956
+ Enabled: false
2840
2957
  VersionAdded: '0.25'
2841
2958
  VersionChanged: '0.87'
2842
2959
  CountComments: false # count full line comments?
@@ -2854,6 +2971,10 @@ Metrics/CollectionLiteralLength:
2854
2971
  Metrics/CyclomaticComplexity:
2855
2972
  Description: 'Checks that the cyclomatic complexity of methods is not higher than the configured maximum.'
2856
2973
  Enabled: true
2974
+ # Expected to be disabled by default in the next major release.
2975
+ # Rejected by a third of projects; those that keep it raise the limit to 10 or more.
2976
+ Preview:
2977
+ Enabled: false
2857
2978
  VersionAdded: '0.25'
2858
2979
  VersionChanged: '0.81'
2859
2980
  AllowedMethods: []
@@ -2864,6 +2985,10 @@ Metrics/MethodLength:
2864
2985
  Description: 'Avoid methods longer than 10 lines of code.'
2865
2986
  StyleGuide: '#short-methods'
2866
2987
  Enabled: true
2988
+ # Expected to be disabled by default in the next major release.
2989
+ # Rejected outright by a third of projects; the ones that keep it disagree on the limit.
2990
+ Preview:
2991
+ Enabled: false
2867
2992
  VersionAdded: '0.25'
2868
2993
  VersionChanged: '1.5'
2869
2994
  CountComments: false # count full line comments?
@@ -2875,6 +3000,10 @@ Metrics/MethodLength:
2875
3000
  Metrics/ModuleLength:
2876
3001
  Description: 'Avoid modules longer than 100 lines of code.'
2877
3002
  Enabled: true
3003
+ # Expected to be disabled by default in the next major release.
3004
+ # Same story as `ClassLength`.
3005
+ Preview:
3006
+ Enabled: false
2878
3007
  VersionAdded: '0.31'
2879
3008
  VersionChanged: '0.87'
2880
3009
  CountComments: false # count full line comments?
@@ -2885,6 +3014,10 @@ Metrics/ParameterLists:
2885
3014
  Description: 'Avoid parameter lists longer than three or four parameters.'
2886
3015
  StyleGuide: '#too-many-params'
2887
3016
  Enabled: true
3017
+ # Expected to be disabled by default in the next major release.
3018
+ # Rejected by a fifth of projects, more than raise the limit.
3019
+ Preview:
3020
+ Enabled: false
2888
3021
  VersionAdded: '0.25'
2889
3022
  VersionChanged: '1.5'
2890
3023
  Max: 5
@@ -2894,6 +3027,10 @@ Metrics/ParameterLists:
2894
3027
  Metrics/PerceivedComplexity:
2895
3028
  Description: 'Checks that the perceived complexity of methods is not higher than the configured maximum.'
2896
3029
  Enabled: true
3030
+ # Expected to be disabled by default in the next major release.
3031
+ # Same story as `CyclomaticComplexity`.
3032
+ Preview:
3033
+ Enabled: false
2897
3034
  VersionAdded: '0.25'
2898
3035
  VersionChanged: '1.88'
2899
3036
  AllowedMethods: []
@@ -3066,6 +3203,10 @@ Naming/HeredocDelimiterNaming:
3066
3203
  Description: 'Use descriptive heredoc delimiters.'
3067
3204
  StyleGuide: '#heredoc-delimiters'
3068
3205
  Enabled: true
3206
+ # Expected to be disabled by default in the next major release.
3207
+ # Heredoc delimiter names are rarely worth policing.
3208
+ Preview:
3209
+ Enabled: false
3069
3210
  VersionAdded: '0.50'
3070
3211
  ForbiddenDelimiters:
3071
3212
  - !ruby/regexp '/(^|\s)(EO[A-Z]{1}|END)(\s|$)/i'
@@ -3243,6 +3384,10 @@ Naming/VariableNumber:
3243
3384
  Description: 'Use the configured style when numbering symbols, methods and variables.'
3244
3385
  StyleGuide: '#snake-case-symbols-methods-vars-with-numbers'
3245
3386
  Enabled: true
3387
+ # Expected to be disabled by default in the next major release.
3388
+ # A naming convention few projects want enforced.
3389
+ Preview:
3390
+ Enabled: false
3246
3391
  VersionAdded: '0.50'
3247
3392
  VersionChanged: '1.4'
3248
3393
  EnforcedStyle: normalcase
@@ -3360,6 +3505,10 @@ Style/Alias:
3360
3505
  VersionAdded: '0.9'
3361
3506
  VersionChanged: '0.36'
3362
3507
  EnforcedStyle: prefer_alias
3508
+ # Expected to become the default in the next major release.
3509
+ # `alias_method` is the pick of most projects that set this.
3510
+ Preview:
3511
+ EnforcedStyle: prefer_alias_method
3363
3512
  SupportedStyles:
3364
3513
  - prefer_alias
3365
3514
  - prefer_alias_method
@@ -3415,6 +3564,7 @@ Style/ArrayCoercion:
3415
3564
 
3416
3565
  Style/ArrayFirstLast:
3417
3566
  Description: 'Use `arr.first` and `arr.last` instead of `arr[0]` and `arr[-1]`.'
3567
+ StyleGuide: '#first-and-last'
3418
3568
  References:
3419
3569
  - '#first-and-last'
3420
3570
  Enabled: false
@@ -3505,6 +3655,10 @@ Style/BlockDelimiters:
3505
3655
  Prefer {...} over do...end for single-line blocks.
3506
3656
  StyleGuide: '#single-line-blocks'
3507
3657
  Enabled: true
3658
+ # Expected to be disabled by default in the next major release.
3659
+ # Brace-versus-`do` rules by line count are widely overridden or switched off.
3660
+ Preview:
3661
+ Enabled: false
3508
3662
  VersionAdded: '0.30'
3509
3663
  VersionChanged: '0.35'
3510
3664
  EnforcedStyle: line_count_based
@@ -3663,6 +3817,10 @@ Style/ClassAndModuleChildren:
3663
3817
  # project-wide index is consulted for both operations.
3664
3818
  SafeAutoCorrect: false
3665
3819
  Enabled: true
3820
+ # Expected to be disabled by default in the next major release.
3821
+ # Fights Rails autoloading conventions, and the autocorrect is unsafe.
3822
+ Preview:
3823
+ Enabled: false
3666
3824
  VersionAdded: '0.19'
3667
3825
  VersionChanged: '1.89'
3668
3826
  #
@@ -3878,6 +4036,7 @@ Style/ConditionalAssignment:
3878
4036
  Use the return value of `if` and `case` statements for
3879
4037
  assignment to a variable and variable comparison instead
3880
4038
  of assigning that variable inside of each branch.
4039
+ StyleGuide: '#use-if-case-returns'
3881
4040
  Enabled: true
3882
4041
  VersionAdded: '0.36'
3883
4042
  VersionChanged: '0.47'
@@ -3938,7 +4097,7 @@ Style/DataInheritance:
3938
4097
 
3939
4098
  Style/DateTime:
3940
4099
  Description: 'Use Time over DateTime.'
3941
- StyleGuide: '#date-time'
4100
+ StyleGuide: '#no-datetime'
3942
4101
  Enabled: false
3943
4102
  VersionAdded: '0.51'
3944
4103
  VersionChanged: '0.92'
@@ -3971,14 +4130,33 @@ Style/DirEmpty:
3971
4130
  Enabled: pending
3972
4131
  VersionAdded: '1.48'
3973
4132
 
4133
+ Style/DirectiveScope:
4134
+ Description: >-
4135
+ Checks for directive scopes that can be expressed with the
4136
+ tighter `disable-next` form.
4137
+ Enabled: pending
4138
+ SafeAutoCorrect: false
4139
+ VersionAdded: '1.90'
4140
+ VersionChanged: '1.91'
4141
+
3974
4142
  Style/DisableCopsWithinSourceCodeDirective:
3975
4143
  Description: >-
3976
4144
  Forbids disabling/enabling cops within source code.
3977
4145
  Enabled: false
3978
4146
  VersionAdded: '0.82'
3979
- VersionChanged: '1.89'
4147
+ VersionChanged: '1.90'
4148
+ # Cop or department names. A directive is exempt only when everything it
4149
+ # disables is listed here.
3980
4150
  AllowedCops: []
4151
+ # Cop or department names. When set, only directives touching these are
4152
+ # flagged.
3981
4153
  DisallowedCops: []
4154
+ # Permit a directive that carries a `-- reason` justification, instead of
4155
+ # forbidding directives outright.
4156
+ AllowWithReason: false
4157
+ # Directive forms this cop ignores entirely. One or more of `disable`,
4158
+ # `todo`, `disable-next`, `todo-next`, `push`, `next`.
4159
+ AllowedDirectives: []
3982
4160
 
3983
4161
  Style/DocumentDynamicEvalDefinition:
3984
4162
  Description: >-
@@ -3992,6 +4170,10 @@ Style/DocumentDynamicEvalDefinition:
3992
4170
  Style/Documentation:
3993
4171
  Description: 'Document classes and non-namespace modules.'
3994
4172
  Enabled: true
4173
+ # Turned off by over half of the projects that configure RuboCop at all, so it
4174
+ # is expected to be disabled by default in the next major release.
4175
+ Preview:
4176
+ Enabled: false
3995
4177
  VersionAdded: '0.9'
3996
4178
  VersionChanged: '1.89'
3997
4179
  AllowedConstants: []
@@ -4009,15 +4191,14 @@ Style/DocumentationMethod:
4009
4191
  - 'test/**/*'
4010
4192
  RequireForNonPublicMethods: false
4011
4193
 
4012
- Style/DoubleCopDisableDirective:
4013
- Description: 'Checks for double rubocop:disable comments on a single line.'
4014
- Enabled: true
4015
- VersionAdded: '0.73'
4016
-
4017
4194
  Style/DoubleNegation:
4018
4195
  Description: 'Checks for uses of double negation (!!).'
4019
4196
  StyleGuide: '#no-bang-bang'
4020
4197
  Enabled: true
4198
+ # Expected to be disabled by default in the next major release.
4199
+ # `!!` is the idiomatic boolean coercion.
4200
+ Preview:
4201
+ Enabled: false
4021
4202
  VersionAdded: '0.19'
4022
4203
  VersionChanged: '1.2'
4023
4204
  EnforcedStyle: allowed_in_returns
@@ -4051,6 +4232,7 @@ Style/EmptyCaseCondition:
4051
4232
 
4052
4233
  Style/EmptyClassDefinition:
4053
4234
  Description: 'Enforces consistent style for empty class definitions.'
4235
+ StyleGuide: '#single-line-classes'
4054
4236
  Enabled: pending
4055
4237
  VersionAdded: '1.84'
4056
4238
  VersionChanged: '1.86'
@@ -4104,6 +4286,10 @@ Style/EmptyMethod:
4104
4286
  VersionAdded: '0.46'
4105
4287
  VersionChanged: '1.61'
4106
4288
  EnforcedStyle: compact
4289
+ # Expected to become the default in the next major release.
4290
+ # Expanded empty methods are the pick of nearly every project that sets this.
4291
+ Preview:
4292
+ EnforcedStyle: expanded
4107
4293
  SupportedStyles:
4108
4294
  - compact
4109
4295
  - expanded
@@ -4216,12 +4402,14 @@ Style/FileEmpty:
4216
4402
 
4217
4403
  Style/FileNull:
4218
4404
  Description: 'Use `File::NULL` instead of hardcoding "dev/null".'
4405
+ StyleGuide: '#null-devices'
4219
4406
  Enabled: pending
4220
4407
  SafeAutoCorrect: false
4221
4408
  VersionAdded: '1.69'
4222
4409
 
4223
4410
  Style/FileOpen:
4224
4411
  Description: 'Checks for `File.open` without a block, which can leak file descriptors.'
4412
+ StyleGuide: '#auto-release-resources'
4225
4413
  Enabled: pending
4226
4414
  Safe: false
4227
4415
  VersionAdded: '1.85'
@@ -4276,6 +4464,10 @@ Style/FormatString:
4276
4464
  Description: 'Enforce the use of Kernel#sprintf, Kernel#format or String#%.'
4277
4465
  StyleGuide: '#sprintf'
4278
4466
  Enabled: true
4467
+ # Expected to be disabled by default in the next major release.
4468
+ # A pure preference between `format`, `sprintf` and `%`.
4469
+ Preview:
4470
+ Enabled: false
4279
4471
  VersionAdded: '0.19'
4280
4472
  VersionChanged: '0.49'
4281
4473
  EnforcedStyle: format
@@ -4286,7 +4478,12 @@ Style/FormatString:
4286
4478
 
4287
4479
  Style/FormatStringToken:
4288
4480
  Description: 'Use a consistent style for format string tokens.'
4481
+ StyleGuide: '#named-format-tokens'
4289
4482
  Enabled: true
4483
+ # Expected to be disabled by default in the next major release.
4484
+ # Most real format strings use `%s`, which is what the cop flags.
4485
+ Preview:
4486
+ Enabled: false
4290
4487
  VersionAdded: '0.49'
4291
4488
  VersionChanged: '1.74'
4292
4489
  EnforcedStyle: annotated
@@ -4315,6 +4512,10 @@ Style/FrozenStringLiteralComment:
4315
4512
  Add the frozen_string_literal comment to the top of files
4316
4513
  to help transition to frozen string literals by default.
4317
4514
  Enabled: true
4515
+ # Expected to be disabled by default in the next major release.
4516
+ # Ruby is moving towards frozen string literals by default.
4517
+ Preview:
4518
+ Enabled: false
4318
4519
  VersionAdded: '0.36'
4319
4520
  VersionChanged: '0.79'
4320
4521
  EnforcedStyle: always
@@ -4356,6 +4557,10 @@ Style/GuardClause:
4356
4557
  Description: 'Checks for conditionals that can be replaced with guard clauses.'
4357
4558
  StyleGuide: '#no-nested-conditionals'
4358
4559
  Enabled: true
4560
+ # Expected to be disabled by default in the next major release.
4561
+ # Same objection as `IfUnlessModifier`, and among the most inline-suppressed cops.
4562
+ Preview:
4563
+ Enabled: false
4359
4564
  VersionAdded: '0.20'
4360
4565
  VersionChanged: '1.31'
4361
4566
  # `MinBodyLength` defines the number of lines of the a body of an `if` or `unless`
@@ -4475,6 +4680,7 @@ Style/HashSyntax:
4475
4680
 
4476
4681
  Style/HashTransformKeys:
4477
4682
  Description: 'Prefer `transform_keys` over `each_with_object`, `map`, or `to_h`.'
4683
+ StyleGuide: '#hash-transform-methods'
4478
4684
  Enabled: true
4479
4685
  VersionAdded: '0.80'
4480
4686
  VersionChanged: '0.90'
@@ -4482,6 +4688,7 @@ Style/HashTransformKeys:
4482
4688
 
4483
4689
  Style/HashTransformValues:
4484
4690
  Description: 'Prefer `transform_values` over `each_with_object`, `map`, or `to_h`.'
4691
+ StyleGuide: '#hash-transform-methods'
4485
4692
  Enabled: true
4486
4693
  VersionAdded: '0.80'
4487
4694
  VersionChanged: '0.90'
@@ -4510,6 +4717,10 @@ Style/IfUnlessModifier:
4510
4717
  single-line body.
4511
4718
  StyleGuide: '#if-as-a-modifier'
4512
4719
  Enabled: true
4720
+ # Expected to be disabled by default in the next major release.
4721
+ # Forces a shape on control flow that a quarter of configured projects switch off.
4722
+ Preview:
4723
+ Enabled: false
4513
4724
  VersionAdded: '0.9'
4514
4725
  VersionChanged: '0.30'
4515
4726
 
@@ -4652,7 +4863,7 @@ Style/KeywordArgumentsMerging:
4652
4863
 
4653
4864
  Style/KeywordParametersOrder:
4654
4865
  Description: 'Enforces that optional keyword parameters are placed at the end of the parameters list.'
4655
- StyleGuide: '#keyword-parameters-order'
4866
+ StyleGuide: '#keyword-arguments-order'
4656
4867
  Enabled: true
4657
4868
  VersionAdded: '0.90'
4658
4869
  VersionChanged: '1.7'
@@ -4661,6 +4872,10 @@ Style/Lambda:
4661
4872
  Description: 'Use the new lambda literal syntax for single-line blocks.'
4662
4873
  StyleGuide: '#lambda-multi-line'
4663
4874
  Enabled: true
4875
+ # Expected to be disabled by default in the next major release.
4876
+ # A pure preference between `->` and `lambda`.
4877
+ Preview:
4878
+ Enabled: false
4664
4879
  VersionAdded: '0.9'
4665
4880
  VersionChanged: '0.40'
4666
4881
  EnforcedStyle: line_count_dependent
@@ -4685,6 +4900,7 @@ Style/LineEndConcatenation:
4685
4900
  Description: >-
4686
4901
  Use \ instead of + or << to concatenate two string literals at
4687
4902
  line end.
4903
+ StyleGuide: '#heredoc-long-strings'
4688
4904
  Enabled: true
4689
4905
  SafeAutoCorrect: false
4690
4906
  VersionAdded: '0.18'
@@ -4694,6 +4910,7 @@ Style/MagicCommentFormat:
4694
4910
  Description: 'Use a consistent style for magic comments.'
4695
4911
  Enabled: pending
4696
4912
  VersionAdded: '1.35'
4913
+ VersionChanged: '1.91'
4697
4914
  EnforcedStyle: snake_case
4698
4915
  SupportedStyles:
4699
4916
  # `snake` will enforce the magic comment is written
@@ -4855,6 +5072,10 @@ Style/ModuleFunction:
4855
5072
  Description: 'Checks for usage of `extend self` in modules.'
4856
5073
  StyleGuide: '#module-function'
4857
5074
  Enabled: true
5075
+ # Expected to be disabled by default in the next major release.
5076
+ # `module_function` versus `extend self` is a preference, and the autocorrect is unsafe.
5077
+ Preview:
5078
+ Enabled: false
4858
5079
  VersionAdded: '0.11'
4859
5080
  VersionChanged: '0.65'
4860
5081
  EnforcedStyle: module_function
@@ -4962,6 +5183,10 @@ Style/NegatedIf:
4962
5183
  (or control flow or).
4963
5184
  StyleGuide: '#unless-for-negatives'
4964
5185
  Enabled: true
5186
+ # Expected to be disabled by default in the next major release.
5187
+ # `if !x` versus `unless x` is a preference, and `unless` is contested on its own.
5188
+ Preview:
5189
+ Enabled: false
4965
5190
  VersionAdded: '0.20'
4966
5191
  VersionChanged: '0.48'
4967
5192
  EnforcedStyle: both
@@ -4982,7 +5207,7 @@ Style/NegatedIfElseCondition:
4982
5207
 
4983
5208
  Style/NegatedUnless:
4984
5209
  Description: 'Favor if over unless for negative conditions.'
4985
- StyleGuide: '#if-for-negatives'
5210
+ StyleGuide: '#unless-for-negatives'
4986
5211
  Enabled: true
4987
5212
  VersionAdded: '0.69'
4988
5213
  EnforcedStyle: both
@@ -5056,6 +5281,10 @@ Style/Next:
5056
5281
  Description: 'Use `next` to skip iteration instead of a condition at the end.'
5057
5282
  StyleGuide: '#no-nested-conditionals'
5058
5283
  Enabled: true
5284
+ # Expected to be disabled by default in the next major release.
5285
+ # Same objection as `IfUnlessModifier`: it forces a shape on loop bodies.
5286
+ Preview:
5287
+ Enabled: false
5059
5288
  VersionAdded: '0.22'
5060
5289
  VersionChanged: '1.75'
5061
5290
  # With `always` all conditions at the end of an iteration needs to be
@@ -5139,6 +5368,10 @@ Style/NumericLiterals:
5139
5368
  readability.
5140
5369
  StyleGuide: '#underscores-in-numerics'
5141
5370
  Enabled: true
5371
+ # Expected to be disabled by default in the next major release.
5372
+ # Underscores in long numbers are a preference, and generated tables trip it constantly.
5373
+ Preview:
5374
+ Enabled: false
5142
5375
  VersionAdded: '0.9'
5143
5376
  VersionChanged: '0.48'
5144
5377
  MinDigits: 5
@@ -5157,6 +5390,10 @@ Style/NumericPredicate:
5157
5390
  # of the variables which rubocop doesn't have.
5158
5391
  Safe: false
5159
5392
  Enabled: true
5393
+ # Expected to be disabled by default in the next major release.
5394
+ # A pure preference between `x > 0` and `x.positive?`.
5395
+ Preview:
5396
+ Enabled: false
5160
5397
  VersionAdded: '0.42'
5161
5398
  VersionChanged: '0.59'
5162
5399
  EnforcedStyle: predicate
@@ -5185,6 +5422,7 @@ Style/ObjectThen:
5185
5422
 
5186
5423
  Style/OneClassPerFile:
5187
5424
  Description: 'Checks that each source file defines at most one top-level class or module.'
5425
+ StyleGuide: '#one-class-per-file'
5188
5426
  Enabled: pending
5189
5427
  VersionAdded: '1.85'
5190
5428
  VersionChanged: '1.86'
@@ -5268,6 +5506,10 @@ Style/ParallelAssignment:
5268
5506
  matches on both sides of the assignment.
5269
5507
  StyleGuide: '#parallel-assignment'
5270
5508
  Enabled: true
5509
+ # Expected to be disabled by default in the next major release.
5510
+ # `a, b = 1, 2` is often the clearer form.
5511
+ Preview:
5512
+ Enabled: false
5271
5513
  VersionAdded: '0.32'
5272
5514
 
5273
5515
  Style/ParenthesesAroundCondition:
@@ -5319,6 +5561,10 @@ Style/PerlBackrefs:
5319
5561
  Description: 'Avoid Perl-style regex back references.'
5320
5562
  StyleGuide: '#no-perl-regexp-last-matchers'
5321
5563
  Enabled: true
5564
+ # Expected to be disabled by default in the next major release.
5565
+ # `$1` is idiomatic Ruby.
5566
+ Preview:
5567
+ Enabled: false
5322
5568
  VersionAdded: '0.13'
5323
5569
 
5324
5570
  Style/PredicateWithKind:
@@ -5360,6 +5606,10 @@ Style/RaiseArgs:
5360
5606
  Description: 'Checks the arguments passed to raise/fail.'
5361
5607
  StyleGuide: '#exception-class-messages'
5362
5608
  Enabled: true
5609
+ # Expected to be disabled by default in the next major release.
5610
+ # A pure preference between `raise Foo, msg` and `raise Foo.new(msg)`.
5611
+ Preview:
5612
+ Enabled: false
5363
5613
  Safe: false
5364
5614
  VersionAdded: '0.14'
5365
5615
  VersionChanged: '1.61'
@@ -5550,6 +5800,7 @@ Style/RedundantInterpolationUnfreeze:
5550
5800
 
5551
5801
  Style/RedundantLineContinuation:
5552
5802
  Description: 'Checks for redundant line continuation.'
5803
+ StyleGuide: '#no-trailing-backslash'
5553
5804
  Enabled: pending
5554
5805
  VersionAdded: '1.49'
5555
5806
 
@@ -5586,6 +5837,7 @@ Style/RedundantRegexpConstructor:
5586
5837
 
5587
5838
  Style/RedundantRegexpEscape:
5588
5839
  Description: 'Checks for redundant escapes in Regexps.'
5840
+ StyleGuide: '#limit-escapes'
5589
5841
  Enabled: true
5590
5842
  VersionAdded: '0.85'
5591
5843
 
@@ -5646,6 +5898,10 @@ Style/RegexpLiteral:
5646
5898
  Description: 'Use / or %r around regular expressions.'
5647
5899
  StyleGuide: '#percent-r'
5648
5900
  Enabled: true
5901
+ # Expected to be disabled by default in the next major release.
5902
+ # A pure preference between `//` and `%r{}`.
5903
+ Preview:
5904
+ Enabled: false
5649
5905
  VersionAdded: '0.9'
5650
5906
  VersionChanged: '0.30'
5651
5907
  EnforcedStyle: slashes
@@ -5678,6 +5934,10 @@ Style/RescueStandardError:
5678
5934
  Enabled: true
5679
5935
  VersionAdded: '0.52'
5680
5936
  EnforcedStyle: explicit
5937
+ # Expected to become the default in the next major release.
5938
+ # A bare `rescue` is the pick of most projects that set this.
5939
+ Preview:
5940
+ EnforcedStyle: implicit
5681
5941
  # implicit: Do not include the error class, `rescue`
5682
5942
  # explicit: Require an error class `rescue StandardError`
5683
5943
  SupportedStyles:
@@ -5801,6 +6061,10 @@ Style/SignalException:
5801
6061
  Description: 'Checks for proper usage of fail and raise.'
5802
6062
  StyleGuide: '#prefer-raise-over-fail'
5803
6063
  Enabled: true
6064
+ # Expected to be disabled by default in the next major release.
6065
+ # `raise` versus `fail` stopped being a meaningful distinction long ago.
6066
+ Preview:
6067
+ Enabled: false
5804
6068
  VersionAdded: '0.11'
5805
6069
  VersionChanged: '0.37'
5806
6070
  EnforcedStyle: only_raise
@@ -5862,6 +6126,10 @@ Style/SpecialGlobalVars:
5862
6126
  Description: 'Avoid Perl-style global variables.'
5863
6127
  StyleGuide: '#no-cryptic-perlisms'
5864
6128
  Enabled: true
6129
+ # Expected to be disabled by default in the next major release.
6130
+ # The long names need `require 'English'`; the short ones are idiomatic.
6131
+ Preview:
6132
+ Enabled: false
5865
6133
  VersionAdded: '0.13'
5866
6134
  VersionChanged: '0.36'
5867
6135
  SafeAutoCorrect: false
@@ -5927,6 +6195,10 @@ Style/StringLiterals:
5927
6195
  VersionAdded: '0.9'
5928
6196
  VersionChanged: '0.36'
5929
6197
  EnforcedStyle: single_quotes
6198
+ # Expected to become the default in the next major release.
6199
+ # Double quotes are what most Ruby is written with; Standard and omakase pick them too.
6200
+ Preview:
6201
+ EnforcedStyle: double_quotes
5930
6202
  SupportedStyles:
5931
6203
  - single_quotes
5932
6204
  - double_quotes
@@ -5941,6 +6213,10 @@ Style/StringLiteralsInInterpolation:
5941
6213
  Enabled: true
5942
6214
  VersionAdded: '0.27'
5943
6215
  EnforcedStyle: single_quotes
6216
+ # Expected to become the default in the next major release.
6217
+ # Follows `Style/StringLiterals`.
6218
+ Preview:
6219
+ EnforcedStyle: double_quotes
5944
6220
  SupportedStyles:
5945
6221
  - single_quotes
5946
6222
  - double_quotes
@@ -5997,6 +6273,10 @@ Style/SymbolArray:
5997
6273
  VersionAdded: '0.9'
5998
6274
  VersionChanged: '0.49'
5999
6275
  EnforcedStyle: percent
6276
+ # Expected to become the default in the next major release.
6277
+ # Bracketed arrays are the pick of nearly every project that sets this; Standard turns the cop off instead.
6278
+ Preview:
6279
+ EnforcedStyle: brackets
6000
6280
  MinSize: 2
6001
6281
  SupportedStyles:
6002
6282
  - percent
@@ -6033,12 +6313,22 @@ Style/TernaryParentheses:
6033
6313
  VersionAdded: '0.42'
6034
6314
  VersionChanged: '0.46'
6035
6315
  EnforcedStyle: require_no_parentheses
6316
+ # Expected to become the default in the next major release.
6317
+ # Parentheses only around complex conditions is the pick of nearly every project that sets this.
6318
+ Preview:
6319
+ EnforcedStyle: require_parentheses_when_complex
6036
6320
  SupportedStyles:
6037
6321
  - require_parentheses
6038
6322
  - require_no_parentheses
6039
6323
  - require_parentheses_when_complex
6040
6324
  AllowSafeAssignment: true
6041
6325
 
6326
+ Style/TimeNow:
6327
+ Description: 'Prefer `Time.now` over `Time.new` when retrieving the current system time.'
6328
+ StyleGuide: '#time-now'
6329
+ Enabled: pending
6330
+ VersionAdded: '1.90'
6331
+
6042
6332
  Style/TopLevelMethodDefinition:
6043
6333
  Description: 'Looks for top-level method definitions.'
6044
6334
  StyleGuide: '#top-level-methods'
@@ -6129,6 +6419,7 @@ Style/TrailingUnderscoreVariable:
6129
6419
  Description: >-
6130
6420
  Checks for the usage of unneeded trailing underscores at the
6131
6421
  end of parallel variable assignment.
6422
+ StyleGuide: '#trailing-underscore-variables'
6132
6423
  Enabled: true
6133
6424
  VersionAdded: '0.31'
6134
6425
  VersionChanged: '0.35'
@@ -6243,6 +6534,10 @@ Style/WordArray:
6243
6534
  VersionAdded: '0.9'
6244
6535
  VersionChanged: '1.19'
6245
6536
  EnforcedStyle: percent
6537
+ # Expected to become the default in the next major release.
6538
+ # Same preference as `SymbolArray`, and the two are configured together in practice.
6539
+ Preview:
6540
+ EnforcedStyle: brackets
6246
6541
  SupportedStyles:
6247
6542
  # percent style: %w(word1 word2)
6248
6543
  - percent