rubocop 1.86.2 → 1.88.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 (152) hide show
  1. checksums.yaml +4 -4
  2. data/config/default.yml +82 -71
  3. data/config/obsoletion.yml +21 -1
  4. data/lib/rubocop/cli/command/auto_generate_config.rb +6 -0
  5. data/lib/rubocop/cli.rb +2 -0
  6. data/lib/rubocop/config_loader.rb +17 -2
  7. data/lib/rubocop/config_loader_resolver.rb +11 -3
  8. data/lib/rubocop/config_store.rb +1 -1
  9. data/lib/rubocop/cop/base.rb +25 -4
  10. data/lib/rubocop/cop/bundler/gem_comment.rb +2 -2
  11. data/lib/rubocop/cop/correctors/parentheses_corrector.rb +33 -2
  12. data/lib/rubocop/cop/gemspec/duplicated_assignment.rb +2 -2
  13. data/lib/rubocop/cop/gemspec/require_mfa.rb +1 -1
  14. data/lib/rubocop/cop/gemspec/ruby_version_globals_usage.rb +3 -3
  15. data/lib/rubocop/cop/internal_affairs/redundant_let_rubocop_config_new.rb +5 -3
  16. data/lib/rubocop/cop/layout/begin_end_alignment.rb +1 -1
  17. data/lib/rubocop/cop/layout/block_alignment.rb +41 -4
  18. data/lib/rubocop/cop/layout/class_structure.rb +1 -1
  19. data/lib/rubocop/cop/layout/empty_line_after_guard_clause.rb +14 -5
  20. data/lib/rubocop/cop/layout/end_alignment.rb +2 -2
  21. data/lib/rubocop/cop/layout/indentation_width.rb +13 -1
  22. data/lib/rubocop/cop/layout/redundant_line_break.rb +3 -1
  23. data/lib/rubocop/cop/layout/space_before_brackets.rb +1 -1
  24. data/lib/rubocop/cop/lint/ambiguous_assignment.rb +1 -11
  25. data/lib/rubocop/cop/lint/ambiguous_block_association.rb +1 -1
  26. data/lib/rubocop/cop/lint/ambiguous_operator_precedence.rb +1 -10
  27. data/lib/rubocop/cop/lint/circular_argument_reference.rb +1 -3
  28. data/lib/rubocop/cop/lint/constant_overwritten_in_rescue.rb +1 -1
  29. data/lib/rubocop/cop/lint/constant_reassignment.rb +36 -4
  30. data/lib/rubocop/cop/lint/constant_resolution.rb +5 -5
  31. data/lib/rubocop/cop/lint/debugger.rb +0 -1
  32. data/lib/rubocop/cop/lint/deprecated_constants.rb +2 -8
  33. data/lib/rubocop/cop/lint/empty_block.rb +3 -3
  34. data/lib/rubocop/cop/lint/ensure_return.rb +19 -1
  35. data/lib/rubocop/cop/lint/erb_new_arguments.rb +4 -2
  36. data/lib/rubocop/cop/lint/float_comparison.rb +1 -0
  37. data/lib/rubocop/cop/lint/incompatible_io_select_with_fiber_scheduler.rb +5 -1
  38. data/lib/rubocop/cop/lint/interpolation_check.rb +18 -3
  39. data/lib/rubocop/cop/lint/lambda_without_literal_block.rb +1 -1
  40. data/lib/rubocop/cop/lint/literal_assignment_in_condition.rb +11 -1
  41. data/lib/rubocop/cop/lint/literal_in_interpolation.rb +8 -11
  42. data/lib/rubocop/cop/lint/missing_cop_enable_directive.rb +5 -5
  43. data/lib/rubocop/cop/lint/multiple_comparison.rb +2 -2
  44. data/lib/rubocop/cop/lint/no_return_in_begin_end_blocks.rb +16 -0
  45. data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +1 -1
  46. data/lib/rubocop/cop/lint/non_local_exit_from_iterator.rb +1 -1
  47. data/lib/rubocop/cop/lint/number_conversion.rb +18 -9
  48. data/lib/rubocop/cop/lint/numbered_parameter_assignment.rb +1 -1
  49. data/lib/rubocop/cop/lint/numeric_operation_with_constant_result.rb +3 -0
  50. data/lib/rubocop/cop/lint/ordered_magic_comments.rb +7 -7
  51. data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +1 -1
  52. data/lib/rubocop/cop/lint/raise_exception.rb +1 -1
  53. data/lib/rubocop/cop/lint/rand_one.rb +1 -1
  54. data/lib/rubocop/cop/lint/redundant_cop_disable_directive.rb +4 -1
  55. data/lib/rubocop/cop/lint/redundant_cop_enable_directive.rb +6 -3
  56. data/lib/rubocop/cop/lint/redundant_dir_glob_sort.rb +15 -4
  57. data/lib/rubocop/cop/lint/redundant_safe_navigation.rb +14 -7
  58. data/lib/rubocop/cop/lint/redundant_splat_expansion.rb +4 -0
  59. data/lib/rubocop/cop/lint/redundant_type_conversion.rb +10 -3
  60. data/lib/rubocop/cop/lint/redundant_with_index.rb +1 -1
  61. data/lib/rubocop/cop/lint/redundant_with_object.rb +5 -0
  62. data/lib/rubocop/cop/lint/refinement_import_methods.rb +8 -1
  63. data/lib/rubocop/cop/lint/regexp_as_condition.rb +9 -1
  64. data/lib/rubocop/cop/lint/require_parentheses.rb +13 -4
  65. data/lib/rubocop/cop/lint/require_range_parentheses.rb +2 -1
  66. data/lib/rubocop/cop/lint/require_relative_self_path.rb +6 -6
  67. data/lib/rubocop/cop/lint/rescue_type.rb +1 -1
  68. data/lib/rubocop/cop/lint/safe_navigation_chain.rb +1 -0
  69. data/lib/rubocop/cop/lint/safe_navigation_with_empty.rb +1 -1
  70. data/lib/rubocop/cop/lint/script_permission.rb +5 -1
  71. data/lib/rubocop/cop/lint/self_assignment.rb +24 -1
  72. data/lib/rubocop/cop/lint/send_with_mixin_argument.rb +1 -1
  73. data/lib/rubocop/cop/lint/shadowed_exception.rb +1 -1
  74. data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +14 -0
  75. data/lib/rubocop/cop/lint/shared_mutable_default.rb +3 -1
  76. data/lib/rubocop/cop/lint/suppressed_exception_in_number_conversion.rb +12 -0
  77. data/lib/rubocop/cop/lint/symbol_conversion.rb +21 -4
  78. data/lib/rubocop/cop/lint/to_enum_arguments.rb +28 -1
  79. data/lib/rubocop/cop/lint/top_level_return_with_argument.rb +1 -1
  80. data/lib/rubocop/cop/lint/trailing_comma_in_attribute_declaration.rb +4 -1
  81. data/lib/rubocop/cop/lint/unescaped_bracket_in_regexp.rb +4 -2
  82. data/lib/rubocop/cop/lint/unreachable_code.rb +2 -2
  83. data/lib/rubocop/cop/lint/useless_assignment.rb +10 -5
  84. data/lib/rubocop/cop/lint/useless_ruby2_keywords.rb +8 -4
  85. data/lib/rubocop/cop/lint/useless_setter_call.rb +4 -1
  86. data/lib/rubocop/cop/lint/useless_times.rb +22 -1
  87. data/lib/rubocop/cop/metrics/block_length.rb +1 -1
  88. data/lib/rubocop/cop/metrics/collection_literal_length.rb +1 -1
  89. data/lib/rubocop/cop/metrics/method_length.rb +1 -1
  90. data/lib/rubocop/cop/metrics/utils/iterating_block.rb +1 -1
  91. data/lib/rubocop/cop/mixin/project_index_help.rb +48 -0
  92. data/lib/rubocop/cop/mixin.rb +1 -0
  93. data/lib/rubocop/cop/naming/binary_operator_parameter_name.rb +1 -1
  94. data/lib/rubocop/cop/naming/predicate_method.rb +2 -2
  95. data/lib/rubocop/cop/naming/predicate_prefix.rb +1 -1
  96. data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +1 -1
  97. data/lib/rubocop/cop/registry.rb +28 -6
  98. data/lib/rubocop/cop/security/io_methods.rb +1 -1
  99. data/lib/rubocop/cop/style/alias.rb +11 -2
  100. data/lib/rubocop/cop/style/and_or.rb +1 -1
  101. data/lib/rubocop/cop/style/array_first_last.rb +12 -1
  102. data/lib/rubocop/cop/style/array_intersect.rb +4 -0
  103. data/lib/rubocop/cop/style/array_intersect_with_single_element.rb +3 -0
  104. data/lib/rubocop/cop/style/block_delimiters.rb +16 -2
  105. data/lib/rubocop/cop/style/case_equality.rb +14 -2
  106. data/lib/rubocop/cop/style/character_literal.rb +2 -2
  107. data/lib/rubocop/cop/style/class_and_module_children.rb +8 -0
  108. data/lib/rubocop/cop/style/class_equality_comparison.rb +21 -13
  109. data/lib/rubocop/cop/style/class_methods_definitions.rb +11 -5
  110. data/lib/rubocop/cop/style/colon_method_call.rb +13 -6
  111. data/lib/rubocop/cop/style/combinable_loops.rb +5 -0
  112. data/lib/rubocop/cop/style/comparable_clamp.rb +12 -1
  113. data/lib/rubocop/cop/style/concat_array_literals.rb +5 -1
  114. data/lib/rubocop/cop/style/conditional_assignment.rb +6 -1
  115. data/lib/rubocop/cop/style/constant_visibility.rb +4 -1
  116. data/lib/rubocop/cop/style/date_time.rb +2 -2
  117. data/lib/rubocop/cop/style/dig_chain.rb +5 -0
  118. data/lib/rubocop/cop/style/disable_cops_within_source_code_directive.rb +1 -1
  119. data/lib/rubocop/cop/style/fetch_env_var.rb +1 -1
  120. data/lib/rubocop/cop/style/file_write.rb +21 -16
  121. data/lib/rubocop/cop/style/format_string.rb +4 -3
  122. data/lib/rubocop/cop/style/hash_conversion.rb +1 -1
  123. data/lib/rubocop/cop/style/hash_slice.rb +16 -0
  124. data/lib/rubocop/cop/style/if_unless_modifier.rb +1 -1
  125. data/lib/rubocop/cop/style/magic_comment_format.rb +1 -1
  126. data/lib/rubocop/cop/style/min_max_comparison.rb +1 -1
  127. data/lib/rubocop/cop/style/mutable_constant.rb +105 -11
  128. data/lib/rubocop/cop/style/parallel_assignment.rb +8 -1
  129. data/lib/rubocop/cop/style/redundant_array_constructor.rb +2 -2
  130. data/lib/rubocop/cop/style/redundant_constant_base.rb +5 -5
  131. data/lib/rubocop/cop/style/redundant_format.rb +1 -0
  132. data/lib/rubocop/cop/style/redundant_regexp_constructor.rb +2 -2
  133. data/lib/rubocop/cop/style/regexp_literal.rb +2 -2
  134. data/lib/rubocop/cop/style/rescue_modifier.rb +3 -3
  135. data/lib/rubocop/cop/style/self_assignment.rb +1 -1
  136. data/lib/rubocop/cop/style/semicolon.rb +16 -1
  137. data/lib/rubocop/cop/style/struct_inheritance.rb +13 -0
  138. data/lib/rubocop/cop/style/top_level_method_definition.rb +2 -2
  139. data/lib/rubocop/cop/style/unless_logical_operators.rb +3 -3
  140. data/lib/rubocop/cop/style/while_until_do.rb +7 -0
  141. data/lib/rubocop/cop/style/word_array.rb +1 -0
  142. data/lib/rubocop/cop/style/yoda_condition.rb +1 -1
  143. data/lib/rubocop/cop/style/zero_length_predicate.rb +6 -3
  144. data/lib/rubocop/file_patterns.rb +9 -1
  145. data/lib/rubocop/formatter/disabled_config_formatter.rb +14 -7
  146. data/lib/rubocop/options.rb +18 -0
  147. data/lib/rubocop/project_index_loader.rb +66 -0
  148. data/lib/rubocop/runner.rb +47 -3
  149. data/lib/rubocop/server/core.rb +6 -0
  150. data/lib/rubocop/version.rb +20 -2
  151. data/lib/rubocop.rb +1 -0
  152. metadata +5 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dfb5d2d113d00eb380202a0e76f462318033838aa240febe88bd2861b1bf6609
