rubocop 1.90.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 (123) hide show
  1. checksums.yaml +4 -4
  2. data/config/default.yml +238 -10
  3. data/config/obsoletion.yml +9 -0
  4. data/lib/rubocop/changed_files.rb +112 -0
  5. data/lib/rubocop/cli/command/execute_runner.rb +21 -1
  6. data/lib/rubocop/cli.rb +9 -3
  7. data/lib/rubocop/comment_config/directive_range.rb +3 -1
  8. data/lib/rubocop/comment_config/disable_next.rb +49 -3
  9. data/lib/rubocop/comment_config/push_pop.rb +55 -0
  10. data/lib/rubocop/comment_config.rb +21 -51
  11. data/lib/rubocop/config.rb +10 -0
  12. data/lib/rubocop/config_loader.rb +12 -4
  13. data/lib/rubocop/config_loader_resolver.rb +49 -7
  14. data/lib/rubocop/config_obsoletion/cop_rule.rb +2 -1
  15. data/lib/rubocop/config_obsoletion/removed_cop.rb +8 -0
  16. data/lib/rubocop/config_obsoletion.rb +1 -1
  17. data/lib/rubocop/config_validator.rb +18 -3
  18. data/lib/rubocop/cop/badge.rb +1 -1
  19. data/lib/rubocop/cop/base.rb +15 -3
  20. data/lib/rubocop/cop/correctors.rb +2 -2
  21. data/lib/rubocop/cop/gemspec/require_mfa.rb +1 -1
  22. data/lib/rubocop/cop/generator.rb +1 -1
  23. data/lib/rubocop/cop/internal_affairs/on_send_without_on_csend.rb +1 -1
  24. data/lib/rubocop/cop/layout/argument_alignment.rb +2 -0
  25. data/lib/rubocop/cop/layout/comment_indentation.rb +8 -5
  26. data/lib/rubocop/cop/layout/else_alignment.rb +1 -0
  27. data/lib/rubocop/cop/layout/empty_lines_after_module_inclusion.rb +1 -1
  28. data/lib/rubocop/cop/layout/first_array_element_indentation.rb +17 -4
  29. data/lib/rubocop/cop/layout/first_parameter_indentation.rb +11 -0
  30. data/lib/rubocop/cop/layout/hash_alignment.rb +6 -5
  31. data/lib/rubocop/cop/layout/indentation_width.rb +2 -2
  32. data/lib/rubocop/cop/layout/line_length.rb +19 -1
  33. data/lib/rubocop/cop/layout/space_around_block_parameters.rb +14 -3
  34. data/lib/rubocop/cop/layout/space_around_operators.rb +5 -1
  35. data/lib/rubocop/cop/lint/argument_mismatch.rb +14 -4
  36. data/lib/rubocop/cop/lint/assignment_in_condition.rb +2 -0
  37. data/lib/rubocop/cop/lint/cop_directive_syntax.rb +88 -14
  38. data/lib/rubocop/cop/lint/duplicate_methods.rb +1 -1
  39. data/lib/rubocop/cop/lint/empty_block.rb +1 -1
  40. data/lib/rubocop/cop/lint/literal_as_condition.rb +8 -2
  41. data/lib/rubocop/cop/lint/misplaced_magic_comment.rb +185 -0
  42. data/lib/rubocop/cop/lint/missing_cop_enable_directive.rb +1 -1
  43. data/lib/rubocop/cop/lint/nested_method_definition.rb +1 -1
  44. data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +1 -1
  45. data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +17 -1
  46. data/lib/rubocop/cop/lint/redundant_cop_disable_directive.rb +30 -16
  47. data/lib/rubocop/cop/lint.rb +1 -0
  48. data/lib/rubocop/cop/migration/department_name.rb +1 -1
  49. data/lib/rubocop/cop/mixin/alignment.rb +1 -1
  50. data/lib/rubocop/cop/mixin/annotation_comment.rb +1 -1
  51. data/lib/rubocop/cop/mixin/hash_alignment_styles.rb +11 -1
  52. data/lib/rubocop/cop/mixin/hash_shorthand_syntax.rb +6 -2
  53. data/lib/rubocop/cop/mixin/hash_transform_method.rb +1 -1
  54. data/lib/rubocop/cop/mixin/preceding_following_alignment.rb +12 -1
  55. data/lib/rubocop/cop/mixin.rb +2 -2
  56. data/lib/rubocop/cop/naming/block_forwarding.rb +4 -1
  57. data/lib/rubocop/cop/naming/block_parameter_name.rb +1 -1
  58. data/lib/rubocop/cop/registry.rb +9 -1
  59. data/lib/rubocop/cop/severity.rb +12 -0
  60. data/lib/rubocop/cop/style/access_modifier_declarations.rb +3 -2
  61. data/lib/rubocop/cop/style/arguments_forwarding.rb +2 -2
  62. data/lib/rubocop/cop/style/case_like_if.rb +3 -3
  63. data/lib/rubocop/cop/style/constant_visibility.rb +6 -2
  64. data/lib/rubocop/cop/style/data_inheritance.rb +14 -0
  65. data/lib/rubocop/cop/style/directive_scope.rb +154 -21
  66. data/lib/rubocop/cop/style/disable_cops_within_source_code_directive.rb +53 -9
  67. data/lib/rubocop/cop/style/documentation_method.rb +1 -9
  68. data/lib/rubocop/cop/style/each_for_simple_loop.rb +1 -1
  69. data/lib/rubocop/cop/style/empty_block_parameter.rb +1 -1
  70. data/lib/rubocop/cop/style/empty_lambda_parameter.rb +1 -1
  71. data/lib/rubocop/cop/style/empty_method.rb +12 -2
  72. data/lib/rubocop/cop/style/endless_method.rb +31 -12
  73. data/lib/rubocop/cop/style/file_null.rb +2 -2
  74. data/lib/rubocop/cop/style/float_division.rb +10 -16
  75. data/lib/rubocop/cop/style/for.rb +5 -0
  76. data/lib/rubocop/cop/style/format_string_token.rb +1 -1
  77. data/lib/rubocop/cop/style/guard_clause.rb +4 -0
  78. data/lib/rubocop/cop/style/hash_lookup_method.rb +3 -0
  79. data/lib/rubocop/cop/style/magic_comment_format.rb +1 -1
  80. data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +1 -1
  81. data/lib/rubocop/cop/style/nested_modifier.rb +9 -4
  82. data/lib/rubocop/cop/style/nil_comparison.rb +36 -8
  83. data/lib/rubocop/cop/style/nil_lambda.rb +1 -1
  84. data/lib/rubocop/cop/style/non_nil_check.rb +18 -2
  85. data/lib/rubocop/cop/style/not.rb +3 -1
  86. data/lib/rubocop/cop/style/numeric_literal_prefix.rb +11 -1
  87. data/lib/rubocop/cop/style/one_line_conditional.rb +1 -1
  88. data/lib/rubocop/cop/style/parallel_assignment.rb +1 -1
  89. data/lib/rubocop/cop/style/parentheses_around_condition.rb +6 -1
  90. data/lib/rubocop/cop/style/redundant_condition.rb +4 -4
  91. data/lib/rubocop/cop/style/redundant_double_splat_hash_braces.rb +10 -1
  92. data/lib/rubocop/cop/style/redundant_fetch_block.rb +1 -1
  93. data/lib/rubocop/cop/style/redundant_parentheses.rb +11 -1
  94. data/lib/rubocop/cop/style/redundant_regexp_character_class.rb +6 -5
  95. data/lib/rubocop/cop/style/redundant_regexp_constructor.rb +6 -6
  96. data/lib/rubocop/cop/style/single_line_block_params.rb +1 -1
  97. data/lib/rubocop/cop/style/special_global_vars.rb +1 -1
  98. data/lib/rubocop/cop/style/struct_inheritance.rb +14 -0
  99. data/lib/rubocop/cop/style/trailing_comma_in_block_args.rb +1 -1
  100. data/lib/rubocop/cop/style.rb +0 -1
  101. data/lib/rubocop/cop/util.rb +1 -1
  102. data/lib/rubocop/cops_documentation_generator.rb +23 -2
  103. data/lib/rubocop/directive_comment.rb +37 -8
  104. data/lib/rubocop/formatter/disabled_config_formatter.rb +19 -1
  105. data/lib/rubocop/formatter/formatter_set.rb +2 -1
  106. data/lib/rubocop/formatter/github_actions_formatter.rb +6 -5
  107. data/lib/rubocop/formatter/html_formatter.rb +2 -2
  108. data/lib/rubocop/formatter/junit_formatter.rb +1 -1
  109. data/lib/rubocop/formatter/sarif_formatter.rb +181 -0
  110. data/lib/rubocop/formatter.rb +1 -0
  111. data/lib/rubocop/magic_comment.rb +27 -0
  112. data/lib/rubocop/options.rb +59 -1
  113. data/lib/rubocop/path_util.rb +1 -1
  114. data/lib/rubocop/plugin/loader.rb +1 -1
  115. data/lib/rubocop/rake_task.rb +1 -1
  116. data/lib/rubocop/remote_config.rb +4 -4
  117. data/lib/rubocop/result_cache.rb +16 -5
  118. data/lib/rubocop/runner.rb +64 -21
  119. data/lib/rubocop/unified_diff.rb +257 -0
  120. data/lib/rubocop/version.rb +1 -1
  121. data/lib/rubocop.rb +4 -1
  122. metadata +8 -4
  123. data/lib/rubocop/cop/style/double_cop_disable_directive.rb +0 -46
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 382da6a2b30d9de3a34dfad6d8a2aba1f4c314881d4a7a419d698b58faf07cd4
4
- data.tar.gz: 3807b557f0eedb44f81b1a20880649e15b8c76ed31a916756d626a13b391d556
3
+ metadata.gz: a1d198a5503ecb56c2ee7fc8fc0a22f1bcf5b733cb2d1d22164fc3322da20390
4
+ data.tar.gz: d698c0ca090ee2dd64879448b9a1e5fc9f51cc2b1816385f60e5c90f490aad99
5
5
  SHA512:
6
- metadata.gz: 7654d620f9e6504e76855f15335df419416a8353da06cb55c0a15b1fa123b2cabc170792846e8ee5ab1b122003d14038809f524fdf7a07773d51a69b1faca234
7
- data.tar.gz: 296dc584530a8191088320cfcfe2fdd38339da0888aac861b510ba219b50a601bd4bd060b831f9733f12553031c20abd91fdcc7ece654d0e716857ef7eb8cee8
6
+ metadata.gz: f31306b39a0d1daf1606fac0c7e812f04f9d0f50dacb37a22bcd31d3d848e1e66a33c8dc317f1d536c7a96cfb90a6736aacdb6aeacbc5670f9657eab390fe534
7
+ data.tar.gz: d576dfbeaa9e6eb91c162b8c210054f3b5764a02bf4d8f2bcb8cc01c65441847ed287a040cb28e1e440e74d36ea77bef48c428142f8c34bd5940bc500f9c515f
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
@@ -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,7 +648,7 @@ Layout/EmptyLineAfterMagicComment:
618
648
  StyleGuide: '#separate-magic-comments-from-code'
619
649
  Enabled: true
620
650
  VersionAdded: '0.49'
621
- VersionChanged: '1.90'
651
+ VersionChanged: '1.91'
622
652
  # The minimum number of empty lines required after the last magic comment. Set this
