rubocop 1.32.0 → 1.35.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/config/default.yml +73 -16
- data/config/obsoletion.yml +23 -1
- data/lib/rubocop/cache_config.rb +29 -0
- data/lib/rubocop/cli/command/{auto_genenerate_config.rb → auto_generate_config.rb} +2 -2
- data/lib/rubocop/cli/command/init_dotfile.rb +1 -1
- data/lib/rubocop/cli/command/suggest_extensions.rb +53 -15
- data/lib/rubocop/config.rb +1 -1
- data/lib/rubocop/config_finder.rb +68 -0
- data/lib/rubocop/config_loader.rb +12 -40
- data/lib/rubocop/config_loader_resolver.rb +1 -5
- data/lib/rubocop/config_obsoletion/changed_parameter.rb +5 -0
- data/lib/rubocop/config_obsoletion/parameter_rule.rb +4 -0
- data/lib/rubocop/config_obsoletion.rb +7 -2
- data/lib/rubocop/cop/cop.rb +1 -1
- data/lib/rubocop/cop/correctors/parentheses_corrector.rb +58 -0
- data/lib/rubocop/cop/gemspec/require_mfa.rb +1 -1
- data/lib/rubocop/cop/generator/require_file_injector.rb +2 -2
- data/lib/rubocop/cop/internal_affairs/numblock_handler.rb +69 -0
- data/lib/rubocop/cop/internal_affairs/single_line_comparison.rb +62 -0
- data/lib/rubocop/cop/internal_affairs.rb +2 -0
- data/lib/rubocop/cop/layout/block_alignment.rb +2 -0
- data/lib/rubocop/cop/layout/block_end_newline.rb +35 -5
- data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +5 -2
- data/lib/rubocop/cop/layout/empty_lines_around_block_body.rb +2 -0
- data/lib/rubocop/cop/layout/end_of_line.rb +4 -4
- data/lib/rubocop/cop/layout/first_argument_indentation.rb +6 -1
- data/lib/rubocop/cop/layout/first_array_element_indentation.rb +2 -2
- data/lib/rubocop/cop/layout/first_hash_element_indentation.rb +2 -2
- data/lib/rubocop/cop/layout/indentation_width.rb +2 -0
- data/lib/rubocop/cop/layout/line_length.rb +4 -1
- data/lib/rubocop/cop/layout/multiline_assignment_layout.rb +1 -1
- data/lib/rubocop/cop/layout/multiline_block_layout.rb +2 -0
- data/lib/rubocop/cop/layout/redundant_line_break.rb +1 -1
- data/lib/rubocop/cop/layout/space_around_block_parameters.rb +1 -1
- data/lib/rubocop/cop/layout/space_around_keyword.rb +1 -1
- data/lib/rubocop/cop/layout/space_before_block_braces.rb +2 -0
- data/lib/rubocop/cop/legacy/corrections_proxy.rb +1 -1
- data/lib/rubocop/cop/legacy/corrector.rb +1 -1
- data/lib/rubocop/cop/lint/ambiguous_block_association.rb +21 -8
- data/lib/rubocop/cop/lint/debugger.rb +26 -16
- data/lib/rubocop/cop/lint/deprecated_class_methods.rb +4 -4
- data/lib/rubocop/cop/lint/empty_block.rb +1 -1
- data/lib/rubocop/cop/lint/empty_conditional_body.rb +65 -1
- data/lib/rubocop/cop/lint/erb_new_arguments.rb +9 -9
- data/lib/rubocop/cop/lint/literal_in_interpolation.rb +4 -0
- data/lib/rubocop/cop/lint/next_without_accumulator.rb +25 -6
- data/lib/rubocop/cop/lint/non_atomic_file_operation.rb +6 -6
- data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +12 -0
- data/lib/rubocop/cop/lint/number_conversion.rb +24 -8
- data/lib/rubocop/cop/lint/redundant_safe_navigation.rb +9 -3
- data/lib/rubocop/cop/lint/redundant_with_index.rb +13 -10
- data/lib/rubocop/cop/lint/redundant_with_object.rb +12 -11
- data/lib/rubocop/cop/lint/shadowed_exception.rb +15 -0
- data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +10 -1
- data/lib/rubocop/cop/lint/unreachable_loop.rb +7 -1
- data/lib/rubocop/cop/lint/useless_access_modifier.rb +6 -4
- data/lib/rubocop/cop/lint/void.rb +2 -0
- data/lib/rubocop/cop/metrics/abc_size.rb +3 -1
- data/lib/rubocop/cop/metrics/block_length.rb +6 -7
- data/lib/rubocop/cop/metrics/method_length.rb +8 -8
- data/lib/rubocop/cop/mixin/allowed_methods.rb +15 -1
- data/lib/rubocop/cop/mixin/allowed_pattern.rb +9 -1
- data/lib/rubocop/cop/mixin/check_line_breakable.rb +1 -1
- data/lib/rubocop/cop/mixin/comments_help.rb +5 -1
- data/lib/rubocop/cop/mixin/enforce_superclass.rb +2 -1
- data/lib/rubocop/cop/mixin/hash_shorthand_syntax.rb +76 -1
- data/lib/rubocop/cop/mixin/hash_transform_method.rb +1 -1
- data/lib/rubocop/cop/mixin/method_complexity.rb +8 -13
- data/lib/rubocop/cop/mixin/multiline_element_indentation.rb +1 -1
- data/lib/rubocop/cop/mixin/range_help.rb +4 -5
- data/lib/rubocop/cop/naming/block_parameter_name.rb +1 -1
- data/lib/rubocop/cop/naming/constant_name.rb +2 -2
- data/lib/rubocop/cop/naming/predicate_name.rb +24 -3
- data/lib/rubocop/cop/style/arguments_forwarding.rb +2 -2
- data/lib/rubocop/cop/style/block_delimiters.rb +26 -7
- data/lib/rubocop/cop/style/class_and_module_children.rb +4 -4
- data/lib/rubocop/cop/style/class_equality_comparison.rb +32 -7
- data/lib/rubocop/cop/style/class_methods_definitions.rb +2 -1
- data/lib/rubocop/cop/style/collection_methods.rb +2 -0
- data/lib/rubocop/cop/style/combinable_loops.rb +3 -1
- data/lib/rubocop/cop/style/double_negation.rb +2 -0
- data/lib/rubocop/cop/style/each_for_simple_loop.rb +1 -1
- data/lib/rubocop/cop/style/each_with_object.rb +39 -8
- data/lib/rubocop/cop/style/empty_block_parameter.rb +1 -1
- data/lib/rubocop/cop/style/empty_heredoc.rb +15 -1
- data/lib/rubocop/cop/style/empty_lambda_parameter.rb +1 -1
- data/lib/rubocop/cop/style/for.rb +2 -0
- data/lib/rubocop/cop/style/format_string_token.rb +21 -8
- data/lib/rubocop/cop/style/guard_clause.rb +27 -16
- data/lib/rubocop/cop/style/hash_each_methods.rb +3 -1
- data/lib/rubocop/cop/style/hash_except.rb +0 -4
- data/lib/rubocop/cop/style/hash_syntax.rb +17 -0
- data/lib/rubocop/cop/style/if_unless_modifier.rb +1 -1
- data/lib/rubocop/cop/style/inverse_methods.rb +8 -6
- data/lib/rubocop/cop/style/magic_comment_format.rb +307 -0
- data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +2 -2
- data/lib/rubocop/cop/style/method_call_with_args_parentheses/require_parentheses.rb +5 -1
- data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +7 -7
- data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +11 -6
- data/lib/rubocop/cop/style/method_called_on_do_end_block.rb +4 -1
- data/lib/rubocop/cop/style/multiline_block_chain.rb +3 -1
- data/lib/rubocop/cop/style/multiline_in_pattern_then.rb +1 -1
- data/lib/rubocop/cop/style/next.rb +3 -5
- data/lib/rubocop/cop/style/nil_lambda.rb +1 -1
- data/lib/rubocop/cop/style/numeric_literals.rb +16 -1
- data/lib/rubocop/cop/style/numeric_predicate.rb +28 -8
- data/lib/rubocop/cop/style/object_then.rb +2 -0
- data/lib/rubocop/cop/style/proc.rb +4 -1
- data/lib/rubocop/cop/style/redundant_begin.rb +2 -0
- data/lib/rubocop/cop/style/redundant_condition.rb +19 -4
- data/lib/rubocop/cop/style/redundant_fetch_block.rb +1 -1
- data/lib/rubocop/cop/style/redundant_parentheses.rb +15 -22
- data/lib/rubocop/cop/style/redundant_self.rb +2 -0
- data/lib/rubocop/cop/style/redundant_sort.rb +21 -6
- data/lib/rubocop/cop/style/redundant_sort_by.rb +24 -8
- data/lib/rubocop/cop/style/safe_navigation.rb +4 -2
- data/lib/rubocop/cop/style/single_line_block_params.rb +1 -1
- data/lib/rubocop/cop/style/sole_nested_conditional.rb +14 -5
- data/lib/rubocop/cop/style/symbol_array.rb +1 -1
- data/lib/rubocop/cop/style/symbol_proc.rb +34 -9
- data/lib/rubocop/cop/style/ternary_parentheses.rb +1 -13
- data/lib/rubocop/cop/style/top_level_method_definition.rb +3 -1
- data/lib/rubocop/cop/style/trailing_comma_in_block_args.rb +1 -1
- data/lib/rubocop/cop/style/word_array.rb +1 -1
- data/lib/rubocop/cop/util.rb +1 -1
- data/lib/rubocop/ext/range.rb +15 -0
- data/lib/rubocop/feature_loader.rb +94 -0
- data/lib/rubocop/formatter/clang_style_formatter.rb +1 -1
- data/lib/rubocop/formatter/disabled_config_formatter.rb +1 -1
- data/lib/rubocop/formatter/html_formatter.rb +3 -3
- data/lib/rubocop/formatter/markdown_formatter.rb +1 -1
- data/lib/rubocop/formatter/tap_formatter.rb +1 -1
- data/lib/rubocop/result_cache.rb +22 -20
- data/lib/rubocop/server/cache.rb +36 -1
- data/lib/rubocop/server/cli.rb +19 -2
- data/lib/rubocop/version.rb +1 -1
- data/lib/rubocop.rb +5 -3
- metadata +15 -9
- data/lib/rubocop/cop/mixin/ignored_methods.rb +0 -52
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52ce553282d97fbec24636f7104e3c1c1ceb32b27610542ae22470d84a6421ce
|
4
|
+
data.tar.gz: 6176cfc6699491e9d755e323a813964c1dd244a16d61ad2545e93f8109d69fa6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69e648784e186575033e4f8b65be6f5fb8f456e557d597e5321bbe0f70d9aef39b0a4c974347d13498b5e88c664177b72aae809b5f39bec98292cb0e7a4fb18a
|
7
|
+
data.tar.gz: 866c506305659953fe31ea005c51d936dcfed82429e7582f7d64daab5ea5b077ef1fb619f7932c204749582dc1bec695e090c32d5b81450984d30e7a2e3125b4
|
data/README.md
CHANGED
@@ -46,14 +46,14 @@ If you'd rather install RuboCop using `bundler`, add a line for it in your `Gemf
|
|
46
46
|
gem 'rubocop', require: false
|
47
47
|
```
|
48
48
|
|
49
|
-
RuboCop is stable between
|
49
|
+
RuboCop is stable between minor versions, both in terms of API and cop configuration.
|
50
50
|
We aim to ease the maintenance of RuboCop extensions and the upgrades between RuboCop
|
51
51
|
releases. All big changes are reserved for major releases.
|
52
52
|
To prevent an unwanted RuboCop update you might want to use a conservative version lock
|
53
53
|
in your `Gemfile`:
|
54
54
|
|
55
55
|
```rb
|
56
|
-
gem 'rubocop', '~> 1.
|
56
|
+
gem 'rubocop', '~> 1.35', require: false
|
57
57
|
```
|
58
58
|
|
59
59
|
See [our versioning policy](https://docs.rubocop.org/rubocop/versioning.html) for further details.
|
data/config/default.yml
CHANGED
@@ -1502,7 +1502,9 @@ Lint/AmbiguousBlockAssociation:
|
|
1502
1502
|
Enabled: true
|
1503
1503
|
VersionAdded: '0.48'
|
1504
1504
|
VersionChanged: '1.13'
|
1505
|
-
|
1505
|
+
AllowedMethods: []
|
1506
|
+
AllowedPatterns: []
|
1507
|
+
IgnoredMethods: [] # deprecated
|
1506
1508
|
|
1507
1509
|
Lint/AmbiguousOperator:
|
1508
1510
|
Description: >-
|
@@ -1602,6 +1604,7 @@ Lint/Debugger:
|
|
1602
1604
|
# a user's configuration, but are otherwise not significant.
|
1603
1605
|
Kernel:
|
1604
1606
|
- binding.irb
|
1607
|
+
- Kernel.binding.irb
|
1605
1608
|
Byebug:
|
1606
1609
|
- byebug
|
1607
1610
|
- remote_byebug
|
@@ -1619,6 +1622,9 @@ Lint/Debugger:
|
|
1619
1622
|
- binding.pry
|
1620
1623
|
- binding.remote_pry
|
1621
1624
|
- binding.pry_remote
|
1625
|
+
- Kernel.binding.pry
|
1626
|
+
- Kernel.binding.remote_pry
|
1627
|
+
- Kernel.binding.pry_remote
|
1622
1628
|
- Pry.rescue
|
1623
1629
|
Rails:
|
1624
1630
|
- debugger
|
@@ -1751,8 +1757,10 @@ Lint/EmptyClass:
|
|
1751
1757
|
Lint/EmptyConditionalBody:
|
1752
1758
|
Description: 'Checks for the presence of `if`, `elsif` and `unless` branches without a body.'
|
1753
1759
|
Enabled: true
|
1760
|
+
SafeAutoCorrect: false
|
1754
1761
|
AllowComments: true
|
1755
1762
|
VersionAdded: '0.89'
|
1763
|
+
VersionChanged: '1.34'
|
1756
1764
|
|
1757
1765
|
Lint/EmptyEnsure:
|
1758
1766
|
Description: 'Checks for empty ensure block.'
|
@@ -1970,6 +1978,7 @@ Lint/NoReturnInBeginEndBlocks:
|
|
1970
1978
|
|
1971
1979
|
Lint/NonAtomicFileOperation:
|
1972
1980
|
Description: Checks for non-atomic file operations.
|
1981
|
+
StyleGuide: '#atomic-file-operations'
|
1973
1982
|
Enabled: pending
|
1974
1983
|
VersionAdded: '1.31'
|
1975
1984
|
SafeAutoCorrect: false
|
@@ -1991,7 +2000,9 @@ Lint/NumberConversion:
|
|
1991
2000
|
VersionAdded: '0.53'
|
1992
2001
|
VersionChanged: '1.1'
|
1993
2002
|
SafeAutoCorrect: false
|
1994
|
-
|
2003
|
+
AllowedMethods: []
|
2004
|
+
AllowedPatterns: []
|
2005
|
+
IgnoredMethods: [] # deprecated
|
1995
2006
|
IgnoredClasses:
|
1996
2007
|
- Time
|
1997
2008
|
- DateTime
|
@@ -2443,7 +2454,9 @@ Metrics/AbcSize:
|
|
2443
2454
|
VersionChanged: '1.5'
|
2444
2455
|
# The ABC size is a calculated magnitude, so this number can be an Integer or
|
2445
2456
|
# a Float.
|
2446
|
-
|
2457
|
+
AllowedMethods: []
|
2458
|
+
AllowedPatterns: []
|
2459
|
+
IgnoredMethods: [] # deprecated
|
2447
2460
|
CountRepeatedAttributes: true
|
2448
2461
|
Max: 17
|
2449
2462
|
|
@@ -2456,10 +2469,12 @@ Metrics/BlockLength:
|
|
2456
2469
|
Max: 25
|
2457
2470
|
CountAsOne: []
|
2458
2471
|
ExcludedMethods: [] # deprecated, retained for backwards compatibility
|
2459
|
-
|
2472
|
+
AllowedMethods:
|
2460
2473
|
# By default, exclude the `#refine` method, as it tends to have larger
|
2461
2474
|
# associated blocks.
|
2462
2475
|
- refine
|
2476
|
+
AllowedPatterns: []
|
2477
|
+
IgnoredMethods: [] # deprecated
|
2463
2478
|
Exclude:
|
2464
2479
|
- '**/*.gemspec'
|
2465
2480
|
|
@@ -2489,7 +2504,9 @@ Metrics/CyclomaticComplexity:
|
|
2489
2504
|
Enabled: true
|
2490
2505
|
VersionAdded: '0.25'
|
2491
2506
|
VersionChanged: '0.81'
|
2492
|
-
|
2507
|
+
AllowedMethods: []
|
2508
|
+
AllowedPatterns: []
|
2509
|
+
IgnoredMethods: [] # deprecated
|
2493
2510
|
Max: 7
|
2494
2511
|
|
2495
2512
|
Metrics/MethodLength:
|
@@ -2502,7 +2519,9 @@ Metrics/MethodLength:
|
|
2502
2519
|
Max: 10
|
2503
2520
|
CountAsOne: []
|
2504
2521
|
ExcludedMethods: [] # deprecated, retained for backwards compatibility
|
2505
|
-
|
2522
|
+
AllowedMethods: []
|
2523
|
+
AllowedPatterns: []
|
2524
|
+
IgnoredMethods: [] # deprecated
|
2506
2525
|
|
2507
2526
|
Metrics/ModuleLength:
|
2508
2527
|
Description: 'Avoid modules longer than 100 lines of code.'
|
@@ -2530,7 +2549,9 @@ Metrics/PerceivedComplexity:
|
|
2530
2549
|
Enabled: true
|
2531
2550
|
VersionAdded: '0.25'
|
2532
2551
|
VersionChanged: '0.81'
|
2533
|
-
|
2552
|
+
AllowedMethods: []
|
2553
|
+
AllowedPatterns: []
|
2554
|
+
IgnoredMethods: [] # deprecated
|
2534
2555
|
Max: 8
|
2535
2556
|
|
2536
2557
|
################## Migration #############################
|
@@ -3061,7 +3082,7 @@ Style/BlockDelimiters:
|
|
3061
3082
|
# This looks at the usage of a block's method to determine its type (e.g. is
|
3062
3083
|
# the result of a `map` assigned to a variable or passed to another
|
3063
3084
|
# method) but exceptions are permitted in the `ProceduralMethods`,
|
3064
|
-
# `FunctionalMethods` and `
|
3085
|
+
# `FunctionalMethods` and `AllowedMethods` sections below.
|
3065
3086
|
- semantic
|
3066
3087
|
# The `braces_for_chaining` style enforces braces around single line blocks
|
3067
3088
|
# and do..end around multi-line blocks, except for multi-line blocks whose
|
@@ -3102,7 +3123,7 @@ Style/BlockDelimiters:
|
|
3102
3123
|
- let!
|
3103
3124
|
- subject
|
3104
3125
|
- watch
|
3105
|
-
|
3126
|
+
AllowedMethods:
|
3106
3127
|
# Methods that can be either procedural or functional and cannot be
|
3107
3128
|
# categorised from their usage alone, e.g.
|
3108
3129
|
#
|
@@ -3119,6 +3140,8 @@ Style/BlockDelimiters:
|
|
3119
3140
|
- lambda
|
3120
3141
|
- proc
|
3121
3142
|
- it
|
3143
|
+
AllowedPatterns: []
|
3144
|
+
IgnoredMethods: [] # deprecated
|
3122
3145
|
# The AllowBracesOnProceduralOneLiners option is ignored unless the
|
3123
3146
|
# EnforcedStyle is set to `semantic`. If so:
|
3124
3147
|
#
|
@@ -3222,10 +3245,12 @@ Style/ClassEqualityComparison:
|
|
3222
3245
|
StyleGuide: '#instance-of-vs-class-comparison'
|
3223
3246
|
Enabled: true
|
3224
3247
|
VersionAdded: '0.93'
|
3225
|
-
|
3248
|
+
AllowedMethods:
|
3226
3249
|
- ==
|
3227
3250
|
- equal?
|
3228
3251
|
- eql?
|
3252
|
+
AllowedPatterns: []
|
3253
|
+
IgnoredMethods: [] # deprecated
|
3229
3254
|
|
3230
3255
|
Style/ClassMethods:
|
3231
3256
|
Description: 'Use self when defining module/class methods.'
|
@@ -3687,7 +3712,9 @@ Style/FormatStringToken:
|
|
3687
3712
|
MaxUnannotatedPlaceholdersAllowed: 1
|
3688
3713
|
VersionAdded: '0.49'
|
3689
3714
|
VersionChanged: '1.0'
|
3690
|
-
|
3715
|
+
AllowedMethods: []
|
3716
|
+
AllowedPatterns: []
|
3717
|
+
IgnoredMethods: [] # deprecated
|
3691
3718
|
|
3692
3719
|
Style/FrozenStringLiteralComment:
|
3693
3720
|
Description: >-
|
@@ -3812,6 +3839,8 @@ Style/HashSyntax:
|
|
3812
3839
|
- never
|
3813
3840
|
# accepts both shorthand and explicit use of hash literal value.
|
3814
3841
|
- either
|
3842
|
+
# like "always", but will avoid mixing styles in a single hash
|
3843
|
+
- consistent
|
3815
3844
|
# Force hashes that have a symbol value to use hash rockets
|
3816
3845
|
UseHashRocketsWithSymbolValues: false
|
3817
3846
|
# Do not suggest { a?: 1 } over { :a? => 1 } in ruby19 style
|
@@ -3988,6 +4017,26 @@ Style/LineEndConcatenation:
|
|
3988
4017
|
VersionAdded: '0.18'
|
3989
4018
|
VersionChanged: '0.64'
|
3990
4019
|
|
4020
|
+
Style/MagicCommentFormat:
|
4021
|
+
Description: 'Use a consistent style for magic comments.'
|
4022
|
+
Enabled: pending
|
4023
|
+
VersionAdded: '1.35'
|
4024
|
+
EnforcedStyle: snake_case
|
4025
|
+
SupportedStyles:
|
4026
|
+
# `snake` will enforce the magic comment is written
|
4027
|
+
# in snake case (words separated by underscores).
|
4028
|
+
# Eg: froze_string_literal: true
|
4029
|
+
- snake_case
|
4030
|
+
# `kebab` will enforce the magic comment is written
|
4031
|
+
# in kebab case (words separated by hyphens).
|
4032
|
+
# Eg: froze-string-literal: true
|
4033
|
+
- kebab_case
|
4034
|
+
DirectiveCapitalization: lowercase
|
4035
|
+
ValueCapitalization: ~
|
4036
|
+
SupportedCapitalizations:
|
4037
|
+
- lowercase
|
4038
|
+
- uppercase
|
4039
|
+
|
3991
4040
|
Style/MapCompactWithConditionalBlock:
|
3992
4041
|
Description: 'Prefer `select` or `reject` over `map { ... }.compact`.'
|
3993
4042
|
Enabled: pending
|
@@ -4006,7 +4055,8 @@ Style/MethodCallWithArgsParentheses:
|
|
4006
4055
|
VersionAdded: '0.47'
|
4007
4056
|
VersionChanged: '1.7'
|
4008
4057
|
IgnoreMacros: true
|
4009
|
-
|
4058
|
+
AllowedMethods: []
|
4059
|
+
IgnoredMethods: [] # deprecated
|
4010
4060
|
AllowedPatterns: []
|
4011
4061
|
IgnoredPatterns: [] # deprecated
|
4012
4062
|
IncludedMacros: []
|
@@ -4023,7 +4073,9 @@ Style/MethodCallWithoutArgsParentheses:
|
|
4023
4073
|
Description: 'Do not use parentheses for method calls with no arguments.'
|
4024
4074
|
StyleGuide: '#method-invocation-parens'
|
4025
4075
|
Enabled: true
|
4026
|
-
|
4076
|
+
AllowedMethods: []
|
4077
|
+
AllowedPatterns: []
|
4078
|
+
IgnoredMethods: [] # deprecated
|
4027
4079
|
VersionAdded: '0.47'
|
4028
4080
|
VersionChanged: '0.55'
|
4029
4081
|
|
@@ -4375,6 +4427,7 @@ Style/NumericLiterals:
|
|
4375
4427
|
Strict: false
|
4376
4428
|
# You can specify allowed numbers. (e.g. port number 3000, 8080, and etc)
|
4377
4429
|
AllowedNumbers: []
|
4430
|
+
AllowedPatterns: []
|
4378
4431
|
|
4379
4432
|
Style/NumericPredicate:
|
4380
4433
|
Description: >-
|
@@ -4393,7 +4446,9 @@ Style/NumericPredicate:
|
|
4393
4446
|
SupportedStyles:
|
4394
4447
|
- predicate
|
4395
4448
|
- comparison
|
4396
|
-
|
4449
|
+
AllowedMethods: []
|
4450
|
+
AllowedPatterns: []
|
4451
|
+
IgnoredMethods: [] # deprecated
|
4397
4452
|
# Exclude RSpec specs because assertions like `expect(1).to be > 0` cause
|
4398
4453
|
# false positives.
|
4399
4454
|
Exclude:
|
@@ -5030,11 +5085,13 @@ Style/SymbolProc:
|
|
5030
5085
|
VersionAdded: '0.26'
|
5031
5086
|
VersionChanged: '1.28'
|
5032
5087
|
AllowMethodsWithArguments: false
|
5033
|
-
# A list of method names to be
|
5088
|
+
# A list of method names to be always allowed by the check.
|
5034
5089
|
# The names should be fairly unique, otherwise you'll end up ignoring lots of code.
|
5035
|
-
|
5090
|
+
AllowedMethods:
|
5036
5091
|
- respond_to
|
5037
5092
|
- define_method
|
5093
|
+
AllowedPatterns: []
|
5094
|
+
IgnoredMethods: [] # deprecated
|
5038
5095
|
AllowComments: false
|
5039
5096
|
|
5040
5097
|
Style/TernaryParentheses:
|
data/config/obsoletion.yml
CHANGED
@@ -187,7 +187,9 @@ changed_parameters:
|
|
187
187
|
- Metrics/BlockLength
|
188
188
|
- Metrics/MethodLength
|
189
189
|
parameters: ExcludedMethods
|
190
|
-
|
190
|
+
alternatives:
|
191
|
+
- AllowedMethods
|
192
|
+
- AllowedPatterns
|
191
193
|
severity: warning
|
192
194
|
- cops: Lint/Debugger
|
193
195
|
parameters: DebuggerReceivers
|
@@ -202,6 +204,26 @@ changed_parameters:
|
|
202
204
|
parameters: IgnoredPatterns
|
203
205
|
alternative: AllowedPatterns
|
204
206
|
severity: warning
|
207
|
+
- cops:
|
208
|
+
- Lint/AmbiguousBlockAssociation
|
209
|
+
- Lint/NumberConversion
|
210
|
+
- Metrics/AbcSize
|
211
|
+
- Metrics/BlockLength
|
212
|
+
- Metrics/CyclomaticComplexity
|
213
|
+
- Metrics/MethodLength
|
214
|
+
- Metrics/PerceivedComplexity
|
215
|
+
- Style/BlockDelimiters
|
216
|
+
- Style/ClassEqualityComparison
|
217
|
+
- Style/FormatStringToken
|
218
|
+
- Style/MethodCallWithArgsParentheses
|
219
|
+
- Style/MethodCallWithoutArgsParentheses
|
220
|
+
- Style/NumericPredicate
|
221
|
+
- Style/SymbolLiteral
|
222
|
+
parameters: IgnoredMethods
|
223
|
+
alternatives:
|
224
|
+
- AllowedMethods
|
225
|
+
- AllowedPatterns
|
226
|
+
severity: warning
|
205
227
|
|
206
228
|
# Enforced styles that have been removed or replaced
|
207
229
|
changed_enforced_styles:
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
# This class represents the cache config of the caching RuboCop runs.
|
5
|
+
# @api private
|
6
|
+
class CacheConfig
|
7
|
+
def self.root_dir
|
8
|
+
root = ENV.fetch('RUBOCOP_CACHE_ROOT', nil)
|
9
|
+
root ||= yield
|
10
|
+
root ||= if ENV.key?('XDG_CACHE_HOME')
|
11
|
+
# Include user ID in the path to make sure the user has write
|
12
|
+
# access.
|
13
|
+
File.join(ENV.fetch('XDG_CACHE_HOME'), Process.uid.to_s)
|
14
|
+
else
|
15
|
+
# On FreeBSD, the /home path is a symbolic link to /usr/home
|
16
|
+
# and the $HOME environment variable returns the /home path.
|
17
|
+
#
|
18
|
+
# As $HOME is a built-in environment variable, FreeBSD users
|
19
|
+
# always get a warning message.
|
20
|
+
#
|
21
|
+
# To avoid raising warn log messages on FreeBSD, we retrieve
|
22
|
+
# the real path of the home folder.
|
23
|
+
File.join(File.realpath(Dir.home), '.cache')
|
24
|
+
end
|
25
|
+
|
26
|
+
File.join(root, 'rubocop_cache')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -98,7 +98,7 @@ module RuboCop
|
|
98
98
|
def add_inheritance_from_auto_generated_file(config_file)
|
99
99
|
file_string = " #{relative_path_to_todo_from_options_config}"
|
100
100
|
|
101
|
-
config_file ||=
|
101
|
+
config_file ||= ConfigFinder::DOTFILE
|
102
102
|
|
103
103
|
if File.exist?(config_file)
|
104
104
|
files = Array(ConfigLoader.load_yaml_configuration(config_file)['inherit_from'])
|
@@ -113,7 +113,7 @@ module RuboCop
|
|
113
113
|
write_config_file(config_file, file_string, rubocop_yml_contents)
|
114
114
|
|
115
115
|
puts "Added inheritance from `#{relative_path_to_todo_from_options_config}` " \
|
116
|
-
"in `#{
|
116
|
+
"in `#{ConfigFinder::DOTFILE}`."
|
117
117
|
end
|
118
118
|
|
119
119
|
def existing_configuration(config_file)
|
@@ -17,20 +17,10 @@ module RuboCop
|
|
17
17
|
def run
|
18
18
|
return if skip? || extensions.none?
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
'RuboCop extension libraries might be helpful:'
|
23
|
-
|
24
|
-
extensions.sort.each do |extension|
|
25
|
-
puts " * #{extension} (https://rubygems.org/gems/#{extension})"
|
26
|
-
end
|
20
|
+
print_install_suggestions if not_installed_extensions.any?
|
21
|
+
print_load_suggestions if installed_and_not_loaded_extensions.any?
|
27
22
|
|
28
|
-
|
29
|
-
puts 'You can opt out of this message by adding the following to your config ' \
|
30
|
-
'(see https://docs.rubocop.org/rubocop/extensions.html#extension-suggestions ' \
|
31
|
-
'for more options):'
|
32
|
-
puts ' AllCops:'
|
33
|
-
puts ' SuggestExtensions: false'
|
23
|
+
print_opt_out_instruction
|
34
24
|
|
35
25
|
puts if @options[:display_time]
|
36
26
|
end
|
@@ -48,15 +38,63 @@ module RuboCop
|
|
48
38
|
!INCLUDED_FORMATTERS.include?(current_formatter)
|
49
39
|
end
|
50
40
|
|
41
|
+
def print_install_suggestions
|
42
|
+
puts
|
43
|
+
puts 'Tip: Based on detected gems, the following ' \
|
44
|
+
'RuboCop extension libraries might be helpful:'
|
45
|
+
|
46
|
+
not_installed_extensions.sort.each do |extension|
|
47
|
+
puts " * #{extension} (https://rubygems.org/gems/#{extension})"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def print_load_suggestions
|
52
|
+
puts
|
53
|
+
puts 'The following RuboCop extension libraries are installed but not loaded in config:'
|
54
|
+
|
55
|
+
installed_and_not_loaded_extensions.sort.each do |extension|
|
56
|
+
puts " * #{extension}"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def print_opt_out_instruction
|
61
|
+
puts
|
62
|
+
puts 'You can opt out of this message by adding the following to your config ' \
|
63
|
+
'(see https://docs.rubocop.org/rubocop/extensions.html#extension-suggestions ' \
|
64
|
+
'for more options):'
|
65
|
+
puts ' AllCops:'
|
66
|
+
puts ' SuggestExtensions: false'
|
67
|
+
end
|
68
|
+
|
51
69
|
def current_formatter
|
52
70
|
@options[:format] || @config_store.for_pwd.for_all_cops['DefaultFormatter'] || 'p'
|
53
71
|
end
|
54
72
|
|
55
|
-
def
|
73
|
+
def all_extensions
|
56
74
|
return [] unless lockfile.dependencies.any?
|
57
75
|
|
58
76
|
extensions = @config_store.for_pwd.for_all_cops['SuggestExtensions'] || {}
|
59
|
-
extensions.select { |_, v| (Array(v) & dependent_gems).any? }.keys
|
77
|
+
extensions.select { |_, v| (Array(v) & dependent_gems).any? }.keys
|
78
|
+
end
|
79
|
+
|
80
|
+
def extensions
|
81
|
+
not_installed_extensions + installed_and_not_loaded_extensions
|
82
|
+
end
|
83
|
+
|
84
|
+
def installed_extensions
|
85
|
+
all_extensions & installed_gems
|
86
|
+
end
|
87
|
+
|
88
|
+
def not_installed_extensions
|
89
|
+
all_extensions - installed_gems
|
90
|
+
end
|
91
|
+
|
92
|
+
def loaded_extensions
|
93
|
+
@config_store.for_pwd.loaded_features.to_a
|
94
|
+
end
|
95
|
+
|
96
|
+
def installed_and_not_loaded_extensions
|
97
|
+
installed_extensions - loaded_extensions
|
60
98
|
end
|
61
99
|
|
62
100
|
def lockfile
|
data/lib/rubocop/config.rb
CHANGED
@@ -242,7 +242,7 @@ module RuboCop
|
|
242
242
|
return nil unless loaded_path
|
243
243
|
|
244
244
|
base_path = base_dir_for_path_parameters
|
245
|
-
['
|
245
|
+
['Gemfile.lock', 'gems.locked'].each do |file_name|
|
246
246
|
path = find_file_upwards(file_name, base_path)
|
247
247
|
return path if path
|
248
248
|
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'file_finder'
|
4
|
+
|
5
|
+
module RuboCop
|
6
|
+
# This class has methods related to finding configuration path.
|
7
|
+
# @api private
|
8
|
+
class ConfigFinder
|
9
|
+
DOTFILE = '.rubocop.yml'
|
10
|
+
XDG_CONFIG = 'config.yml'
|
11
|
+
RUBOCOP_HOME = File.realpath(File.join(File.dirname(__FILE__), '..', '..'))
|
12
|
+
DEFAULT_FILE = File.join(RUBOCOP_HOME, 'config', 'default.yml')
|
13
|
+
|
14
|
+
class << self
|
15
|
+
include FileFinder
|
16
|
+
|
17
|
+
attr_writer :project_root
|
18
|
+
|
19
|
+
def find_config_path(target_dir)
|
20
|
+
find_project_dotfile(target_dir) || find_user_dotfile || find_user_xdg_config ||
|
21
|
+
DEFAULT_FILE
|
22
|
+
end
|
23
|
+
|
24
|
+
# Returns the path RuboCop inferred as the root of the project. No file
|
25
|
+
# searches will go past this directory.
|
26
|
+
def project_root
|
27
|
+
@project_root ||= find_project_root
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def find_project_root
|
33
|
+
pwd = Dir.pwd
|
34
|
+
gems_file = find_last_file_upwards('Gemfile', pwd) || find_last_file_upwards('gems.rb', pwd)
|
35
|
+
return unless gems_file
|
36
|
+
|
37
|
+
File.dirname(gems_file)
|
38
|
+
end
|
39
|
+
|
40
|
+
def find_project_dotfile(target_dir)
|
41
|
+
find_file_upwards(DOTFILE, target_dir, project_root)
|
42
|
+
end
|
43
|
+
|
44
|
+
def find_user_dotfile
|
45
|
+
return unless ENV.key?('HOME')
|
46
|
+
|
47
|
+
file = File.join(Dir.home, DOTFILE)
|
48
|
+
|
49
|
+
return file if File.exist?(file)
|
50
|
+
end
|
51
|
+
|
52
|
+
def find_user_xdg_config
|
53
|
+
xdg_config_home = expand_path(ENV.fetch('XDG_CONFIG_HOME', '~/.config'))
|
54
|
+
xdg_config = File.join(xdg_config_home, 'rubocop', XDG_CONFIG)
|
55
|
+
|
56
|
+
return xdg_config if File.exist?(xdg_config)
|
57
|
+
end
|
58
|
+
|
59
|
+
def expand_path(path)
|
60
|
+
File.expand_path(path)
|
61
|
+
rescue ArgumentError
|
62
|
+
# Could happen because HOME or ID could not be determined. Fall back on
|
63
|
+
# using the path literally in that case.
|
64
|
+
path
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'erb'
|
4
4
|
require 'yaml'
|
5
5
|
require 'pathname'
|
6
|
+
require_relative 'config_finder'
|
6
7
|
|
7
8
|
module RuboCop
|
8
9
|
# Raised when a RuboCop configuration file is not found.
|
@@ -15,8 +16,7 @@ module RuboCop
|
|
15
16
|
# during a run of the rubocop program, if files in several
|
16
17
|
# directories are inspected.
|
17
18
|
class ConfigLoader
|
18
|
-
DOTFILE =
|
19
|
-
XDG_CONFIG = 'config.yml'
|
19
|
+
DOTFILE = ConfigFinder::DOTFILE
|
20
20
|
RUBOCOP_HOME = File.realpath(File.join(File.dirname(__FILE__), '..', '..'))
|
21
21
|
DEFAULT_FILE = File.join(RUBOCOP_HOME, 'config', 'default.yml')
|
22
22
|
|
@@ -25,7 +25,7 @@ module RuboCop
|
|
25
25
|
|
26
26
|
attr_accessor :debug, :ignore_parent_exclusion, :disable_pending_cops, :enable_pending_cops,
|
27
27
|
:ignore_unrecognized_cops
|
28
|
-
attr_writer :default_configuration
|
28
|
+
attr_writer :default_configuration
|
29
29
|
attr_reader :loaded_features
|
30
30
|
|
31
31
|
alias debug? debug
|
@@ -95,8 +95,7 @@ module RuboCop
|
|
95
95
|
# user's home directory is checked. If there's no .rubocop.yml
|
96
96
|
# there either, the path to the default file is returned.
|
97
97
|
def configuration_file_for(target_dir)
|
98
|
-
|
99
|
-
find_user_xdg_config || DEFAULT_FILE
|
98
|
+
ConfigFinder.find_config_path(target_dir)
|
100
99
|
end
|
101
100
|
|
102
101
|
def configuration_from_file(config_file, check: true)
|
@@ -122,7 +121,7 @@ module RuboCop
|
|
122
121
|
end
|
123
122
|
|
124
123
|
def add_excludes_from_files(config, config_file)
|
125
|
-
exclusion_file = find_last_file_upwards(DOTFILE, config_file, project_root)
|
124
|
+
exclusion_file = find_last_file_upwards(DOTFILE, config_file, ConfigFinder.project_root)
|
126
125
|
|
127
126
|
return unless exclusion_file
|
128
127
|
return if PathUtil.relative_path(exclusion_file) == PathUtil.relative_path(config_file)
|
@@ -140,8 +139,14 @@ module RuboCop
|
|
140
139
|
|
141
140
|
# Returns the path RuboCop inferred as the root of the project. No file
|
142
141
|
# searches will go past this directory.
|
142
|
+
# @deprecated Use `RuboCop::ConfigFinder.project_root` instead.
|
143
143
|
def project_root
|
144
|
-
|
144
|
+
warn Rainbow(<<~WARNING).yellow
|
145
|
+
`RuboCop::ConfigLoader.project_root` is deprecated and will be removed in RuboCop 2.0. \
|
146
|
+
Use `RuboCop::ConfigFinder.project_root` instead.
|
147
|
+
WARNING
|
148
|
+
|
149
|
+
ConfigFinder.project_root
|
145
150
|
end
|
146
151
|
|
147
152
|
PENDING_BANNER = <<~BANNER
|
@@ -187,39 +192,6 @@ module RuboCop
|
|
187
192
|
File.absolute_path(file.is_a?(RemoteConfig) ? file.file : file)
|
188
193
|
end
|
189
194
|
|
190
|
-
def find_project_dotfile(target_dir)
|
191
|
-
find_file_upwards(DOTFILE, target_dir, project_root)
|
192
|
-
end
|
193
|
-
|
194
|
-
def find_project_root
|
195
|
-
pwd = Dir.pwd
|
196
|
-
gems_file = find_last_file_upwards('Gemfile', pwd) || find_last_file_upwards('gems.rb', pwd)
|
197
|
-
return unless gems_file
|
198
|
-
|
199
|
-
File.dirname(gems_file)
|
200
|
-
end
|
201
|
-
|
202
|
-
def find_user_dotfile
|
203
|
-
return unless ENV.key?('HOME')
|
204
|
-
|
205
|
-
file = File.join(Dir.home, DOTFILE)
|
206
|
-
return file if File.exist?(file)
|
207
|
-
end
|
208
|
-
|
209
|
-
def find_user_xdg_config
|
210
|
-
xdg_config_home = expand_path(ENV.fetch('XDG_CONFIG_HOME', '~/.config'))
|
211
|
-
xdg_config = File.join(xdg_config_home, 'rubocop', XDG_CONFIG)
|
212
|
-
return xdg_config if File.exist?(xdg_config)
|
213
|
-
end
|
214
|
-
|
215
|
-
def expand_path(path)
|
216
|
-
File.expand_path(path)
|
217
|
-
rescue ArgumentError
|
218
|
-
# Could happen because HOME or ID could not be determined. Fall back on
|
219
|
-
# using the path literally in that case.
|
220
|
-
path
|
221
|
-
end
|
222
|
-
|
223
195
|
def resolver
|
224
196
|
@resolver ||= ConfigLoaderResolver.new
|
225
197
|
end
|
@@ -11,11 +11,7 @@ module RuboCop
|
|
11
11
|
config_dir = File.dirname(path)
|
12
12
|
hash.delete('require').tap do |loaded_features|
|
13
13
|
Array(loaded_features).each do |feature|
|
14
|
-
|
15
|
-
require(File.join(config_dir, feature))
|
16
|
-
else
|
17
|
-
require(feature)
|
18
|
-
end
|
14
|
+
FeatureLoader.load(config_directory_path: config_dir, feature: feature)
|
19
15
|
end
|
20
16
|
end
|
21
17
|
end
|
@@ -12,6 +12,11 @@ module RuboCop
|
|
12
12
|
|
13
13
|
if alternative
|
14
14
|
"#{base}\n`#{parameter}` has been renamed to `#{alternative.chomp}`."
|
15
|
+
elsif alternatives
|
16
|
+
"#{base}\n`#{parameter}` has been renamed to #{to_sentence(alternatives.map do |item|
|
17
|
+
"`#{item}`"
|
18
|
+
end,
|
19
|
+
connector: 'and/or')}."
|
15
20
|
else
|
16
21
|
"#{base}\n#{reason.chomp}"
|
17
22
|
end
|