4
- data.tar.gz: 9463407310a9babcc5869f9b1db0ca273ed036a3b440b5c27438cba855bee4ec
3
+ metadata.gz: 672884fb2ea66b13be308094ffcec44f915943867fac5542b82ceaba3ecf32e9
4
+ data.tar.gz: f489cbc9ae6385c18d4d97140e4589503ac28a82a4288c5bac915679471ea683
5
5
  SHA512:
6
- metadata.gz: 5084465b6aa455c8ecd75e8b8f1e52f92e966d64117d2d88ad343ca535eb6fdc02f05056e6f21ac86e2344ec52cc1db2d69f8bf14a76b76bdee86a2bd5971520
7
- data.tar.gz: 2101bc8bb5b392fa971f9a881e96b03321442b5067b4952413d806363bb89389cb2631671bfa6af0e30203800cff947d587ac0c68ef1651fdec455cc453faa18
6
+ metadata.gz: 8d2cb39bc17b788f176096a12ddf766dbdcfafe8a6fcd09e830544053665b3b42f204b0b7fe01a61d2be94d64fe859f6783710f01df71f136e28d9e46ec1ebf6
7
+ data.tar.gz: 18067fc7914382cf8c13a07a34b9774647bd85ea34e85eac8a705da85af7039f31befae4e850b23989ddb91918f4cf10bccd4d578dc79a65de5422db86b51ad2
data/config/default.yml CHANGED
@@ -104,6 +104,12 @@ AllCops:
104
104
  # When `NewCops` is `disable`, pending cops are disabled in bulk. Can be overridden by