623
653
  # to `2` when using YARD, which otherwise treats the magic comments as documentation
624
654
  # for the first module or class in the file. `Layout/EmptyLines` has to be disabled
@@ -760,10 +790,15 @@ Layout/EndAlignment:
760
790
  # The value `start_of_line` means that `end` should be aligned with the start
761
791
  # of the line which the matching keyword appears on.
762
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
763
797
  SupportedStylesAlignWith:
764
798
  - keyword
765
799
  - variable
766
800
  - start_of_line
801
+ # A misaligned `end` usually means a structural mistake, so this reports as a lint would.
767
802
  Severity: warning
768
803
 
769
804
  Layout/EndOfLine:
@@ -839,6 +874,10 @@ Layout/FirstArrayElementIndentation:
839
874
  # The value `align_brackets` means that the indentation of the first element
840
875
  # shall always be relative to the position of the opening bracket.
841
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
842
881
  SupportedStyles:
843
882
  - special_inside_parentheses
844
883
  - consistent
@@ -873,6 +912,10 @@ Layout/FirstHashElementIndentation:
873
912
  # The value `align_braces` means that the indentation of the first key shall
874
913
  # always be relative to the position of the opening brace.
875
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
876
919
  SupportedStyles:
877
920
  - special_inside_parentheses
