rubocop 1.87.0 → 1.88.1

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 (162) hide show
  1. checksums.yaml +4 -4
  2. data/config/default.yml +78 -72
  3. data/config/obsoletion.yml +21 -1
  4. data/lib/rubocop/cli/command/auto_generate_config.rb +6 -0
  5. data/lib/rubocop/cop/base.rb +17 -2
  6. data/lib/rubocop/cop/bundler/gem_comment.rb +5 -3
  7. data/lib/rubocop/cop/correctors/each_to_for_corrector.rb +1 -1
  8. data/lib/rubocop/cop/correctors/lambda_literal_to_method_corrector.rb +7 -1
  9. data/lib/rubocop/cop/correctors/ordered_gem_corrector.rb +8 -1
  10. data/lib/rubocop/cop/gemspec/development_dependencies.rb +1 -1
  11. data/lib/rubocop/cop/gemspec/require_mfa.rb +4 -1
  12. data/lib/rubocop/cop/internal_affairs/redundant_let_rubocop_config_new.rb +5 -3
  13. data/lib/rubocop/cop/layout/block_alignment.rb +58 -4
  14. data/lib/rubocop/cop/layout/class_structure.rb +7 -3
  15. data/lib/rubocop/cop/layout/condition_position.rb +13 -3
  16. data/lib/rubocop/cop/layout/empty_comment.rb +8 -10
  17. data/lib/rubocop/cop/layout/empty_line_between_defs.rb +14 -1
  18. data/lib/rubocop/cop/layout/first_hash_element_indentation.rb +13 -14
  19. data/lib/rubocop/cop/layout/indentation_width.rb +28 -0
  20. data/lib/rubocop/cop/layout/space_around_operators.rb +6 -2
  21. data/lib/rubocop/cop/lint/ambiguous_assignment.rb +1 -11
  22. data/lib/rubocop/cop/lint/ambiguous_operator_precedence.rb +1 -10
  23. data/lib/rubocop/cop/lint/assignment_in_condition.rb +13 -1
  24. data/lib/rubocop/cop/lint/circular_argument_reference.rb +1 -3
  25. data/lib/rubocop/cop/lint/debugger.rb +0 -1
  26. data/lib/rubocop/cop/lint/deprecated_constants.rb +1 -7
  27. data/lib/rubocop/cop/lint/empty_block.rb +3 -3
  28. data/lib/rubocop/cop/lint/ensure_return.rb +19 -1
  29. data/lib/rubocop/cop/lint/erb_new_arguments.rb +3 -1
  30. data/lib/rubocop/cop/lint/float_comparison.rb +1 -0
  31. data/lib/rubocop/cop/lint/incompatible_io_select_with_fiber_scheduler.rb +5 -1
  32. data/lib/rubocop/cop/lint/interpolation_check.rb +18 -3
  33. data/lib/rubocop/cop/lint/lambda_without_literal_block.rb +1 -1
  34. data/lib/rubocop/cop/lint/literal_assignment_in_condition.rb +11 -1
  35. data/lib/rubocop/cop/lint/literal_in_interpolation.rb +8 -11
  36. data/lib/rubocop/cop/lint/missing_cop_enable_directive.rb +4 -4
  37. data/lib/rubocop/cop/lint/no_return_in_begin_end_blocks.rb +16 -0
  38. data/lib/rubocop/cop/lint/non_local_exit_from_iterator.rb +1 -1
  39. data/lib/rubocop/cop/lint/number_conversion.rb +13 -4
  40. data/lib/rubocop/cop/lint/numeric_operation_with_constant_result.rb +3 -0
  41. data/lib/rubocop/cop/lint/ordered_magic_comments.rb +7 -7
  42. data/lib/rubocop/cop/lint/raise_exception.rb +1 -1
  43. data/lib/rubocop/cop/lint/rand_one.rb +1 -1
  44. data/lib/rubocop/cop/lint/redundant_cop_disable_directive.rb +4 -1
  45. data/lib/rubocop/cop/lint/redundant_cop_enable_directive.rb +4 -1
  46. data/lib/rubocop/cop/lint/redundant_dir_glob_sort.rb +15 -4
  47. data/lib/rubocop/cop/lint/redundant_safe_navigation.rb +14 -7
  48. data/lib/rubocop/cop/lint/redundant_splat_expansion.rb +4 -0
  49. data/lib/rubocop/cop/lint/redundant_type_conversion.rb +7 -0
  50. data/lib/rubocop/cop/lint/redundant_with_index.rb +1 -1
  51. data/lib/rubocop/cop/lint/redundant_with_object.rb +5 -0
  52. data/lib/rubocop/cop/lint/refinement_import_methods.rb +8 -1
  53. data/lib/rubocop/cop/lint/regexp_as_condition.rb +9 -1
  54. data/lib/rubocop/cop/lint/require_parentheses.rb +13 -4
  55. data/lib/rubocop/cop/lint/require_range_parentheses.rb +2 -1
  56. data/lib/rubocop/cop/lint/require_relative_self_path.rb +5 -5
  57. data/lib/rubocop/cop/lint/rescue_type.rb +1 -1
  58. data/lib/rubocop/cop/lint/safe_navigation_chain.rb +1 -0
  59. data/lib/rubocop/cop/lint/safe_navigation_with_empty.rb +1 -1
  60. data/lib/rubocop/cop/lint/script_permission.rb +5 -1
  61. data/lib/rubocop/cop/lint/self_assignment.rb +24 -1
  62. data/lib/rubocop/cop/lint/send_with_mixin_argument.rb +1 -1
  63. data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +14 -0
  64. data/lib/rubocop/cop/lint/shared_mutable_default.rb +3 -1
  65. data/lib/rubocop/cop/lint/suppressed_exception_in_number_conversion.rb +12 -0
  66. data/lib/rubocop/cop/lint/symbol_conversion.rb +21 -4
  67. data/lib/rubocop/cop/lint/to_enum_arguments.rb +35 -2
  68. data/lib/rubocop/cop/lint/top_level_return_with_argument.rb +1 -1
  69. data/lib/rubocop/cop/lint/trailing_comma_in_attribute_declaration.rb +4 -1
  70. data/lib/rubocop/cop/lint/unescaped_bracket_in_regexp.rb +35 -9
  71. data/lib/rubocop/cop/lint/useless_assignment.rb +10 -5
  72. data/lib/rubocop/cop/lint/useless_ruby2_keywords.rb +7 -3
  73. data/lib/rubocop/cop/lint/useless_setter_call.rb +4 -1
  74. data/lib/rubocop/cop/lint/useless_times.rb +22 -1
  75. data/lib/rubocop/cop/metrics/collection_literal_length.rb +1 -1
  76. data/lib/rubocop/cop/metrics/method_length.rb +1 -1
  77. data/lib/rubocop/cop/metrics/perceived_complexity.rb +38 -7
  78. data/lib/rubocop/cop/mixin/hash_subset.rb +8 -0
  79. data/lib/rubocop/cop/mixin/hash_transform_method.rb +4 -0
  80. data/lib/rubocop/cop/naming/file_name.rb +4 -3
  81. data/lib/rubocop/cop/naming/inclusive_language.rb +8 -2
  82. data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +9 -0
  83. data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +9 -3
  84. data/lib/rubocop/cop/security/io_methods.rb +1 -1
  85. data/lib/rubocop/cop/security/marshal_load.rb +1 -1
  86. data/lib/rubocop/cop/style/accessor_grouping.rb +11 -1
  87. data/lib/rubocop/cop/style/alias.rb +1 -1
  88. data/lib/rubocop/cop/style/and_or.rb +1 -1
  89. data/lib/rubocop/cop/style/array_first_last.rb +12 -1
  90. data/lib/rubocop/cop/style/array_intersect.rb +4 -0
  91. data/lib/rubocop/cop/style/array_intersect_with_single_element.rb +3 -0
  92. data/lib/rubocop/cop/style/block_delimiters.rb +16 -2
  93. data/lib/rubocop/cop/style/case_equality.rb +14 -2
  94. data/lib/rubocop/cop/style/class_equality_comparison.rb +21 -13
  95. data/lib/rubocop/cop/style/class_methods_definitions.rb +11 -5
  96. data/lib/rubocop/cop/style/colon_method_call.rb +13 -6
  97. data/lib/rubocop/cop/style/combinable_loops.rb +5 -0
  98. data/lib/rubocop/cop/style/comparable_clamp.rb +12 -1
  99. data/lib/rubocop/cop/style/concat_array_literals.rb +5 -1
  100. data/lib/rubocop/cop/style/conditional_assignment.rb +6 -1
  101. data/lib/rubocop/cop/style/constant_visibility.rb +4 -1
  102. data/lib/rubocop/cop/style/data_inheritance.rb +4 -0
  103. data/lib/rubocop/cop/style/date_time.rb +2 -2
  104. data/lib/rubocop/cop/style/dig_chain.rb +5 -0
  105. data/lib/rubocop/cop/style/dir_empty.rb +4 -0
  106. data/lib/rubocop/cop/style/empty_case_condition.rb +12 -2
  107. data/lib/rubocop/cop/style/empty_class_definition.rb +8 -1
  108. data/lib/rubocop/cop/style/empty_heredoc.rb +4 -0
  109. data/lib/rubocop/cop/style/empty_literal.rb +7 -2
  110. data/lib/rubocop/cop/style/empty_string_inside_interpolation.rb +30 -20
  111. data/lib/rubocop/cop/style/env_home.rb +4 -0
  112. data/lib/rubocop/cop/style/even_odd.rb +11 -1
  113. data/lib/rubocop/cop/style/exact_regexp_match.rb +8 -1
  114. data/lib/rubocop/cop/style/fetch_env_var.rb +1 -1
  115. data/lib/rubocop/cop/style/file_null.rb +4 -2
  116. data/lib/rubocop/cop/style/file_write.rb +17 -14
  117. data/lib/rubocop/cop/style/format_string.rb +13 -1
  118. data/lib/rubocop/cop/style/hash_slice.rb +16 -0
  119. data/lib/rubocop/cop/style/hash_syntax.rb +2 -0
  120. data/lib/rubocop/cop/style/if_unless_modifier.rb +1 -1
  121. data/lib/rubocop/cop/style/if_with_semicolon.rb +9 -1
  122. data/lib/rubocop/cop/style/inline_comment.rb +1 -1
  123. data/lib/rubocop/cop/style/keyword_arguments_merging.rb +4 -0
  124. data/lib/rubocop/cop/style/keyword_parameters_order.rb +7 -3
  125. data/lib/rubocop/cop/style/lambda.rb +7 -1
  126. data/lib/rubocop/cop/style/map_compact_with_conditional_block.rb +11 -0
  127. data/lib/rubocop/cop/style/map_into_array.rb +1 -1
  128. data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +6 -2
  129. data/lib/rubocop/cop/style/method_def_parentheses.rb +1 -1
  130. data/lib/rubocop/cop/style/min_max_comparison.rb +3 -0
  131. data/lib/rubocop/cop/style/multiline_if_then.rb +1 -1
  132. data/lib/rubocop/cop/style/multiline_memoization.rb +7 -1
  133. data/lib/rubocop/cop/style/multiline_method_signature.rb +11 -4
  134. data/lib/rubocop/cop/style/mutable_constant.rb +105 -11
  135. data/lib/rubocop/cop/style/nil_lambda.rb +8 -0
  136. data/lib/rubocop/cop/style/numeric_predicate.rb +1 -1
  137. data/lib/rubocop/cop/style/open_struct_use.rb +1 -1
  138. data/lib/rubocop/cop/style/option_hash.rb +1 -1
  139. data/lib/rubocop/cop/style/optional_arguments.rb +1 -0
  140. data/lib/rubocop/cop/style/parallel_assignment.rb +19 -3
  141. data/lib/rubocop/cop/style/percent_literal_delimiters.rb +2 -0
  142. data/lib/rubocop/cop/style/perl_backrefs.rb +5 -3
  143. data/lib/rubocop/cop/style/redundant_exception.rb +6 -0
  144. data/lib/rubocop/cop/style/redundant_filter_chain.rb +1 -1
  145. data/lib/rubocop/cop/style/redundant_format.rb +29 -0
  146. data/lib/rubocop/cop/style/redundant_line_continuation.rb +11 -3
  147. data/lib/rubocop/cop/style/redundant_regexp_escape.rb +8 -4
  148. data/lib/rubocop/cop/style/redundant_self.rb +9 -0
  149. data/lib/rubocop/cop/style/redundant_struct_keyword_init.rb +23 -4
  150. data/lib/rubocop/cop/style/semicolon.rb +20 -5
  151. data/lib/rubocop/cop/style/single_line_do_end_block.rb +17 -4
  152. data/lib/rubocop/cop/style/string_hash_keys.rb +1 -0
  153. data/lib/rubocop/cop/style/ternary_parentheses.rb +11 -0
  154. data/lib/rubocop/cop/style/trailing_underscore_variable.rb +7 -8
  155. data/lib/rubocop/cop/style/while_until_do.rb +7 -0
  156. data/lib/rubocop/cop/style/word_array.rb +1 -0
  157. data/lib/rubocop/cop/style/zero_length_predicate.rb +6 -3
  158. data/lib/rubocop/formatter/disabled_config_formatter.rb +14 -7
  159. data/lib/rubocop/runner.rb +5 -3
  160. data/lib/rubocop/server/core.rb +6 -0
  161. data/lib/rubocop/version.rb +1 -1
  162. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9386e7f8b3fc90e4096eb5436a4d35612586e27dd1ff46ba40e1051a7909fd52