105
105
  # the `--disable-pending-cops` command-line option.
106
106
  NewCops: pending
107
+ # When `true`, RuboCop builds a project index (a project-wide map of declarations and references)
108
+ # once per run and makes it available to cops that opt in.
109
+ # The project index is implemented by the optional `rubydex` gem; when `rubydex` is not installed,
110
+ # a warning is shown and the flag has no effect.
111
+ # The default `false` preserves RuboCop's traditional file-local analysis.
112
+ UseProjectIndex: false
107
113
  # Enables the result cache if `true`. Can be overridden by the `--cache` command
108
114
  # line option.
109
115
  UseCache: true
@@ -194,12 +200,12 @@ Bundler/GemComment:
194
200
  Description: 'Add a comment describing each gem.'
195
201
  Enabled: false
196
202
  VersionAdded: '0.59'
197
- VersionChanged: '0.85'
203
+ VersionChanged: '1.88'
198
204
  Include:
199
205
  - '**/*.gemfile'
200
206
  - '**/Gemfile'
201
207
  - '**/gems.rb'
202
- IgnoredGems: []
208
+ AllowedGems: []
203
209
  OnlyFor: []
204
210
 
205
211
  Bundler/GemFilename:
@@ -366,7 +372,7 @@ Gemspec/RubyVersionGlobalsUsage:
366
372
  Include:
367
373
  - '**/*.gemspec'
368
374
 
369
- #################### Layout ###########################
375
+ #################### Layout ################################
370
376
 
371
377
  Layout/AccessModifierIndentation:
372
378
  Description: Checks indentation of private/protected visibility modifiers.
@@ -484,7 +490,7 @@ Layout/BlockEndNewline:
484
490
  VersionAdded: '0.49'
485
491
 
486
492
  Layout/CaseIndentation:
487
- Description: 'Indentation of when in a case/(when|in)/[else/]end.'
493
+ Description: 'Checks how the `when` and `in` clauses of a `case` expression are indented.'
488
494
  StyleGuide: '#indent-when-to-case'
489
495
  Enabled: true
490
496
  VersionAdded: '0.49'
@@ -535,13 +541,13 @@ Layout/ClosingParenthesisIndentation:
535
541
  IndentationWidth: ~
536
542
 
537
543
  Layout/CommentIndentation:
538
- Description: 'Indentation of comments.'
544
+ Description: 'Checks the indentation of comments.'
539
545
  Enabled: true
546
+ VersionAdded: '0.49'
547
+ VersionChanged: '1.86'
540
548
  # When true, allows comments to have extra indentation if that aligns them
541
549
  # with a comment on the preceding line.
542
550
  AllowForAlignment: false
543
- VersionAdded: '0.49'
544
- VersionChanged: '1.86'
545
551
  # By default the indentation width from `Layout/IndentationWidth` is used,
546
552
  # but it can be overridden by setting this parameter.
547
553
  IndentationWidth: ~
@@ -906,9 +912,9 @@ Layout/HashAlignment:
906
912
  Align the elements of a hash literal if they span more than
907
913
  one line.
908
914
  Enabled: true
909
- AllowMultipleStyles: true
910
915
  VersionAdded: '0.49'
911
916
  VersionChanged: '1.16'
917
+ AllowMultipleStyles: true
912
918
  # Alignment of entries using hash rocket as separator. Valid values are:
913
919
  #
914
920
  # key - left alignment of keys
@@ -983,8 +989,8 @@ Layout/HeredocArgumentClosingParenthesis:
983
989
  Description: >-
984
990
  Checks for the placement of the closing parenthesis in a
985
991
  method call that passes a HEREDOC string as an argument.
