rubocop 1.75.8 → 1.81.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 (164) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +20 -16
  3. data/config/default.yml +117 -26
  4. data/config/obsoletion.yml +6 -3
  5. data/exe/rubocop +1 -8
  6. data/lib/rubocop/cli/command/auto_generate_config.rb +2 -2
  7. data/lib/rubocop/cli.rb +18 -3
  8. data/lib/rubocop/config_loader.rb +4 -39
  9. data/lib/rubocop/config_store.rb +5 -0
  10. data/lib/rubocop/cop/autocorrect_logic.rb +4 -4
  11. data/lib/rubocop/cop/bundler/ordered_gems.rb +1 -1
  12. data/lib/rubocop/cop/correctors/alignment_corrector.rb +7 -4
  13. data/lib/rubocop/cop/correctors/for_to_each_corrector.rb +7 -2
  14. data/lib/rubocop/cop/correctors/parentheses_corrector.rb +5 -2
  15. data/lib/rubocop/cop/gemspec/attribute_assignment.rb +91 -0
  16. data/lib/rubocop/cop/gemspec/duplicated_assignment.rb +0 -22
  17. data/lib/rubocop/cop/gemspec/ordered_dependencies.rb +1 -1
  18. data/lib/rubocop/cop/gemspec/require_mfa.rb +15 -1
  19. data/lib/rubocop/cop/internal_affairs/example_description.rb +1 -1
  20. data/lib/rubocop/cop/internal_affairs/node_matcher_directive.rb +4 -4
  21. data/lib/rubocop/cop/internal_affairs/node_pattern_groups.rb +4 -1
  22. data/lib/rubocop/cop/internal_affairs/node_type_group.rb +3 -2
  23. data/lib/rubocop/cop/internal_affairs/on_send_without_on_csend.rb +1 -1
  24. data/lib/rubocop/cop/internal_affairs/useless_restrict_on_send.rb +1 -1
  25. data/lib/rubocop/cop/layout/class_structure.rb +1 -1
  26. data/lib/rubocop/cop/layout/closing_parenthesis_indentation.rb +1 -1
  27. data/lib/rubocop/cop/layout/dot_position.rb +1 -1
  28. data/lib/rubocop/cop/layout/empty_line_between_defs.rb +30 -12
  29. data/lib/rubocop/cop/layout/empty_lines_after_module_inclusion.rb +101 -0
  30. data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +1 -1
  31. data/lib/rubocop/cop/layout/empty_lines_around_arguments.rb +8 -29
  32. data/lib/rubocop/cop/layout/empty_lines_around_class_body.rb +1 -1
  33. data/lib/rubocop/cop/layout/line_length.rb +35 -6
  34. data/lib/rubocop/cop/layout/multiline_operation_indentation.rb +8 -4
  35. data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +8 -0
  36. data/lib/rubocop/cop/layout/space_around_keyword.rb +6 -1
  37. data/lib/rubocop/cop/layout/space_around_operators.rb +8 -0
  38. data/lib/rubocop/cop/layout/space_before_brackets.rb +2 -9
  39. data/lib/rubocop/cop/layout/space_inside_array_literal_brackets.rb +7 -2
  40. data/lib/rubocop/cop/layout/trailing_whitespace.rb +1 -1
  41. data/lib/rubocop/cop/lint/ambiguous_range.rb +5 -0
  42. data/lib/rubocop/cop/lint/deprecated_open_ssl_constant.rb +4 -1
  43. data/lib/rubocop/cop/lint/duplicate_methods.rb +25 -4
  44. data/lib/rubocop/cop/lint/duplicate_regexp_character_class_element.rb +5 -42
  45. data/lib/rubocop/cop/lint/empty_interpolation.rb +3 -1
  46. data/lib/rubocop/cop/lint/float_comparison.rb +4 -4
  47. data/lib/rubocop/cop/lint/identity_comparison.rb +19 -15
  48. data/lib/rubocop/cop/lint/literal_as_condition.rb +34 -28
  49. data/lib/rubocop/cop/lint/missing_cop_enable_directive.rb +1 -2
  50. data/lib/rubocop/cop/lint/numeric_operation_with_constant_result.rb +1 -0
  51. data/lib/rubocop/cop/lint/redundant_regexp_quantifiers.rb +1 -1
  52. data/lib/rubocop/cop/lint/redundant_safe_navigation.rb +101 -2
  53. data/lib/rubocop/cop/lint/redundant_type_conversion.rb +4 -4
  54. data/lib/rubocop/cop/lint/require_range_parentheses.rb +1 -1
  55. data/lib/rubocop/cop/lint/rescue_type.rb +1 -1
  56. data/lib/rubocop/cop/lint/safe_navigation_chain.rb +4 -4
  57. data/lib/rubocop/cop/lint/self_assignment.rb +30 -4
  58. data/lib/rubocop/cop/lint/shadowed_argument.rb +7 -7
  59. data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +5 -0
  60. data/lib/rubocop/cop/lint/uri_escape_unescape.rb +2 -0
  61. data/lib/rubocop/cop/lint/useless_access_modifier.rb +29 -4
  62. data/lib/rubocop/cop/lint/useless_default_value_argument.rb +90 -0
  63. data/lib/rubocop/cop/lint/useless_numeric_operation.rb +1 -0
  64. data/lib/rubocop/cop/lint/useless_or.rb +98 -0
  65. data/lib/rubocop/cop/lint/useless_ruby2_keywords.rb +3 -3
  66. data/lib/rubocop/cop/lint/utils/nil_receiver_checker.rb +121 -0
  67. data/lib/rubocop/cop/lint/void.rb +7 -0
  68. data/lib/rubocop/cop/message_annotator.rb +1 -1
  69. data/lib/rubocop/cop/mixin/alignment.rb +1 -1
  70. data/lib/rubocop/cop/mixin/check_line_breakable.rb +1 -1
  71. data/lib/rubocop/cop/mixin/end_keyword_alignment.rb +1 -7
  72. data/lib/rubocop/cop/mixin/frozen_string_literal.rb +1 -1
  73. data/lib/rubocop/cop/mixin/gemspec_help.rb +22 -0
  74. data/lib/rubocop/cop/mixin/line_length_help.rb +24 -8
  75. data/lib/rubocop/cop/mixin/ordered_gem_node.rb +1 -1
  76. data/lib/rubocop/cop/mixin/trailing_comma.rb +1 -1
  77. data/lib/rubocop/cop/naming/file_name.rb +2 -2
  78. data/lib/rubocop/cop/naming/method_name.rb +127 -13
  79. data/lib/rubocop/cop/naming/predicate_method.rb +319 -0
  80. data/lib/rubocop/cop/naming/{predicate_name.rb → predicate_prefix.rb} +4 -4
  81. data/lib/rubocop/cop/security/eval.rb +2 -1
  82. data/lib/rubocop/cop/security/open.rb +1 -0
  83. data/lib/rubocop/cop/style/access_modifier_declarations.rb +1 -1
  84. data/lib/rubocop/cop/style/accessor_grouping.rb +13 -1
  85. data/lib/rubocop/cop/style/arguments_forwarding.rb +11 -17
  86. data/lib/rubocop/cop/style/array_intersect.rb +98 -34
  87. data/lib/rubocop/cop/style/array_intersect_with_single_element.rb +47 -0
  88. data/lib/rubocop/cop/style/bitwise_predicate.rb +8 -1
  89. data/lib/rubocop/cop/style/block_delimiters.rb +1 -1
  90. data/lib/rubocop/cop/style/case_like_if.rb +1 -1
  91. data/lib/rubocop/cop/style/collection_querying.rb +167 -0
  92. data/lib/rubocop/cop/style/conditional_assignment.rb +4 -2
  93. data/lib/rubocop/cop/style/dig_chain.rb +1 -1
  94. data/lib/rubocop/cop/style/double_negation.rb +1 -1
  95. data/lib/rubocop/cop/style/empty_string_inside_interpolation.rb +100 -0
  96. data/lib/rubocop/cop/style/explicit_block_argument.rb +1 -1
  97. data/lib/rubocop/cop/style/exponential_notation.rb +3 -2
  98. data/lib/rubocop/cop/style/fetch_env_var.rb +32 -6
  99. data/lib/rubocop/cop/style/hash_conversion.rb +16 -8
  100. data/lib/rubocop/cop/style/hash_syntax.rb +1 -1
  101. data/lib/rubocop/cop/style/if_unless_modifier.rb +13 -6
  102. data/lib/rubocop/cop/style/infinite_loop.rb +1 -1
  103. data/lib/rubocop/cop/style/inverse_methods.rb +1 -1
  104. data/lib/rubocop/cop/style/it_assignment.rb +69 -12
  105. data/lib/rubocop/cop/style/it_block_parameter.rb +36 -15
  106. data/lib/rubocop/cop/style/map_to_hash.rb +1 -3
  107. data/lib/rubocop/cop/style/map_to_set.rb +1 -3
  108. data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +4 -6
  109. data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +16 -0
  110. data/lib/rubocop/cop/style/min_max_comparison.rb +13 -5
  111. data/lib/rubocop/cop/style/nil_comparison.rb +9 -7
  112. data/lib/rubocop/cop/style/parallel_assignment.rb +32 -20
  113. data/lib/rubocop/cop/style/redundant_array_flatten.rb +50 -0
  114. data/lib/rubocop/cop/style/redundant_begin.rb +34 -0
  115. data/lib/rubocop/cop/style/redundant_condition.rb +1 -1
  116. data/lib/rubocop/cop/style/redundant_exception.rb +1 -1
  117. data/lib/rubocop/cop/style/redundant_fetch_block.rb +1 -9
  118. data/lib/rubocop/cop/style/redundant_format.rb +18 -3
  119. data/lib/rubocop/cop/style/redundant_freeze.rb +1 -1
  120. data/lib/rubocop/cop/style/redundant_interpolation.rb +1 -1
  121. data/lib/rubocop/cop/style/redundant_line_continuation.rb +1 -1
  122. data/lib/rubocop/cop/style/redundant_parentheses.rb +55 -16
  123. data/lib/rubocop/cop/style/redundant_regexp_argument.rb +4 -0
  124. data/lib/rubocop/cop/style/redundant_regexp_escape.rb +8 -0
  125. data/lib/rubocop/cop/style/redundant_self.rb +8 -5
  126. data/lib/rubocop/cop/style/safe_navigation.rb +44 -12
  127. data/lib/rubocop/cop/style/single_line_methods.rb +7 -4
  128. data/lib/rubocop/cop/style/sole_nested_conditional.rb +32 -2
  129. data/lib/rubocop/cop/style/stabby_lambda_parentheses.rb +1 -1
  130. data/lib/rubocop/cop/style/string_concatenation.rb +17 -13
  131. data/lib/rubocop/cop/style/symbol_array.rb +1 -1
  132. data/lib/rubocop/cop/style/symbol_proc.rb +1 -1
  133. data/lib/rubocop/cop/style/trailing_comma_in_arguments.rb +45 -0
  134. data/lib/rubocop/cop/style/trailing_comma_in_block_args.rb +1 -1
  135. data/lib/rubocop/cop/style/unless_else.rb +10 -9
  136. data/lib/rubocop/cop/utils/format_string.rb +10 -0
  137. data/lib/rubocop/cop/variable_force/variable.rb +1 -1
  138. data/lib/rubocop/cop/variable_force.rb +25 -8
  139. data/lib/rubocop/cops_documentation_generator.rb +1 -0
  140. data/lib/rubocop/formatter/disabled_config_formatter.rb +18 -5
  141. data/lib/rubocop/formatter/fuubar_style_formatter.rb +1 -1
  142. data/lib/rubocop/formatter/markdown_formatter.rb +1 -0
  143. data/lib/rubocop/formatter/offense_count_formatter.rb +1 -1
  144. data/lib/rubocop/formatter/pacman_formatter.rb +1 -0
  145. data/lib/rubocop/lsp/diagnostic.rb +25 -24
  146. data/lib/rubocop/lsp/routes.rb +65 -9
  147. data/lib/rubocop/lsp/runtime.rb +2 -2
  148. data/lib/rubocop/lsp/server.rb +2 -2
  149. data/lib/rubocop/lsp/stdin_runner.rb +0 -16
  150. data/lib/rubocop/pending_cops_reporter.rb +56 -0
  151. data/lib/rubocop/result_cache.rb +14 -12
  152. data/lib/rubocop/rspec/expect_offense.rb +9 -3
  153. data/lib/rubocop/runner.rb +6 -4
  154. data/lib/rubocop/server/cache.rb +4 -2
  155. data/lib/rubocop/server/client_command/base.rb +10 -0
  156. data/lib/rubocop/server/client_command/exec.rb +2 -1
  157. data/lib/rubocop/server/client_command/start.rb +11 -1
  158. data/lib/rubocop/target_finder.rb +9 -9
  159. data/lib/rubocop/target_ruby.rb +10 -1
  160. data/lib/rubocop/version.rb +1 -1
  161. data/lib/rubocop.rb +12 -1
  162. data/lib/ruby_lsp/rubocop/addon.rb +25 -10
  163. data/lib/ruby_lsp/rubocop/runtime_adapter.rb +49 -15
  164. metadata +22 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 31a9b16f521cb4dd8d22db58d5473cd527162b65934d8e210993f7c435a85d26