878
921
  - consistent
@@ -1260,6 +1303,10 @@ Layout/MultilineMethodCallIndentation:
1260
1303
  Enabled: true
1261
1304
  VersionAdded: '0.49'
1262
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
1263
1310
  SupportedStyles:
1264
1311
  - aligned
1265
1312
  - indented
@@ -1299,6 +1346,10 @@ Layout/MultilineOperationIndentation:
1299
1346
  Enabled: true
1300
1347
  VersionAdded: '0.49'
1301
1348
  EnforcedStyle: aligned
1349
+ # Expected to become the default in the next major release.
1350
+ # Same preference as `MultilineMethodCallIndentation`.
1351
+ Preview:
1352
+ EnforcedStyle: indented
1302
1353
  SupportedStyles:
1303
1354
  - aligned
1304
1355
  - indented
@@ -1328,6 +1379,10 @@ Layout/ParameterAlignment:
1328
1379
  # def method_foo(a,
1329
1380
  # b)
1330
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
1331
1386
  SupportedStyles:
1332
1387
  - with_first_parameter
1333
1388
  - with_fixed_indentation
@@ -1746,9 +1801,9 @@ Lint/ConstantResolution:
1746
1801
 
1747
1802
  Lint/CopDirectiveSyntax:
1748
1803
  Description: 'Checks that `# rubocop:` directives are strictly formatted.'
1749
- Enabled: pending
1804
+ Enabled: true
1750
1805
  VersionAdded: '1.72'
1751
- VersionChanged: '1.90'
1806
+ VersionChanged: '1.91'
1752
1807
 
1753
1808
  Lint/DataDefineOverride:
1754
1809
  Description: 'Disallow overriding the `Data` built-in methods via `Data.define`.'
@@ -2160,6 +2215,13 @@ Lint/Loop:
2160
2215
  VersionChanged: '1.3'
2161
2216
  Safe: false
2162
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
+
2163
2225
  Lint/MissingCopEnableDirective:
2164
2226
  Description: 'Checks for a `# rubocop:enable` after `# rubocop:disable`.'
2165
2227
  Enabled: true
@@ -2289,7 +2351,7 @@ Lint/OrderedMagicComments:
2289
2351
  Enabled: true
2290
2352
  SafeAutoCorrect: false
2291
2353
  VersionAdded: '0.53'
2292
- VersionChanged: '1.37'
2354
+ VersionChanged: '1.91'
2293
2355
 
2294
2356
  Lint/OutOfRangeRegexpRef:
2295
2357
  Description: 'Checks for out of range reference for Regexp because it always returns nil.'
@@ -2838,6 +2900,10 @@ Metrics/AbcSize:
2838
2900
  - https://wiki.c2.com/?AbcMetric
2839
2901
  - https://en.wikipedia.org/wiki/ABC_Software_Metric
2840
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
2841
2907
  VersionAdded: '0.27'
2842
2908
  VersionChanged: '1.5'
2843
2909
  # The ABC size is a calculated magnitude, so this number can be an Integer or
@@ -2850,6 +2916,10 @@ Metrics/AbcSize:
2850
2916
  Metrics/BlockLength:
2851
2917
  Description: 'Avoid long blocks with many lines.'
2852
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
2853
2923
  VersionAdded: '0.44'
2854
2924
  VersionChanged: '1.5'
2855
2925
  CountComments: false # count full line comments?
@@ -2867,6 +2937,10 @@ Metrics/BlockNesting:
2867
2937
  Description: 'Avoid excessive block nesting.'
2868
2938
  StyleGuide: '#three-is-the-number-thou-shalt-count'
