rubocop 1.2.0 → 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +16 -10
- data/config/default.yml +84 -13
- data/lib/rubocop.rb +5 -0
- data/lib/rubocop/cli/command/execute_runner.rb +26 -11
- data/lib/rubocop/config_loader.rb +14 -5
- data/lib/rubocop/config_regeneration.rb +1 -1
- data/lib/rubocop/cop/autocorrect_logic.rb +21 -6
- data/lib/rubocop/cop/bundler/duplicated_gem.rb +3 -3
- data/lib/rubocop/cop/bundler/gem_comment.rb +1 -1
- data/lib/rubocop/cop/commissioner.rb +1 -1
- data/lib/rubocop/cop/correctors/percent_literal_corrector.rb +1 -1
- data/lib/rubocop/cop/gemspec/duplicated_assignment.rb +3 -3
- data/lib/rubocop/cop/gemspec/required_ruby_version.rb +4 -5
- data/lib/rubocop/cop/gemspec/ruby_version_globals_usage.rb +1 -1
- data/lib/rubocop/cop/generator.rb +2 -9
- data/lib/rubocop/cop/generator/configuration_injector.rb +1 -1
- data/lib/rubocop/cop/internal_affairs/useless_message_assertion.rb +1 -1
- data/lib/rubocop/cop/layout/block_alignment.rb +3 -4
- data/lib/rubocop/cop/layout/class_structure.rb +15 -3
- data/lib/rubocop/cop/layout/empty_line_between_defs.rb +80 -10
- data/lib/rubocop/cop/layout/line_length.rb +8 -1
- data/lib/rubocop/cop/layout/space_around_method_call_operator.rb +1 -1
- data/lib/rubocop/cop/lint/ambiguous_regexp_literal.rb +2 -1
- data/lib/rubocop/cop/lint/constant_definition_in_block.rb +26 -2
- data/lib/rubocop/cop/lint/debugger.rb +17 -27
- data/lib/rubocop/cop/lint/duplicate_branch.rb +93 -0
- data/lib/rubocop/cop/lint/duplicate_case_condition.rb +2 -12
- data/lib/rubocop/cop/lint/empty_block.rb +23 -0
- data/lib/rubocop/cop/lint/empty_class.rb +93 -0
- data/lib/rubocop/cop/lint/literal_in_interpolation.rb +22 -4
- data/lib/rubocop/cop/lint/loop.rb +4 -0
- data/lib/rubocop/cop/lint/missing_super.rb +7 -4
- data/lib/rubocop/cop/lint/redundant_cop_enable_directive.rb +19 -16
- data/lib/rubocop/cop/lint/shadowed_exception.rb +4 -5
- data/lib/rubocop/cop/lint/to_enum_arguments.rb +6 -15
- data/lib/rubocop/cop/lint/unmodified_reduce_accumulator.rb +17 -6
- data/lib/rubocop/cop/lint/useless_method_definition.rb +2 -4
- data/lib/rubocop/cop/metrics/method_length.rb +1 -1
- data/lib/rubocop/cop/mixin/check_line_breakable.rb +1 -1
- data/lib/rubocop/cop/mixin/configurable_numbering.rb +4 -3
- data/lib/rubocop/cop/mixin/enforce_superclass.rb +9 -1
- data/lib/rubocop/cop/mixin/multiline_expression_indentation.rb +1 -1
- data/lib/rubocop/cop/mixin/statement_modifier.rb +9 -4
- data/lib/rubocop/cop/mixin/visibility_help.rb +1 -3
- data/lib/rubocop/cop/naming/variable_number.rb +16 -0
- data/lib/rubocop/cop/style/and_or.rb +1 -3
- data/lib/rubocop/cop/style/collection_compact.rb +6 -0
- data/lib/rubocop/cop/style/document_dynamic_eval_definition.rb +107 -5
- data/lib/rubocop/cop/style/documentation.rb +12 -1
- data/lib/rubocop/cop/style/format_string.rb +8 -3
- data/lib/rubocop/cop/style/identical_conditional_branches.rb +7 -2
- data/lib/rubocop/cop/style/if_inside_else.rb +37 -1
- data/lib/rubocop/cop/style/if_unless_modifier.rb +7 -3
- data/lib/rubocop/cop/style/infinite_loop.rb +4 -0
- data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +2 -2
- data/lib/rubocop/cop/style/multiple_comparison.rb +3 -2
- data/lib/rubocop/cop/style/negated_if_else_condition.rb +10 -3
- data/lib/rubocop/cop/style/nil_lambda.rb +52 -0
- data/lib/rubocop/cop/style/redundant_argument.rb +75 -0
- data/lib/rubocop/cop/style/static_class.rb +97 -0
- data/lib/rubocop/cop/style/while_until_modifier.rb +9 -0
- data/lib/rubocop/cop/util.rb +1 -1
- data/lib/rubocop/cop/variable_force/branch.rb +1 -1
- data/lib/rubocop/cop/variable_force/scope.rb +1 -1
- data/lib/rubocop/formatter/disabled_config_formatter.rb +21 -6
- data/lib/rubocop/options.rb +5 -0
- data/lib/rubocop/rake_task.rb +2 -2
- data/lib/rubocop/runner.rb +1 -1
- data/lib/rubocop/target_finder.rb +1 -1
- data/lib/rubocop/target_ruby.rb +65 -1
- data/lib/rubocop/version.rb +1 -1
- metadata +10 -8
- data/bin/console +0 -10
- data/bin/rubocop-profile +0 -32
- data/bin/setup +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea427ad9cf52b48c6d81ea6b730474acccb359cef988e0e00020a358f1e4662e
|
4
|
+
data.tar.gz: fb7383af86d50886bef707d52c835e0af030f002cbd22f0864fab28494f0f592
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b35dbc1cb654f63c19fe863c6e1cc64778a94ac3b961505a565fa8202c20ea8a45a75347c8166456a5e5d420072c30516a51f31c0b76c456ecd53eade62d743
|
7
|
+
data.tar.gz: aa36afc87c4bef92a5032e26c81a31c6a26623f1257180b55db693cd56f2926130639b99220786c6f7708db374ab57eff90d280aa0d4519c7d9c651059efe95b
|
data/README.md
CHANGED
@@ -11,11 +11,6 @@
|
|
11
11
|
[![Maintainability](https://api.codeclimate.com/v1/badges/d2d67f728e88ea84ac69/maintainability)](https://codeclimate.com/github/rubocop-hq/rubocop/maintainability)
|
12
12
|
[![SemVer](https://api.dependabot.com/badges/compatibility_score?dependency-name=rubocop&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=rubocop&package-manager=bundler&version-scheme=semver)
|
13
13
|
|
14
|
-
[![Patreon](https://img.shields.io/badge/patreon-donate-orange.svg)](https://www.patreon.com/bbatsov)
|
15
|
-
[![OpenCollective](https://opencollective.com/rubocop/backers/badge.svg)](#open-collective-backers)
|
16
|
-
[![OpenCollective](https://opencollective.com/rubocop/sponsors/badge.svg)](#open-collective-sponsors)
|
17
|
-
[![Tidelift](https://tidelift.com/badges/package/rubygems/rubocop)](https://tidelift.com/subscription/pkg/rubygems-rubocop?utm_source=rubygems-rubocop&utm_medium=referral&utm_campaign=readme)
|
18
|
-
|
19
14
|
> Role models are important. <br/>
|
20
15
|
> -- Officer Alex J. Murphy / RoboCop
|
21
16
|
|
@@ -27,6 +22,12 @@ RuboCop can also automatically fix many of them for you.
|
|
27
22
|
RuboCop is extremely flexible and most aspects of its behavior can be tweaked via various
|
28
23
|
[configuration options](https://github.com/rubocop-hq/rubocop/blob/master/config/default.yml).
|
29
24
|
|
25
|
+
----------
|
26
|
+
[![Patreon](https://img.shields.io/badge/patreon-donate-orange.svg)](https://www.patreon.com/bbatsov)
|
27
|
+
[![OpenCollective](https://opencollective.com/rubocop/backers/badge.svg)](#open-collective-backers)
|
28
|
+
[![OpenCollective](https://opencollective.com/rubocop/sponsors/badge.svg)](#open-collective-sponsors)
|
29
|
+
[![Tidelift](https://tidelift.com/badges/package/rubygems/rubocop)](https://tidelift.com/subscription/pkg/rubygems-rubocop?utm_source=rubygems-rubocop&utm_medium=referral&utm_campaign=readme)
|
30
|
+
|
30
31
|
**Please consider [financially supporting its ongoing development](#funding).**
|
31
32
|
|
32
33
|
## Installation
|
@@ -50,7 +51,7 @@ To prevent an unwanted RuboCop update you might want to use a conservative versi
|
|
50
51
|
in your `Gemfile`:
|
51
52
|
|
52
53
|
```rb
|
53
|
-
gem 'rubocop', '~> 1.
|
54
|
+
gem 'rubocop', '~> 1.4', require: false
|
54
55
|
```
|
55
56
|
|
56
57
|
See [versioning](https://docs.rubocop.org/rubocop/1.0/versioning.html) for further details.
|
@@ -150,14 +151,19 @@ wide array of funding channels to account for your preferences
|
|
150
151
|
currently [Open Collective](https://opencollective.com/rubocop) is our
|
151
152
|
preferred funding platform).
|
152
153
|
|
153
|
-
If you're working in a company that's making significant use of RuboCop we'd appreciate it if you suggest to your company
|
154
|
-
to become a RuboCop sponsor
|
154
|
+
**If you're working in a company that's making significant use of RuboCop we'd appreciate it if you suggest to your company
|
155
|
+
to become a RuboCop sponsor.**
|
155
156
|
|
156
157
|
You can support the development of RuboCop via
|
157
158
|
[GitHub Sponsors](https://github.com/sponsors/bbatsov),
|
158
159
|
[Patreon](https://www.patreon.com/bbatsov),
|
159
|
-
[PayPal](https://paypal.me/bbatsov)
|
160
|
-
|
160
|
+
[PayPal](https://paypal.me/bbatsov),
|
161
|
+
[Open Collective](https://opencollective.com/rubocop)
|
162
|
+
and [Tidelift](https://tidelift.com/subscription/pkg/rubygems-rubocop?utm_source=rubygems-rubocop&utm_medium=referral&utm_campaign=readme)
|
163
|
+
.
|
164
|
+
|
165
|
+
**Note:** If doing a sponsorship in the form of donation is problematic for your company from an accounting standpoint, we'd recommend
|
166
|
+
the use of Tidelift, where you can get a support-like subscription instead.
|
161
167
|
|
162
168
|
### Open Collective Backers
|
163
169
|
|
data/config/default.yml
CHANGED
@@ -459,10 +459,14 @@ Layout/EmptyLineAfterMultilineCondition:
|
|
459
459
|
- https://github.com/airbnb/ruby#multiline-if-newline
|
460
460
|
|
461
461
|
Layout/EmptyLineBetweenDefs:
|
462
|
-
Description: 'Use empty lines between defs.'
|
462
|
+
Description: 'Use empty lines between class/module/method defs.'
|
463
463
|
StyleGuide: '#empty-lines-between-methods'
|
464
464
|
Enabled: true
|
465
465
|
VersionAdded: '0.49'
|
466
|
+
VersionChanged: '1.4'
|
467
|
+
EmptyLineBetweenMethodDefs: true
|
468
|
+
EmptyLineBetweenClassDefs: true
|
469
|
+
EmptyLineBetweenModuleDefs: true
|
466
470
|
# If `true`, this parameter means that single line method definitions don't
|
467
471
|
# need an empty line between them.
|
468
472
|
AllowAdjacentOneLineDefs: false
|
@@ -891,8 +895,8 @@ Layout/LineLength:
|
|
891
895
|
StyleGuide: '#max-line-length'
|
892
896
|
Enabled: true
|
893
897
|
VersionAdded: '0.25'
|
894
|
-
VersionChanged: '
|
895
|
-
AutoCorrect:
|
898
|
+
VersionChanged: '1.4'
|
899
|
+
AutoCorrect: true
|
896
900
|
Max: 120
|
897
901
|
# To make it possible to copy or click on URIs in the code, we allow lines
|
898
902
|
# containing a URI to be longer than Max.
|
@@ -1176,7 +1180,7 @@ Layout/SpaceBeforeBlockBraces:
|
|
1176
1180
|
SupportedStylesForEmptyBraces:
|
1177
1181
|
- space
|
1178
1182
|
- no_space
|
1179
|
-
VersionChanged: '0.52
|
1183
|
+
VersionChanged: '0.52'
|
1180
1184
|
|
1181
1185
|
Layout/SpaceBeforeComma:
|
1182
1186
|
Description: 'No spaces before commas.'
|
@@ -1400,6 +1404,11 @@ Lint/ConstantDefinitionInBlock:
|
|
1400
1404
|
StyleGuide: '#no-constant-definition-in-block'
|
1401
1405
|
Enabled: true
|
1402
1406
|
VersionAdded: '0.91'
|
1407
|
+
VersionChanged: '1.3'
|
1408
|
+
# `enums` for Typed Enums via T::Enum in Sorbet.
|
1409
|
+
# https://sorbet.org/docs/tenum
|
1410
|
+
AllowedMethods:
|
1411
|
+
- enums
|
1403
1412
|
|
1404
1413
|
Lint/ConstantResolution:
|
1405
1414
|
Description: 'Check that constants are fully qualified with `::`.'
|
@@ -1415,6 +1424,22 @@ Lint/Debugger:
|
|
1415
1424
|
Enabled: true
|
1416
1425
|
VersionAdded: '0.14'
|
1417
1426
|
VersionChanged: '0.49'
|
1427
|
+
DebuggerReceivers:
|
1428
|
+
- binding
|
1429
|
+
- Kernel
|
1430
|
+
- Pry
|
1431
|
+
DebuggerMethods:
|
1432
|
+
- debugger
|
1433
|
+
- byebug
|
1434
|
+
- remote_byebug
|
1435
|
+
- pry
|
1436
|
+
- remote_pry
|
1437
|
+
- pry_remote
|
1438
|
+
- console
|
1439
|
+
- rescue
|
1440
|
+
- save_and_open_page
|
1441
|
+
- save_and_open_screenshot
|
1442
|
+
- irb
|
1418
1443
|
|
1419
1444
|
Lint/DeprecatedClassMethods:
|
1420
1445
|
Description: 'Check for deprecated class method calls.'
|
@@ -1433,6 +1458,11 @@ Lint/DisjunctiveAssignmentInConstructor:
|
|
1433
1458
|
VersionAdded: '0.62'
|
1434
1459
|
VersionChanged: '0.88'
|
1435
1460
|
|
1461
|
+
Lint/DuplicateBranch:
|
1462
|
+
Description: Checks that there are no repeated bodies within `if/unless`, `case-when` and `rescue` constructs.
|
1463
|
+
Enabled: pending
|
1464
|
+
VersionAdded: '1.3'
|
1465
|
+
|
1436
1466
|
Lint/DuplicateCaseCondition:
|
1437
1467
|
Description: 'Do not repeat values in case conditionals.'
|
1438
1468
|
Enabled: true
|
@@ -1484,7 +1514,15 @@ Lint/EmptyBlock:
|
|
1484
1514
|
Description: 'This cop checks for blocks without a body.'
|
1485
1515
|
Enabled: pending
|
1486
1516
|
VersionAdded: '1.1'
|
1517
|
+
VersionChanged: '1.3'
|
1487
1518
|
AllowComments: true
|
1519
|
+
AllowEmptyLambdas: true
|
1520
|
+
|
1521
|
+
Lint/EmptyClass:
|
1522
|
+
Description: 'Checks for classes and metaclasses without a body.'
|
1523
|
+
Enabled: pending
|
1524
|
+
VersionAdded: '1.3'
|
1525
|
+
AllowComments: false
|
1488
1526
|
|
1489
1527
|
Lint/EmptyConditionalBody:
|
1490
1528
|
Description: 'This cop checks for the presence of `if`, `elsif` and `unless` branches without a body.'
|
@@ -1628,7 +1666,8 @@ Lint/Loop:
|
|
1628
1666
|
StyleGuide: '#loop-with-break'
|
1629
1667
|
Enabled: true
|
1630
1668
|
VersionAdded: '0.9'
|
1631
|
-
VersionChanged: '
|
1669
|
+
VersionChanged: '1.3'
|
1670
|
+
Safe: false
|
1632
1671
|
|
1633
1672
|
Lint/MissingCopEnableDirective:
|
1634
1673
|
Description: 'Checks for a `# rubocop:enable` after `# rubocop:disable`.'
|
@@ -1649,6 +1688,7 @@ Lint/MissingSuper:
|
|
1649
1688
|
without calls to `super`'.
|
1650
1689
|
Enabled: true
|
1651
1690
|
VersionAdded: '0.89'
|
1691
|
+
VersionChanged: '1.4'
|
1652
1692
|
|
1653
1693
|
Lint/MixedRegexpCaptureTypes:
|
1654
1694
|
Description: 'Do not mix named captures and numbered captures in a Regexp literal.'
|
@@ -1830,7 +1870,7 @@ Lint/RescueException:
|
|
1830
1870
|
StyleGuide: '#no-blind-rescues'
|
1831
1871
|
Enabled: true
|
1832
1872
|
VersionAdded: '0.9'
|
1833
|
-
VersionChanged: '0.27
|
1873
|
+
VersionChanged: '0.27'
|
1834
1874
|
|
1835
1875
|
Lint/RescueType:
|
1836
1876
|
Description: 'Avoid rescuing from non constants that could result in a `TypeError`.'
|
@@ -2416,7 +2456,7 @@ Naming/VariableNumber:
|
|
2416
2456
|
StyleGuide: '#snake-case-symbols-methods-vars-with-numbers'
|
2417
2457
|
Enabled: true
|
2418
2458
|
VersionAdded: '0.50'
|
2419
|
-
VersionChanged: '1.
|
2459
|
+
VersionChanged: '1.4'
|
2420
2460
|
EnforcedStyle: normalcase
|
2421
2461
|
SupportedStyles:
|
2422
2462
|
- snake_case
|
@@ -2424,6 +2464,7 @@ Naming/VariableNumber:
|
|
2424
2464
|
- non_integer
|
2425
2465
|
CheckMethodNames: true
|
2426
2466
|
CheckSymbols: true
|
2467
|
+
AllowedIdentifiers: []
|
2427
2468
|
|
2428
2469
|
#################### Security ##############################
|
2429
2470
|
|
@@ -2805,7 +2846,9 @@ Style/ClassVars:
|
|
2805
2846
|
Style/CollectionCompact:
|
2806
2847
|
Description: 'Use `{Array,Hash}#{compact,compact!}` instead of custom logic to reject nils.'
|
2807
2848
|
Enabled: pending
|
2849
|
+
Safe: false
|
2808
2850
|
VersionAdded: '1.2'
|
2851
|
+
VersionChanged: '1.3'
|
2809
2852
|
|
2810
2853
|
# Align with the style guide.
|
2811
2854
|
Style/CollectionMethods:
|
@@ -2870,17 +2913,18 @@ Style/CommandLiteral:
|
|
2870
2913
|
Style/CommentAnnotation:
|
2871
2914
|
Description: >-
|
2872
2915
|
Checks formatting of special comments
|
2873
|
-
(TODO, FIXME, OPTIMIZE, HACK, REVIEW).
|
2916
|
+
(TODO, FIXME, OPTIMIZE, HACK, REVIEW, NOTE).
|
2874
2917
|
StyleGuide: '#annotate-keywords'
|
2875
2918
|
Enabled: true
|
2876
2919
|
VersionAdded: '0.10'
|
2877
|
-
VersionChanged: '
|
2920
|
+
VersionChanged: '1.3'
|
2878
2921
|
Keywords:
|
2879
2922
|
- TODO
|
2880
2923
|
- FIXME
|
2881
2924
|
- OPTIMIZE
|
2882
2925
|
- HACK
|
2883
2926
|
- REVIEW
|
2927
|
+
- NOTE
|
2884
2928
|
|
2885
2929
|
Style/CommentedKeyword:
|
2886
2930
|
Description: 'Do not place comments on the same line as certain keywords.'
|
@@ -2976,6 +3020,7 @@ Style/DocumentDynamicEvalDefinition:
|
|
2976
3020
|
StyleGuide: '#eval-comment-docs'
|
2977
3021
|
Enabled: pending
|
2978
3022
|
VersionAdded: '1.1'
|
3023
|
+
VersionChanged: '1.3'
|
2979
3024
|
|
2980
3025
|
Style/Documentation:
|
2981
3026
|
Description: 'Document classes and non-namespace modules.'
|
@@ -3303,6 +3348,7 @@ Style/IfInsideElse:
|
|
3303
3348
|
Enabled: true
|
3304
3349
|
AllowIfModifier: false
|
3305
3350
|
VersionAdded: '0.36'
|
3351
|
+
VersionChanged: '1.3'
|
3306
3352
|
|
3307
3353
|
Style/IfUnlessModifier:
|
3308
3354
|
Description: >-
|
@@ -3335,12 +3381,14 @@ Style/ImplicitRuntimeError:
|
|
3335
3381
|
VersionAdded: '0.41'
|
3336
3382
|
|
3337
3383
|
Style/InfiniteLoop:
|
3338
|
-
Description:
|
3384
|
+
Description: >-
|
3385
|
+
Use Kernel#loop for infinite loops.
|
3386
|
+
This cop is unsafe in the body may raise a `StopIteration` exception.
|
3387
|
+
Safe: false
|
3339
3388
|
StyleGuide: '#infinite-loop'
|
3340
3389
|
Enabled: true
|
3341
3390
|
VersionAdded: '0.26'
|
3342
3391
|
VersionChanged: '0.61'
|
3343
|
-
SafeAutoCorrect: true
|
3344
3392
|
|
3345
3393
|
Style/InlineComment:
|
3346
3394
|
Description: 'Avoid trailing inline comments.'
|
@@ -3723,6 +3771,11 @@ Style/NilComparison:
|
|
3723
3771
|
- predicate
|
3724
3772
|
- comparison
|
3725
3773
|
|
3774
|
+
Style/NilLambda:
|
3775
|
+
Description: 'Prefer `-> {}` to `-> { nil }`.'
|
3776
|
+
Enabled: pending
|
3777
|
+
VersionAdded: '1.3'
|
3778
|
+
|
3726
3779
|
Style/NonNilCheck:
|
3727
3780
|
Description: 'Checks for redundant nil checks.'
|
3728
3781
|
StyleGuide: '#no-non-nil-checks'
|
@@ -3872,7 +3925,7 @@ Style/PercentLiteralDelimiters:
|
|
3872
3925
|
'%r': '{}'
|
3873
3926
|
'%w': '[]'
|
3874
3927
|
'%W': '[]'
|
3875
|
-
VersionChanged: '0.48
|
3928
|
+
VersionChanged: '0.48'
|
3876
3929
|
|
3877
3930
|
Style/PercentQLiterals:
|
3878
3931
|
Description: 'Checks if uses of %Q/%q match the configured preference.'
|
@@ -3928,6 +3981,17 @@ Style/RandomWithOffset:
|
|
3928
3981
|
Enabled: true
|
3929
3982
|
VersionAdded: '0.52'
|
3930
3983
|
|
3984
|
+
Style/RedundantArgument:
|
3985
|
+
Description: 'Check for a redundant argument passed to certain methods.'
|
3986
|
+
Enabled: pending
|
3987
|
+
Safe: false
|
3988
|
+
VersionAdded: '1.4'
|
3989
|
+
Methods:
|
3990
|
+
# Array#join
|
3991
|
+
join: ''
|
3992
|
+
# String#split
|
3993
|
+
split: ' '
|
3994
|
+
|
3931
3995
|
Style/RedundantAssignment:
|
3932
3996
|
Description: 'Checks for redundant assignment before returning.'
|
3933
3997
|
Enabled: true
|
@@ -4222,6 +4286,13 @@ Style/StabbyLambdaParentheses:
|
|
4222
4286
|
- require_parentheses
|
4223
4287
|
- require_no_parentheses
|
4224
4288
|
|
4289
|
+
Style/StaticClass:
|
4290
|
+
Description: 'Prefer modules to classes with only class methods.'
|
4291
|
+
StyleGuide: '#modules-vs-classes'
|
4292
|
+
Enabled: false
|
4293
|
+
Safe: false
|
4294
|
+
VersionAdded: '1.3'
|
4295
|
+
|
4225
4296
|
Style/StderrPuts:
|
4226
4297
|
Description: 'Use `warn` instead of `$stderr.puts`.'
|
4227
4298
|
StyleGuide: '#warn'
|
@@ -4272,7 +4343,7 @@ Style/StringMethods:
|
|
4272
4343
|
Description: 'Checks if configured preferred methods are used over non-preferred.'
|
4273
4344
|
Enabled: false
|
4274
4345
|
VersionAdded: '0.34'
|
4275
|
-
VersionChanged: '0.34
|
4346
|
+
VersionChanged: '0.34'
|
4276
4347
|
# Mapping from undesired method to desired_method
|
4277
4348
|
# e.g. to use `to_sym` over `intern`:
|
4278
4349
|
#
|
data/lib/rubocop.rb
CHANGED
@@ -259,6 +259,7 @@ require_relative 'rubocop/cop/lint/debugger'
|
|
259
259
|
require_relative 'rubocop/cop/lint/deprecated_class_methods'
|
260
260
|
require_relative 'rubocop/cop/lint/deprecated_open_ssl_constant'
|
261
261
|
require_relative 'rubocop/cop/lint/disjunctive_assignment_in_constructor'
|
262
|
+
require_relative 'rubocop/cop/lint/duplicate_branch'
|
262
263
|
require_relative 'rubocop/cop/lint/duplicate_case_condition'
|
263
264
|
require_relative 'rubocop/cop/lint/duplicate_elsif_condition'
|
264
265
|
require_relative 'rubocop/cop/lint/duplicate_hash_key'
|
@@ -269,6 +270,7 @@ require_relative 'rubocop/cop/lint/duplicate_rescue_exception'
|
|
269
270
|
require_relative 'rubocop/cop/lint/each_with_object_argument'
|
270
271
|
require_relative 'rubocop/cop/lint/else_layout'
|
271
272
|
require_relative 'rubocop/cop/lint/empty_block'
|
273
|
+
require_relative 'rubocop/cop/lint/empty_class'
|
272
274
|
require_relative 'rubocop/cop/lint/empty_conditional_body'
|
273
275
|
require_relative 'rubocop/cop/lint/empty_ensure'
|
274
276
|
require_relative 'rubocop/cop/lint/empty_expression'
|
@@ -480,6 +482,7 @@ require_relative 'rubocop/cop/style/redundant_fetch_block'
|
|
480
482
|
require_relative 'rubocop/cop/style/redundant_file_extension_in_require'
|
481
483
|
require_relative 'rubocop/cop/style/redundant_self_assignment'
|
482
484
|
require_relative 'rubocop/cop/style/sole_nested_conditional'
|
485
|
+
require_relative 'rubocop/cop/style/static_class'
|
483
486
|
require_relative 'rubocop/cop/style/method_called_on_do_end_block'
|
484
487
|
require_relative 'rubocop/cop/style/method_def_parentheses'
|
485
488
|
require_relative 'rubocop/cop/style/min_max'
|
@@ -506,6 +509,7 @@ require_relative 'rubocop/cop/style/nested_parenthesized_calls'
|
|
506
509
|
require_relative 'rubocop/cop/style/nested_ternary_operator'
|
507
510
|
require_relative 'rubocop/cop/style/next'
|
508
511
|
require_relative 'rubocop/cop/style/nil_comparison'
|
512
|
+
require_relative 'rubocop/cop/style/nil_lambda'
|
509
513
|
require_relative 'rubocop/cop/style/non_nil_check'
|
510
514
|
require_relative 'rubocop/cop/style/not'
|
511
515
|
require_relative 'rubocop/cop/style/numeric_literals'
|
@@ -525,6 +529,7 @@ require_relative 'rubocop/cop/style/preferred_hash_methods'
|
|
525
529
|
require_relative 'rubocop/cop/style/proc'
|
526
530
|
require_relative 'rubocop/cop/style/raise_args'
|
527
531
|
require_relative 'rubocop/cop/style/random_with_offset'
|
532
|
+
require_relative 'rubocop/cop/style/redundant_argument'
|
528
533
|
require_relative 'rubocop/cop/style/redundant_begin'
|
529
534
|
require_relative 'rubocop/cop/style/redundant_capital_w'
|
530
535
|
require_relative 'rubocop/cop/style/redundant_condition'
|
@@ -22,12 +22,13 @@ module RuboCop
|
|
22
22
|
def execute_runner(paths)
|
23
23
|
runner = Runner.new(@options, @config_store)
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
all_pass_or_excluded = with_redirect do
|
26
|
+
all_passed = runner.run(paths)
|
27
|
+
display_summary(runner)
|
28
|
+
all_passed || @options[:auto_gen_config]
|
29
|
+
end
|
29
30
|
|
30
|
-
|
31
|
+
maybe_print_corrected_source
|
31
32
|
|
32
33
|
if runner.aborting?
|
33
34
|
STATUS_INTERRUPTED
|
@@ -38,6 +39,25 @@ module RuboCop
|
|
38
39
|
end
|
39
40
|
end
|
40
41
|
|
42
|
+
def with_redirect
|
43
|
+
if @options[:stderr]
|
44
|
+
orig_stdout = $stdout.dup
|
45
|
+
$stdout.reopen($stderr)
|
46
|
+
|
47
|
+
result = yield
|
48
|
+
|
49
|
+
$stdout.reopen(orig_stdout)
|
50
|
+
result
|
51
|
+
else
|
52
|
+
yield
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def display_summary(runner)
|
57
|
+
display_warning_summary(runner.warnings)
|
58
|
+
display_error_summary(runner.errors)
|
59
|
+
end
|
60
|
+
|
41
61
|
def display_warning_summary(warnings)
|
42
62
|
return if warnings.empty?
|
43
63
|
|
@@ -69,14 +89,9 @@ module RuboCop
|
|
69
89
|
# See: https://github.com/rubocop-hq/rubocop/issues/8673
|
70
90
|
return if INTEGRATION_FORMATTERS.include?(@options[:format])
|
71
91
|
|
72
|
-
# If we are asked to autocorrect source code read from stdin, the only
|
73
|
-
# reasonable place to write it is to stdout
|
74
|
-
# Unfortunately, we also write other information to stdout
|
75
|
-
# So a delimiter is needed for tools to easily identify where the
|
76
|
-
# autocorrected source begins
|
77
92
|
return unless @options[:stdin] && @options[:auto_correct]
|
78
93
|
|
79
|
-
puts '=' * 20
|
94
|
+
(@options[:stderr] ? $stderr : $stdout).puts '=' * 20
|
80
95
|
print @options[:stdin]
|
81
96
|
end
|
82
97
|
end
|
@@ -256,16 +256,25 @@ module RuboCop
|
|
256
256
|
end
|
257
257
|
|
258
258
|
def yaml_safe_load(yaml_code, filename)
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
259
|
+
yaml_safe_load!(yaml_code, filename)
|
260
|
+
rescue ::StandardError
|
261
|
+
if defined?(::SafeYAML)
|
262
|
+
raise 'SafeYAML is unmaintained, no longer needed and should be removed'
|
263
|
+
end
|
264
|
+
|
265
|
+
raise
|
266
|
+
end
|
267
|
+
|
268
|
+
if Gem::Version.new(Psych::VERSION) >= Gem::Version.new('3.1.0')
|
269
|
+
def yaml_safe_load!(yaml_code, filename)
|
263
270
|
YAML.safe_load(yaml_code,
|
264
271
|
permitted_classes: [Regexp, Symbol],
|
265
272
|
permitted_symbols: [],
|
266
273
|
aliases: true,
|
267
274
|
filename: filename)
|
268
|
-
|
275
|
+
end
|
276
|
+
else # Ruby < 2.6
|
277
|
+
def yaml_safe_load!(yaml_code, filename)
|
269
278
|
YAML.safe_load(yaml_code, [Regexp, Symbol], [], true, filename)
|
270
279
|
end
|
271
280
|
end
|