4
- data.tar.gz: 57af5692e8b85aca41224e621a0ba6b54001944a6625edef169a78278066a532
3
+ metadata.gz: 2e194323f7062efb4f5777f4039ff475256dfa86b6e95dd63f42f682b3e59a55
4
+ data.tar.gz: 533b2e1fe940252958b245c2d492e0e4b39e37babd9e918fbc3ee505faf030ac
5
5
  SHA512:
6
- metadata.gz: ef0ab376b3993e9ad1961560911ed5b5e2abf069a2b9acd0187e3d31c03f853a520646f2c421813bc3c03aedd74004dcf057cbadecad0ea86acafbd6670c8e46
7
- data.tar.gz: b76bd8b4d7492577429bab8abd02ebcf7f2d9d2f83066e81c48b060abcaad68a2660b064c1f5b0b9c42bc80cc78ce15cd6e10ace393cd636310055515af925db
6
+ metadata.gz: c4bbe12c2a1c627b8f4938a3cc52cd3e4c51ee334b8f1d3b2c373dd109c20741721c090b9152ef2e3f8a908f95c90cc7d8021ba48a1354884361219880153581
7
+ data.tar.gz: 0ee2973781e011caf6069a9072f8f6a59196d0430fe3d90af740bc2795423d4ead9fc62ddbe11bfe2be8230b769446e734eebcf461c494bb2921a3fb16135c7c
data/README.md CHANGED
@@ -6,8 +6,6 @@
6
6
  [![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop/rubocop)
7
7
  [![Gem Version](https://badge.fury.io/rb/rubocop.svg)](https://badge.fury.io/rb/rubocop)
8
8
  [![CI](https://github.com/rubocop/rubocop/actions/workflows/rubocop.yml/badge.svg)](https://github.com/rubocop/rubocop/actions/workflows/rubocop.yml)
9
- [![Test Coverage](https://api.codeclimate.com/v1/badges/d2d67f728e88ea84ac69/test_coverage)](https://codeclimate.com/github/rubocop/rubocop/test_coverage)
10
- [![Maintainability](https://api.codeclimate.com/v1/badges/d2d67f728e88ea84ac69/maintainability)](https://codeclimate.com/github/rubocop/rubocop/maintainability)
11
9
  [![Discord](https://img.shields.io/badge/chat-on%20discord-7289da.svg?sanitize=true)](https://discord.gg/wJjWvGRDmm)
12
10
 
13
11
  > Role models are important. <br/>
@@ -36,10 +34,11 @@ Working on RuboCop is often fun, but it also requires a great deal of time and e
36
34
  **RuboCop**'s installation is pretty standard:
37
35
 
38
36
  ```sh
39
- $ gem install rubocop
37
+ gem install rubocop
40
38
  ```
41
39
 
42
- If you'd rather install RuboCop using `bundler`, add a line for it in your `Gemfile` (but set the `require` option to `false`, as it is a standalone tool):
40
+ If you'd rather install RuboCop using `bundler`, add a line for it in your
41
+ `Gemfile` (but set the `require` option to `false`, as it is a standalone tool):
43
42
 
44
43
  ```rb
45
44
  gem 'rubocop', require: false
@@ -52,7 +51,7 @@ To prevent an unwanted RuboCop update you might want to use a conservative versi
52
51
  in your `Gemfile`:
53
52
 
54
53
  ```rb
55
- gem 'rubocop', '~> 1.75', require: false
54
+ gem 'rubocop', '~> 1.81', require: false
56
55
  ```
57
56
 
58
57
  See [our versioning policy](https://docs.rubocop.org/rubocop/versioning.html) for further details.
@@ -61,12 +60,15 @@ See [our versioning policy](https://docs.rubocop.org/rubocop/versioning.html) fo
61
60
 
62
61
  Just type `rubocop` in a Ruby project's folder and watch the magic happen.
63
62
 
64
- ```
65
- $ cd my/cool/ruby/project
66
- $ rubocop
63
+ ```sh
64
+ cd my/cool/ruby/project
65
+ rubocop
67
66
  ```
68
67
 
69
- You can also use this magic in your favorite editor with RuboCop's [built-in LSP server](https://docs.rubocop.org/rubocop/usage/lsp.html).
68
+ > [!TIP]
69
+ >
70
+ > You can also use this magic in your favorite editor with RuboCop's
71
+ > [built-in LSP server](https://docs.rubocop.org/rubocop/usage/lsp.html).
70
72
 
71
73
  ## Documentation
72
74
 
@@ -79,7 +81,7 @@ RuboCop officially supports the following runtime Ruby implementations:
79
81
  * MRI 2.7+
80
82
  * JRuby 9.4+
81
83
 
82
- Targets Ruby 2.0+ code analysis.
84
+ It targets Ruby 2.0+ for code analysis.
83
85
 
84
86
  See the [compatibility documentation](https://docs.rubocop.org/rubocop/compatibility.html) for further details.
85
87
 
@@ -91,7 +93,6 @@ If you use RuboCop in your project, you can include one of these badges in your
91
93
 
92
94
  [![Ruby Style Guide](https://img.shields.io/badge/code_style-community-brightgreen.svg)](https://rubystyle.guide)
93
95
 
94
-
95
96
  Here are the Markdown snippets for the two badges:
96
97
 
97
98
  ``` markdown
@@ -109,7 +110,7 @@ Here's a list of RuboCop's core developers:
109
110
  * [Yuji Nakayama](https://github.com/yujinakayama) (retired)
110
111
  * [Evgeni Dzhelyov](https://github.com/edzhelyov) (retired)
111
112
  * [Ted Johansson](https://github.com/drenmi)
112
- * [Masataka Kuwabara](https://github.com/pocke)
113
+ * [Masataka Kuwabara](https://github.com/pocke) (retired)
113
114
  * [Koichi Ito](https://github.com/koic)
114
115
  * [Maxim Krizhanovski](https://github.com/darhazer)
115
116
  * [Benjamin Quorning](https://github.com/bquorning)
@@ -157,8 +158,8 @@ wide array of funding channels to account for your preferences
157
158
  currently [Open Collective](https://opencollective.com/rubocop) is our
158
159
  preferred funding platform).
159
160
 
160
- **If you're working in a company that's making significant use of RuboCop we'd appreciate it if you suggest to your company
161
- to become a RuboCop sponsor.**
161
+ **If you're working in a company that's making significant use of RuboCop we'd
162
+ appreciate it if you suggest to your company to become a RuboCop sponsor.**
162
163
 
163
164
  You can support the development of RuboCop via
164
165
  [GitHub Sponsors](https://github.com/sponsors/bbatsov),
@@ -168,8 +169,11 @@ You can support the development of RuboCop via
168
169
  and [Tidelift](https://tidelift.com/subscription/pkg/rubygems-rubocop?utm_source=rubygems-rubocop&utm_medium=referral&utm_campaign=readme)
169
170
  .
170
171
 
171
- **Note:** If doing a sponsorship in the form of donation is problematic for your company from an accounting standpoint, we'd recommend
172
- the use of Tidelift, where you can get a support-like subscription instead.
172
+ > [!NOTE]
173
+ >
174
+ > If doing a sponsorship in the form of donation is problematic for your company
175
+ > from an accounting standpoint, we'd recommend the use of Tidelift, where you
176
+ > can get a support-like subscription instead.
173
177
 
174
178
  ### Open Collective for Individuals
175
179
 
data/config/default.yml CHANGED
@@ -281,6 +281,13 @@ Gemspec/AddRuntimeDependency:
281
281
  Include:
282
282
  - '**/*.gemspec'
283
283
 
284
+ Gemspec/AttributeAssignment:
285
+ Description: 'Use consistent style for Gemspec attributes assignment.'
286
+ Enabled: pending
287
+ VersionAdded: '1.77'
288
+ Include:
289
+ - '**/*.gemspec'
290
+
284
291
  Gemspec/DependencyVersion:
285
292
  Description: 'Requires or forbids specifying gem dependency versions.'
286
293
  Enabled: false
@@ -371,7 +378,7 @@ Gemspec/RubyVersionGlobalsUsage:
371
378
  #################### Layout ###########################
372
379
 
373
380
  Layout/AccessModifierIndentation:
374
- Description: Check indentation of private/protected visibility modifiers.
381
+ Description: Checks indentation of private/protected visibility modifiers.
375
382
  StyleGuide: '#indent-public-private-protected'
376
383
  Enabled: true
377
384
  VersionAdded: '0.49'
@@ -631,6 +638,12 @@ Layout/EmptyLines:
631
638
  Enabled: true
632
639
  VersionAdded: '0.49'
633
640
 
641
+ Layout/EmptyLinesAfterModuleInclusion:
642
+ Description: 'Keeps track of empty lines after module inclusion methods.'
643
+ StyleGuide: '#empty-lines-after-module-inclusion'
644
+ Enabled: pending
645
+ VersionAdded: '1.79'
646
+
634
647
  Layout/EmptyLinesAroundAccessModifier:
635
648
  Description: "Keep blank lines around access modifiers."
636
649
  StyleGuide: '#empty-lines-around-access-modifier'
@@ -1044,7 +1057,7 @@ Layout/LeadingCommentSpace:
1044
1057
  AllowSteepAnnotation: false
1045
1058
 
1046
1059
  Layout/LeadingEmptyLines:
1047
- Description: Check for unnecessary blank lines at the beginning of a file.
1060
+ Description: Checks for unnecessary blank lines at the beginning of a file.
1048
1061
  Enabled: true
1049
1062
  VersionAdded: '0.57'
1050
1063
  VersionChanged: '0.77'
@@ -1095,6 +1108,7 @@ Layout/LineLength:
1095
1108
  # To make it possible to copy or click on URIs in the code, we allow lines
1096
1109
  # containing a URI to be longer than Max.
1097
1110
  AllowURI: true
1111
+ AllowQualifiedName: true
1098
1112
  URISchemes:
1099
1113
  - http
1100
1114
  - https
@@ -1133,7 +1147,7 @@ Layout/MultilineArrayLineBreaks:
1133
1147
  AllowMultilineFinalElement: false
1134
1148
 
1135
1149
  Layout/MultilineAssignmentLayout:
1136
- Description: 'Check for a newline after the assignment operator in multi-line assignments.'
1150
+ Description: 'Checks for a newline after the assignment operator in multi-line assignments.'
1137
1151
  StyleGuide: '#indent-conditional-assignment'
1138
1152
  Enabled: false
1139
1153
  VersionAdded: '0.49'
@@ -1647,7 +1661,7 @@ Lint/BinaryOperatorWithIdenticalOperands:
1647
1661
  VersionChanged: '1.69'
1648
1662
 
1649
1663
  Lint/BooleanSymbol:
1650
- Description: 'Check for `:true` and `:false` symbols.'
1664
+ Description: 'Checks for `:true` and `:false` symbols.'
1651
1665
  Enabled: true
1652
1666
  SafeAutoCorrect: false
1653
1667
  VersionAdded: '0.50'
@@ -1680,7 +1694,7 @@ Lint/ConstantReassignment:
1680
1694
  VersionAdded: '1.70'
1681
1695
 
1682
1696
  Lint/ConstantResolution:
1683
- Description: 'Check that constants are fully qualified with `::`.'
1697
+ Description: 'Checks that constants are fully qualified with `::`.'
1684
1698
  Enabled: false
1685
1699
  VersionAdded: '0.86'
1686
1700
  # Restrict this cop to only looking at certain names
@@ -1694,7 +1708,7 @@ Lint/CopDirectiveSyntax:
1694
1708
  VersionAdded: '1.72'
1695
1709
 
1696
1710
  Lint/Debugger:
1697
- Description: 'Check for debugger calls.'
1711
+ Description: 'Checks for debugger calls.'
1698
1712
  Enabled: true
1699
1713
  VersionAdded: '0.14'
1700
1714
  VersionChanged: '1.63'
@@ -1745,7 +1759,7 @@ Lint/Debugger:
1745
1759
  - debug/start
1746
1760
 
1747
1761
  Lint/DeprecatedClassMethods:
1748
- Description: 'Check for deprecated class method calls.'
1762
+ Description: 'Checks for deprecated class method calls.'
1749
1763
  Enabled: true
1750
1764
  VersionAdded: '0.19'
1751
1765
 
@@ -1819,13 +1833,13 @@ Lint/DuplicateElsifCondition:
1819
1833
  VersionAdded: '0.88'
1820
1834
 
1821
1835
  Lint/DuplicateHashKey:
1822
- Description: 'Check for duplicate keys in hash literals.'
1836
+ Description: 'Checks for duplicate keys in hash literals.'
1823
1837
  Enabled: true
1824
1838
  VersionAdded: '0.34'
1825
1839
  VersionChanged: '0.77'
1826
1840
 
1827
1841
  Lint/DuplicateMagicComment:
1828
- Description: 'Check for duplicated magic comments.'
1842
+ Description: 'Checks for duplicated magic comments.'
1829
1843
  Enabled: pending
1830
1844
  VersionAdded: '1.37'
1831
1845
 
@@ -1835,7 +1849,7 @@ Lint/DuplicateMatchPattern:
1835
1849
  VersionAdded: '1.50'
1836
1850
 
1837
1851
  Lint/DuplicateMethods:
1838
- Description: 'Check for duplicate method definitions.'
1852
+ Description: 'Checks for duplicate method definitions.'
1839
1853
  Enabled: true
1840
1854
  VersionAdded: '0.29'
1841
1855
 
@@ -1845,7 +1859,7 @@ Lint/DuplicateRegexpCharacterClassElement:
1845
1859
  VersionAdded: '1.1'
1846
1860
 
1847
1861
  Lint/DuplicateRequire:
1848
- Description: 'Check for duplicate `require`s and `require_relative`s.'
1862
+ Description: 'Checks for duplicate `require`s and `require_relative`s.'
1849
1863
  Enabled: true
1850
1864
  SafeAutoCorrect: false
1851
1865
  VersionAdded: '0.90'
@@ -1862,12 +1876,12 @@ Lint/DuplicateSetElement:
1862
1876
  VersionAdded: '1.67'
1863
1877
 
1864
1878
  Lint/EachWithObjectArgument:
1865
- Description: 'Check for immutable argument given to each_with_object.'
1879
+ Description: 'Checks for immutable argument given to each_with_object.'
1866
1880
  Enabled: true
1867
1881
  VersionAdded: '0.31'
1868
1882
 
1869
1883
  Lint/ElseLayout:
1870
- Description: 'Check for odd code arrangement in an else block.'
1884
+ Description: 'Checks for odd code arrangement in an else block.'
1871
1885
  Enabled: true
1872
1886
  VersionAdded: '0.17'
1873
1887
  VersionChanged: '1.2'
@@ -1923,7 +1937,7 @@ Lint/EmptyInterpolation:
1923
1937
  Enabled: true
1924
1938
  AutoCorrect: contextual
1925
1939
  VersionAdded: '0.20'
1926
- VersionChanged: '1.61'
1940
+ VersionChanged: '1.76'
1927
1941
 
1928
1942
  Lint/EmptyWhen:
1929
1943
  Description: 'Checks for `when` branches with empty bodies.'
@@ -2270,6 +2284,7 @@ Lint/RedundantSafeNavigation:
2270
2284
  Description: 'Checks for redundant safe navigation calls.'
2271
2285
  Enabled: true
2272
2286
  VersionAdded: '0.93'
2287
+ VersionChanged: '1.79'
2273
2288
  AllowedMethods:
2274
2289
  - instance_of?
2275
2290
  - kind_of?
@@ -2277,6 +2292,12 @@ Lint/RedundantSafeNavigation:
2277
2292
  - eql?
2278
2293
  - respond_to?
2279
2294
  - equal?
2295
+ InferNonNilReceiver: false
2296
+ AdditionalNilMethods:
2297
+ - present?
2298
+ - blank?
2299
+ - try
2300
+ - try!
2280
2301
  Safe: false
2281
2302
 
2282
2303
  Lint/RedundantSplatExpansion:
@@ -2400,6 +2421,7 @@ Lint/SelfAssignment:
2400
2421
  Description: 'Checks for self-assignments.'
2401
2422
  Enabled: true
2402
2423
  VersionAdded: '0.89'
2424
+ AllowRBSInlineAnnotation: false
2403
2425
 
2404
2426
  Lint/SendWithMixinArgument:
2405
2427
  Description: 'Checks for `send` method when using mixin.'
@@ -2423,8 +2445,9 @@ Lint/ShadowingOuterLocalVariable:
2423
2445
  Description: >-
2424
2446
  Do not use the same name as outer local variable
2425
2447
  for block arguments or block local variables.
2426
- Enabled: true
2448
+ Enabled: false
2427
2449
  VersionAdded: '0.9'
2450
+ VersionChanged: '1.76'
2428
2451
 
2429
2452
  Lint/SharedMutableDefault:
2430
2453
  Description: 'Checks for mutable literals used as default arguments during Hash initialization.'
@@ -2612,6 +2635,13 @@ Lint/UselessConstantScoping:
2612
2635
  Enabled: pending
2613
2636
  VersionAdded: '1.72'
2614
2637
 
2638
+ Lint/UselessDefaultValueArgument:
2639
+ Description: 'Checks for usage of `fetch` or `Array.new` with default value argument and block.'
2640
+ Enabled: pending
2641
+ VersionAdded: '1.76'
2642
+ Safe: false
2643
+ AllowedReceivers: []
2644
+
2615
2645
  Lint/UselessDefined:
2616
2646
  Description: 'Checks for calls to `defined?` with strings and symbols. The result of such a call will always be truthy.'
2617
2647
  Enabled: pending
@@ -2636,6 +2666,11 @@ Lint/UselessNumericOperation:
2636
2666
  Enabled: pending
2637
2667
  VersionAdded: '1.66'
2638
2668
 
2669
+ Lint/UselessOr:
2670
+ Description: 'Checks for useless OR expressions.'
2671
+ Enabled: pending
2672
+ VersionAdded: '1.76'
2673
+
2639
2674
  Lint/UselessRescue:
2640
2675
  Description: 'Checks for useless `rescue`s.'
2641
2676
  Enabled: pending
@@ -2676,7 +2711,7 @@ Metrics/AbcSize:
2676
2711
  A calculated magnitude based on number of assignments,
2677
2712
  branches, and conditions.
2678
2713
  References:
2679
- - http://c2.com/cgi/wiki?AbcMetric
2714
+ - https://wiki.c2.com/?AbcMetric
2680
2715
  - https://en.wikipedia.org/wiki/ABC_Software_Metric
2681
2716
  Enabled: true
2682
2717
  VersionAdded: '0.27'
@@ -2795,7 +2830,7 @@ Migration/DepartmentName:
2795
2830
  #################### Naming ##############################
2796
2831
 
2797
2832
  Naming/AccessorMethodName:
2798
- Description: Check the naming of accessor methods for get_/set_.
2833
+ Description: Checks the naming of accessor methods for get_/set_.
2799
2834
  StyleGuide: '#accessor_mutator_method_names'
2800
2835
  Enabled: true
2801
2836
  VersionAdded: '0.50'
@@ -3046,8 +3081,26 @@ Naming/MethodParameterName:
3046
3081
  # Forbidden names that will register an offense
3047
3082
  ForbiddenNames: []
3048
3083
 
3049
- Naming/PredicateName:
3050
- Description: 'Check the names of predicate methods.'
3084
+ Naming/PredicateMethod:
3085
+ Description: 'Checks that predicate methods end with `?` and non-predicate methods do not.'
3086
+ Enabled: pending
3087
+ VersionAdded: '1.76'
3088
+ VersionChanged: '1.78'
3089
+ # In `aggressive` mode, the cop will register an offense for predicate methods that
3090
+ # may return a non-boolean value.
3091
+ # In `conservative` mode, the cop will *not* register an offense for predicate methods
3092
+ # that may return a non-boolean value.
3093
+ Mode: conservative
3094
+ AllowedMethods:
3095
+ - call
3096
+ AllowedPatterns: []
3097
+ AllowBangMethods: false
3098
+ # Methods that are known to not return a boolean value, despite ending in `?`.
3099
+ WaywardPredicates:
3100
+ - nonzero?
3101
+
3102
+ Naming/PredicatePrefix:
3103
+ Description: 'Predicate method names should not be prefixed and end with a `?`.'
3051
3104
  StyleGuide: '#bool-methods-qmark'
3052
3105
  Enabled: true
3053
3106
  VersionAdded: '0.50'
@@ -3288,6 +3341,12 @@ Style/ArrayIntersect:
3288
3341
  Safe: false
3289
3342
  VersionAdded: '1.40'
3290
3343
 
3344
+ Style/ArrayIntersectWithSingleElement:
3345
+ Description: 'Use `include?(element)` instead of `intersect?([element])`.'
3346
+ Enabled: 'pending'
3347
+ Safe: false
3348
+ VersionAdded: '1.81'
3349
+
3291
3350
  Style/ArrayJoin:
3292
3351
  Description: 'Use Array#join instead of Array#*.'
3293
3352
  StyleGuide: '#array-join'
@@ -3632,6 +3691,13 @@ Style/CollectionMethods:
3632
3691
  - inject
3633
3692
  - reduce
3634
3693
 
3694
+ Style/CollectionQuerying:
3695
+ Description: 'Prefer `Enumerable` predicate methods over expressions with `count`.'
3696
+ StyleGuide: '#collection-querying'
3697
+ Enabled: pending
3698
+ VersionAdded: '1.77'
3699
+ Safe: false
3700
+
3635
3701
  Style/ColonMethodCall:
3636
3702
  Description: 'Do not use :: for method call.'
3637
3703
  StyleGuide: '#double-colons'
@@ -3939,6 +4005,16 @@ Style/EmptyMethod:
3939
4005
  - compact
3940
4006
  - expanded
3941
4007
 
4008
+ Style/EmptyStringInsideInterpolation:
4009
+ Description: 'Checks for empty strings being assigned inside string interpolation.'
4010
+ StyleGuide: '#empty-strings-in-interpolation'
4011
+ Enabled: pending
4012
+ EnforcedStyle: trailing_conditional
4013
+ SupportedStyles:
4014
+ - trailing_conditional
4015
+ - ternary
4016
+ VersionAdded: '1.76'
4017
+
3942
4018
  Style/Encoding:
3943
4019
  Description: 'Use UTF-8 as the source file encoding.'
3944
4020
  StyleGuide: '#utf-8'
@@ -4023,6 +4099,9 @@ Style/FetchEnvVar:
4023
4099
  VersionAdded: '1.28'
4024
4100
  # Environment variables to be excluded from the inspection.
4025
4101
  AllowedVars: []
4102
+ # When `true`, autocorrects `ENV["key"]` to `ENV.fetch("key", nil)`.
4103
+ # When `false`, autocorrects `ENV["key"]` to `ENV.fetch("key")`.
4104
+ DefaultToNil: true
4026
4105
 
4027
4106
  Style/FileEmpty:
4028
4107
  Description: >-
@@ -4164,7 +4243,7 @@ Style/GlobalVars:
4164
4243
  AllowedVariables: []
4165
4244
 
4166
4245
  Style/GuardClause:
4167
- Description: 'Check for conditionals that can be replaced with guard clauses.'
4246
+ Description: 'Checks for conditionals that can be replaced with guard clauses.'
4168
4247
  StyleGuide: '#no-nested-conditionals'
4169
4248
  Enabled: true
4170
4249
  VersionAdded: '0.20'
@@ -4426,19 +4505,21 @@ Style/IpAddresses:
4426
4505
  - '**/*.gemspec'
4427
4506
 
4428
4507
  Style/ItAssignment:
4429
- Description: 'Checks for assignment to `it` inside a block.'
4508
+ Description: 'Checks for local variables and method parameters named `it`.'
4430
4509
  Enabled: pending
4431
4510
  VersionAdded: '1.70'
4432
4511
 
4433
4512
  Style/ItBlockParameter:
4434
4513
  Description: 'Checks for blocks with one argument where `it` block parameter can be used.'
4435
4514
  Enabled: pending
4436
- EnforcedStyle: only_numbered_parameters
4515
+ EnforcedStyle: allow_single_line
4437
4516
  SupportedStyles:
4517
+ - allow_single_line
4438
4518
  - only_numbered_parameters
4439
4519
  - always
4440
4520
  - disallow
4441
4521
  VersionAdded: '1.75'
4522
+ VersionChanged: '1.76'
4442
4523
 
4443
4524
  Style/KeywordArgumentsMerging:
4444
4525
  Description: >-
@@ -4969,7 +5050,7 @@ Style/OpenStructUse:
4969
5050
  Avoid using OpenStruct. As of Ruby 3.0, use is officially discouraged due to performance,
4970
5051
  version compatibility, and potential security issues.
4971
5052
  References:
4972
- - https://docs.ruby-lang.org/en/3.0.0/OpenStruct.html#class-OpenStruct-label-Caveats
5053
+ - https://docs.ruby-lang.org/en/3.0/OpenStruct.html#class-OpenStruct-label-Caveats
4973
5054
 
4974
5055
  Enabled: pending
4975
5056
  Safe: false
@@ -5125,7 +5206,7 @@ Style/RandomWithOffset:
5125
5206
  VersionAdded: '0.52'
5126
5207
 
5127
5208
  Style/RedundantArgument:
5128
- Description: 'Check for a redundant argument passed to certain methods.'
5209
+ Description: 'Checks for a redundant argument passed to certain methods.'
5129
5210
  Enabled: pending
5130
5211
  Safe: false
5131
5212
  VersionAdded: '1.4'
@@ -5151,6 +5232,12 @@ Style/RedundantArrayConstructor:
5151
5232
  Enabled: pending
5152
5233
  VersionAdded: '1.52'
5153
5234
 
5235
+ Style/RedundantArrayFlatten:
5236
+ Description: 'Checks for redundant calls of `Array#flatten`.'
5237
+ Enabled: pending
5238
+ Safe: false
5239
+ VersionAdded: '1.76'
5240
+
5154
5241
  Style/RedundantAssignment:
5155
5242
  Description: 'Checks for redundant assignment before returning.'
5156
5243
  Enabled: true
@@ -5280,7 +5367,7 @@ Style/RedundantInterpolationUnfreeze:
5280
5367
  VersionAdded: '1.66'
5281
5368
 
5282
5369
  Style/RedundantLineContinuation:
5283
- Description: 'Check for redundant line continuation.'
5370
+ Description: 'Checks for redundant line continuation.'
5284
5371
  Enabled: pending
5285
5372
  VersionAdded: '1.49'
5286
5373
 
@@ -5574,7 +5661,7 @@ Style/SpecialGlobalVars:
5574
5661
  - use_builtin_english_names
5575
5662
 
5576
5663
  Style/StabbyLambdaParentheses:
5577
- Description: 'Check for the usage of parentheses around stabby lambda arguments.'
5664
+ Description: 'Checks for the usage of parentheses around stabby lambda arguments.'
5578
5665
  StyleGuide: '#stabby-lambda-with-args'
5579
5666
  Enabled: true
5580
5667
  VersionAdded: '0.35'
@@ -5763,10 +5850,14 @@ Style/TrailingCommaInArguments:
5763
5850
  # parenthesized method calls where each argument is on its own line.
5764
5851
  # If `consistent_comma`, the cop requires a comma after the last argument,
5765
5852
  # for all parenthesized method calls with arguments.
5853
+ # If `diff_comma`, the cop requires a comma after the last argument, but only
5854
+ # when that argument is followed by an immediate newline, even if
5855
+ # there is an inline comment.
5766
5856
  EnforcedStyleForMultiline: no_comma
5767
5857
  SupportedStylesForMultiline:
5768
5858
  - comma
5769
5859
  - consistent_comma
5860
+ - diff_comma
5770
5861
  - no_comma
5771
5862
 
5772
5863
  Style/TrailingCommaInArrayLiteral:
@@ -31,6 +31,9 @@ renamed:
31
31
  Lint/UnneededRequireStatement: Lint/RedundantRequireStatement
32
32
  Lint/UnneededSplatExpansion: Lint/RedundantSplatExpansion
33
33
  Metrics/LineLength: Layout/LineLength
34
+ Naming/PredicateName:
35
+ new_name: Naming/PredicatePrefix
36
+ severity: warning
34
37
  Naming/UncommunicativeBlockParamName: Naming/BlockParameterName
35
38
  Naming/UncommunicativeMethodParamName: Naming/MethodParameterName
36
39
  Style/AccessorMethodName: Naming/AccessorMethodName
@@ -44,7 +47,7 @@ renamed:
44
47
  Style/MethodName: Naming/MethodName
45
48
  Style/OpMethod: Naming/BinaryOperatorParameterName
46
49
  Style/PredicateName:
47
- new_name: Naming/PredicateName
50
+ new_name: Naming/PredicatePrefix
48
51
  severity: warning
49
52
  Style/SingleSpaceBeforeFirstArg: Layout/SpaceBeforeFirstArg
50
53
  Style/UnneededCapitalW: Style/RedundantCapitalW
@@ -179,10 +182,10 @@ changed_parameters:
179
182
  - cops: Naming/HeredocDelimiterNaming
180
183
  parameters: Blacklist
181
184
  alternative: ForbiddenDelimiters
182
- - cops: Naming/PredicateName
185
+ - cops: Naming/PredicatePrefix
183
186
  parameters: NamePrefixBlacklist
184
187
  alternative: ForbiddenPrefixes
185
- - cops: Naming/PredicateName
188
+ - cops: Naming/PredicatePrefix
186
189
  parameters: NameWhitelist
187
190
  alternative: AllowedMethods
188
191
  - cops:
data/exe/rubocop CHANGED
@@ -12,13 +12,6 @@ if RuboCop::Server.running?
12
12
  exit_status = RuboCop::Server::ClientCommand::Exec.new.run
13
13
  else
14
14
  require 'rubocop'
15
-
16
- cli = RuboCop::CLI.new
17
-
18
- time_start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
19
- exit_status = cli.run
20
- elapsed_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) - time_start
21
-
22
- puts "Finished in #{elapsed_time} seconds" if cli.options[:debug] || cli.options[:display_time]
15
+ exit_status = RuboCop::CLI.new.run
23
16
  end
24
17
  exit exit_status
@@ -83,7 +83,7 @@ module RuboCop
83
83
  execute_runner
84
84
  @options.delete(:only)
85
85
  @config_store = ConfigStore.new
86
- @config_store.options_config = @options[:config] if @options[:config]
86
+ @config_store.apply_options!(@options)
87
87
  # Save the todo configuration of the LineLength cop.
88
88
  File.read(AUTO_GENERATED_FILE).lines.drop_while { |line| line.start_with?('#') }.join
89
89
  end
@@ -99,7 +99,7 @@ module RuboCop
99
99
 
100
100
  def reset_config_and_auto_gen_file
101
101
  @config_store = ConfigStore.new
102
- @config_store.options_config = @options[:config] if @options[:config]
102
+ @config_store.apply_options!(@options)
103
103
  File.open(AUTO_GENERATED_FILE, 'w') {} # create or truncate if exists
104
104
  add_inheritance_from_auto_generated_file(@options[:config])
105
105
  end
data/lib/rubocop/cli.rb CHANGED
@@ -12,7 +12,7 @@ module RuboCop
12
12
  STATUS_INTERRUPTED = Signal.list['INT'] + 128
13
13
  DEFAULT_PARALLEL_OPTIONS = %i[
14
14
  color config debug display_style_guide display_time display_only_fail_level_offenses
15
- display_only_failed editor_mode except extra_details fail_level fix_layout format
15
+ display_only_failed editor_mode except extra_details fail_level fix_layout format formatters
16
16
  ignore_disable_comments lint only only_guide_cops require safe
17
17
  autocorrect safe_autocorrect autocorrect_all
18
18
  ].freeze
@@ -37,6 +37,8 @@ module RuboCop
37
37
  #
38
38
  # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
39
39
  def run(args = ARGV)
40
+ time_start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
41
+
40
42
  @options, paths = Options.new.parse(args)
41
43
  @env = Environment.new(@options, @config_store, paths)
42
44
 
@@ -48,6 +50,7 @@ module RuboCop
48
50
  validate_options_vs_config
49
51
  parallel_by_default!
50
52
  apply_default_formatter
53
+ report_pending_cops
51
54
  execute_runners
52
55
  end
53
56
  end
@@ -71,6 +74,9 @@ module RuboCop
71
74
  warn e.message
72
75
  warn e.backtrace
73
76
  STATUS_ERROR
77
+ ensure
78
+ elapsed_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) - time_start
79
+ puts "Finished in #{elapsed_time} seconds" if @options[:debug] || @options[:display_time]
74
80
  end
75
81
  # rubocop:enable Metrics/MethodLength, Metrics/AbcSize
76
82
 
@@ -155,10 +161,10 @@ module RuboCop
155
161
 
156
162
  def act_on_options
157
163
  set_options_to_config_loader
164
+ set_options_to_pending_cops_reporter
158
165
  handle_editor_mode
159
166
 
160
- @config_store.options_config = @options[:config] if @options[:config]
161
- @config_store.force_default_config! if @options[:force_default_config]
167
+ @config_store.apply_options!(@options)
162
168
 
163
169
  handle_exiting_options
164
170
 
@@ -179,6 +185,11 @@ module RuboCop
179
185
  ConfigLoader.ignore_unrecognized_cops = @options[:ignore_unrecognized_cops]
180
186
  end
181
187
 
188
+ def set_options_to_pending_cops_reporter
189
+ PendingCopsReporter.disable_pending_cops = @options[:disable_pending_cops]
190
+ PendingCopsReporter.enable_pending_cops = @options[:enable_pending_cops]
191
+ end
192
+
182
193
  def handle_editor_mode
183
194
  RuboCop::LSP.enable if @options[:editor_mode]
184
195
  end
@@ -208,5 +219,9 @@ module RuboCop
208
219
  [[formatter, @options[:output_path]]]
209
220
  end
210
221
  end
222
+
223
+ def report_pending_cops
224
+ PendingCopsReporter.warn_if_needed(@config_store.for_pwd)
225
+ end
211
226
  end
212
227
  end