2869
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
2870
2944
  VersionAdded: '0.25'
2871
2945
  VersionChanged: '1.65'
2872
2946
  CountBlocks: false
@@ -2876,6 +2950,10 @@ Metrics/BlockNesting:
2876
2950
  Metrics/ClassLength:
2877
2951
  Description: 'Avoid classes longer than 100 lines of code.'
2878
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
2879
2957
  VersionAdded: '0.25'
2880
2958
  VersionChanged: '0.87'
2881
2959
  CountComments: false # count full line comments?
@@ -2893,6 +2971,10 @@ Metrics/CollectionLiteralLength:
2893
2971
  Metrics/CyclomaticComplexity:
2894
2972
  Description: 'Checks that the cyclomatic complexity of methods is not higher than the configured maximum.'
2895
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
2896
2978
  VersionAdded: '0.25'
2897
2979
  VersionChanged: '0.81'
2898
2980
  AllowedMethods: []
@@ -2903,6 +2985,10 @@ Metrics/MethodLength:
2903
2985
  Description: 'Avoid methods longer than 10 lines of code.'
2904
2986
  StyleGuide: '#short-methods'
2905
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
2906
2992
  VersionAdded: '0.25'
2907
2993
  VersionChanged: '1.5'
2908
2994
  CountComments: false # count full line comments?
@@ -2914,6 +3000,10 @@ Metrics/MethodLength:
2914
3000
  Metrics/ModuleLength:
2915
3001
  Description: 'Avoid modules longer than 100 lines of code.'
2916
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
2917
3007
  VersionAdded: '0.31'
2918
3008
  VersionChanged: '0.87'
2919
3009
  CountComments: false # count full line comments?
@@ -2924,6 +3014,10 @@ Metrics/ParameterLists:
2924
3014
  Description: 'Avoid parameter lists longer than three or four parameters.'
2925
3015
  StyleGuide: '#too-many-params'
2926
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
2927
3021
  VersionAdded: '0.25'
2928
3022
  VersionChanged: '1.5'
2929
3023
  Max: 5
@@ -2933,6 +3027,10 @@ Metrics/ParameterLists:
2933
3027
  Metrics/PerceivedComplexity:
2934
3028
  Description: 'Checks that the perceived complexity of methods is not higher than the configured maximum.'
2935
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
2936
3034
  VersionAdded: '0.25'
2937
3035
  VersionChanged: '1.88'
2938
3036
  AllowedMethods: []
@@ -3105,6 +3203,10 @@ Naming/HeredocDelimiterNaming:
3105
3203
  Description: 'Use descriptive heredoc delimiters.'
3106
3204
  StyleGuide: '#heredoc-delimiters'
3107
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
3108
3210
  VersionAdded: '0.50'
3109
3211
  ForbiddenDelimiters:
3110
3212
  - !ruby/regexp '/(^|\s)(EO[A-Z]{1}|END)(\s|$)/i'
@@ -3282,6 +3384,10 @@ Naming/VariableNumber:
3282
3384
  Description: 'Use the configured style when numbering symbols, methods and variables.'
3283
3385
  StyleGuide: '#snake-case-symbols-methods-vars-with-numbers'
3284
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
3285
3391
  VersionAdded: '0.50'
3286
3392
  VersionChanged: '1.4'
3287
3393
  EnforcedStyle: normalcase
@@ -3399,6 +3505,10 @@ Style/Alias:
3399
3505
  VersionAdded: '0.9'
3400
3506
  VersionChanged: '0.36'
3401
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
3402
3512
  SupportedStyles:
3403
3513
  - prefer_alias
3404
3514
  - prefer_alias_method
@@ -3545,6 +3655,10 @@ Style/BlockDelimiters:
3545
3655
  Prefer {...} over do...end for single-line blocks.
3546
3656
  StyleGuide: '#single-line-blocks'
3547
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
3548
3662
  VersionAdded: '0.30'
3549
3663
  VersionChanged: '0.35'
3550
3664
  EnforcedStyle: line_count_based
@@ -3703,6 +3817,10 @@ Style/ClassAndModuleChildren:
3703
3817
  # project-wide index is consulted for both operations.