4
- data.tar.gz: 615ec2ec69759dce081efc1fddb8469a7ddf6a72223fea741368b501f333bce0
3
+ metadata.gz: 04f5790c0be94705978732f52d462bd3afe919498e1e6be410fcfece0faaf4cd
4
+ data.tar.gz: 87c79acdf7db812d889bc2464a61d9921db70daf4e6c11117be879d7d9b64991
5
5
  SHA512:
6
- metadata.gz: c07cb70ee9d4c997a85c079361624d43574b78e6c364e8d0ff939b4d826c19b0e1ef2aad9569aea4f2f247b9b792ae9b21a776f69161da1c9a193e2f3de74d40
7
- data.tar.gz: f6b44267bdfeba1237e06af52009143f13a7c0419a5ccaddf47dc9701c328f2b2ef6d87811ae5c8f05ece533ca236425e599c77a5a283ba44c641de09fc1b7e6
6
+ metadata.gz: c8491483d605d97e0c746f171fdebf6b5b009a0e1e01392764a9fbf12208dad6a7fe8e8529f32d3a2b1ae37e39f150b689638cd7dbc901040f27b6cdf1981ab5
7
+ data.tar.gz: 7aa878cbe87d967607a65f37a1b3eafd47507d7a9c54c3bede0398f689527254fa4d65460d3af11d233244eb53eb7058bd5b69326588d7b3d3ed0fbb864afef8
data/config/default.yml CHANGED
@@ -200,12 +200,12 @@ Bundler/GemComment:
200
200
  Description: 'Add a comment describing each gem.'
