rubocop 1.75.8 → 1.79.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 (109) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +20 -16
  3. data/config/default.yml +107 -26
  4. data/config/obsoletion.yml +6 -3
  5. data/lib/rubocop/cli.rb +12 -1
  6. data/lib/rubocop/config_loader.rb +1 -38
  7. data/lib/rubocop/cop/bundler/ordered_gems.rb +1 -1
  8. data/lib/rubocop/cop/correctors/parentheses_corrector.rb +5 -2
  9. data/lib/rubocop/cop/gemspec/attribute_assignment.rb +91 -0
  10. data/lib/rubocop/cop/gemspec/duplicated_assignment.rb +0 -22
  11. data/lib/rubocop/cop/gemspec/ordered_dependencies.rb +1 -1
  12. data/lib/rubocop/cop/gemspec/require_mfa.rb +15 -1
  13. data/lib/rubocop/cop/internal_affairs/example_description.rb +1 -1
  14. data/lib/rubocop/cop/internal_affairs/node_matcher_directive.rb +4 -4
  15. data/lib/rubocop/cop/internal_affairs/node_pattern_groups.rb +1 -0
  16. data/lib/rubocop/cop/internal_affairs/node_type_group.rb +3 -2
  17. data/lib/rubocop/cop/internal_affairs/useless_restrict_on_send.rb +1 -1
  18. data/lib/rubocop/cop/layout/closing_parenthesis_indentation.rb +1 -1
  19. data/lib/rubocop/cop/layout/empty_lines_after_module_inclusion.rb +99 -0
  20. data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +1 -1
  21. data/lib/rubocop/cop/layout/line_length.rb +26 -5
  22. data/lib/rubocop/cop/layout/space_around_keyword.rb +6 -1
  23. data/lib/rubocop/cop/layout/space_around_operators.rb +8 -0
  24. data/lib/rubocop/cop/layout/space_before_brackets.rb +2 -9
  25. data/lib/rubocop/cop/layout/space_inside_array_literal_brackets.rb +7 -2
  26. data/lib/rubocop/cop/lint/ambiguous_range.rb +5 -0
  27. data/lib/rubocop/cop/lint/duplicate_methods.rb +25 -4
  28. data/lib/rubocop/cop/lint/empty_interpolation.rb +3 -1
  29. data/lib/rubocop/cop/lint/float_comparison.rb +4 -4
  30. data/lib/rubocop/cop/lint/identity_comparison.rb +19 -15
  31. data/lib/rubocop/cop/lint/literal_as_condition.rb +34 -28
  32. data/lib/rubocop/cop/lint/numeric_operation_with_constant_result.rb +1 -0
  33. data/lib/rubocop/cop/lint/redundant_regexp_quantifiers.rb +1 -1
  34. data/lib/rubocop/cop/lint/redundant_safe_navigation.rb +101 -2
  35. data/lib/rubocop/cop/lint/redundant_type_conversion.rb +4 -4
  36. data/lib/rubocop/cop/lint/require_range_parentheses.rb +1 -1
  37. data/lib/rubocop/cop/lint/rescue_type.rb +1 -1
  38. data/lib/rubocop/cop/lint/safe_navigation_chain.rb +4 -4
  39. data/lib/rubocop/cop/lint/self_assignment.rb +25 -0
  40. data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +5 -0
  41. data/lib/rubocop/cop/lint/useless_access_modifier.rb +29 -4
  42. data/lib/rubocop/cop/lint/useless_default_value_argument.rb +90 -0
  43. data/lib/rubocop/cop/lint/useless_numeric_operation.rb +1 -0
  44. data/lib/rubocop/cop/lint/useless_or.rb +98 -0
  45. data/lib/rubocop/cop/lint/useless_ruby2_keywords.rb +3 -3
  46. data/lib/rubocop/cop/lint/utils/nil_receiver_checker.rb +121 -0
  47. data/lib/rubocop/cop/mixin/alignment.rb +1 -1
  48. data/lib/rubocop/cop/mixin/frozen_string_literal.rb +1 -1
  49. data/lib/rubocop/cop/mixin/gemspec_help.rb +22 -0
  50. data/lib/rubocop/cop/mixin/line_length_help.rb +24 -8
  51. data/lib/rubocop/cop/mixin/ordered_gem_node.rb +1 -1
  52. data/lib/rubocop/cop/naming/file_name.rb +2 -2
  53. data/lib/rubocop/cop/naming/method_name.rb +127 -13
  54. data/lib/rubocop/cop/naming/predicate_method.rb +306 -0
  55. data/lib/rubocop/cop/naming/{predicate_name.rb → predicate_prefix.rb} +4 -4
  56. data/lib/rubocop/cop/security/eval.rb +2 -1
  57. data/lib/rubocop/cop/security/open.rb +1 -0
  58. data/lib/rubocop/cop/style/access_modifier_declarations.rb +1 -1
  59. data/lib/rubocop/cop/style/accessor_grouping.rb +13 -1
  60. data/lib/rubocop/cop/style/arguments_forwarding.rb +11 -17
  61. data/lib/rubocop/cop/style/array_intersect.rb +53 -23
  62. data/lib/rubocop/cop/style/block_delimiters.rb +1 -1
  63. data/lib/rubocop/cop/style/case_like_if.rb +1 -1
  64. data/lib/rubocop/cop/style/collection_querying.rb +167 -0
  65. data/lib/rubocop/cop/style/conditional_assignment.rb +4 -2
  66. data/lib/rubocop/cop/style/dig_chain.rb +1 -1
  67. data/lib/rubocop/cop/style/empty_string_inside_interpolation.rb +100 -0
  68. data/lib/rubocop/cop/style/exponential_notation.rb +3 -2
  69. data/lib/rubocop/cop/style/fetch_env_var.rb +32 -6
  70. data/lib/rubocop/cop/style/hash_conversion.rb +16 -8
  71. data/lib/rubocop/cop/style/if_unless_modifier.rb +13 -6
  72. data/lib/rubocop/cop/style/inverse_methods.rb +1 -1
  73. data/lib/rubocop/cop/style/it_assignment.rb +69 -12
  74. data/lib/rubocop/cop/style/it_block_parameter.rb +36 -15
  75. data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +4 -6
  76. data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +16 -0
  77. data/lib/rubocop/cop/style/min_max_comparison.rb +13 -5
  78. data/lib/rubocop/cop/style/parallel_assignment.rb +32 -20
  79. data/lib/rubocop/cop/style/redundant_array_flatten.rb +50 -0
  80. data/lib/rubocop/cop/style/redundant_fetch_block.rb +1 -9
  81. data/lib/rubocop/cop/style/redundant_freeze.rb +1 -1
  82. data/lib/rubocop/cop/style/redundant_interpolation.rb +1 -1
  83. data/lib/rubocop/cop/style/redundant_line_continuation.rb +1 -1
  84. data/lib/rubocop/cop/style/redundant_parentheses.rb +35 -5
  85. data/lib/rubocop/cop/style/redundant_self.rb +8 -5
  86. data/lib/rubocop/cop/style/safe_navigation.rb +24 -11
  87. data/lib/rubocop/cop/style/single_line_methods.rb +7 -4
  88. data/lib/rubocop/cop/style/sole_nested_conditional.rb +32 -2
  89. data/lib/rubocop/cop/style/stabby_lambda_parentheses.rb +1 -1
  90. data/lib/rubocop/cop/style/symbol_proc.rb +1 -1
  91. data/lib/rubocop/cop/style/trailing_comma_in_block_args.rb +1 -1
  92. data/lib/rubocop/cop/variable_force.rb +18 -7
  93. data/lib/rubocop/cops_documentation_generator.rb +1 -0
  94. data/lib/rubocop/formatter/fuubar_style_formatter.rb +1 -1
  95. data/lib/rubocop/formatter/markdown_formatter.rb +1 -0
  96. data/lib/rubocop/formatter/offense_count_formatter.rb +1 -1
  97. data/lib/rubocop/formatter/pacman_formatter.rb +1 -0
  98. data/lib/rubocop/lsp/diagnostic.rb +4 -4
  99. data/lib/rubocop/lsp/routes.rb +4 -4
  100. data/lib/rubocop/pending_cops_reporter.rb +56 -0
  101. data/lib/rubocop/rspec/expect_offense.rb +9 -3
  102. data/lib/rubocop/server/cache.rb +4 -2
  103. data/lib/rubocop/server/client_command/base.rb +10 -0
  104. data/lib/rubocop/server/client_command/exec.rb +2 -1
  105. data/lib/rubocop/server/client_command/start.rb +11 -1
  106. data/lib/rubocop/version.rb +1 -1
  107. data/lib/rubocop.rb +11 -1
  108. data/lib/ruby_lsp/rubocop/addon.rb +2 -2
  109. metadata +21 -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: dc8a905ea4a217b5c7a43390a0777107217ce2a1a14b325e5367a4dbafb6cf1d