3704
3818
  SafeAutoCorrect: false
3705
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
3706
3824
  VersionAdded: '0.19'
3707
3825
  VersionChanged: '1.89'
3708
3826
  #
@@ -4019,6 +4137,7 @@ Style/DirectiveScope:
4019
4137
  Enabled: pending
4020
4138
  SafeAutoCorrect: false
4021
4139
  VersionAdded: '1.90'
4140
+ VersionChanged: '1.91'
4022
4141
 
4023
4142
  Style/DisableCopsWithinSourceCodeDirective:
4024
4143
  Description: >-
@@ -4026,9 +4145,18 @@ Style/DisableCopsWithinSourceCodeDirective:
4026
4145
  Enabled: false
4027
4146
  VersionAdded: '0.82'
4028
4147
  VersionChanged: '1.90'
4148
+ # Cop or department names. A directive is exempt only when everything it
4149
+ # disables is listed here.
4029
4150
  AllowedCops: []
4151
+ # Cop or department names. When set, only directives touching these are
4152
+ # flagged.
4030
4153
  DisallowedCops: []
4031
- AllowTrailingComment: false
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: []
4032
4160
 
4033
4161
  Style/DocumentDynamicEvalDefinition:
4034
4162
  Description: >-
@@ -4042,6 +4170,10 @@ Style/DocumentDynamicEvalDefinition:
4042
4170
  Style/Documentation:
4043
4171
  Description: 'Document classes and non-namespace modules.'
4044
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
4045
4177
  VersionAdded: '0.9'
4046
4178
  VersionChanged: '1.89'
4047
4179
  AllowedConstants: []
@@ -4059,15 +4191,14 @@ Style/DocumentationMethod:
4059
4191
  - 'test/**/*'
4060
4192
  RequireForNonPublicMethods: false
4061
4193
 
4062
- Style/DoubleCopDisableDirective:
4063
- Description: 'Checks for double rubocop:disable comments on a single line.'
4064
- Enabled: true
4065
- VersionAdded: '0.73'
4066
-
4067
4194
  Style/DoubleNegation:
4068
4195
  Description: 'Checks for uses of double negation (!!).'
4069
4196
  StyleGuide: '#no-bang-bang'
4070
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
4071
4202
  VersionAdded: '0.19'
4072
4203
  VersionChanged: '1.2'
4073
4204
  EnforcedStyle: allowed_in_returns
@@ -4155,6 +4286,10 @@ Style/EmptyMethod:
4155
4286
  VersionAdded: '0.46'
4156
4287
  VersionChanged: '1.61'
4157
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
4158
4293
  SupportedStyles:
4159
4294
  - compact
4160
4295
  - expanded
@@ -4329,6 +4464,10 @@ Style/FormatString:
4329
4464
  Description: 'Enforce the use of Kernel#sprintf, Kernel#format or String#%.'
4330
4465
  StyleGuide: '#sprintf'
4331
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
4332
4471
  VersionAdded: '0.19'
4333
4472
  VersionChanged: '0.49'
4334
4473
  EnforcedStyle: format
@@ -4341,6 +4480,10 @@ Style/FormatStringToken:
4341
4480
  Description: 'Use a consistent style for format string tokens.'
4342
4481
  StyleGuide: '#named-format-tokens'
4343
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
4344
4487
  VersionAdded: '0.49'
4345
4488
  VersionChanged: '1.74'
4346
4489
  EnforcedStyle: annotated
@@ -4369,6 +4512,10 @@ Style/FrozenStringLiteralComment:
4369
4512
  Add the frozen_string_literal comment to the top of files
4370
4513
  to help transition to frozen string literals by default.
4371
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
4372
4519
  VersionAdded: '0.36'
4373
4520
  VersionChanged: '0.79'
4374
4521
  EnforcedStyle: always
@@ -4410,6 +4557,10 @@ Style/GuardClause:
4410
4557
  Description: 'Checks for conditionals that can be replaced with guard clauses.'
4411
4558
  StyleGuide: '#no-nested-conditionals'
4412
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
4413
4564
  VersionAdded: '0.20'