201
201
  Enabled: false
202
202
  VersionAdded: '0.59'
203
- VersionChanged: '0.85'
203
+ VersionChanged: '1.88'
204
204
  Include:
205
205
  - '**/*.gemfile'
206
206
  - '**/Gemfile'
207
207
  - '**/gems.rb'
208
- IgnoredGems: []
208
+ AllowedGems: []
209
209
  OnlyFor: []
210
210
 
211
211
  Bundler/GemFilename:
@@ -372,7 +372,7 @@ Gemspec/RubyVersionGlobalsUsage:
372
372
  Include:
373
373
  - '**/*.gemspec'
374
374
 
375
- #################### Layout ###########################
375
+ #################### Layout ################################
376
376
 
377
377
  Layout/AccessModifierIndentation:
378
378
  Description: Checks indentation of private/protected visibility modifiers.
@@ -490,7 +490,7 @@ Layout/BlockEndNewline:
490
490
  VersionAdded: '0.49'
491
491
 
492
492
  Layout/CaseIndentation:
493
- 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.'
494
494
  StyleGuide: '#indent-when-to-case'
495
495
  Enabled: true
496
496
  VersionAdded: '0.49'
@@ -541,13 +541,13 @@ Layout/ClosingParenthesisIndentation:
541
541
  IndentationWidth: ~
542
542
 
543
543
  Layout/CommentIndentation:
544
- Description: 'Indentation of comments.'
544
+ Description: 'Checks the indentation of comments.'
545
545
  Enabled: true
546
+ VersionAdded: '0.49'
547
+ VersionChanged: '1.86'
546
548
  # When true, allows comments to have extra indentation if that aligns them
547
549
  # with a comment on the preceding line.