986
- Enabled: false
987
992
  StyleGuide: '#heredoc-argument-closing-parentheses'
993
+ Enabled: false
988
994
  VersionAdded: '0.68'
989
995
 
990
996
  Layout/HeredocIndentation:
@@ -1420,6 +1426,7 @@ Layout/SpaceBeforeBlockBraces:
1420
1426
  before it.
1421
1427
  Enabled: true
1422
1428
  VersionAdded: '0.49'
1429
+ VersionChanged: '0.52'
1423
1430
  EnforcedStyle: space
1424
1431
  SupportedStyles:
1425
1432
  - space
@@ -1428,7 +1435,6 @@ Layout/SpaceBeforeBlockBraces:
1428
1435
  SupportedStylesForEmptyBraces:
1429
1436
  - space
1430
1437
  - no_space
1431
- VersionChanged: '0.52'
1432
1438
 
1433
1439
  Layout/SpaceBeforeBrackets:
1434
1440
  Description: 'Checks for receiver with a space before the opening brackets.'
@@ -1703,6 +1709,7 @@ Lint/ConstantReassignment:
1703
1709
  Description: 'Checks for constant reassignments.'
1704
1710
  Enabled: pending
1705
1711
  VersionAdded: '1.70'
1712
+ VersionChanged: '1.87'
1706
1713
 
1707
1714
  Lint/ConstantResolution:
1708
1715
  Description: 'Checks that constants are fully qualified with `::`.'
@@ -1920,9 +1927,9 @@ Lint/EmptyConditionalBody:
1920
1927
  Description: 'Checks for the presence of `if`, `elsif` and `unless` branches without a body.'
1921
1928
  Enabled: true
1922
1929
  AutoCorrect: contextual
1923
- AllowComments: true
1924
1930
  VersionAdded: '0.89'
1925
1931
  VersionChanged: '1.73'
1932
+ AllowComments: true
1926
1933
 
1927
1934
  Lint/EmptyEnsure:
1928
1935
  Description: 'Checks for empty ensure block.'
@@ -1958,9 +1965,9 @@ Lint/EmptyInterpolation:
1958
1965
  Lint/EmptyWhen:
1959
1966
  Description: 'Checks for `when` branches with empty bodies.'
1960
1967
  Enabled: true
1961
- AllowComments: true
1962
1968
  VersionAdded: '0.45'
1963
1969
  VersionChanged: '0.83'
1970
+ AllowComments: true
1964
1971
 
1965
1972
  Lint/EnsureReturn:
1966
1973
  Description: 'Do not use return in an ensure block.'
@@ -1994,7 +2001,7 @@ Lint/FloatOutOfRange:
1994
2001
  VersionAdded: '0.36'
1995
2002
 
1996
2003
  Lint/FormatParameterMismatch:
1997
- Description: 'The number of parameters to format/sprint must match the fields.'
2004
+ Description: 'Checks for a mismatch between the format fields and the arguments to `format`/`sprintf`/`%`.'
1998
2005
  Enabled: true
1999
2006
  VersionAdded: '0.33'
2000
2007
 
@@ -2014,14 +2021,14 @@ Lint/HeredocMethodCallPosition:
2014
2021
  Description: >-
2015
2022
  Checks for the ordering of a method call where
2016
2023
  the receiver of the call is a HEREDOC.
2017
- Enabled: false
2018
2024
  StyleGuide: '#heredoc-method-calls'
2025
+ Enabled: false
2019
2026
  VersionAdded: '0.68'
2020
2027
 
2021
2028
  Lint/IdentityComparison:
2022
2029
  Description: 'Prefer `equal?` over `==` when comparing `object_id`.'
2023
- Enabled: true
2024
2030
  StyleGuide: '#identity-comparison'
2031
+ Enabled: true
2025
2032
  VersionAdded: '0.91'
2026
2033
 
2027
2034
  Lint/ImplicitStringConcatenation:
@@ -2107,6 +2114,7 @@ Lint/MissingCopEnableDirective:
2107
2114
  Description: 'Checks for a `# rubocop:enable` after `# rubocop:disable`.'
2108
2115
  Enabled: true
2109
2116
  VersionAdded: '0.52'
2117
+ VersionChanged: '1.88'
2110
2118
  # Maximum number of consecutive lines the cop can be disabled for.
2111
2119
  # 0 allows only single-line disables
2112
2120
  # 1 would mean the maximum allowed is the following:
@@ -2114,16 +2122,16 @@ Lint/MissingCopEnableDirective:
2114
2122
  # a = 1
2115
2123
  # # rubocop:enable SomeCop
2116
2124
  # .inf for any size
2117
- MaximumRangeSize: .inf
2125
+ MaxRangeSize: .inf
2118
2126
 
2119
2127
  Lint/MissingSuper:
2120
2128
  Description: >-
2121
2129
  Checks for the presence of constructors and lifecycle callbacks
2122
2130
  without calls to `super`.
2123
2131
  Enabled: true
2124
- AllowedParentClasses: []
2125
2132
  VersionAdded: '0.89'
2126
2133
  VersionChanged: '1.4'
2134
+ AllowedParentClasses: []
2127
2135
 
2128
2136
  Lint/MixedCaseRange:
2129
2137
  Description: 'Checks for mixed-case character ranges since they include likely unintended characters.'
@@ -2189,11 +2197,11 @@ Lint/NumberConversion:
2189
2197
  Description: 'Checks unsafe usage of number conversion methods.'
2190
2198
  Enabled: false
2191
2199
  VersionAdded: '0.53'
2192
- VersionChanged: '1.1'
2200
+ VersionChanged: '1.88'
2193
2201
  SafeAutoCorrect: false
2194
2202
  AllowedMethods: []
2195
2203
  AllowedPatterns: []
2196
- IgnoredClasses:
2204
+ AllowedClasses:
2197
2205
  - Time
2198
2206
  - DateTime
2199
2207
 
@@ -2343,13 +2351,16 @@ Lint/RedundantWithIndex:
2343
2351
  Lint/RedundantWithObject:
2344
2352
  Description: 'Checks for redundant `with_object`.'
2345
2353
  Enabled: true
2354
+ SafeAutoCorrect: false
2346
2355
  VersionAdded: '0.51'
2356
+ VersionChanged: '1.88'
2347
2357
 
2348
2358
  Lint/RefinementImportMethods:
2349
2359
  Description: 'Use `Refinement#import_methods` when using `include` or `prepend` in `refine` block.'
2350
2360
  Enabled: pending
2351
2361
  SafeAutoCorrect: false
2352
2362
  VersionAdded: '1.27'
2363
+ VersionChanged: '1.88'
2353
2364
 
2354
2365
  Lint/RegexpAsCondition:
2355
2366
  Description: >-
@@ -2481,10 +2492,10 @@ Lint/SuppressedException:
2481
2492
  Description: "Don't suppress exceptions."
2482
2493
  StyleGuide: '#dont-hide-exceptions'
2483
2494
  Enabled: true
2484
- AllowComments: true
2485
- AllowNil: true
2486
2495
  VersionAdded: '0.9'
2487
2496
  VersionChanged: '1.12'
2497
+ AllowComments: true
2498
+ AllowNil: true
2488
2499
 
2489
2500
  Lint/SuppressedExceptionInNumberConversion:
2490
2501
  Description: 'Checks for cases where exceptions unrelated to the numeric constructors may be unintentionally swallowed.'
@@ -2577,7 +2588,7 @@ Lint/UnmodifiedReduceAccumulator:
2577
2588
  VersionChanged: '1.5'
2578
2589
 
2579
2590
  Lint/UnreachableCode:
2580
- Description: 'Unreachable code.'
2591
+ Description: 'Checks for unreachable code.'
2581
2592
  Enabled: true
2582
2593
  VersionAdded: '0.9'
2583
2594
 
@@ -2722,7 +2733,7 @@ Lint/UselessTimes:
2722
2733
  VersionChanged: '1.61'
2723
2734
 
2724
2735
  Lint/Void:
2725
- Description: 'Possible use of operator/literal/variable in void context.'
2736
+ Description: 'Checks for operators, literals, lambdas, and procs used in void context.'
2726
2737
  Enabled: true
2727
2738
  AutoCorrect: contextual
2728
2739
  VersionAdded: '0.9'
@@ -2732,9 +2743,7 @@ Lint/Void:
2732
2743
  #################### Metrics ###############################
2733
2744
 
2734
2745
  Metrics/AbcSize:
2735
- Description: >-
2736
- A calculated magnitude based on number of assignments,
2737
- branches, and conditions.
2746
+ Description: 'Checks that the ABC size of methods is not higher than the configured maximum.'
2738
2747
  References:
2739
2748
  - https://wiki.c2.com/?AbcMetric
2740
2749
  - https://en.wikipedia.org/wiki/ABC_Software_Metric
@@ -2787,13 +2796,12 @@ Metrics/CollectionLiteralLength:
2787
2796
  Description: 'Checks for `Array` or `Hash` literals with many entries.'
2788
2797
  Enabled: pending
2789
2798
  VersionAdded: '1.47'
2790
- LengthThreshold: 250
2799
+ VersionChanged: '1.88'
2800
+ Max: 250
2791
2801
 
2792
2802
  # Avoid complex methods.
2793
2803
  Metrics/CyclomaticComplexity:
2794
- Description: >-
2795
- A complexity metric that is strongly correlated to the number
2796
- of test cases needed to validate a method.
2804
+ Description: 'Checks that the cyclomatic complexity of methods is not higher than the configured maximum.'
2797
2805
  Enabled: true
2798
2806
  VersionAdded: '0.25'
2799
2807
  VersionChanged: '0.81'
@@ -2833,9 +2841,7 @@ Metrics/ParameterLists:
2833
2841
  MaxOptionalParameters: 3
2834
2842
 
2835
2843
  Metrics/PerceivedComplexity:
2836
- Description: >-
2837
- A complexity metric geared towards measuring complexity for a
2838
- human reader.
2844
+ Description: 'Checks that the perceived complexity of methods is not higher than the configured maximum.'
2839
2845
  Enabled: true
2840
2846
  VersionAdded: '0.25'
2841
2847
  VersionChanged: '0.81'
@@ -2843,16 +2849,14 @@ Metrics/PerceivedComplexity:
2843
2849
  AllowedPatterns: []
2844
2850
  Max: 8
2845
2851
 
2846
- ################## Migration #############################
2852
+ #################### Migration #############################
2847
2853
 
2848
2854
  Migration/DepartmentName:
2849
- Description: >-
2850
- Check that cop names in rubocop:disable (etc) comments are
2851
- given with department name.
2855
+ Description: 'Checks that cop names in `rubocop:disable` (etc.) comments are given with a department name.'
2852
2856
  Enabled: true
2853
2857
  VersionAdded: '0.75'
2854
2858
 
2855
- #################### Naming ##############################
2859
+ #################### Naming ################################
2856
2860
 
2857
2861
  Naming/AccessorMethodName:
2858
2862
  Description: Checks the naming of accessor methods for get_/set_.
@@ -2869,7 +2873,7 @@ Naming/AsciiIdentifiers:
2869
2873
  AsciiConstants: true
2870
2874
 
2871
2875
  Naming/BinaryOperatorParameterName:
2872
- Description: 'When defining binary operators, name the argument other.'
2876
+ Description: 'Checks that the sole parameter of binary operator methods is named `other`.'
2873
2877
  StyleGuide: '#other-arg'
2874
2878
  Enabled: true
2875
2879
  VersionAdded: '0.50'
@@ -3039,7 +3043,10 @@ Naming/InclusiveLanguage:
3039
3043
  - block
3040
3044
  slave:
3041
3045
  WholeWord: true
3042
- Suggestions: ['replica', 'secondary', 'follower']
3046
+ Suggestions:
3047
+ - replica
3048
+ - secondary
3049
+ - follower
3043
3050
 