4414
4565
  VersionChanged: '1.31'
4415
4566
  # `MinBodyLength` defines the number of lines of the a body of an `if` or `unless`
@@ -4566,6 +4717,10 @@ Style/IfUnlessModifier:
4566
4717
  single-line body.
4567
4718
  StyleGuide: '#if-as-a-modifier'
4568
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
4569
4724
  VersionAdded: '0.9'
4570
4725
  VersionChanged: '0.30'
4571
4726
 
@@ -4717,6 +4872,10 @@ Style/Lambda:
4717
4872
  Description: 'Use the new lambda literal syntax for single-line blocks.'
4718
4873
  StyleGuide: '#lambda-multi-line'
4719
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
4720
4879
  VersionAdded: '0.9'
4721
4880
  VersionChanged: '0.40'
4722
4881
  EnforcedStyle: line_count_dependent
@@ -4751,6 +4910,7 @@ Style/MagicCommentFormat:
4751
4910
  Description: 'Use a consistent style for magic comments.'
4752
4911
  Enabled: pending
4753
4912
  VersionAdded: '1.35'
4913
+ VersionChanged: '1.91'
4754
4914
  EnforcedStyle: snake_case
4755
4915
  SupportedStyles:
4756
4916
  # `snake` will enforce the magic comment is written
@@ -4912,6 +5072,10 @@ Style/ModuleFunction:
4912
5072
  Description: 'Checks for usage of `extend self` in modules.'
4913
5073
  StyleGuide: '#module-function'
4914
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
4915
5079
  VersionAdded: '0.11'
4916
5080
  VersionChanged: '0.65'
4917
5081
  EnforcedStyle: module_function
@@ -5019,6 +5183,10 @@ Style/NegatedIf:
5019
5183
  (or control flow or).
5020
5184
  StyleGuide: '#unless-for-negatives'
5021
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
5022
5190
  VersionAdded: '0.20'
5023
5191
  VersionChanged: '0.48'
5024
5192
  EnforcedStyle: both
@@ -5113,6 +5281,10 @@ Style/Next:
5113
5281
  Description: 'Use `next` to skip iteration instead of a condition at the end.'
5114
5282
  StyleGuide: '#no-nested-conditionals'
5115
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
5116
5288
  VersionAdded: '0.22'
5117
5289
  VersionChanged: '1.75'
5118
5290
  # With `always` all conditions at the end of an iteration needs to be
@@ -5196,6 +5368,10 @@ Style/NumericLiterals:
5196
5368
  readability.
5197
5369
  StyleGuide: '#underscores-in-numerics'
5198
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
5199
5375
  VersionAdded: '0.9'
5200
5376
  VersionChanged: '0.48'
5201
5377
  MinDigits: 5
@@ -5214,6 +5390,10 @@ Style/NumericPredicate:
5214
5390
  # of the variables which rubocop doesn't have.
5215
5391
  Safe: false
5216
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
5217
5397
  VersionAdded: '0.42'
5218
5398
  VersionChanged: '0.59'
5219
5399
  EnforcedStyle: predicate
@@ -5326,6 +5506,10 @@ Style/ParallelAssignment:
5326
5506
  matches on both sides of the assignment.
5327
5507
  StyleGuide: '#parallel-assignment'
5328
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
5329
5513
  VersionAdded: '0.32'
5330
5514
 
5331
5515
  Style/ParenthesesAroundCondition:
@@ -5377,6 +5561,10 @@ Style/PerlBackrefs:
5377
5561
  Description: 'Avoid Perl-style regex back references.'
5378
5562
  StyleGuide: '#no-perl-regexp-last-matchers'
5379
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
5380
5568
  VersionAdded: '0.13'
5381
5569
 
5382
5570
  Style/PredicateWithKind:
@@ -5418,6 +5606,10 @@ Style/RaiseArgs:
5418
5606
  Description: 'Checks the arguments passed to raise/fail.'
5419
5607
  StyleGuide: '#exception-class-messages'
5420
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
5421
5613
  Safe: false
5422
5614
  VersionAdded: '0.14'
5423
5615
  VersionChanged: '1.61'