4
+ data.tar.gz: 01e471a4471ee7ac1151db63ace049693be1a8008955722b1028843034c00e82
5
5
  SHA512:
6
- metadata.gz: ef0ab376b3993e9ad1961560911ed5b5e2abf069a2b9acd0187e3d31c03f853a520646f2c421813bc3c03aedd74004dcf057cbadecad0ea86acafbd6670c8e46
7
- data.tar.gz: b76bd8b4d7492577429bab8abd02ebcf7f2d9d2f83066e81c48b060abcaad68a2660b064c1f5b0b9c42bc80cc78ce15cd6e10ace393cd636310055515af925db
6
+ metadata.gz: 21c054eb2cb142bbf75ed66598252f114e1b759d4a699f6319f804ed761cdf68b51ad75a96c02475b5bafdf5341198684c3764aadd4ccdf256d0509bf207ea0c
7
+ data.tar.gz: 11c7240440560b7ec024b469634ce3621a0e10363083f5ce2a8bd8d8af9ff5e5c1814a87d320297109534e0c7654c20837f9d4963e9c322e24595d907042f285
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.79', 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'
@@ -3632,6 +3685,13 @@ Style/CollectionMethods:
3632
3685
  - inject
3633
3686
  - reduce
3634
3687
 
3688
+ Style/CollectionQuerying:
3689
+ Description: 'Prefer `Enumerable` predicate methods over expressions with `count`.'
3690
+ StyleGuide: '#collection-querying'
3691
+ Enabled: pending
3692
+ VersionAdded: '1.77'
3693
+ Safe: false
3694
+
3635
3695
  Style/ColonMethodCall:
3636
3696
  Description: 'Do not use :: for method call.'
3637
3697
  StyleGuide: '#double-colons'
@@ -3939,6 +3999,16 @@ Style/EmptyMethod:
3939
3999
  - compact
3940
4000
  - expanded
3941
4001
 
4002
+ Style/EmptyStringInsideInterpolation:
4003
+ Description: 'Checks for empty strings being assigned inside string interpolation.'
4004
+ StyleGuide: '#empty-strings-in-interpolation'
4005
+ Enabled: pending
4006
+ EnforcedStyle: trailing_conditional
4007
+ SupportedStyles:
4008
+ - trailing_conditional
4009
+ - ternary
4010
+ VersionAdded: '1.76'
4011
+
3942
4012
  Style/Encoding:
3943
4013
  Description: 'Use UTF-8 as the source file encoding.'
3944
4014
  StyleGuide: '#utf-8'
@@ -4023,6 +4093,9 @@ Style/FetchEnvVar:
4023
4093
  VersionAdded: '1.28'
4024
4094
  # Environment variables to be excluded from the inspection.
4025
4095
  AllowedVars: []
4096
+ # When `true`, autocorrects `ENV["key"]` to `ENV.fetch("key", nil)`.
4097
+ # When `false`, autocorrects `ENV["key"]` to `ENV.fetch("key")`.
4098
+ DefaultToNil: true
4026
4099
 
4027
4100
  Style/FileEmpty:
4028
4101
  Description: >-
@@ -4164,7 +4237,7 @@ Style/GlobalVars:
4164
4237
  AllowedVariables: []
4165
4238
 
4166
4239
  Style/GuardClause:
4167
- Description: 'Check for conditionals that can be replaced with guard clauses.'
4240
+ Description: 'Checks for conditionals that can be replaced with guard clauses.'
4168
4241
  StyleGuide: '#no-nested-conditionals'
4169
4242
  Enabled: true
4170
4243
  VersionAdded: '0.20'
@@ -4426,19 +4499,21 @@ Style/IpAddresses:
4426
4499
  - '**/*.gemspec'
4427
4500
 
4428
4501
  Style/ItAssignment:
4429
- Description: 'Checks for assignment to `it` inside a block.'
4502
+ Description: 'Checks for local variables and method parameters named `it`.'
4430
4503
  Enabled: pending
4431
4504
  VersionAdded: '1.70'