548
550
  AllowForAlignment: false
549
- VersionAdded: '0.49'
550
- VersionChanged: '1.86'
551
551
  # By default the indentation width from `Layout/IndentationWidth` is used,
552
552
  # but it can be overridden by setting this parameter.
553
553
  IndentationWidth: ~
@@ -912,9 +912,9 @@ Layout/HashAlignment:
912
912
  Align the elements of a hash literal if they span more than
913
913
  one line.
914
914
  Enabled: true
915
- AllowMultipleStyles: true
916
915
  VersionAdded: '0.49'
917
916
  VersionChanged: '1.16'
917
+ AllowMultipleStyles: true
918
918
  # Alignment of entries using hash rocket as separator. Valid values are:
919
919
  #
920
920
  # key - left alignment of keys
@@ -989,8 +989,8 @@ Layout/HeredocArgumentClosingParenthesis:
989
989
  Description: >-
990
990
  Checks for the placement of the closing parenthesis in a
991
991
  method call that passes a HEREDOC string as an argument.
992
- Enabled: false
993
992
  StyleGuide: '#heredoc-argument-closing-parentheses'
993
+ Enabled: false
994
994
  VersionAdded: '0.68'
995
995
 
996
996
  Layout/HeredocIndentation:
@@ -1426,6 +1426,7 @@ Layout/SpaceBeforeBlockBraces:
1426
1426
  before it.
1427
1427
  Enabled: true
1428
1428
  VersionAdded: '0.49'
1429
+ VersionChanged: '0.52'
1429
1430
  EnforcedStyle: space
1430
1431
  SupportedStyles:
1431
1432
  - space
@@ -1434,7 +1435,6 @@ Layout/SpaceBeforeBlockBraces:
1434
1435
  SupportedStylesForEmptyBraces:
1435
1436
  - space
1436
1437
  - no_space
1437
- VersionChanged: '0.52'
1438
1438
 
1439
1439
  Layout/SpaceBeforeBrackets:
1440
1440
  Description: 'Checks for receiver with a space before the opening brackets.'
@@ -1927,9 +1927,9 @@ Lint/EmptyConditionalBody:
1927
1927
  Description: 'Checks for the presence of `if`, `elsif` and `unless` branches without a body.'
1928
1928
  Enabled: true
1929
1929
  AutoCorrect: contextual
1930
- AllowComments: true
1931
1930
  VersionAdded: '0.89'
1932
1931
  VersionChanged: '1.73'
1932
+ AllowComments: true
1933
1933
 
1934
1934
  Lint/EmptyEnsure:
1935
1935
  Description: 'Checks for empty ensure block.'
@@ -1965,9 +1965,9 @@ Lint/EmptyInterpolation:
1965
1965
  Lint/EmptyWhen:
1966
1966
  Description: 'Checks for `when` branches with empty bodies.'
1967
1967
  Enabled: true
1968
- AllowComments: true
1969
1968
  VersionAdded: '0.45'
1970
1969
  VersionChanged: '0.83'
1970
+ AllowComments: true
1971
1971
 
1972
1972
  Lint/EnsureReturn:
1973
1973
  Description: 'Do not use return in an ensure block.'
@@ -2001,7 +2001,7 @@ Lint/FloatOutOfRange:
2001
2001
  VersionAdded: '0.36'
2002
2002
 
2003
2003
  Lint/FormatParameterMismatch:
2004
- 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`/`%`.'
2005
2005
  Enabled: true
2006
2006
  VersionAdded: '0.33'
2007
2007
 
@@ -2021,14 +2021,14 @@ Lint/HeredocMethodCallPosition:
2021
2021
  Description: >-
2022
2022
  Checks for the ordering of a method call where
2023
2023
  the receiver of the call is a HEREDOC.
2024
- Enabled: false
2025
2024
  StyleGuide: '#heredoc-method-calls'
2025
+ Enabled: false
2026
2026
  VersionAdded: '0.68'
2027
2027
 
2028
2028
  Lint/IdentityComparison:
2029
2029
  Description: 'Prefer `equal?` over `==` when comparing `object_id`.'
2030
- Enabled: true
2031
2030
  StyleGuide: '#identity-comparison'
2031
+ Enabled: true
2032
2032
  VersionAdded: '0.91'
2033
2033
 
2034
2034
  Lint/ImplicitStringConcatenation:
@@ -2114,6 +2114,7 @@ Lint/MissingCopEnableDirective:
2114
2114
  Description: 'Checks for a `# rubocop:enable` after `# rubocop:disable`.'
2115
2115
  Enabled: true
2116
2116
  VersionAdded: '0.52'
2117
+ VersionChanged: '1.88'
2117
2118
  # Maximum number of consecutive lines the cop can be disabled for.
2118
2119
  # 0 allows only single-line disables
2119
2120
  # 1 would mean the maximum allowed is the following:
@@ -2121,16 +2122,16 @@ Lint/MissingCopEnableDirective:
2121
2122
  # a = 1
2122
2123
  # # rubocop:enable SomeCop
2123
2124
  # .inf for any size
2124
- MaximumRangeSize: .inf
2125
+ MaxRangeSize: .inf
2125
2126
 
2126
2127
  Lint/MissingSuper:
2127
2128
  Description: >-
2128
2129
  Checks for the presence of constructors and lifecycle callbacks
2129
2130
  without calls to `super`.
2130
2131
  Enabled: true
2131
- AllowedParentClasses: []
2132
2132
  VersionAdded: '0.89'
2133
2133
  VersionChanged: '1.4'
2134
+ AllowedParentClasses: []
2134
2135
 
2135
2136
  Lint/MixedCaseRange:
2136
2137
  Description: 'Checks for mixed-case character ranges since they include likely unintended characters.'
@@ -2196,11 +2197,11 @@ Lint/NumberConversion:
2196
2197
  Description: 'Checks unsafe usage of number conversion methods.'
2197
2198
  Enabled: false
2198
2199
  VersionAdded: '0.53'
2199
- VersionChanged: '1.1'
2200
+ VersionChanged: '1.88'
2200
2201
  SafeAutoCorrect: false
2201
2202
  AllowedMethods: []
2202
2203
  AllowedPatterns: []
2203
- IgnoredClasses:
2204
+ AllowedClasses:
2204
2205
  - Time
2205
2206
  - DateTime
2206
2207
 
@@ -2350,13 +2351,16 @@ Lint/RedundantWithIndex:
2350
2351
  Lint/RedundantWithObject:
2351
2352
  Description: 'Checks for redundant `with_object`.'
2352
2353
  Enabled: true
2354
+ SafeAutoCorrect: false
2353
2355
  VersionAdded: '0.51'
2356
+ VersionChanged: '1.88'
2354
2357
 
2355
2358
  Lint/RefinementImportMethods:
2356
2359
  Description: 'Use `Refinement#import_methods` when using `include` or `prepend` in `refine` block.'
2357
2360
  Enabled: pending
2358
2361
  SafeAutoCorrect: false
2359
2362
  VersionAdded: '1.27'
2363
+ VersionChanged: '1.88'
2360
2364
 
2361
2365
  Lint/RegexpAsCondition:
2362
2366
  Description: >-
@@ -2488,10 +2492,10 @@ Lint/SuppressedException:
2488
2492
  Description: "Don't suppress exceptions."
2489
2493
  StyleGuide: '#dont-hide-exceptions'
2490
2494
  Enabled: true
2491
- AllowComments: true
2492
- AllowNil: true
2493
2495
  VersionAdded: '0.9'
2494
2496
  VersionChanged: '1.12'
2497
+ AllowComments: true
2498
+ AllowNil: true
2495
2499
 
2496
2500
  Lint/SuppressedExceptionInNumberConversion:
2497
2501
  Description: 'Checks for cases where exceptions unrelated to the numeric constructors may be unintentionally swallowed.'
@@ -2584,7 +2588,7 @@ Lint/UnmodifiedReduceAccumulator:
2584
2588
  VersionChanged: '1.5'
2585
2589
 
2586
2590
  Lint/UnreachableCode:
2587
- Description: 'Unreachable code.'
2591
+ Description: 'Checks for unreachable code.'
2588
2592
  Enabled: true
2589
2593
  VersionAdded: '0.9'
2590
2594
 
@@ -2729,7 +2733,7 @@ Lint/UselessTimes:
2729
2733
  VersionChanged: '1.61'
2730
2734
 
2731
2735
  Lint/Void:
2732
- Description: 'Possible use of operator/literal/variable in void context.'
2736
+ Description: 'Checks for operators, literals, lambdas, and procs used in void context.'
2733
2737
  Enabled: true
2734
2738
  AutoCorrect: contextual
2735
2739
  VersionAdded: '0.9'
@@ -2739,9 +2743,7 @@ Lint/Void:
2739
2743
  #################### Metrics ###############################
2740
2744
 
2741
2745
  Metrics/AbcSize:
2742
- Description: >-
2743
- A calculated magnitude based on number of assignments,
2744
- branches, and conditions.
2746
+ Description: 'Checks that the ABC size of methods is not higher than the configured maximum.'
2745
2747
  References:
2746
2748
  - https://wiki.c2.com/?AbcMetric
2747
2749
  - https://en.wikipedia.org/wiki/ABC_Software_Metric
@@ -2794,13 +2796,12 @@ Metrics/CollectionLiteralLength:
2794
2796
  Description: 'Checks for `Array` or `Hash` literals with many entries.'
2795
2797
  Enabled: pending
2796
2798
  VersionAdded: '1.47'
2797
- LengthThreshold: 250
2799
+ VersionChanged: '1.88'
2800
+ Max: 250
2798
2801
 
2799
2802
  # Avoid complex methods.
2800
2803
  Metrics/CyclomaticComplexity:
2801
- Description: >-
2802
- A complexity metric that is strongly correlated to the number
2803
- of test cases needed to validate a method.
2804
+ Description: 'Checks that the cyclomatic complexity of methods is not higher than the configured maximum.'
2804
2805
  Enabled: true
2805
2806
  VersionAdded: '0.25'
2806
2807
  VersionChanged: '0.81'
@@ -2840,26 +2841,22 @@ Metrics/ParameterLists:
2840
2841
  MaxOptionalParameters: 3
2841
2842
 
2842
2843
  Metrics/PerceivedComplexity:
2843
- Description: >-
2844
- A complexity metric geared towards measuring complexity for a
2845
- human reader.
2844
+ Description: 'Checks that the perceived complexity of methods is not higher than the configured maximum.'
2846
2845
  Enabled: true
2847
2846
  VersionAdded: '0.25'
2848
- VersionChanged: '0.81'
2847
+ VersionChanged: '1.88'
2849
2848
  AllowedMethods: []
2850
2849
  AllowedPatterns: []
2851
2850
  Max: 8
2852
2851
 
2853
- ################## Migration #############################
2852
+ #################### Migration #############################
2854
2853
 
2855
2854
  Migration/DepartmentName:
2856
- Description: >-
2857
- Check that cop names in rubocop:disable (etc) comments are
2858
- given with department name.
2855
+ Description: 'Checks that cop names in `rubocop:disable` (etc.) comments are given with a department name.'
2859
2856
  Enabled: true
2860
2857
  VersionAdded: '0.75'