@@ -5706,6 +5898,10 @@ Style/RegexpLiteral:
5706
5898
  Description: 'Use / or %r around regular expressions.'
5707
5899
  StyleGuide: '#percent-r'
5708
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
5709
5905
  VersionAdded: '0.9'
5710
5906
  VersionChanged: '0.30'
5711
5907
  EnforcedStyle: slashes
@@ -5738,6 +5934,10 @@ Style/RescueStandardError:
5738
5934
  Enabled: true
5739
5935
  VersionAdded: '0.52'
5740
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
5741
5941
  # implicit: Do not include the error class, `rescue`
5742
5942
  # explicit: Require an error class `rescue StandardError`
5743
5943
  SupportedStyles:
@@ -5861,6 +6061,10 @@ Style/SignalException:
5861
6061
  Description: 'Checks for proper usage of fail and raise.'
5862
6062
  StyleGuide: '#prefer-raise-over-fail'
5863
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
5864
6068
  VersionAdded: '0.11'
5865
6069
  VersionChanged: '0.37'
5866
6070
  EnforcedStyle: only_raise
@@ -5922,6 +6126,10 @@ Style/SpecialGlobalVars:
5922
6126
  Description: 'Avoid Perl-style global variables.'
5923
6127
  StyleGuide: '#no-cryptic-perlisms'
5924
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
5925
6133
  VersionAdded: '0.13'
5926
6134
  VersionChanged: '0.36'
5927
6135
  SafeAutoCorrect: false
@@ -5987,6 +6195,10 @@ Style/StringLiterals:
5987
6195
  VersionAdded: '0.9'
5988
6196
  VersionChanged: '0.36'
5989
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
5990
6202
  SupportedStyles:
5991
6203
  - single_quotes
5992
6204
  - double_quotes
@@ -6001,6 +6213,10 @@ Style/StringLiteralsInInterpolation:
6001
6213
  Enabled: true
6002
6214
  VersionAdded: '0.27'
6003
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
6004
6220
  SupportedStyles:
6005
6221
  - single_quotes
6006
6222
  - double_quotes
@@ -6057,6 +6273,10 @@ Style/SymbolArray:
6057
6273
  VersionAdded: '0.9'
6058
6274
  VersionChanged: '0.49'
6059
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
6060
6280
  MinSize: 2
6061
6281
  SupportedStyles:
6062
6282
  - percent
@@ -6093,6 +6313,10 @@ Style/TernaryParentheses:
6093
6313
  VersionAdded: '0.42'
6094
6314
  VersionChanged: '0.46'
6095
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
6096
6320
  SupportedStyles:
6097
6321
  - require_parentheses
6098
6322
  - require_no_parentheses
@@ -6310,6 +6534,10 @@ Style/WordArray:
6310
6534
  VersionAdded: '0.9'
6311
6535
  VersionChanged: '1.19'
6312
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
6313
6541
  SupportedStyles:
6314
6542
  # percent style: %w(word1 word2)
6315
6543
  - percent
@@ -80,6 +80,11 @@ removed:
80
80
  `Lint/BinaryOperatorWithIdenticalOperands`. Please use
81
81
  `Lint/BinaryOperatorWithIdenticalOperands` instead
82
82
  Style/BracesAroundHashParameters: true
83
+ Style/DoubleCopDisableDirective:
84
+ severity: warning
85
+ reason: >
86
+ it has been superseded by `Lint/CopDirectiveSyntax`. Please use
87
+ `Lint/CopDirectiveSyntax` instead
83
88
  Style/MethodMissingSuper:
84
89
  reason: >
85
90
  it has been superseded by `Lint/MissingSuper`. Please use
@@ -149,6 +154,10 @@ changed_parameters:
149
154
  parameters: IgnoreCopDirectives
150
155
  alternative: AllowCopDirectives
151
156
  severity: warning
157
+ - cops: Style/DisableCopsWithinSourceCodeDirective
158
+ parameters: AllowTrailingComment
159
+ alternative: AllowWithReason
160
+ severity: warning
152
161
  - cops:
153
162
  - Lint/BlockAlignment
154
163
  - Layout/BlockAlignment