4432
4505
 
4433
4506
  Style/ItBlockParameter:
4434
4507
  Description: 'Checks for blocks with one argument where `it` block parameter can be used.'
4435
4508
  Enabled: pending
4436
- EnforcedStyle: only_numbered_parameters
4509
+ EnforcedStyle: allow_single_line
4437
4510
  SupportedStyles:
4511
+ - allow_single_line
4438
4512
  - only_numbered_parameters
4439
4513
  - always
4440
4514
  - disallow
4441
4515
  VersionAdded: '1.75'
4516
+ VersionChanged: '1.76'
4442
4517
 
4443
4518
  Style/KeywordArgumentsMerging:
4444
4519
  Description: >-
@@ -4969,7 +5044,7 @@ Style/OpenStructUse:
4969
5044
  Avoid using OpenStruct. As of Ruby 3.0, use is officially discouraged due to performance,
4970
5045
  version compatibility, and potential security issues.
4971
5046
  References:
4972
- - https://docs.ruby-lang.org/en/3.0.0/OpenStruct.html#class-OpenStruct-label-Caveats
5047
+ - https://docs.ruby-lang.org/en/3.0/OpenStruct.html#class-OpenStruct-label-Caveats
4973
5048
 
4974
5049
  Enabled: pending
4975
5050
  Safe: false
@@ -5125,7 +5200,7 @@ Style/RandomWithOffset:
5125
5200
  VersionAdded: '0.52'
5126
5201
 
5127
5202
  Style/RedundantArgument:
5128
- Description: 'Check for a redundant argument passed to certain methods.'
5203
+ Description: 'Checks for a redundant argument passed to certain methods.'
5129
5204
  Enabled: pending
5130
5205
  Safe: false
5131
5206
  VersionAdded: '1.4'
@@ -5151,6 +5226,12 @@ Style/RedundantArrayConstructor:
5151
5226
  Enabled: pending
5152
5227
  VersionAdded: '1.52'
5153
5228
 
5229
+ Style/RedundantArrayFlatten:
5230
+ Description: 'Checks for redundant calls of `Array#flatten`.'
5231
+ Enabled: pending
5232
+ Safe: false
5233
+ VersionAdded: '1.76'
5234
+
5154
5235
  Style/RedundantAssignment:
5155
5236
  Description: 'Checks for redundant assignment before returning.'
5156
5237
  Enabled: true
@@ -5280,7 +5361,7 @@ Style/RedundantInterpolationUnfreeze:
5280
5361
  VersionAdded: '1.66'
5281
5362
 
5282
5363
  Style/RedundantLineContinuation:
5283
- Description: 'Check for redundant line continuation.'
5364
+ Description: 'Checks for redundant line continuation.'
5284
5365
  Enabled: pending
5285
5366
  VersionAdded: '1.49'
5286
5367
 
@@ -5574,7 +5655,7 @@ Style/SpecialGlobalVars:
5574
5655
  - use_builtin_english_names
5575
5656
 
5576
5657
  Style/StabbyLambdaParentheses:
5577
- Description: 'Check for the usage of parentheses around stabby lambda arguments.'
5658
+ Description: 'Checks for the usage of parentheses around stabby lambda arguments.'
5578
5659
  StyleGuide: '#stabby-lambda-with-args'
5579
5660
  Enabled: true
5580
5661
  VersionAdded: '0.35'
@@ -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/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
@@ -48,6 +48,7 @@ module RuboCop
48
48
  validate_options_vs_config
49
49
  parallel_by_default!
50
50
  apply_default_formatter
51
+ report_pending_cops
51
52
  execute_runners
52
53
  end
53
54
  end
@@ -155,6 +156,7 @@ module RuboCop
155
156
 
156
157
  def act_on_options
157
158
  set_options_to_config_loader
159
+ set_options_to_pending_cops_reporter
158
160
  handle_editor_mode
159
161
 
160
162
  @config_store.options_config = @options[:config] if @options[:config]
@@ -179,6 +181,11 @@ module RuboCop
179
181
  ConfigLoader.ignore_unrecognized_cops = @options[:ignore_unrecognized_cops]
180
182
  end
181
183
 
184
+ def set_options_to_pending_cops_reporter
185
+ PendingCopsReporter.disable_pending_cops = @options[:disable_pending_cops]
186
+ PendingCopsReporter.enable_pending_cops = @options[:enable_pending_cops]
187
+ end
188
+
182
189
  def handle_editor_mode