3044
3051
  Naming/MemoizedInstanceVariableName:
3045
3052
  Description: >-
@@ -3126,7 +3133,7 @@ Naming/PredicateMethod:
3126
3133
  - nonzero?
3127
3134
 
3128
3135
  Naming/PredicatePrefix:
3129
- Description: 'Predicate method names should not be prefixed and end with a `?`.'
3136
+ Description: 'Checks that predicate method names end with a question mark and do not start with a forbidden prefix.'
3130
3137
  StyleGuide: '#bool-methods-qmark'
3131
3138
  Enabled: true
3132
3139
  VersionAdded: '0.50'
@@ -3208,14 +3215,14 @@ Naming/VariableNumber:
3208
3215
  #################### Security ##############################
3209
3216
 
3210
3217
  Security/CompoundHash:
3211
- Description: 'When overwriting Object#hash to combine values, prefer delegating to Array#hash over writing a custom implementation.'
3218
+ Description: 'Checks for `hash` implementations that combine values manually instead of delegating to `Array#hash`.'
3212
3219
  Enabled: pending
3213
3220
  Safe: false
3214
3221
  VersionAdded: '1.28'
3215
3222
  VersionChanged: '1.51'
3216
3223
 
3217
3224
  Security/Eval:
3218
- Description: 'The use of eval represents a serious security risk.'
3225
+ Description: 'Checks for the use of `Kernel#eval` and `Binding#eval` with dynamic arguments.'
3219
3226
  Enabled: true
3220
3227
  VersionAdded: '0.47'
3221
3228
 
@@ -3251,7 +3258,7 @@ Security/MarshalLoad:
3251
3258
  VersionAdded: '0.47'
3252
3259
 
3253
3260
  Security/Open:
3254
- Description: 'The use of `Kernel#open` and `URI.open` represent a serious security risk.'
3261
+ Description: 'Checks for the use of `Kernel#open` and `URI.open` with dynamic data.'
3255
3262
  Enabled: true
3256
3263
  VersionAdded: '0.53'
3257
3264
  VersionChanged: '1.0'
@@ -3267,7 +3274,7 @@ Security/YAMLLoad:
3267
3274
  VersionAdded: '0.47'
3268
3275
  SafeAutoCorrect: false
3269
3276
 
3270
- #################### Style ###############################
3277
+ #################### Style #################################
3271
3278
 
3272
3279
  Style/AccessModifierDeclarations:
3273
3280
  Description: 'Checks style of how access modifiers are used.'
@@ -3329,6 +3336,8 @@ Style/ArgumentsForwarding:
3329
3336
  Description: 'Use arguments forwarding.'
3330
3337
  StyleGuide: '#arguments-forwarding'
3331
3338
  Enabled: pending
3339
+ VersionAdded: '1.1'
3340
+ VersionChanged: '1.58'
3332
3341
  AllowOnlyRestArgument: true
3333
3342
  UseAnonymousForwarding: true
3334
3343
  RedundantRestArgumentNames:
@@ -3342,8 +3351,6 @@ Style/ArgumentsForwarding:
3342
3351
  - blk
3343
3352
  - block
3344
3353
  - proc
3345
- VersionAdded: '1.1'
3346
- VersionChanged: '1.58'
3347
3354
 
3348
3355
  Style/ArrayCoercion:
3349
3356
  Description: >-
@@ -3694,7 +3701,7 @@ Style/CollectionCompact:
3694
3701
 
3695
3702
  # Align with the style guide.
3696
3703
  Style/CollectionMethods:
3697
- Description: 'Preferred collection methods.'
3704
+ Description: 'Enforces the use of consistent method names from the `Enumerable` module.'
3698
3705
  StyleGuide: '#map-find-select-reduce-include-size'
3699
3706
  Enabled: false
3700
3707
  VersionAdded: '0.9'
@@ -3796,11 +3803,11 @@ Style/CommentedKeyword:
3796
3803
 
3797
3804
  Style/ComparableBetween:
3798
3805
  Description: 'Enforces the use of `Comparable#between?` instead of logical comparison.'
3806
+ StyleGuide: '#ranges-or-between'
3799
3807
  Enabled: pending
3800
3808
  Safe: false
3801
3809
  VersionAdded: '1.74'
3802
3810
  VersionChanged: '1.75'
3803
- StyleGuide: '#ranges-or-between'
3804
3811
 
3805
3812
  Style/ComparableClamp:
3806
3813
  Description: 'Enforces the use of `Comparable#clamp` instead of comparison by minimum and maximum.'
@@ -4121,7 +4128,7 @@ Style/ExplicitBlockArgument:
4121
4128
  VersionChanged: '1.8'
4122
4129
 
4123
4130
  Style/ExponentialNotation:
4124
- Description: 'When using exponential notation, favor a mantissa between 1 (inclusive) and 10 (exclusive).'
4131
+ Description: 'Enforces consistency in the use of exponential (scientific) notation.'
4125
4132
  StyleGuide: '#exponential-notation'
4126
4133
  Enabled: true
4127
4134
  VersionAdded: '0.82'
@@ -4138,8 +4145,9 @@ Style/FetchEnvVar:
4138
4145
  - https://rubystyle.guide/#hash-fetch-defaults
4139
4146
  Enabled: pending
4140
4147
  VersionAdded: '1.28'
4148
+ VersionChanged: '1.88'
4141
4149
  # Environment variables to be excluded from the inspection.
4142
- AllowedVars: []
4150
+ AllowedVariables: []
4143
4151
  # When `true`, autocorrects `ENV["key"]` to `ENV.fetch("key", nil)`.
4144
4152
  # When `false`, autocorrects `ENV["key"]` to `ENV.fetch("key")`.
4145
4153
  DefaultToNil: true
@@ -4224,6 +4232,8 @@ Style/FormatString:
4224
4232
  Style/FormatStringToken:
4225
4233
  Description: 'Use a consistent style for format string tokens.'
4226
4234
  Enabled: true