2861
2858
 
2862
- #################### Naming ##############################
2859
+ #################### Naming ################################
2863
2860
 
2864
2861
  Naming/AccessorMethodName:
2865
2862
  Description: Checks the naming of accessor methods for get_/set_.
@@ -2876,7 +2873,7 @@ Naming/AsciiIdentifiers:
2876
2873
  AsciiConstants: true
2877
2874
 
2878
2875
  Naming/BinaryOperatorParameterName:
2879
- Description: 'When defining binary operators, name the argument other.'
2876
+ Description: 'Checks that the sole parameter of binary operator methods is named `other`.'
2880
2877
  StyleGuide: '#other-arg'
2881
2878
  Enabled: true
2882
2879
  VersionAdded: '0.50'
@@ -3046,7 +3043,10 @@ Naming/InclusiveLanguage:
3046
3043
  - block
3047
3044
  slave:
3048
3045
  WholeWord: true
3049
- Suggestions: ['replica', 'secondary', 'follower']
3046
+ Suggestions:
3047
+ - replica
3048
+ - secondary
3049
+ - follower
3050
3050
 
3051
3051
  Naming/MemoizedInstanceVariableName:
3052
3052
  Description: >-
@@ -3133,7 +3133,7 @@ Naming/PredicateMethod:
3133
3133
  - nonzero?
3134
3134
 
3135
3135
  Naming/PredicatePrefix:
3136
- 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.'
3137
3137
  StyleGuide: '#bool-methods-qmark'
3138
3138
  Enabled: true
3139
3139
  VersionAdded: '0.50'
@@ -3215,14 +3215,14 @@ Naming/VariableNumber:
3215
3215
  #################### Security ##############################
3216
3216
 
3217
3217
  Security/CompoundHash:
3218
- 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`.'
3219
3219
  Enabled: pending
3220
3220
  Safe: false
3221
3221
  VersionAdded: '1.28'
3222
3222
  VersionChanged: '1.51'
3223
3223
 
3224
3224
  Security/Eval:
3225
- 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.'
3226
3226
  Enabled: true
3227
3227
  VersionAdded: '0.47'
3228
3228
 
@@ -3258,7 +3258,7 @@ Security/MarshalLoad:
3258
3258
  VersionAdded: '0.47'
3259
3259
 
3260
3260
  Security/Open:
3261
- 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.'
3262
3262
  Enabled: true
3263
3263
  VersionAdded: '0.53'
3264
3264
  VersionChanged: '1.0'
@@ -3274,7 +3274,7 @@ Security/YAMLLoad:
3274
3274
  VersionAdded: '0.47'
3275
3275
  SafeAutoCorrect: false
3276
3276
 
3277
- #################### Style ###############################
3277
+ #################### Style #################################
3278
3278
 
3279
3279
  Style/AccessModifierDeclarations:
3280
3280
  Description: 'Checks style of how access modifiers are used.'
@@ -3336,6 +3336,8 @@ Style/ArgumentsForwarding:
3336
3336
  Description: 'Use arguments forwarding.'
3337
3337
  StyleGuide: '#arguments-forwarding'
3338
3338
  Enabled: pending
3339
+ VersionAdded: '1.1'
3340
+ VersionChanged: '1.58'
3339
3341
  AllowOnlyRestArgument: true
3340
3342
  UseAnonymousForwarding: true
3341
3343
  RedundantRestArgumentNames:
@@ -3349,8 +3351,6 @@ Style/ArgumentsForwarding:
3349
3351
  - blk
3350
3352
  - block
3351
3353
  - proc
3352
- VersionAdded: '1.1'
3353
- VersionChanged: '1.58'
3354
3354
 
3355
3355
  Style/ArrayCoercion:
3356
3356
  Description: >-
@@ -3701,7 +3701,7 @@ Style/CollectionCompact:
3701
3701
 
3702
3702
  # Align with the style guide.
3703
3703
  Style/CollectionMethods:
3704
- Description: 'Preferred collection methods.'
3704
+ Description: 'Enforces the use of consistent method names from the `Enumerable` module.'
3705
3705
  StyleGuide: '#map-find-select-reduce-include-size'
3706
3706
  Enabled: false
3707
3707
  VersionAdded: '0.9'
@@ -3803,11 +3803,11 @@ Style/CommentedKeyword:
3803
3803
 
3804
3804
  Style/ComparableBetween:
3805
3805
  Description: 'Enforces the use of `Comparable#between?` instead of logical comparison.'
3806
+ StyleGuide: '#ranges-or-between'
3806
3807
  Enabled: pending
3807
3808
  Safe: false
3808
3809
  VersionAdded: '1.74'
3809
3810
  VersionChanged: '1.75'
3810
- StyleGuide: '#ranges-or-between'
3811
3811
 
3812
3812
  Style/ComparableClamp:
3813
3813
  Description: 'Enforces the use of `Comparable#clamp` instead of comparison by minimum and maximum.'
@@ -4128,7 +4128,7 @@ Style/ExplicitBlockArgument:
4128
4128
  VersionChanged: '1.8'
4129
4129
 
4130
4130
  Style/ExponentialNotation:
4131
- 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.'
4132
4132
  StyleGuide: '#exponential-notation'
4133
4133
  Enabled: true
4134
4134
  VersionAdded: '0.82'
@@ -4145,8 +4145,9 @@ Style/FetchEnvVar:
4145
4145
  - https://rubystyle.guide/#hash-fetch-defaults
4146
4146
  Enabled: pending
4147
4147
  VersionAdded: '1.28'
4148
+ VersionChanged: '1.88'
4148
4149
  # Environment variables to be excluded from the inspection.
