rubocop 0.81.0 → 0.82.0
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 +2 -2
- data/config/default.yml +59 -13
- data/lib/rubocop.rb +4 -2
- data/lib/rubocop/ast/node.rb +1 -1
- data/lib/rubocop/ast/node/array_node.rb +13 -0
- data/lib/rubocop/ast/node/mixin/method_dispatch_node.rb +8 -0
- data/lib/rubocop/cli.rb +10 -4
- data/lib/rubocop/config.rb +9 -1
- data/lib/rubocop/config_loader.rb +24 -15
- data/lib/rubocop/config_loader_resolver.rb +1 -1
- data/lib/rubocop/config_obsoletion.rb +1 -0
- data/lib/rubocop/config_validator.rb +16 -0
- data/lib/rubocop/cop/badge.rb +5 -5
- data/lib/rubocop/cop/bundler/insecure_protocol_source.rb +1 -1
- data/lib/rubocop/cop/corrector.rb +48 -24
- data/lib/rubocop/cop/correctors/alignment_corrector.rb +2 -2
- data/lib/rubocop/cop/correctors/condition_corrector.rb +1 -2
- data/lib/rubocop/cop/correctors/empty_line_corrector.rb +1 -1
- data/lib/rubocop/cop/correctors/lambda_literal_to_method_corrector.rb +3 -3
- data/lib/rubocop/cop/correctors/line_break_corrector.rb +2 -2
- data/lib/rubocop/cop/correctors/percent_literal_corrector.rb +1 -1
- data/lib/rubocop/cop/correctors/string_literal_corrector.rb +2 -2
- data/lib/rubocop/cop/internal_affairs/offense_location_keyword.rb +1 -1
- data/lib/rubocop/cop/layout/dot_position.rb +1 -1
- data/lib/rubocop/cop/layout/end_of_line.rb +2 -2
- data/lib/rubocop/cop/layout/first_array_element_indentation.rb +16 -10
- data/lib/rubocop/cop/layout/first_hash_element_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +2 -2
- data/lib/rubocop/cop/layout/heredoc_indentation.rb +2 -2
- data/lib/rubocop/cop/layout/{tab.rb → indentation_style.rb} +48 -6
- data/lib/rubocop/cop/layout/leading_comment_space.rb +1 -1
- data/lib/rubocop/cop/layout/line_length.rb +2 -2
- data/lib/rubocop/cop/layout/multiline_block_layout.rb +1 -1
- data/lib/rubocop/cop/layout/space_around_block_parameters.rb +3 -3
- data/lib/rubocop/cop/layout/space_around_method_call_operator.rb +133 -0
- data/lib/rubocop/cop/layout/space_around_operators.rb +1 -1
- data/lib/rubocop/cop/layout/space_in_lambda_literal.rb +1 -1
- data/lib/rubocop/cop/layout/space_inside_block_braces.rb +2 -2
- data/lib/rubocop/cop/layout/space_inside_range_literal.rb +2 -2
- data/lib/rubocop/cop/lint/boolean_symbol.rb +2 -2
- data/lib/rubocop/cop/lint/debugger.rb +1 -1
- data/lib/rubocop/cop/lint/implicit_string_concatenation.rb +1 -1
- data/lib/rubocop/cop/lint/inherit_exception.rb +1 -1
- data/lib/rubocop/cop/lint/interpolation_check.rb +1 -1
- data/lib/rubocop/cop/lint/literal_in_interpolation.rb +1 -1
- data/lib/rubocop/cop/lint/multiple_comparison.rb +1 -1
- data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +2 -2
- data/lib/rubocop/cop/lint/number_conversion.rb +1 -1
- data/lib/rubocop/cop/lint/percent_string_array.rb +2 -2
- data/lib/rubocop/cop/lint/raise_exception.rb +42 -6
- data/lib/rubocop/cop/lint/redundant_string_coercion.rb +1 -1
- data/lib/rubocop/cop/lint/unified_integer.rb +0 -2
- data/lib/rubocop/cop/lint/uri_regexp.rb +4 -4
- data/lib/rubocop/cop/mixin/hash_transform_method.rb +1 -1
- data/lib/rubocop/cop/mixin/line_length_help.rb +1 -1
- data/lib/rubocop/cop/mixin/statement_modifier.rb +4 -3
- data/lib/rubocop/cop/mixin/trailing_comma.rb +1 -1
- data/lib/rubocop/cop/naming/class_and_module_camel_case.rb +1 -1
- data/lib/rubocop/cop/naming/constant_name.rb +2 -1
- data/lib/rubocop/cop/naming/heredoc_delimiter_naming.rb +1 -1
- data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +1 -1
- data/lib/rubocop/cop/registry.rb +11 -4
- data/lib/rubocop/cop/style/alias.rb +4 -4
- data/lib/rubocop/cop/style/and_or.rb +5 -6
- data/lib/rubocop/cop/style/array_join.rb +1 -1
- data/lib/rubocop/cop/style/case_equality.rb +24 -1
- data/lib/rubocop/cop/style/character_literal.rb +2 -2
- data/lib/rubocop/cop/style/conditional_assignment.rb +8 -8
- data/lib/rubocop/cop/style/copyright.rb +1 -1
- data/lib/rubocop/cop/style/dir.rb +1 -1
- data/lib/rubocop/cop/style/disable_cops_within_source_code_directive.rb +49 -0
- data/lib/rubocop/cop/style/double_cop_disable_directive.rb +1 -1
- data/lib/rubocop/cop/style/each_for_simple_loop.rb +1 -1
- data/lib/rubocop/cop/style/each_with_object.rb +3 -3
- data/lib/rubocop/cop/style/empty_method.rb +1 -1
- data/lib/rubocop/cop/style/even_odd.rb +1 -1
- data/lib/rubocop/cop/style/expand_path_arguments.rb +3 -3
- data/lib/rubocop/cop/style/exponential_notation.rb +119 -0
- data/lib/rubocop/cop/style/format_string.rb +2 -2
- data/lib/rubocop/cop/style/hash_each_methods.rb +3 -3
- data/lib/rubocop/cop/style/hash_syntax.rb +3 -5
- data/lib/rubocop/cop/style/hash_transform_values.rb +0 -3
- data/lib/rubocop/cop/style/if_unless_modifier.rb +23 -3
- data/lib/rubocop/cop/style/lambda.rb +2 -2
- data/lib/rubocop/cop/style/lambda_call.rb +2 -2
- data/lib/rubocop/cop/style/mixin_grouping.rb +1 -1
- data/lib/rubocop/cop/style/module_function.rb +2 -2
- data/lib/rubocop/cop/style/multiline_if_modifier.rb +1 -1
- data/lib/rubocop/cop/style/multiline_memoization.rb +1 -1
- data/lib/rubocop/cop/style/mutable_constant.rb +2 -4
- data/lib/rubocop/cop/style/next.rb +2 -2
- data/lib/rubocop/cop/style/nil_comparison.rb +1 -1
- data/lib/rubocop/cop/style/non_nil_check.rb +4 -4
- data/lib/rubocop/cop/style/not.rb +1 -1
- data/lib/rubocop/cop/style/numeric_literal_prefix.rb +1 -1
- data/lib/rubocop/cop/style/numeric_literals.rb +1 -1
- data/lib/rubocop/cop/style/numeric_predicate.rb +1 -1
- data/lib/rubocop/cop/style/one_line_conditional.rb +1 -1
- data/lib/rubocop/cop/style/or_assignment.rb +1 -1
- data/lib/rubocop/cop/style/percent_q_literals.rb +1 -1
- data/lib/rubocop/cop/style/perl_backrefs.rb +2 -2
- data/lib/rubocop/cop/style/proc.rb +1 -1
- data/lib/rubocop/cop/style/raise_args.rb +1 -1
- data/lib/rubocop/cop/style/random_with_offset.rb +3 -3
- data/lib/rubocop/cop/style/redundant_condition.rb +3 -4
- data/lib/rubocop/cop/style/redundant_conditional.rb +1 -1
- data/lib/rubocop/cop/style/redundant_exception.rb +3 -3
- data/lib/rubocop/cop/style/redundant_interpolation.rb +2 -2
- data/lib/rubocop/cop/style/redundant_percent_q.rb +2 -2
- data/lib/rubocop/cop/style/redundant_return.rb +5 -7
- data/lib/rubocop/cop/style/redundant_self.rb +1 -1
- data/lib/rubocop/cop/style/rescue_modifier.rb +1 -1
- data/lib/rubocop/cop/style/return_nil.rb +1 -1
- data/lib/rubocop/cop/style/safe_navigation.rb +1 -1
- data/lib/rubocop/cop/style/self_assignment.rb +1 -1
- data/lib/rubocop/cop/style/special_global_vars.rb +1 -1
- data/lib/rubocop/cop/style/stabby_lambda_parentheses.rb +1 -4
- data/lib/rubocop/cop/style/string_hash_keys.rb +1 -1
- data/lib/rubocop/cop/style/symbol_array.rb +1 -1
- data/lib/rubocop/cop/style/symbol_literal.rb +2 -2
- data/lib/rubocop/cop/style/ternary_parentheses.rb +1 -2
- data/lib/rubocop/cop/style/trailing_comma_in_arguments.rb +2 -1
- data/lib/rubocop/cop/style/trailing_comma_in_block_args.rb +3 -0
- data/lib/rubocop/cop/style/trivial_accessors.rb +1 -1
- data/lib/rubocop/cop/style/unpack_first.rb +0 -4
- data/lib/rubocop/cop/style/variable_interpolation.rb +1 -1
- data/lib/rubocop/cop/style/while_until_modifier.rb +1 -1
- data/lib/rubocop/cop/style/word_array.rb +1 -1
- data/lib/rubocop/cop/style/zero_length_predicate.rb +1 -1
- data/lib/rubocop/formatter/formatter_set.rb +0 -1
- data/lib/rubocop/formatter/pacman_formatter.rb +1 -1
- data/lib/rubocop/options.rb +7 -1
- data/lib/rubocop/processed_source.rb +0 -3
- data/lib/rubocop/rspec/cop_helper.rb +1 -1
- data/lib/rubocop/rspec/expect_offense.rb +1 -1
- data/lib/rubocop/rspec/shared_contexts.rb +0 -4
- data/lib/rubocop/runner.rb +1 -1
- data/lib/rubocop/target_ruby.rb +2 -2
- data/lib/rubocop/version.rb +1 -1
- metadata +7 -5
- data/lib/rubocop/formatter/disabled_lines_formatter.rb +0 -57
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e04c6e897293df4ef1c7bf05a0c0077512e2cba797a7caee484b1c08a7300ad
|
4
|
+
data.tar.gz: 92fbc98b5068e5c30bf83d058e3cfe774a1a65cc90608027ff8d6624c8c2910c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cacf128617d233de65c2061d0300d345357840b151f65c78a2463fa23830115dcaa667cc2110ef39cacd14d957e626fc3fb4857443e40a1ab0fb485ce9cbfeed
|
7
|
+
data.tar.gz: f7a095da673a5b32de33293c6056c580995d1b2ad913e2891c1740ab1ffb42896f1b0c69491eb75656907b60e4de6f6a58a119c8936cff26d1ed678bc1159e0c
|
data/README.md
CHANGED
@@ -53,7 +53,7 @@ haven't reached version 1.0 yet). To prevent an unwanted RuboCop update you
|
|
53
53
|
might want to use a conservative version lock in your `Gemfile`:
|
54
54
|
|
55
55
|
```rb
|
56
|
-
gem 'rubocop', '~> 0.
|
56
|
+
gem 'rubocop', '~> 0.82.0', require: false
|
57
57
|
```
|
58
58
|
|
59
59
|
## Quickstart
|
@@ -73,7 +73,7 @@ You can read a lot more about RuboCop in its [official docs](https://docs.ruboco
|
|
73
73
|
|
74
74
|
RuboCop supports the following Ruby implementations:
|
75
75
|
|
76
|
-
* MRI 2.
|
76
|
+
* MRI 2.4+
|
77
77
|
* JRuby 9.2+
|
78
78
|
|
79
79
|
## Team
|
data/config/default.yml
CHANGED
@@ -97,6 +97,14 @@ AllCops:
|
|
97
97
|
# to true in the same configuration.
|
98
98
|
EnabledByDefault: false
|
99
99
|
DisabledByDefault: false
|
100
|
+
# New cops introduced between major versions are set to a special pending status
|
101
|
+
# and are not enabled by default with warning message.
|
102
|
+
# Change this behavior by overriding either `NewCops: enable` or `NewCops: disable`.
|
103
|
+
# When `NewCops` is `enable`, pending cops are enabled in bulk. Can be overridden by
|
104
|
+
# the `--enable-pending-cops` command-line option.
|
105
|
+
# When `NewCops` is `disable`, pending cops are disabled in bulk. Can be overridden by
|
106
|
+
# the `--disable-pending-cops` command-line option.
|
107
|
+
NewCops: pending
|
100
108
|
# Enables the result cache if `true`. Can be overridden by the `--cache` command
|
101
109
|
# line option.
|
102
110
|
UseCache: true
|
@@ -125,7 +133,7 @@ AllCops:
|
|
125
133
|
# followed by the Gemfile.lock or gems.locked file. (Although the Ruby version
|
126
134
|
# is specified in the Gemfile or gems.rb file, RuboCop reads the final value
|
127
135
|
# from the lock file.) If the Ruby version is still unresolved, RuboCop will
|
128
|
-
# use the oldest officially supported Ruby version (currently Ruby 2.
|
136
|
+
# use the oldest officially supported Ruby version (currently Ruby 2.4).
|
129
137
|
TargetRubyVersion: ~
|
130
138
|
|
131
139
|
#################### Bundler ###############################
|
@@ -793,6 +801,22 @@ Layout/IndentationConsistency:
|
|
793
801
|
# A reference to `EnforcedStyle: indented_internal_methods`.
|
794
802
|
- https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#follow-the-coding-conventions
|
795
803
|
|
804
|
+
Layout/IndentationStyle:
|
805
|
+
Description: 'Consistent indentation either with tabs only or spaces only.'
|
806
|
+
StyleGuide: '#spaces-indentation'
|
807
|
+
Enabled: true
|
808
|
+
VersionAdded: '0.49'
|
809
|
+
VersionChanged: '0.82'
|
810
|
+
# By default, the indentation width from Layout/IndentationWidth is used
|
811
|
+
# But it can be overridden by setting this parameter
|
812
|
+
# It is used during auto-correction to determine how many spaces should
|
813
|
+
# replace each tab.
|
814
|
+
IndentationWidth: ~
|
815
|
+
EnforcedStyle: spaces
|
816
|
+
SupportedStyles:
|
817
|
+
- spaces
|
818
|
+
- tabs
|
819
|
+
|
796
820
|
Layout/IndentationWidth:
|
797
821
|
Description: 'Use 2 spaces for indentation.'
|
798
822
|
StyleGuide: '#spaces-indentation'
|
@@ -1080,6 +1104,11 @@ Layout/SpaceAroundKeyword:
|
|
1080
1104
|
Enabled: true
|
1081
1105
|
VersionAdded: '0.49'
|
1082
1106
|
|
1107
|
+
Layout/SpaceAroundMethodCallOperator:
|
1108
|
+
Description: 'Checks method call operators to not have spaces around them.'
|
1109
|
+
Enabled: pending
|
1110
|
+
VersionAdded: '0.82'
|
1111
|
+
|
1083
1112
|
Layout/SpaceAroundOperators:
|
1084
1113
|
Description: 'Use a single space around operators.'
|
1085
1114
|
StyleGuide: '#spaces-operators'
|
@@ -1250,18 +1279,6 @@ Layout/SpaceInsideStringInterpolation:
|
|
1250
1279
|
- space
|
1251
1280
|
- no_space
|
1252
1281
|
|
1253
|
-
Layout/Tab:
|
1254
|
-
Description: 'No hard tabs.'
|
1255
|
-
StyleGuide: '#spaces-indentation'
|
1256
|
-
Enabled: true
|
1257
|
-
VersionAdded: '0.49'
|
1258
|
-
VersionChanged: '0.51'
|
1259
|
-
# By default, the indentation width from Layout/IndentationWidth is used
|
1260
|
-
# But it can be overridden by setting this parameter
|
1261
|
-
# It is used during auto-correction to determine how many spaces should
|
1262
|
-
# replace each tab.
|
1263
|
-
IndentationWidth: ~
|
1264
|
-
|
1265
1282
|
Layout/TrailingEmptyLines:
|
1266
1283
|
Description: 'Checks trailing blank lines and final newline.'
|
1267
1284
|
StyleGuide: '#newline-eof'
|
@@ -1567,6 +1584,8 @@ Lint/RaiseException:
|
|
1567
1584
|
StyleGuide: '#raise-exception'
|
1568
1585
|
Enabled: pending
|
1569
1586
|
VersionAdded: '0.81'
|
1587
|
+
AllowedImplicitNamespaces:
|
1588
|
+
- 'Gem'
|
1570
1589
|
|
1571
1590
|
Lint/RandOne:
|
1572
1591
|
Description: >-
|
@@ -2409,6 +2428,15 @@ Style/CaseEquality:
|
|
2409
2428
|
StyleGuide: '#no-case-equality'
|
2410
2429
|
Enabled: true
|
2411
2430
|
VersionAdded: '0.9'
|
2431
|
+
# If AllowOnConstant is enabled, the cop will ignore violations when the receiver of
|
2432
|
+
# the case equality operator is a constant.
|
2433
|
+
#
|
2434
|
+
# # bad
|
2435
|
+
# /string/ === "string"
|
2436
|
+
#
|
2437
|
+
# # good
|
2438
|
+
# String === "string"
|
2439
|
+
AllowOnConstant: false
|
2412
2440
|
|
2413
2441
|
Style/CharacterLiteral:
|
2414
2442
|
Description: 'Checks for uses of character literals.'
|
@@ -2449,6 +2477,7 @@ Style/ClassAndModuleChildren:
|
|
2449
2477
|
|
2450
2478
|
Style/ClassCheck:
|
2451
2479
|
Description: 'Enforces consistent use of `Object#is_a?` or `Object#kind_of?`.'
|
2480
|
+
StyleGuide: '#is-a-vs-kind-of'
|
2452
2481
|
Enabled: true
|
2453
2482
|
VersionAdded: '0.24'
|
2454
2483
|
EnforcedStyle: is_a?
|
@@ -2616,6 +2645,12 @@ Style/Dir:
|
|
2616
2645
|
Enabled: true
|
2617
2646
|
VersionAdded: '0.50'
|
2618
2647
|
|
2648
|
+
Style/DisableCopsWithinSourceCodeDirective:
|
2649
|
+
Description: >-
|
2650
|
+
Forbids disabling/enabling cops within source code.
|
2651
|
+
Enabled: false
|
2652
|
+
VersionAdded: '0.82'
|
2653
|
+
|
2619
2654
|
Style/Documentation:
|
2620
2655
|
Description: 'Document classes and non-namespace modules.'
|
2621
2656
|
Enabled: true
|
@@ -2734,6 +2769,17 @@ Style/ExpandPathArguments:
|
|
2734
2769
|
Enabled: true
|
2735
2770
|
VersionAdded: '0.53'
|
2736
2771
|
|
2772
|
+
Style/ExponentialNotation:
|
2773
|
+
Description: 'When using exponential notation, favor a mantissa between 1 (inclusive) and 10 (exclusive).'
|
2774
|
+
StyleGuide: '#exponential-notation'
|
2775
|
+
Enabled: pending
|
2776
|
+
VersionAdded: '0.82'
|
2777
|
+
EnforcedStyle: scientific
|
2778
|
+
SupportedStyles:
|
2779
|
+
- scientific
|
2780
|
+
- engineering
|
2781
|
+
- integral
|
2782
|
+
|
2737
2783
|
Style/FloatDivision:
|
2738
2784
|
Description: 'For performing float division, coerce one side only.'
|
2739
2785
|
StyleGuide: '#float-division'
|
data/lib/rubocop.rb
CHANGED
@@ -235,6 +235,7 @@ require_relative 'rubocop/cop/layout/hash_alignment'
|
|
235
235
|
require_relative 'rubocop/cop/layout/heredoc_argument_closing_parenthesis'
|
236
236
|
require_relative 'rubocop/cop/layout/heredoc_indentation'
|
237
237
|
require_relative 'rubocop/cop/layout/indentation_consistency'
|
238
|
+
require_relative 'rubocop/cop/layout/indentation_style'
|
238
239
|
require_relative 'rubocop/cop/layout/indentation_width'
|
239
240
|
require_relative 'rubocop/cop/layout/initial_indentation'
|
240
241
|
require_relative 'rubocop/cop/layout/leading_comment_space'
|
@@ -261,6 +262,7 @@ require_relative 'rubocop/cop/layout/space_after_semicolon'
|
|
261
262
|
require_relative 'rubocop/cop/layout/space_around_block_parameters'
|
262
263
|
require_relative 'rubocop/cop/layout/space_around_equals_in_parameter_default'
|
263
264
|
require_relative 'rubocop/cop/layout/space_around_keyword'
|
265
|
+
require_relative 'rubocop/cop/layout/space_around_method_call_operator'
|
264
266
|
require_relative 'rubocop/cop/layout/space_around_operators'
|
265
267
|
require_relative 'rubocop/cop/layout/space_before_block_braces'
|
266
268
|
require_relative 'rubocop/cop/layout/space_before_comma'
|
@@ -277,7 +279,6 @@ require_relative 'rubocop/cop/layout/space_inside_percent_literal_delimiters'
|
|
277
279
|
require_relative 'rubocop/cop/layout/space_inside_range_literal'
|
278
280
|
require_relative 'rubocop/cop/layout/space_inside_reference_brackets'
|
279
281
|
require_relative 'rubocop/cop/layout/space_inside_string_interpolation'
|
280
|
-
require_relative 'rubocop/cop/layout/tab'
|
281
282
|
require_relative 'rubocop/cop/layout/trailing_empty_lines'
|
282
283
|
require_relative 'rubocop/cop/layout/trailing_whitespace'
|
283
284
|
|
@@ -423,6 +424,7 @@ require_relative 'rubocop/cop/style/copyright'
|
|
423
424
|
require_relative 'rubocop/cop/style/date_time'
|
424
425
|
require_relative 'rubocop/cop/style/def_with_parentheses'
|
425
426
|
require_relative 'rubocop/cop/style/dir'
|
427
|
+
require_relative 'rubocop/cop/style/disable_cops_within_source_code_directive'
|
426
428
|
require_relative 'rubocop/cop/style/documentation_method'
|
427
429
|
require_relative 'rubocop/cop/style/documentation'
|
428
430
|
require_relative 'rubocop/cop/style/double_cop_disable_directive'
|
@@ -440,6 +442,7 @@ require_relative 'rubocop/cop/style/end_block'
|
|
440
442
|
require_relative 'rubocop/cop/style/eval_with_location'
|
441
443
|
require_relative 'rubocop/cop/style/even_odd'
|
442
444
|
require_relative 'rubocop/cop/style/expand_path_arguments'
|
445
|
+
require_relative 'rubocop/cop/style/exponential_notation'
|
443
446
|
require_relative 'rubocop/cop/style/float_division'
|
444
447
|
require_relative 'rubocop/cop/style/for'
|
445
448
|
require_relative 'rubocop/cop/style/format_string'
|
@@ -585,7 +588,6 @@ require_relative 'rubocop/formatter/simple_text_formatter'
|
|
585
588
|
# relies on simple text
|
586
589
|
require_relative 'rubocop/formatter/clang_style_formatter'
|
587
590
|
require_relative 'rubocop/formatter/disabled_config_formatter'
|
588
|
-
require_relative 'rubocop/formatter/disabled_lines_formatter'
|
589
591
|
require_relative 'rubocop/formatter/emacs_style_formatter'
|
590
592
|
require_relative 'rubocop/formatter/file_list_formatter'
|
591
593
|
require_relative 'rubocop/formatter/fuubar_style_formatter'
|
data/lib/rubocop/ast/node.rb
CHANGED
@@ -116,7 +116,7 @@ module RuboCop
|
|
116
116
|
#
|
117
117
|
# @return [Integer] the index of the receiver node in its siblings
|
118
118
|
def sibling_index
|
119
|
-
parent
|
119
|
+
parent&.children&.index { |sibling| sibling.equal?(self) }
|
120
120
|
end
|
121
121
|
|
122
122
|
# Common destructuring method. This can be used to normalize
|
@@ -18,6 +18,19 @@ module RuboCop
|
|
18
18
|
each_child_node.to_a
|
19
19
|
end
|
20
20
|
|
21
|
+
# Calls the given block for all values in the `array` literal.
|
22
|
+
#
|
23
|
+
# @yieldparam [Node] node each node
|
24
|
+
# @return [self] if a block is given
|
25
|
+
# @return [Enumerator] if no block is given
|
26
|
+
def each_value(&block)
|
27
|
+
return to_enum(__method__) unless block_given?
|
28
|
+
|
29
|
+
values.each(&block)
|
30
|
+
|
31
|
+
self
|
32
|
+
end
|
33
|
+
|
21
34
|
# Checks whether the `array` literal is delimited by square brackets.
|
22
35
|
#
|
23
36
|
# @return [Boolean] whether the array is enclosed in square brackets
|
@@ -121,6 +121,14 @@ module RuboCop
|
|
121
121
|
loc.respond_to?(:dot) && loc.dot && loc.dot.is?('::')
|
122
122
|
end
|
123
123
|
|
124
|
+
# Checks whether the dispatched method uses a safe navigation operator to
|
125
|
+
# connect the receiver and the method name.
|
126
|
+
#
|
127
|
+
# @return [Boolean] whether the method was called with a connecting dot
|
128
|
+
def safe_navigation?
|
129
|
+
loc.respond_to?(:dot) && loc.dot && loc.dot.is?('&.')
|
130
|
+
end
|
131
|
+
|
124
132
|
# Checks whether the *explicit* receiver of this method dispatch is
|
125
133
|
# `self`.
|
126
134
|
#
|
data/lib/rubocop/cli.rb
CHANGED
@@ -83,10 +83,7 @@ module RuboCop
|
|
83
83
|
end
|
84
84
|
|
85
85
|
def act_on_options
|
86
|
-
|
87
|
-
ConfigLoader.auto_gen_config = @options[:auto_gen_config]
|
88
|
-
ConfigLoader.ignore_parent_exclusion = @options[:ignore_parent_exclusion]
|
89
|
-
ConfigLoader.options_config = @options[:config]
|
86
|
+
set_options_to_config_loader
|
90
87
|
|
91
88
|
@config_store.options_config = @options[:config] if @options[:config]
|
92
89
|
@config_store.force_default_config! if @options[:force_default_config]
|
@@ -102,6 +99,15 @@ module RuboCop
|
|
102
99
|
end
|
103
100
|
end
|
104
101
|
|
102
|
+
def set_options_to_config_loader
|
103
|
+
ConfigLoader.debug = @options[:debug]
|
104
|
+
ConfigLoader.auto_gen_config = @options[:auto_gen_config]
|
105
|
+
ConfigLoader.disable_pending_cops = @options[:disable_pending_cops]
|
106
|
+
ConfigLoader.enable_pending_cops = @options[:enable_pending_cops]
|
107
|
+
ConfigLoader.ignore_parent_exclusion = @options[:ignore_parent_exclusion]
|
108
|
+
ConfigLoader.options_config = @options[:config]
|
109
|
+
end
|
110
|
+
|
105
111
|
def handle_exiting_options
|
106
112
|
return unless Options::EXITING_OPTIONS.any? { |o| @options.key? o }
|
107
113
|
|
data/lib/rubocop/config.rb
CHANGED
@@ -47,7 +47,7 @@ module RuboCop
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def_delegators :@hash, :[], :[]=, :delete, :each, :key?, :keys, :each_key,
|
50
|
-
:map, :merge, :to_h, :to_hash
|
50
|
+
:map, :merge, :to_h, :to_hash, :transform_values
|
51
51
|
def_delegators :@validator, :validate, :target_ruby_version
|
52
52
|
|
53
53
|
def to_s
|
@@ -116,6 +116,14 @@ module RuboCop
|
|
116
116
|
@for_all_cops ||= self['AllCops'] || {}
|
117
117
|
end
|
118
118
|
|
119
|
+
def disabled_new_cops?
|
120
|
+
for_all_cops['NewCops'] == 'disable'
|
121
|
+
end
|
122
|
+
|
123
|
+
def enabled_new_cops?
|
124
|
+
for_all_cops['NewCops'] == 'enable'
|
125
|
+
end
|
126
|
+
|
119
127
|
def file_to_include?(file)
|
120
128
|
relative_file_path = path_relative_to_config(file)
|
121
129
|
|
@@ -24,7 +24,7 @@ module RuboCop
|
|
24
24
|
include FileFinder
|
25
25
|
|
26
26
|
attr_accessor :debug, :auto_gen_config, :ignore_parent_exclusion,
|
27
|
-
:options_config
|
27
|
+
:options_config, :disable_pending_cops, :enable_pending_cops
|
28
28
|
attr_writer :default_configuration
|
29
29
|
|
30
30
|
alias debug? debug
|
@@ -55,7 +55,10 @@ module RuboCop
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def add_missing_namespaces(path, hash)
|
58
|
-
hash.
|
58
|
+
# Using `hash.each_key` will cause the
|
59
|
+
# `can't add a new key into hash during iteration` error
|
60
|
+
hash_keys = hash.keys
|
61
|
+
hash_keys.each do |key|
|
59
62
|
q = Cop::Cop.qualified_cop_name(key, path)
|
60
63
|
next if q == key
|
61
64
|
|
@@ -76,30 +79,35 @@ module RuboCop
|
|
76
79
|
# user's home directory is checked. If there's no .rubocop.yml
|
77
80
|
# there either, the path to the default file is returned.
|
78
81
|
def configuration_file_for(target_dir)
|
79
|
-
find_project_dotfile(target_dir) ||
|
80
|
-
|
81
|
-
find_user_xdg_config ||
|
82
|
-
DEFAULT_FILE
|
82
|
+
find_project_dotfile(target_dir) || find_user_dotfile ||
|
83
|
+
find_user_xdg_config || DEFAULT_FILE
|
83
84
|
end
|
84
85
|
|
85
86
|
def configuration_from_file(config_file)
|
86
|
-
|
87
|
-
return config if config_file == DEFAULT_FILE
|
87
|
+
return ConfigLoader.default_configuration if config_file == DEFAULT_FILE
|
88
88
|
|
89
|
+
config = load_file(config_file)
|
89
90
|
if ignore_parent_exclusion?
|
90
91
|
print 'Ignoring AllCops/Exclude from parent folders' if debug?
|
91
92
|
else
|
92
93
|
add_excludes_from_files(config, config_file)
|
93
94
|
end
|
95
|
+
|
94
96
|
merge_with_default(config, config_file).tap do |merged_config|
|
95
|
-
|
97
|
+
unless possible_new_cops?(config)
|
98
|
+
warn_on_pending_cops(merged_config.pending_cops)
|
99
|
+
end
|
96
100
|
end
|
97
101
|
end
|
98
102
|
|
103
|
+
def possible_new_cops?(config)
|
104
|
+
disable_pending_cops || enable_pending_cops ||
|
105
|
+
config.disabled_new_cops? || config.enabled_new_cops?
|
106
|
+
end
|
107
|
+
|
99
108
|
def add_excludes_from_files(config, config_file)
|
100
|
-
found_files =
|
101
|
-
|
102
|
-
[find_user_dotfile, find_user_xdg_config].compact
|
109
|
+
found_files = find_files_upwards(DOTFILE, config_file) +
|
110
|
+
[find_user_dotfile, find_user_xdg_config].compact
|
103
111
|
|
104
112
|
return if found_files.empty?
|
105
113
|
return if PathUtil.relative_path(found_files.last) ==
|
@@ -198,7 +206,9 @@ module RuboCop
|
|
198
206
|
def write_config_file(file_name, file_string, rubocop_yml_contents)
|
199
207
|
File.open(file_name, 'w') do |f|
|
200
208
|
f.write "inherit_from:#{file_string}\n"
|
201
|
-
|
209
|
+
if /\S/.match?(rubocop_yml_contents)
|
210
|
+
f.write "\n#{rubocop_yml_contents}"
|
211
|
+
end
|
202
212
|
end
|
203
213
|
end
|
204
214
|
|
@@ -250,8 +260,7 @@ module RuboCop
|
|
250
260
|
|
251
261
|
def yaml_safe_load(yaml_code, filename)
|
252
262
|
if defined?(SafeYAML) && SafeYAML.respond_to?(:load)
|
253
|
-
SafeYAML.load(yaml_code, filename,
|
254
|
-
whitelisted_tags: %w[!ruby/regexp])
|
263
|
+
SafeYAML.load(yaml_code, filename, whitelisted_tags: %w[!ruby/regexp])
|
255
264
|
# Ruby 2.6+
|
256
265
|
elsif Gem::Version.new(Psych::VERSION) >= Gem::Version.new('3.1.0')
|
257
266
|
YAML.safe_load(
|
@@ -17,6 +17,7 @@ module RuboCop
|
|
17
17
|
'Layout/IndentHash' => 'Layout/FirstHashElementIndentation',
|
18
18
|
'Layout/IndentHeredoc' => 'Layout/HeredocIndentation',
|
19
19
|
'Layout/LeadingBlankLines' => 'Layout/LeadingEmptyLines',
|
20
|
+
'Layout/Tab' => 'Layout/IndentationStyle',
|
20
21
|
'Layout/TrailingBlankLines' => 'Layout/TrailingEmptyLines',
|
21
22
|
'Lint/DuplicatedKey' => 'Lint/DuplicateHashKey',
|
22
23
|
'Lint/EndInMethod' => 'Style/EndBlock',
|
@@ -13,6 +13,7 @@ module RuboCop
|
|
13
13
|
INTERNAL_PARAMS = %w[Description StyleGuide
|
14
14
|
VersionAdded VersionChanged VersionRemoved
|
15
15
|
Reference Safe SafeAutoCorrect].freeze
|
16
|
+
NEW_COPS_VALUES = %w[pending disable enable].freeze
|
16
17
|
|
17
18
|
def_delegators :@config, :smart_loaded_path, :for_all_cops
|
18
19
|
|
@@ -22,6 +23,7 @@ module RuboCop
|
|
22
23
|
@target_ruby = TargetRuby.new(config)
|
23
24
|
end
|
24
25
|
|
26
|
+
# rubocop:disable Metrics/AbcSize
|
25
27
|
def validate
|
26
28
|
check_cop_config_value(@config)
|
27
29
|
reject_conflicting_safe_settings
|
@@ -37,11 +39,13 @@ module RuboCop
|
|
37
39
|
|
38
40
|
alert_about_unrecognized_cops(invalid_cop_names)
|
39
41
|
check_target_ruby
|
42
|
+
validate_new_cops_parameter
|
40
43
|
validate_parameter_names(valid_cop_names)
|
41
44
|
validate_enforced_styles(valid_cop_names)
|
42
45
|
validate_syntax_cop
|
43
46
|
reject_mutually_exclusive_defaults
|
44
47
|
end
|
48
|
+
# rubocop:enable Metrics/AbcSize
|
45
49
|
|
46
50
|
def target_ruby_version
|
47
51
|
target_ruby.version
|
@@ -107,6 +111,18 @@ module RuboCop
|
|
107
111
|
'It\'s not possible to disable this cop.'
|
108
112
|
end
|
109
113
|
|
114
|
+
def validate_new_cops_parameter
|
115
|
+
new_cop_parameter = @config.for_all_cops['NewCops']
|
116
|
+
return if new_cop_parameter.nil? ||
|
117
|
+
NEW_COPS_VALUES.include?(new_cop_parameter)
|
118
|
+
|
119
|
+
message = "invalid #{new_cop_parameter} for `NewCops` found in" \
|
120
|
+
"#{smart_loaded_path}\n" \
|
121
|
+
"Valid choices are: #{NEW_COPS_VALUES.join(', ')}"
|
122
|
+
|
123
|
+
raise ValidationError, message
|
124
|
+
end
|
125
|
+
|
110
126
|
def validate_parameter_names(valid_cop_names)
|
111
127
|
valid_cop_names.each do |name|
|
112
128
|
validate_section_presence(name)
|