4235
+ VersionAdded: '0.49'
4236
+ VersionChanged: '1.74'
4227
4237
  EnforcedStyle: annotated
4228
4238
  SupportedStyles:
4229
4239
  # Prefer tokens which contain a sprintf like type annotation like
@@ -4242,8 +4252,6 @@ Style/FormatStringToken:
4242
4252
  # only register offenses for strings given to `printf`, `sprintf`,
4243
4253
  # format` and `%` methods. Other strings are not considered.
4244
4254
  Mode: aggressive
4245
- VersionAdded: '0.49'
4246
- VersionChanged: '1.74'
4247
4255
  AllowedMethods: []
4248
4256
  AllowedPatterns: []
4249
4257
 
@@ -4437,9 +4445,9 @@ Style/IdenticalConditionalBranches:
4437
4445
  Style/IfInsideElse:
4438
4446
  Description: 'Finds if nodes inside else, which can be converted to elsif.'
4439
4447
  Enabled: true
4440
- AllowIfModifier: false
4441
4448
  VersionAdded: '0.36'
4442
4449
  VersionChanged: '1.3'
4450
+ AllowIfModifier: false
4443
4451
 
4444
4452
  Style/IfUnlessModifier:
4445
4453
  Description: >-
@@ -4570,14 +4578,14 @@ Style/ItAssignment:
4570
4578
  Style/ItBlockParameter:
4571
4579
  Description: 'Checks for blocks with one argument where `it` block parameter can be used.'
4572
4580
  Enabled: pending
4581
+ VersionAdded: '1.75'
4582
+ VersionChanged: '1.76'
4573
4583
  EnforcedStyle: allow_single_line
4574
4584
  SupportedStyles:
4575
4585
  - allow_single_line
4576
4586
  - only_numbered_parameters
4577
4587
  - always
4578
4588
  - disallow
4579
- VersionAdded: '1.75'
4580
- VersionChanged: '1.76'
4581
4589
 
4582
4590
  Style/KeywordArgumentsMerging:
4583
4591
  Description: >-
@@ -4702,10 +4710,10 @@ Style/MethodCallWithoutArgsParentheses:
4702
4710
  Description: 'Do not use parentheses for method calls with no arguments.'
4703
4711
  StyleGuide: '#method-invocation-parens'
4704
4712
  Enabled: true
4705
- AllowedMethods: []
4706
- AllowedPatterns: []
4707
4713
  VersionAdded: '0.47'
4708
4714
  VersionChanged: '0.55'
4715
+ AllowedMethods: []
4716
+ AllowedPatterns: []
4709
4717
 
4710
4718
  Style/MethodCalledOnDoEndBlock:
4711
4719
  Description: 'Avoid chaining a method call on a do...end block.'
@@ -4811,7 +4819,7 @@ Style/MultilineBlockChain:
4811
4819
  VersionAdded: '0.13'
4812
4820
 
4813
4821
  Style/MultilineIfModifier:
4814
- Description: 'Only use if/unless modifiers on single line statements.'
4822
+ Description: 'Checks for uses of `if`/`unless` modifiers with multiline bodies.'
4815
4823
  StyleGuide: '#no-multiline-if-modifiers'
4816
4824
  Enabled: true
4817
4825
  VersionAdded: '0.45'
@@ -4874,7 +4882,7 @@ Style/MutableConstant:
4874
4882
  Description: 'Do not assign mutable objects to constants.'
4875
4883
  Enabled: true
4876
4884
  VersionAdded: '0.34'
4877
- VersionChanged: '1.8'
4885
+ VersionChanged: '1.88'
4878
4886
  SafeAutoCorrect: false
4879
4887
  EnforcedStyle: literals
4880
4888
  SupportedStyles:
@@ -4886,6 +4894,9 @@ Style/MutableConstant:
4886
4894
  # no harm in freezing an already frozen object.
4887
4895
  - literals
4888
4896
  - strict
4897
+ # When `true`, recursively check and freeze mutable literals nested inside
4898
+ # arrays and hashes (e.g. `[{a: []}]` becomes `[{a: [].freeze}.freeze].freeze`).
4899
+ Recursive: false
4889
4900
 
4890
4901
  Style/NegatedIf:
4891
4902
  Description: >-
@@ -5130,9 +5141,9 @@ Style/OneLineConditional:
5130
5141
  single-line if/then/else/end constructs.
5131
5142
  StyleGuide: '#ternary-operator'
5132
5143
  Enabled: true
5133
- AlwaysCorrectToMultiline: false
5134
5144
  VersionAdded: '0.9'
5135
5145
  VersionChanged: '0.90'
5146
+ AlwaysCorrectToMultiline: false
5136
5147
 
5137
5148
  Style/OpenStructUse:
5138
5149
  Description: >-
@@ -5225,6 +5236,7 @@ Style/PercentLiteralDelimiters:
5225
5236
  StyleGuide: '#percent-literal-braces'
5226
5237
  Enabled: true
5227
5238
  VersionAdded: '0.19'
5239
+ VersionChanged: '0.48'
5228
5240
  # Specify the default preferred delimiter for all types with the 'default' key
5229
5241
  # Override individual delimiters (even with default specified) by specifying
5230
5242
  # an individual key
@@ -5235,7 +5247,6 @@ Style/PercentLiteralDelimiters:
5235
5247
  '%r': '{}'
5236
5248
  '%w': '[]'
5237
5249
  '%W': '[]'
5238
- VersionChanged: '0.48'
5239
5250
 
5240
5251
  Style/PercentQLiterals:
5241
5252
  Description: 'Checks if uses of %Q/%q match the configured preference.'
@@ -5462,9 +5473,9 @@ Style/RedundantInitialize:
5462
5473
  Enabled: pending
5463
5474
  AutoCorrect: contextual
5464
5475
  Safe: false
5465
- AllowComments: true
5466
5476
  VersionAdded: '1.27'
5467
5477
  VersionChanged: '1.61'
5478
+ AllowComments: true
5468
5479
 