183
190
  RuboCop::LSP.enable if @options[:editor_mode]
184
191
  end
@@ -208,5 +215,9 @@ module RuboCop
208
215
  [[formatter, @options[:output_path]]]
209
216
  end
210
217
  end
218
+
219
+ def report_pending_cops
220
+ PendingCopsReporter.warn_if_needed(@config_store.for_pwd)
221
+ end
211
222
  end
212
223
  end
@@ -22,14 +22,6 @@ module RuboCop
22
22
  class << self
23
23
  include FileFinder
24
24
 
25
- PENDING_BANNER = <<~BANNER
26
- The following cops were added to RuboCop, but are not configured. Please set Enabled to either `true` or `false` in your `.rubocop.yml` file.
27
-
28
- Please also note that you can opt-in to new cops by default by adding this to your config:
29
- AllCops:
30
- NewCops: enable
31
- BANNER
32
-
33
25
  attr_accessor :debug, :ignore_parent_exclusion, :disable_pending_cops, :enable_pending_cops,
34
26
  :ignore_unrecognized_cops
35
27
  attr_writer :default_configuration
@@ -132,21 +124,7 @@ module RuboCop
132
124
  add_excludes_from_files(config, config_file)
133
125
  end
134
126
 
135
- merge_with_default(config, config_file).tap do |merged_config|
136
- unless possible_new_cops?(merged_config)
137
- pending_cops = pending_cops_only_qualified(merged_config.pending_cops)
138
- warn_on_pending_cops(pending_cops) unless pending_cops.empty?
139
- end
140
- end
141
- end
142
-
143
- def pending_cops_only_qualified(pending_cops)
144
- pending_cops.select { |cop| Cop::Registry.qualified_cop?(cop.name) }
145
- end
146
-
147
- def possible_new_cops?(config)
148
- disable_pending_cops || enable_pending_cops ||
149
- config.disabled_new_cops? || config.enabled_new_cops?
127
+ merge_with_default(config, config_file)
150
128
  end
151
129
 
152
130
  def add_excludes_from_files(config, config_file)
@@ -208,21 +186,6 @@ module RuboCop
208
186
  ConfigFinder.project_root
209
187
  end
210
188
 
211
- def warn_on_pending_cops(pending_cops)
212
- warn Rainbow(PENDING_BANNER).yellow
213
-
214
- pending_cops.each { |cop| warn_pending_cop cop }
215
-
216
- warn Rainbow('For more information: https://docs.rubocop.org/rubocop/versioning.html').yellow
217
- end
218
-
219
- def warn_pending_cop(cop)
220
- version = cop.metadata['VersionAdded'] || 'N/A'
221
-
222
- warn Rainbow("#{cop.name}: # new in #{version}").yellow
223
- warn Rainbow(' Enabled: true').yellow
224
- end
225
-
226
189
  # Merges the given configuration with the default one.
227
190
  def merge_with_default(config, config_file, unset_nil: true)
228
191
  resolver.merge_with_default(config, config_file, unset_nil: unset_nil)
@@ -45,7 +45,7 @@ module RuboCop
45
45
 
46
46
  gem_declarations(processed_source.ast)
47
47
  .each_cons(2) do |previous, current|
48
- next unless consecutive_lines(previous, current)
48
+ next unless consecutive_lines?(previous, current)
49
49
  next unless case_insensitive_out_of_order?(gem_name(current), gem_name(previous))
50
50
 
51
51
  register_offense(previous, current)
@@ -10,8 +10,11 @@ module RuboCop
10
10
  COMMA_REGEXP = /(?<=\))\s*,/.freeze
11
11
 
12
12
  def correct(corrector, node)
13
- corrector.remove(node.loc.begin)
14
- corrector.remove(node.loc.end)
13
+ buffer = node.source_range.source_buffer
14
+ corrector.remove(range_with_surrounding_space(range: node.loc.begin, buffer: buffer,
15
+ side: :right, whitespace: true))
16
+ corrector.remove(range_with_surrounding_space(range: node.loc.end, buffer: buffer,
17
+ side: :left))
15
18
  handle_orphaned_comma(corrector, node)
16
19
 
17
20
  return unless ternary_condition?(node) && next_char_is_question_mark?(node)