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.
- checksums.yaml +4 -4
- data/README.md +20 -16
- data/config/default.yml +107 -26
- data/config/obsoletion.yml +6 -3
- data/lib/rubocop/cli.rb +12 -1
- data/lib/rubocop/config_loader.rb +1 -38
- data/lib/rubocop/cop/bundler/ordered_gems.rb +1 -1
- data/lib/rubocop/cop/correctors/parentheses_corrector.rb +5 -2
- data/lib/rubocop/cop/gemspec/attribute_assignment.rb +91 -0
- data/lib/rubocop/cop/gemspec/duplicated_assignment.rb +0 -22
- data/lib/rubocop/cop/gemspec/ordered_dependencies.rb +1 -1
- data/lib/rubocop/cop/gemspec/require_mfa.rb +15 -1
- data/lib/rubocop/cop/internal_affairs/example_description.rb +1 -1
- data/lib/rubocop/cop/internal_affairs/node_matcher_directive.rb +4 -4
- data/lib/rubocop/cop/internal_affairs/node_pattern_groups.rb +1 -0
- data/lib/rubocop/cop/internal_affairs/node_type_group.rb +3 -2
- data/lib/rubocop/cop/internal_affairs/useless_restrict_on_send.rb +1 -1
- data/lib/rubocop/cop/layout/closing_parenthesis_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/empty_lines_after_module_inclusion.rb +99 -0
- data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +1 -1
- data/lib/rubocop/cop/layout/line_length.rb +26 -5
- data/lib/rubocop/cop/layout/space_around_keyword.rb +6 -1
- data/lib/rubocop/cop/layout/space_around_operators.rb +8 -0
- data/lib/rubocop/cop/layout/space_before_brackets.rb +2 -9
- data/lib/rubocop/cop/layout/space_inside_array_literal_brackets.rb +7 -2
- data/lib/rubocop/cop/lint/ambiguous_range.rb +5 -0
- data/lib/rubocop/cop/lint/duplicate_methods.rb +25 -4
- data/lib/rubocop/cop/lint/empty_interpolation.rb +3 -1
- data/lib/rubocop/cop/lint/float_comparison.rb +4 -4
- data/lib/rubocop/cop/lint/identity_comparison.rb +19 -15
- data/lib/rubocop/cop/lint/literal_as_condition.rb +34 -28
- data/lib/rubocop/cop/lint/numeric_operation_with_constant_result.rb +1 -0
- data/lib/rubocop/cop/lint/redundant_regexp_quantifiers.rb +1 -1
- data/lib/rubocop/cop/lint/redundant_safe_navigation.rb +101 -2
- data/lib/rubocop/cop/lint/redundant_type_conversion.rb +4 -4
- data/lib/rubocop/cop/lint/require_range_parentheses.rb +1 -1
- data/lib/rubocop/cop/lint/rescue_type.rb +1 -1
- data/lib/rubocop/cop/lint/safe_navigation_chain.rb +4 -4
- data/lib/rubocop/cop/lint/self_assignment.rb +25 -0
- data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +5 -0
- data/lib/rubocop/cop/lint/useless_access_modifier.rb +29 -4
- data/lib/rubocop/cop/lint/useless_default_value_argument.rb +90 -0
- data/lib/rubocop/cop/lint/useless_numeric_operation.rb +1 -0
- data/lib/rubocop/cop/lint/useless_or.rb +98 -0
- data/lib/rubocop/cop/lint/useless_ruby2_keywords.rb +3 -3
- data/lib/rubocop/cop/lint/utils/nil_receiver_checker.rb +121 -0
- data/lib/rubocop/cop/mixin/alignment.rb +1 -1
- data/lib/rubocop/cop/mixin/frozen_string_literal.rb +1 -1
- data/lib/rubocop/cop/mixin/gemspec_help.rb +22 -0
- data/lib/rubocop/cop/mixin/line_length_help.rb +24 -8
- data/lib/rubocop/cop/mixin/ordered_gem_node.rb +1 -1
- data/lib/rubocop/cop/naming/file_name.rb +2 -2
- data/lib/rubocop/cop/naming/method_name.rb +127 -13
- data/lib/rubocop/cop/naming/predicate_method.rb +306 -0
- data/lib/rubocop/cop/naming/{predicate_name.rb → predicate_prefix.rb} +4 -4
- data/lib/rubocop/cop/security/eval.rb +2 -1
- data/lib/rubocop/cop/security/open.rb +1 -0
- data/lib/rubocop/cop/style/access_modifier_declarations.rb +1 -1
- data/lib/rubocop/cop/style/accessor_grouping.rb +13 -1
- data/lib/rubocop/cop/style/arguments_forwarding.rb +11 -17
- data/lib/rubocop/cop/style/array_intersect.rb +53 -23
- data/lib/rubocop/cop/style/block_delimiters.rb +1 -1
- data/lib/rubocop/cop/style/case_like_if.rb +1 -1
- data/lib/rubocop/cop/style/collection_querying.rb +167 -0
- data/lib/rubocop/cop/style/conditional_assignment.rb +4 -2
- data/lib/rubocop/cop/style/dig_chain.rb +1 -1
- data/lib/rubocop/cop/style/empty_string_inside_interpolation.rb +100 -0
- data/lib/rubocop/cop/style/exponential_notation.rb +3 -2
- data/lib/rubocop/cop/style/fetch_env_var.rb +32 -6
- data/lib/rubocop/cop/style/hash_conversion.rb +16 -8
- data/lib/rubocop/cop/style/if_unless_modifier.rb +13 -6
- data/lib/rubocop/cop/style/inverse_methods.rb +1 -1
- data/lib/rubocop/cop/style/it_assignment.rb +69 -12
- data/lib/rubocop/cop/style/it_block_parameter.rb +36 -15
- data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +4 -6
- data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +16 -0
- data/lib/rubocop/cop/style/min_max_comparison.rb +13 -5
- data/lib/rubocop/cop/style/parallel_assignment.rb +32 -20
- data/lib/rubocop/cop/style/redundant_array_flatten.rb +50 -0
- data/lib/rubocop/cop/style/redundant_fetch_block.rb +1 -9
- data/lib/rubocop/cop/style/redundant_freeze.rb +1 -1
- data/lib/rubocop/cop/style/redundant_interpolation.rb +1 -1
- data/lib/rubocop/cop/style/redundant_line_continuation.rb +1 -1
- data/lib/rubocop/cop/style/redundant_parentheses.rb +35 -5
- data/lib/rubocop/cop/style/redundant_self.rb +8 -5
- data/lib/rubocop/cop/style/safe_navigation.rb +24 -11
- data/lib/rubocop/cop/style/single_line_methods.rb +7 -4
- data/lib/rubocop/cop/style/sole_nested_conditional.rb +32 -2
- data/lib/rubocop/cop/style/stabby_lambda_parentheses.rb +1 -1
- data/lib/rubocop/cop/style/symbol_proc.rb +1 -1
- data/lib/rubocop/cop/style/trailing_comma_in_block_args.rb +1 -1
- data/lib/rubocop/cop/variable_force.rb +18 -7
- data/lib/rubocop/cops_documentation_generator.rb +1 -0
- data/lib/rubocop/formatter/fuubar_style_formatter.rb +1 -1
- data/lib/rubocop/formatter/markdown_formatter.rb +1 -0
- data/lib/rubocop/formatter/offense_count_formatter.rb +1 -1
- data/lib/rubocop/formatter/pacman_formatter.rb +1 -0
- data/lib/rubocop/lsp/diagnostic.rb +4 -4
- data/lib/rubocop/lsp/routes.rb +4 -4
- data/lib/rubocop/pending_cops_reporter.rb +56 -0
- data/lib/rubocop/rspec/expect_offense.rb +9 -3
- data/lib/rubocop/server/cache.rb +4 -2
- data/lib/rubocop/server/client_command/base.rb +10 -0
- data/lib/rubocop/server/client_command/exec.rb +2 -1
- data/lib/rubocop/server/client_command/start.rb +11 -1
- data/lib/rubocop/version.rb +1 -1
- data/lib/rubocop.rb +11 -1
- data/lib/ruby_lsp/rubocop/addon.rb +2 -2
- metadata +21 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc8a905ea4a217b5c7a43390a0777107217ce2a1a14b325e5367a4dbafb6cf1d
|
4
|
+
data.tar.gz: 01e471a4471ee7ac1151db63ace049693be1a8008955722b1028843034c00e82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21c054eb2cb142bbf75ed66598252f114e1b759d4a699f6319f804ed761cdf68b51ad75a96c02475b5bafdf5341198684c3764aadd4ccdf256d0509bf207ea0c
|
7
|
+
data.tar.gz: 11c7240440560b7ec024b469634ce3621a0e10363083f5ce2a8bd8d8af9ff5e5c1814a87d320297109534e0c7654c20837f9d4963e9c322e24595d907042f285
|
data/README.md
CHANGED
@@ -6,8 +6,6 @@
|
|
6
6
|
[](https://github.com/rubocop/rubocop)
|
7
7
|
[](https://badge.fury.io/rb/rubocop)
|
8
8
|
[](https://github.com/rubocop/rubocop/actions/workflows/rubocop.yml)
|
9
|
-
[](https://codeclimate.com/github/rubocop/rubocop/test_coverage)
|
10
|
-
[](https://codeclimate.com/github/rubocop/rubocop/maintainability)
|
11
9
|
[](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
|
-
|
37
|
+
gem install rubocop
|
40
38
|
```
|
41
39
|
|
42
|
-
If you'd rather install RuboCop using `bundler`, add a line for it in your
|
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.
|
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
|
-
|
66
|
-
|
63
|
+
```sh
|
64
|
+
cd my/cool/ruby/project
|
65
|
+
rubocop
|
67
66
|
```
|
68
67
|
|
69
|
-
|
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
|
-
|
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
|
[](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
|
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
|
-
|
172
|
-
|
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:
|
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:
|
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: '
|
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: '
|
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: '
|
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: '
|
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: '
|
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: '
|
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: '
|
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: '
|
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: '
|
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: '
|
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: '
|
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.
|
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:
|
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
|
-
-
|
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:
|
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/
|
3050
|
-
Description: '
|
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: '
|
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
|
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:
|
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
|
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: '
|
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: '
|
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: '
|
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'
|
data/config/obsoletion.yml
CHANGED
@@ -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/
|
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/
|
185
|
+
- cops: Naming/PredicatePrefix
|
183
186
|
parameters: NamePrefixBlacklist
|
184
187
|
alternative: ForbiddenPrefixes
|
185
|
-
- cops: Naming/
|
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)
|
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
|
-
|
14
|
-
corrector.remove(node.loc.
|
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)
|