5469
5480
  Style/RedundantInterpolation:
5470
5481
  Description: 'Checks for strings that are just an interpolated expression.'
@@ -5628,10 +5639,10 @@ Style/ReturnNilInPredicateMethodDefinition:
5628
5639
  StyleGuide: '#bool-methods-qmark'
5629
5640
  Enabled: pending
5630
5641
  SafeAutoCorrect: false
5631
- AllowedMethods: []
5632
- AllowedPatterns: []
5633
5642
  VersionAdded: '1.53'
5634
5643
  VersionChanged: '1.67'
5644
+ AllowedMethods: []
5645
+ AllowedPatterns: []
5635
5646
 
5636
5647
  Style/ReverseFind:
5637
5648
  Description: 'Use `array.rfind` instead of `array.reverse.find`.'
@@ -5980,12 +5991,12 @@ Style/TrailingBodyOnClass:
5980
5991
  VersionAdded: '0.53'
5981
5992
 
5982
5993
  Style/TrailingBodyOnMethodDefinition:
5983
- Description: 'Method body goes below definition.'
5994
+ Description: 'Checks for trailing code after the method definition.'
5984
5995
  Enabled: true
5985
5996
  VersionAdded: '0.52'
5986
5997
 
5987
5998
  Style/TrailingBodyOnModule:
5988
- Description: 'Module body goes below module statement.'
5999
+ Description: 'Checks for trailing code after the module definition.'
5989
6000
  Enabled: true
5990
6001
  VersionAdded: '0.53'
5991
6002
 
@@ -6058,10 +6069,10 @@ Style/TrailingUnderscoreVariable:
6058
6069
  Description: >-
6059
6070
  Checks for the usage of unneeded trailing underscores at the
6060
6071
  end of parallel variable assignment.
6061
- AllowNamedUnderscoreVariables: true
6062
6072
  Enabled: true
6063
6073
  VersionAdded: '0.31'
6064
6074
  VersionChanged: '0.35'
6075
+ AllowNamedUnderscoreVariables: true
6065
6076
 
6066
6077
  # `TrivialAccessors` requires exact name matches and doesn't allow
6067
6078
  # predicated methods by default.
@@ -6194,6 +6205,9 @@ Style/YodaCondition:
6194
6205
  References:
6195
6206
  - 'https://en.wikipedia.org/wiki/Yoda_conditions'
6196
6207
  Enabled: true
6208
+ Safe: false
6209
+ VersionAdded: '0.49'
6210
+ VersionChanged: '0.75'
6197
6211
  EnforcedStyle: forbid_for_all_comparison_operators
6198
6212
  SupportedStyles:
6199
6213
  # check all comparison operators
@@ -6204,9 +6218,6 @@ Style/YodaCondition:
6204
6218
  - require_for_all_comparison_operators
6205
6219
  # enforce yoda only for equality operators: `!=` and `==`
6206
6220
  - require_for_equality_operators_only
6207
- Safe: false
6208
- VersionAdded: '0.49'
6209
- VersionChanged: '0.75'
6210
6221
 
6211
6222
  Style/YodaExpression:
6212
6223
  Description: 'Forbid the use of yoda expressions.'
@@ -171,7 +171,7 @@ changed_parameters:
171
171
  reason: "`SafeMode` has been removed. Use `SafeAutoCorrect` instead."
172
172
  - cops: Bundler/GemComment
173
173
  parameters: Whitelist
174
- alternative: IgnoredGems
174
+ alternative: AllowedGems
175
175
  - cops:
176
176
  - Lint/SafeNavigationChain
177
177
  - Lint/SafeNavigationConsistency
@@ -238,6 +238,26 @@ changed_parameters:
238
238
  reason: "`AllowOnlyRestArgument` has no effect with TargetRubyVersion >= 3.2."
239
239
  severity: warning
240
240
  minimum_ruby_version: 3.2
241
+ - cops: Bundler/GemComment
242
+ parameters: IgnoredGems
243
+ alternative: AllowedGems
244
+ severity: warning
245
+ - cops: Lint/NumberConversion
246
+ parameters: IgnoredClasses
247
+ alternative: AllowedClasses
248
+ severity: warning
249
+ - cops: Lint/MissingCopEnableDirective
250
+ parameters: MaximumRangeSize
251
+ alternative: MaxRangeSize
252
+ severity: warning
253
+ - cops: Metrics/CollectionLiteralLength
254
+ parameters: LengthThreshold
255
+ alternative: Max
256
+ severity: warning
257
+ - cops: Style/FetchEnvVar
258
+ parameters: AllowedVars
259
+ alternative: AllowedVariables
260
+ severity: warning
241
261
 
242
262
  # Enforced styles that have been removed or replaced
243
263
  changed_enforced_styles:
@@ -31,6 +31,12 @@ module RuboCop
31
31
  result = run_all_cops(line_length_contents)
32
32
  reset_auto_gen_tmp_dir
33
33
  result
34
+ ensure
35
+ # `auto_gen_tmp_dir` points `ExcludeLimit.tmp_dir` at this command's
36
+ # tmp directory. Clear that process-global state on the way out so
37
+ # later in-process callers (e.g. other specs in the same test worker)
38
+ # don't read this run's leftover directory.
39
+ RuboCop::ExcludeLimit.tmp_dir = nil
34
40
  end
35
41
 
36
42
  private
data/lib/rubocop/cli.rb CHANGED
@@ -189,6 +189,8 @@ module RuboCop
189
189
  ConfigLoader.enable_pending_cops = @options[:enable_pending_cops]
190
190
  ConfigLoader.ignore_parent_exclusion = @options[:ignore_parent_exclusion]
191
191
  ConfigLoader.ignore_unrecognized_cops = @options[:ignore_unrecognized_cops]
192
+ ConfigLoader.enabled_by_default = @options[:enable_all_cops]
193
+ ConfigLoader.disabled_by_default = @options[:disable_all_cops]
192
194
  end
193
195
 
194
196
  def set_options_to_pending_cops_reporter