4149
- AllowedVars: []
4150
+ AllowedVariables: []
4150
4151
  # When `true`, autocorrects `ENV["key"]` to `ENV.fetch("key", nil)`.
4151
4152
  # When `false`, autocorrects `ENV["key"]` to `ENV.fetch("key")`.
4152
4153
  DefaultToNil: true
@@ -4231,6 +4232,8 @@ Style/FormatString:
4231
4232
  Style/FormatStringToken:
4232
4233
  Description: 'Use a consistent style for format string tokens.'
4233
4234
  Enabled: true
4235
+ VersionAdded: '0.49'
4236
+ VersionChanged: '1.74'
4234
4237
  EnforcedStyle: annotated
4235
4238
  SupportedStyles:
4236
4239
  # Prefer tokens which contain a sprintf like type annotation like
@@ -4249,8 +4252,6 @@ Style/FormatStringToken:
4249
4252
  # only register offenses for strings given to `printf`, `sprintf`,
4250
4253
  # format` and `%` methods. Other strings are not considered.
4251
4254
  Mode: aggressive
4252
- VersionAdded: '0.49'
4253
- VersionChanged: '1.74'
4254
4255
  AllowedMethods: []
4255
4256
  AllowedPatterns: []
4256
4257
 
@@ -4444,9 +4445,9 @@ Style/IdenticalConditionalBranches:
4444
4445
  Style/IfInsideElse:
4445
4446
  Description: 'Finds if nodes inside else, which can be converted to elsif.'
4446
4447
  Enabled: true
4447
- AllowIfModifier: false
4448
4448
  VersionAdded: '0.36'
4449
4449
  VersionChanged: '1.3'
4450
+ AllowIfModifier: false
4450
4451
 
4451
4452
  Style/IfUnlessModifier:
4452
4453
  Description: >-
@@ -4577,14 +4578,14 @@ Style/ItAssignment:
4577
4578
  Style/ItBlockParameter:
4578
4579
  Description: 'Checks for blocks with one argument where `it` block parameter can be used.'
4579
4580
  Enabled: pending
4581
+ VersionAdded: '1.75'
4582
+ VersionChanged: '1.76'
4580
4583
  EnforcedStyle: allow_single_line
4581
4584
  SupportedStyles:
4582
4585
  - allow_single_line
4583
4586
  - only_numbered_parameters
4584
4587
  - always
4585
4588
  - disallow
4586
- VersionAdded: '1.75'
4587
- VersionChanged: '1.76'
4588
4589
 
4589
4590
  Style/KeywordArgumentsMerging:
4590
4591
  Description: >-
@@ -4657,7 +4658,9 @@ Style/MagicCommentFormat:
4657
4658
  Style/MapCompactWithConditionalBlock:
4658
4659
  Description: 'Prefer `select` or `reject` over `map { ... }.compact`.'
4659
4660
  Enabled: pending
4661
+ SafeAutoCorrect: false
4660
4662
  VersionAdded: '1.30'
4663
+ VersionChanged: '1.88'
4661
4664
 
4662
4665
  Style/MapIntoArray:
4663
4666
  Description: 'Checks for usages of `each` with `<<`, `push`, or `append` which can be replaced by `map`.'
@@ -4709,10 +4712,10 @@ Style/MethodCallWithoutArgsParentheses:
4709
4712
  Description: 'Do not use parentheses for method calls with no arguments.'
4710
4713
  StyleGuide: '#method-invocation-parens'
4711
4714
  Enabled: true
4712
- AllowedMethods: []
4713
- AllowedPatterns: []
4714
4715
  VersionAdded: '0.47'
4715
4716
  VersionChanged: '0.55'
4717
+ AllowedMethods: []
4718
+ AllowedPatterns: []
4716
4719
 
4717
4720
  Style/MethodCalledOnDoEndBlock:
4718
4721
  Description: 'Avoid chaining a method call on a do...end block.'
@@ -4818,7 +4821,7 @@ Style/MultilineBlockChain:
4818
4821
  VersionAdded: '0.13'
4819
4822
 
4820
4823
  Style/MultilineIfModifier:
4821
- Description: 'Only use if/unless modifiers on single line statements.'
4824
+ Description: 'Checks for uses of `if`/`unless` modifiers with multiline bodies.'
4822
4825
  StyleGuide: '#no-multiline-if-modifiers'
4823
4826
  Enabled: true
4824
4827
  VersionAdded: '0.45'
@@ -4881,7 +4884,7 @@ Style/MutableConstant:
4881
4884
  Description: 'Do not assign mutable objects to constants.'
4882
4885
  Enabled: true
4883
4886
  VersionAdded: '0.34'
4884
- VersionChanged: '1.8'
4887
+ VersionChanged: '1.88'
4885
4888
  SafeAutoCorrect: false
4886
4889
  EnforcedStyle: literals
4887
4890
  SupportedStyles:
@@ -4893,6 +4896,9 @@ Style/MutableConstant:
4893
4896
  # no harm in freezing an already frozen object.
4894
4897
  - literals
4895
4898
  - strict
4899
+ # When `true`, recursively check and freeze mutable literals nested inside
4900
+ # arrays and hashes (e.g. `[{a: []}]` becomes `[{a: [].freeze}.freeze].freeze`).
4901
+ Recursive: false
4896
4902
 
4897
4903
  Style/NegatedIf:
4898
4904
  Description: >-
@@ -5137,9 +5143,9 @@ Style/OneLineConditional:
5137
5143
  single-line if/then/else/end constructs.
5138
5144
  StyleGuide: '#ternary-operator'
5139
5145
  Enabled: true
5140
- AlwaysCorrectToMultiline: false
5141
5146
  VersionAdded: '0.9'
5142
5147
  VersionChanged: '0.90'
5148
+ AlwaysCorrectToMultiline: false
5143
5149
 
5144
5150
  Style/OpenStructUse:
5145
5151
  Description: >-
@@ -5232,6 +5238,7 @@ Style/PercentLiteralDelimiters:
5232
5238
  StyleGuide: '#percent-literal-braces'
5233
5239
  Enabled: true
5234
5240
  VersionAdded: '0.19'
5241
+ VersionChanged: '0.48'
5235
5242
  # Specify the default preferred delimiter for all types with the 'default' key
5236
5243
  # Override individual delimiters (even with default specified) by specifying
5237
5244
  # an individual key
@@ -5242,7 +5249,6 @@ Style/PercentLiteralDelimiters:
5242
5249
  '%r': '{}'
5243
5250
  '%w': '[]'
5244
5251
  '%W': '[]'
5245
- VersionChanged: '0.48'
5246
5252
 
5247
5253
  Style/PercentQLiterals:
5248
5254
  Description: 'Checks if uses of %Q/%q match the configured preference.'
@@ -5469,9 +5475,9 @@ Style/RedundantInitialize:
5469
5475
  Enabled: pending
5470
5476
  AutoCorrect: contextual
5471
5477
  Safe: false
5472
- AllowComments: true
5473
5478
  VersionAdded: '1.27'
5474
5479
  VersionChanged: '1.61'
5480
+ AllowComments: true
5475
5481
 
5476
5482
  Style/RedundantInterpolation:
5477
5483
  Description: 'Checks for strings that are just an interpolated expression.'
@@ -5635,10 +5641,10 @@ Style/ReturnNilInPredicateMethodDefinition:
5635
5641
  StyleGuide: '#bool-methods-qmark'
5636
5642
  Enabled: pending
5637
5643
  SafeAutoCorrect: false
5638
- AllowedMethods: []
5639
- AllowedPatterns: []
5640
5644
  VersionAdded: '1.53'
5641
5645
  VersionChanged: '1.67'
5646
+ AllowedMethods: []
5647
+ AllowedPatterns: []
5642
5648
 
5643
5649
  Style/ReverseFind:
5644
5650
  Description: 'Use `array.rfind` instead of `array.reverse.find`.'
@@ -5987,12 +5993,12 @@ Style/TrailingBodyOnClass:
5987
5993
  VersionAdded: '0.53'
5988
5994
 
5989
5995
  Style/TrailingBodyOnMethodDefinition:
5990
- Description: 'Method body goes below definition.'
5996
+ Description: 'Checks for trailing code after the method definition.'
5991
5997
  Enabled: true
5992
5998
  VersionAdded: '0.52'
5993
5999
 
5994
6000
  Style/TrailingBodyOnModule:
5995
- Description: 'Module body goes below module statement.'
6001
+ Description: 'Checks for trailing code after the module definition.'
5996
6002
  Enabled: true
5997
6003
  VersionAdded: '0.53'
5998
6004
 
@@ -6065,10 +6071,10 @@ Style/TrailingUnderscoreVariable:
6065
6071
  Description: >-
6066
6072
  Checks for the usage of unneeded trailing underscores at the
6067
6073
  end of parallel variable assignment.
6068
- AllowNamedUnderscoreVariables: true
6069
6074
  Enabled: true
6070
6075
  VersionAdded: '0.31'
6071
6076
  VersionChanged: '0.35'
6077
+ AllowNamedUnderscoreVariables: true
6072
6078
 
6073
6079
  # `TrivialAccessors` requires exact name matches and doesn't allow
6074
6080
  # predicated methods by default.
@@ -6201,6 +6207,9 @@ Style/YodaCondition:
6201
6207
  References:
6202
6208
  - 'https://en.wikipedia.org/wiki/Yoda_conditions'
6203
6209
  Enabled: true
6210
+ Safe: false
6211
+ VersionAdded: '0.49'
6212
+ VersionChanged: '0.75'
6204
6213
  EnforcedStyle: forbid_for_all_comparison_operators
6205
6214
  SupportedStyles:
6206
6215
  # check all comparison operators
@@ -6211,9 +6220,6 @@ Style/YodaCondition:
6211
6220
  - require_for_all_comparison_operators
6212
6221
  # enforce yoda only for equality operators: `!=` and `==`
6213
6222
  - require_for_equality_operators_only
6214
- Safe: false
6215
- VersionAdded: '0.49'
6216
- VersionChanged: '0.75'
6217
6223
 
6218
6224
  Style/YodaExpression:
6219
6225
  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
@@ -498,8 +498,23 @@ module RuboCop
498
498
  patterns = cop_config[parameter]
499
499
  return default_result unless patterns
500
500
 
501
- patterns = FilePatterns.from(patterns)
502
- patterns.match?(config.path_relative_to_config(file)) || patterns.match?(file)
501
+ file_patterns = FilePatterns.from(patterns)
502
+ relative_file_path = config.path_relative_to_config(file)
503
+ return true if file_patterns.match?(relative_file_path)
504
+
505
+ if parameter == 'Include' && !relative_file_path.start_with?('..')
506
+ matches_absolute_include_pattern?(patterns, file)
507
+ else
508
+ file_patterns.match?(file)
509
+ end
510
+ end
511
+
512
+ def matches_absolute_include_pattern?(patterns, file)
513
+ absolute_file_path = absolute?(file) ? file : File.expand_path(file)
514
+ patterns.any? do |pattern|
515
+ (absolute?(pattern.to_s) || pattern.to_s.start_with?('..')) &&
516
+ match_path?(pattern, absolute_file_path)
517
+ end
503
518
  end
504
519
 
505
520
  def enabled_line?(line_number)