rubocop 1.39.0 → 1.44.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +2 -2
- data/config/default.yml +149 -11
- data/exe/rubocop +1 -1
- data/lib/rubocop/cli.rb +1 -1
- data/lib/rubocop/comment_config.rb +5 -0
- data/lib/rubocop/config.rb +39 -15
- data/lib/rubocop/config_loader.rb +26 -20
- data/lib/rubocop/config_loader_resolver.rb +6 -2
- data/lib/rubocop/config_validator.rb +1 -1
- data/lib/rubocop/cop/badge.rb +9 -4
- data/lib/rubocop/cop/base.rb +84 -74
- data/lib/rubocop/cop/commissioner.rb +8 -3
- data/lib/rubocop/cop/cop.rb +29 -29
- data/lib/rubocop/cop/corrector.rb +30 -10
- data/lib/rubocop/cop/correctors/multiline_literal_brace_corrector.rb +22 -6
- data/lib/rubocop/cop/correctors/ordered_gem_corrector.rb +1 -6
- data/lib/rubocop/cop/gemspec/dependency_version.rb +16 -18
- data/lib/rubocop/cop/gemspec/development_dependencies.rb +107 -0
- data/lib/rubocop/cop/internal_affairs/cop_description.rb +3 -1
- data/lib/rubocop/cop/internal_affairs/lambda_or_proc.rb +46 -0
- data/lib/rubocop/cop/internal_affairs/redundant_let_rubocop_config_new.rb +11 -3
- data/lib/rubocop/cop/internal_affairs.rb +1 -0
- data/lib/rubocop/cop/layout/block_end_newline.rb +7 -1
- data/lib/rubocop/cop/layout/class_structure.rb +32 -11
- data/lib/rubocop/cop/layout/closing_parenthesis_indentation.rb +2 -6
- data/lib/rubocop/cop/layout/comment_indentation.rb +3 -1
- data/lib/rubocop/cop/layout/empty_lines.rb +2 -0
- data/lib/rubocop/cop/layout/extra_spacing.rb +10 -6
- data/lib/rubocop/cop/layout/first_array_element_line_break.rb +38 -2
- data/lib/rubocop/cop/layout/first_hash_element_line_break.rb +49 -2
- data/lib/rubocop/cop/layout/first_method_argument_line_break.rb +61 -2
- data/lib/rubocop/cop/layout/first_method_parameter_line_break.rb +52 -2
- data/lib/rubocop/cop/layout/heredoc_indentation.rb +6 -9
- data/lib/rubocop/cop/layout/indentation_style.rb +7 -2
- data/lib/rubocop/cop/layout/line_continuation_leading_space.rb +5 -0
- data/lib/rubocop/cop/layout/line_continuation_spacing.rb +11 -5
- data/lib/rubocop/cop/layout/line_length.rb +2 -0
- data/lib/rubocop/cop/layout/multiline_array_line_breaks.rb +51 -2
- data/lib/rubocop/cop/layout/multiline_block_layout.rb +1 -1
- data/lib/rubocop/cop/layout/multiline_hash_key_line_breaks.rb +49 -2
- data/lib/rubocop/cop/layout/multiline_method_argument_line_breaks.rb +53 -2
- data/lib/rubocop/cop/layout/multiline_method_parameter_line_breaks.rb +58 -2
- data/lib/rubocop/cop/layout/redundant_line_break.rb +2 -2
- data/lib/rubocop/cop/layout/space_around_keyword.rb +1 -1
- data/lib/rubocop/cop/layout/space_inside_array_literal_brackets.rb +0 -2
- data/lib/rubocop/cop/layout/trailing_empty_lines.rb +1 -1
- data/lib/rubocop/cop/layout/trailing_whitespace.rb +11 -4
- data/lib/rubocop/cop/lint/ambiguous_block_association.rb +1 -1
- data/lib/rubocop/cop/lint/ambiguous_operator.rb +4 -0
- data/lib/rubocop/cop/lint/assignment_in_condition.rb +11 -1
- data/lib/rubocop/cop/lint/constant_resolution.rb +4 -0
- data/lib/rubocop/cop/lint/debugger.rb +3 -1
- data/lib/rubocop/cop/lint/deprecated_class_methods.rb +62 -112
- data/lib/rubocop/cop/lint/deprecated_constants.rb +8 -1
- data/lib/rubocop/cop/lint/duplicate_branch.rb +0 -2
- data/lib/rubocop/cop/lint/duplicate_methods.rb +19 -8
- data/lib/rubocop/cop/lint/else_layout.rb +2 -6
- data/lib/rubocop/cop/lint/empty_block.rb +1 -5
- data/lib/rubocop/cop/lint/empty_conditional_body.rb +1 -1
- data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +11 -7
- data/lib/rubocop/cop/lint/heredoc_method_call_position.rb +15 -17
- data/lib/rubocop/cop/lint/interpolation_check.rb +4 -3
- data/lib/rubocop/cop/lint/mixed_regexp_capture_types.rb +1 -0
- data/lib/rubocop/cop/lint/non_atomic_file_operation.rb +10 -5
- data/lib/rubocop/cop/lint/out_of_range_regexp_ref.rb +19 -0
- data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +5 -0
- data/lib/rubocop/cop/lint/redundant_cop_disable_directive.rb +15 -3
- data/lib/rubocop/cop/lint/redundant_cop_enable_directive.rb +1 -1
- data/lib/rubocop/cop/lint/redundant_require_statement.rb +11 -1
- data/lib/rubocop/cop/lint/regexp_as_condition.rb +6 -0
- data/lib/rubocop/cop/lint/require_parentheses.rb +3 -1
- data/lib/rubocop/cop/lint/safe_navigation_chain.rb +10 -12
- data/lib/rubocop/cop/lint/send_with_mixin_argument.rb +5 -4
- data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +4 -3
- data/lib/rubocop/cop/lint/unused_method_argument.rb +2 -1
- data/lib/rubocop/cop/lint/useless_method_definition.rb +3 -3
- data/lib/rubocop/cop/lint/useless_rescue.rb +85 -0
- data/lib/rubocop/cop/lint/useless_ruby2_keywords.rb +14 -4
- data/lib/rubocop/cop/lint/void.rb +25 -16
- data/lib/rubocop/cop/metrics/block_length.rb +9 -4
- data/lib/rubocop/cop/metrics/block_nesting.rb +1 -1
- data/lib/rubocop/cop/metrics/class_length.rb +10 -5
- data/lib/rubocop/cop/metrics/cyclomatic_complexity.rb +1 -1
- data/lib/rubocop/cop/metrics/method_length.rb +9 -4
- data/lib/rubocop/cop/metrics/module_length.rb +10 -5
- data/lib/rubocop/cop/metrics/parameter_lists.rb +27 -0
- data/lib/rubocop/cop/metrics/perceived_complexity.rb +1 -1
- data/lib/rubocop/cop/metrics/utils/abc_size_calculator.rb +3 -6
- data/lib/rubocop/cop/metrics/utils/code_length_calculator.rb +6 -3
- data/lib/rubocop/cop/mixin/alignment.rb +2 -2
- data/lib/rubocop/cop/mixin/allowed_identifiers.rb +2 -2
- data/lib/rubocop/cop/mixin/annotation_comment.rb +13 -6
- data/lib/rubocop/cop/mixin/configurable_enforced_style.rb +21 -9
- data/lib/rubocop/cop/mixin/first_element_line_break.rb +11 -7
- data/lib/rubocop/cop/mixin/hash_shorthand_syntax.rb +59 -6
- data/lib/rubocop/cop/mixin/line_length_help.rb +11 -2
- data/lib/rubocop/cop/mixin/method_complexity.rb +5 -3
- data/lib/rubocop/cop/mixin/multiline_element_line_breaks.rb +5 -3
- data/lib/rubocop/cop/mixin/percent_array.rb +3 -5
- data/lib/rubocop/cop/mixin/preceding_following_alignment.rb +1 -1
- data/lib/rubocop/cop/mixin/require_library.rb +2 -0
- data/lib/rubocop/cop/mixin/rescue_node.rb +3 -3
- data/lib/rubocop/cop/mixin/statement_modifier.rb +16 -1
- data/lib/rubocop/cop/naming/block_forwarding.rb +5 -1
- data/lib/rubocop/cop/naming/class_and_module_camel_case.rb +2 -0
- data/lib/rubocop/cop/naming/inclusive_language.rb +4 -1
- data/lib/rubocop/cop/registry.rb +63 -43
- data/lib/rubocop/cop/security/compound_hash.rb +2 -1
- data/lib/rubocop/cop/style/access_modifier_declarations.rb +18 -10
- data/lib/rubocop/cop/style/alias.rb +9 -1
- data/lib/rubocop/cop/style/array_intersect.rb +111 -0
- data/lib/rubocop/cop/style/block_comments.rb +1 -1
- data/lib/rubocop/cop/style/block_delimiters.rb +8 -2
- data/lib/rubocop/cop/style/class_and_module_children.rb +2 -9
- data/lib/rubocop/cop/style/comparable_clamp.rb +125 -0
- data/lib/rubocop/cop/style/concat_array_literals.rb +86 -0
- data/lib/rubocop/cop/style/conditional_assignment.rb +0 -6
- data/lib/rubocop/cop/style/documentation.rb +11 -5
- data/lib/rubocop/cop/style/guard_clause.rb +44 -9
- data/lib/rubocop/cop/style/hash_each_methods.rb +13 -1
- data/lib/rubocop/cop/style/hash_syntax.rb +11 -7
- data/lib/rubocop/cop/style/identical_conditional_branches.rb +15 -0
- data/lib/rubocop/cop/style/if_with_semicolon.rb +4 -4
- data/lib/rubocop/cop/style/infinite_loop.rb +2 -5
- data/lib/rubocop/cop/style/inverse_methods.rb +2 -0
- data/lib/rubocop/cop/style/invertible_unless_condition.rb +114 -0
- data/lib/rubocop/cop/style/line_end_concatenation.rb +4 -1
- data/lib/rubocop/cop/style/map_to_set.rb +61 -0
- data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +23 -14
- data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +2 -0
- data/lib/rubocop/cop/style/method_def_parentheses.rb +11 -4
- data/lib/rubocop/cop/style/min_max_comparison.rb +83 -0
- data/lib/rubocop/cop/style/missing_else.rb +13 -1
- data/lib/rubocop/cop/style/multiline_if_modifier.rb +0 -4
- data/lib/rubocop/cop/style/multiline_memoization.rb +2 -2
- data/lib/rubocop/cop/style/negated_if_else_condition.rb +1 -5
- data/lib/rubocop/cop/style/nil_lambda.rb +1 -1
- data/lib/rubocop/cop/style/one_line_conditional.rb +3 -6
- data/lib/rubocop/cop/style/operator_method_call.rb +15 -1
- data/lib/rubocop/cop/style/parallel_assignment.rb +3 -1
- data/lib/rubocop/cop/style/redundant_argument.rb +3 -0
- data/lib/rubocop/cop/style/redundant_conditional.rb +0 -4
- data/lib/rubocop/cop/style/redundant_constant_base.rb +85 -0
- data/lib/rubocop/cop/style/redundant_double_splat_hash_braces.rb +45 -0
- data/lib/rubocop/cop/style/redundant_regexp_escape.rb +2 -1
- data/lib/rubocop/cop/style/redundant_return.rb +7 -0
- data/lib/rubocop/cop/style/redundant_sort.rb +1 -1
- data/lib/rubocop/cop/style/redundant_string_escape.rb +6 -3
- data/lib/rubocop/cop/style/require_order.rb +135 -0
- data/lib/rubocop/cop/style/safe_navigation.rb +35 -6
- data/lib/rubocop/cop/style/select_by_regexp.rb +13 -5
- data/lib/rubocop/cop/style/self_assignment.rb +2 -2
- data/lib/rubocop/cop/style/semicolon.rb +26 -3
- data/lib/rubocop/cop/style/signal_exception.rb +8 -6
- data/lib/rubocop/cop/style/string_hash_keys.rb +4 -1
- data/lib/rubocop/cop/style/string_literals.rb +1 -5
- data/lib/rubocop/cop/style/symbol_proc.rb +2 -4
- data/lib/rubocop/cop/style/trailing_comma_in_arguments.rb +4 -4
- data/lib/rubocop/cop/style/word_array.rb +41 -0
- data/lib/rubocop/cop/style/yoda_expression.rb +81 -0
- data/lib/rubocop/cop/style/zero_length_predicate.rb +31 -14
- data/lib/rubocop/cop/team.rb +30 -30
- data/lib/rubocop/cop/util.rb +32 -5
- data/lib/rubocop/cop/variable_force/assignment.rb +1 -1
- data/lib/rubocop/cop/variable_force/variable_table.rb +3 -1
- data/lib/rubocop/cop/variable_force.rb +18 -30
- data/lib/rubocop/cops_documentation_generator.rb +33 -11
- data/lib/rubocop/directive_comment.rb +1 -1
- data/lib/rubocop/file_patterns.rb +43 -0
- data/lib/rubocop/formatter/disabled_config_formatter.rb +17 -6
- data/lib/rubocop/formatter/html_formatter.rb +1 -1
- data/lib/rubocop/formatter.rb +4 -1
- data/lib/rubocop/options.rb +8 -0
- data/lib/rubocop/path_util.rb +50 -22
- data/lib/rubocop/result_cache.rb +2 -2
- data/lib/rubocop/rspec/cop_helper.rb +4 -1
- data/lib/rubocop/rspec/expect_offense.rb +6 -4
- data/lib/rubocop/rspec/support.rb +2 -2
- data/lib/rubocop/runner.rb +10 -3
- data/lib/rubocop/server/cache.rb +3 -1
- data/lib/rubocop/server/core.rb +1 -1
- data/lib/rubocop/target_finder.rb +1 -1
- data/lib/rubocop/target_ruby.rb +1 -2
- data/lib/rubocop/version.rb +1 -1
- data/lib/rubocop.rb +23 -6
- metadata +23 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f6f58220d287e215fa9baaa9c274e89b128c0e42222595caa432132d27de274
|
4
|
+
data.tar.gz: e3c547bef6b2803f80ba22013eae4cff56f6fb572aca19a886bb2fb52e8ba665
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9d29df635f00839a5da2cee59c55d4a279129529e3f0b130b7ad8602058fa11e733562a8e253dfa03b45e716c406e425d6c1f28fbd5a4a0b06436404058aa91
|
7
|
+
data.tar.gz: 4a80236cfa9402004dddf72346b395e944840da07525658de1a42ce5bbef7a030be86c38af798e6cf977b75b2c6153ecd7f33b9d91ab3cec1d631b68d21a4568
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -53,7 +53,7 @@ To prevent an unwanted RuboCop update you might want to use a conservative versi
|
|
53
53
|
in your `Gemfile`:
|
54
54
|
|
55
55
|
```rb
|
56
|
-
gem 'rubocop', '~> 1.
|
56
|
+
gem 'rubocop', '~> 1.44', require: false
|
57
57
|
```
|
58
58
|
|
59
59
|
See [our versioning policy](https://docs.rubocop.org/rubocop/versioning.html) for further details.
|
@@ -246,5 +246,5 @@ RuboCop's changelog is available [here](CHANGELOG.md).
|
|
246
246
|
|
247
247
|
## Copyright
|
248
248
|
|
249
|
-
Copyright (c) 2012-
|
249
|
+
Copyright (c) 2012-2023 Bozhidar Batsov. See [LICENSE.txt](LICENSE.txt) for
|
250
250
|
further details.
|
data/config/default.yml
CHANGED
@@ -161,7 +161,9 @@ AllCops:
|
|
161
161
|
Bundler/DuplicatedGem:
|
162
162
|
Description: 'Checks for duplicate gem entries in Gemfile.'
|
163
163
|
Enabled: true
|
164
|
+
Severity: warning
|
164
165
|
VersionAdded: '0.46'
|
166
|
+
VersionChanged: '1.40'
|
165
167
|
Include:
|
166
168
|
- '**/*.gemfile'
|
167
169
|
- '**/Gemfile'
|
@@ -213,7 +215,9 @@ Bundler/InsecureProtocolSource:
|
|
213
215
|
because HTTP requests are insecure. Please change your source to
|
214
216
|
'https://rubygems.org' if possible, or 'http://rubygems.org' if not.
|
215
217
|
Enabled: true
|
218
|
+
Severity: warning
|
216
219
|
VersionAdded: '0.50'
|
220
|
+
VersionChanged: '1.40'
|
217
221
|
AllowHttpProtocol: true
|
218
222
|
Include:
|
219
223
|
- '**/*.gemfile'
|
@@ -252,14 +256,34 @@ Gemspec/DependencyVersion:
|
|
252
256
|
Gemspec/DeprecatedAttributeAssignment:
|
253
257
|
Description: Checks that deprecated attribute assignments are not set in a gemspec file.
|
254
258
|
Enabled: pending
|
259
|
+
Severity: warning
|
255
260
|
VersionAdded: '1.30'
|
261
|
+
VersionChanged: '1.40'
|
262
|
+
Include:
|
263
|
+
- '**/*.gemspec'
|
264
|
+
|
265
|
+
Gemspec/DevelopmentDependencies:
|
266
|
+
Description: Checks that development dependencies are specified in Gemfile rather than gemspec.
|
267
|
+
Enabled: pending
|
268
|
+
VersionAdded: '1.44'
|
269
|
+
EnforcedStyle: Gemfile
|
270
|
+
SupportedStyles:
|
271
|
+
- Gemfile
|
272
|
+
- gems.rb
|
273
|
+
- gemspec
|
274
|
+
AllowedGems:
|
275
|
+
- bundler
|
256
276
|
Include:
|
257
277
|
- '**/*.gemspec'
|
278
|
+
- '**/Gemfile'
|
279
|
+
- '**/gems.rb'
|
258
280
|
|
259
281
|
Gemspec/DuplicatedAssignment:
|
260
282
|
Description: 'An attribute assignment method calls should be listed only once in a gemspec.'
|
261
283
|
Enabled: true
|
284
|
+
Severity: warning
|
262
285
|
VersionAdded: '0.52'
|
286
|
+
VersionChanged: '1.40'
|
263
287
|
Include:
|
264
288
|
- '**/*.gemspec'
|
265
289
|
|
@@ -278,7 +302,9 @@ Gemspec/OrderedDependencies:
|
|
278
302
|
Gemspec/RequireMFA:
|
279
303
|
Description: 'Checks that the gemspec has metadata to require Multi-Factor Authentication from RubyGems.'
|
280
304
|
Enabled: pending
|
305
|
+
Severity: warning
|
281
306
|
VersionAdded: '1.23'
|
307
|
+
VersionChanged: '1.40'
|
282
308
|
Reference:
|
283
309
|
- https://guides.rubygems.org/mfa-requirement-opt-in/
|
284
310
|
Include:
|
@@ -287,8 +313,9 @@ Gemspec/RequireMFA:
|
|
287
313
|
Gemspec/RequiredRubyVersion:
|
288
314
|
Description: 'Checks that `required_ruby_version` of gemspec is specified and equal to `TargetRubyVersion` of .rubocop.yml.'
|
289
315
|
Enabled: true
|
316
|
+
Severity: warning
|
290
317
|
VersionAdded: '0.52'
|
291
|
-
VersionChanged: '1.
|
318
|
+
VersionChanged: '1.40'
|
292
319
|
Include:
|
293
320
|
- '**/*.gemspec'
|
294
321
|
|
@@ -296,7 +323,9 @@ Gemspec/RubyVersionGlobalsUsage:
|
|
296
323
|
Description: Checks usage of RUBY_VERSION in gemspec.
|
297
324
|
StyleGuide: '#no-ruby-version-in-the-gemspec'
|
298
325
|
Enabled: true
|
326
|
+
Severity: warning
|
299
327
|
VersionAdded: '0.72'
|
328
|
+
VersionChanged: '1.40'
|
300
329
|
Include:
|
301
330
|
- '**/*.gemspec'
|
302
331
|
|
@@ -378,8 +407,9 @@ Layout/AssignmentIndentation:
|
|
378
407
|
Checks the indentation of the first line of the
|
379
408
|
right-hand-side of a multi-line assignment.
|
380
409
|
Enabled: true
|
410
|
+
SafeAutoCorrect: false
|
381
411
|
VersionAdded: '0.49'
|
382
|
-
VersionChanged: '
|
412
|
+
VersionChanged: '1.40'
|
383
413
|
# By default the indentation width from `Layout/IndentationWidth` is used,
|
384
414
|
# but it can be overridden by setting this parameter.
|
385
415
|
IndentationWidth: ~
|
@@ -748,6 +778,7 @@ Layout/FirstArrayElementLineBreak:
|
|
748
778
|
multi-line array.
|
749
779
|
Enabled: false
|
750
780
|
VersionAdded: '0.49'
|
781
|
+
AllowMultilineFinalElement: false
|
751
782
|
|
752
783
|
Layout/FirstHashElementIndentation:
|
753
784
|
Description: 'Checks the indentation of the first key in a hash literal.'
|
@@ -780,6 +811,7 @@ Layout/FirstHashElementLineBreak:
|
|
780
811
|
multi-line hash.
|
781
812
|
Enabled: false
|
782
813
|
VersionAdded: '0.49'
|
814
|
+
AllowMultilineFinalElement: false
|
783
815
|
|
784
816
|
Layout/FirstMethodArgumentLineBreak:
|
785
817
|
Description: >-
|
@@ -787,6 +819,7 @@ Layout/FirstMethodArgumentLineBreak:
|
|
787
819
|
multi-line method call.
|
788
820
|
Enabled: false
|
789
821
|
VersionAdded: '0.49'
|
822
|
+
AllowMultilineFinalElement: false
|
790
823
|
|
791
824
|
Layout/FirstMethodParameterLineBreak:
|
792
825
|
Description: >-
|
@@ -794,6 +827,7 @@ Layout/FirstMethodParameterLineBreak:
|
|
794
827
|
multi-line method parameter definition.
|
795
828
|
Enabled: false
|
796
829
|
VersionAdded: '0.49'
|
830
|
+
AllowMultilineFinalElement: false
|
797
831
|
|
798
832
|
Layout/FirstParameterIndentation:
|
799
833
|
Description: >-
|
@@ -1053,6 +1087,7 @@ Layout/MultilineArrayLineBreaks:
|
|
1053
1087
|
starts on a separate line.
|
1054
1088
|
Enabled: false
|
1055
1089
|
VersionAdded: '0.67'
|
1090
|
+
AllowMultilineFinalElement: false
|
1056
1091
|
|
1057
1092
|
Layout/MultilineAssignmentLayout:
|
1058
1093
|
Description: 'Check for a newline after the assignment operator in multi-line assignments.'
|
@@ -1103,6 +1138,7 @@ Layout/MultilineHashKeyLineBreaks:
|
|
1103
1138
|
starts on a separate line.
|
1104
1139
|
Enabled: false
|
1105
1140
|
VersionAdded: '0.67'
|
1141
|
+
AllowMultilineFinalElement: false
|
1106
1142
|
|
1107
1143
|
Layout/MultilineMethodArgumentLineBreaks:
|
1108
1144
|
Description: >-
|
@@ -1110,6 +1146,7 @@ Layout/MultilineMethodArgumentLineBreaks:
|
|
1110
1146
|
starts on a separate line.
|
1111
1147
|
Enabled: false
|
1112
1148
|
VersionAdded: '0.67'
|
1149
|
+
AllowMultilineFinalElement: false
|
1113
1150
|
|
1114
1151
|
Layout/MultilineMethodCallBraceLayout:
|
1115
1152
|
Description: >-
|
@@ -1164,6 +1201,7 @@ Layout/MultilineMethodParameterLineBreaks:
|
|
1164
1201
|
starts on a separate line.
|
1165
1202
|
Enabled: false
|
1166
1203
|
VersionAdded: '1.32'
|
1204
|
+
AllowMultilineFinalElement: false
|
1167
1205
|
|
1168
1206
|
Layout/MultilineOperationIndentation:
|
1169
1207
|
Description: >-
|
@@ -1643,7 +1681,7 @@ Lint/DeprecatedConstants:
|
|
1643
1681
|
Description: 'Checks for deprecated constants.'
|
1644
1682
|
Enabled: pending
|
1645
1683
|
VersionAdded: '1.8'
|
1646
|
-
VersionChanged: '1.
|
1684
|
+
VersionChanged: '1.40'
|
1647
1685
|
# You can configure deprecated constants.
|
1648
1686
|
# If there is an alternative method, you can set alternative value as `Alternative`.
|
1649
1687
|
# And you can set the deprecated version as `DeprecatedVersion`.
|
@@ -1670,6 +1708,12 @@ Lint/DeprecatedConstants:
|
|
1670
1708
|
'Random::DEFAULT':
|
1671
1709
|
Alternative: 'Random.new'
|
1672
1710
|
DeprecatedVersion: '3.0'
|
1711
|
+
'Struct::Group':
|
1712
|
+
Alternative: 'Etc::Group'
|
1713
|
+
DeprecatedVersion: '3.0'
|
1714
|
+
'Struct::Passwd':
|
1715
|
+
Alternative: 'Etc::Passwd'
|
1716
|
+
DeprecatedVersion: '3.0'
|
1673
1717
|
|
1674
1718
|
Lint/DeprecatedOpenSSLConstant:
|
1675
1719
|
Description: "Don't use algorithm constants for `OpenSSL::Cipher` and `OpenSSL::Digest`."
|
@@ -1894,11 +1938,11 @@ Lint/InheritException:
|
|
1894
1938
|
- runtime_error
|
1895
1939
|
|
1896
1940
|
Lint/InterpolationCheck:
|
1897
|
-
Description: '
|
1941
|
+
Description: 'Checks for interpolation in a single quoted string.'
|
1898
1942
|
Enabled: true
|
1899
|
-
|
1943
|
+
SafeAutoCorrect: false
|
1900
1944
|
VersionAdded: '0.50'
|
1901
|
-
VersionChanged: '
|
1945
|
+
VersionChanged: '1.40'
|
1902
1946
|
|
1903
1947
|
Lint/LambdaWithoutLiteralBlock:
|
1904
1948
|
Description: 'Checks uses of lambda without a literal block.'
|
@@ -2424,6 +2468,11 @@ Lint/UselessMethodDefinition:
|
|
2424
2468
|
VersionChanged: '0.91'
|
2425
2469
|
Safe: false
|
2426
2470
|
|
2471
|
+
Lint/UselessRescue:
|
2472
|
+
Description: 'Checks for useless `rescue`s.'
|
2473
|
+
Enabled: pending
|
2474
|
+
VersionAdded: '1.43'
|
2475
|
+
|
2427
2476
|
Lint/UselessRuby2Keywords:
|
2428
2477
|
Description: 'Finds unnecessary uses of `ruby2_keywords`.'
|
2429
2478
|
Enabled: pending
|
@@ -2806,6 +2855,7 @@ Naming/MethodParameterName:
|
|
2806
2855
|
- as
|
2807
2856
|
- at
|
2808
2857
|
- by
|
2858
|
+
- cc
|
2809
2859
|
- db
|
2810
2860
|
- id
|
2811
2861
|
- if
|
@@ -3013,6 +3063,11 @@ Style/ArrayCoercion:
|
|
3013
3063
|
Enabled: false
|
3014
3064
|
VersionAdded: '0.88'
|
3015
3065
|
|
3066
|
+
Style/ArrayIntersect:
|
3067
|
+
Description: 'Use `array1.intersect?(array2)` instead of `(array1 & array2).any?`.'
|
3068
|
+
Enabled: 'pending'
|
3069
|
+
VersionAdded: '1.40'
|
3070
|
+
|
3016
3071
|
Style/ArrayJoin:
|
3017
3072
|
Description: 'Use Array#join instead of Array#*.'
|
3018
3073
|
StyleGuide: '#array-join'
|
@@ -3392,6 +3447,17 @@ Style/CommentedKeyword:
|
|
3392
3447
|
VersionAdded: '0.51'
|
3393
3448
|
VersionChanged: '1.19'
|
3394
3449
|
|
3450
|
+
Style/ComparableClamp:
|
3451
|
+
Description: 'Enforces the use of `Comparable#clamp` instead of comparison by minimum and maximum.'
|
3452
|
+
Enabled: pending
|
3453
|
+
VersionAdded: '1.44'
|
3454
|
+
|
3455
|
+
Style/ConcatArrayLiterals:
|
3456
|
+
Description: 'Enforces the use of `Array#push(item)` instead of `Array#concat([item])` to avoid redundant array literals.'
|
3457
|
+
Enabled: pending
|
3458
|
+
Safe: false
|
3459
|
+
VersionAdded: '1.41'
|
3460
|
+
|
3395
3461
|
Style/ConditionalAssignment:
|
3396
3462
|
Description: >-
|
3397
3463
|
Use the return value of `if` and `case` statements for
|
@@ -3813,7 +3879,8 @@ Style/HashEachMethods:
|
|
3813
3879
|
Safe: false
|
3814
3880
|
VersionAdded: '0.80'
|
3815
3881
|
VersionChanged: '1.16'
|
3816
|
-
AllowedReceivers:
|
3882
|
+
AllowedReceivers:
|
3883
|
+
- Thread.current
|
3817
3884
|
|
3818
3885
|
Style/HashExcept:
|
3819
3886
|
Description: >-
|
@@ -3861,7 +3928,7 @@ Style/HashSyntax:
|
|
3861
3928
|
- never
|
3862
3929
|
# accepts both shorthand and explicit use of hash literal value.
|
3863
3930
|
- either
|
3864
|
-
#
|
3931
|
+
# forces use of the 3.1 syntax only if all values can be omitted in the hash.
|
3865
3932
|
- consistent
|
3866
3933
|
# Force hashes that have a symbol value to use hash rockets
|
3867
3934
|
UseHashRocketsWithSymbolValues: false
|
@@ -3985,6 +4052,35 @@ Style/InverseMethods:
|
|
3985
4052
|
:select: :reject
|
3986
4053
|
:select!: :reject!
|
3987
4054
|
|
4055
|
+
Style/InvertibleUnlessCondition:
|
4056
|
+
Description: 'Favor `if` with inverted condition over `unless`.'
|
4057
|
+
Enabled: false
|
4058
|
+
VersionAdded: '1.44'
|
4059
|
+
# `InverseMethods` are methods that can be inverted in a `unless` condition.
|
4060
|
+
# The relationship of inverse methods needs to be defined in both directions.
|
4061
|
+
# Keys and values both need to be defined as symbols.
|
4062
|
+
InverseMethods:
|
4063
|
+
:!=: :==
|
4064
|
+
:>: :<=
|
4065
|
+
:<=: :>
|
4066
|
+
:<: :>=
|
4067
|
+
:>=: :<
|
4068
|
+
:!~: :=~
|
4069
|
+
:zero?: :nonzero?
|
4070
|
+
:nonzero?: :zero?
|
4071
|
+
:any?: :none?
|
4072
|
+
:none?: :any?
|
4073
|
+
:even?: :odd?
|
4074
|
+
:odd?: :even?
|
4075
|
+
# `ActiveSupport` defines some common inverse methods. They are listed below,
|
4076
|
+
# and not enabled by default.
|
4077
|
+
# :present?: :blank?
|
4078
|
+
# :blank?: :present?
|
4079
|
+
# :include?: :exclude?
|
4080
|
+
# :exclude?: :include?
|
4081
|
+
# :one?: :many?
|
4082
|
+
# :many?: :one?
|
4083
|
+
|
3988
4084
|
Style/IpAddresses:
|
3989
4085
|
Description: "Don't include literal IP addresses in code."
|
3990
4086
|
Enabled: false
|
@@ -4070,6 +4166,12 @@ Style/MapToHash:
|
|
4070
4166
|
VersionAdded: '1.24'
|
4071
4167
|
Safe: false
|
4072
4168
|
|
4169
|
+
Style/MapToSet:
|
4170
|
+
Description: 'Prefer `to_set` with a block over `map.to_set`.'
|
4171
|
+
Enabled: pending
|
4172
|
+
Safe: false
|
4173
|
+
VersionAdded: '1.42'
|
4174
|
+
|
4073
4175
|
Style/MethodCallWithArgsParentheses:
|
4074
4176
|
Description: 'Use parentheses for method calls with arguments.'
|
4075
4177
|
StyleGuide: '#method-invocation-parens'
|
@@ -4128,6 +4230,12 @@ Style/MinMax:
|
|
4128
4230
|
Enabled: true
|
4129
4231
|
VersionAdded: '0.50'
|
4130
4232
|
|
4233
|
+
Style/MinMaxComparison:
|
4234
|
+
Description: 'Enforces the use of `max` or `min` instead of comparison for greater or less.'
|
4235
|
+
Enabled: pending
|
4236
|
+
Safe: false
|
4237
|
+
VersionAdded: '1.42'
|
4238
|
+
|
4131
4239
|
Style/MissingElse:
|
4132
4240
|
Description: >-
|
4133
4241
|
Require if/case expressions to have an else branches.
|
@@ -4660,10 +4768,12 @@ Style/RedundantArgument:
|
|
4660
4768
|
Enabled: pending
|
4661
4769
|
Safe: false
|
4662
4770
|
VersionAdded: '1.4'
|
4663
|
-
VersionChanged: '1.
|
4771
|
+
VersionChanged: '1.40'
|
4664
4772
|
Methods:
|
4665
4773
|
# Array#join
|
4666
4774
|
join: ''
|
4775
|
+
# Array#sum
|
4776
|
+
sum: 0
|
4667
4777
|
# String#split
|
4668
4778
|
split: ' '
|
4669
4779
|
# String#chomp
|
@@ -4698,6 +4808,16 @@ Style/RedundantConditional:
|
|
4698
4808
|
Enabled: true
|
4699
4809
|
VersionAdded: '0.50'
|
4700
4810
|
|
4811
|
+
Style/RedundantConstantBase:
|
4812
|
+
Description: Avoid redundant `::` prefix on constant.
|
4813
|
+
Enabled: pending
|
4814
|
+
VersionAdded: '1.40'
|
4815
|
+
|
4816
|
+
Style/RedundantDoubleSplatHashBraces:
|
4817
|
+
Description: 'Checks for redundant uses of double splat hash braces.'
|
4818
|
+
Enabled: pending
|
4819
|
+
VersionAdded: '1.41'
|
4820
|
+
|
4701
4821
|
Style/RedundantEach:
|
4702
4822
|
Description: 'Checks for redundant `each`.'
|
4703
4823
|
Enabled: pending
|
@@ -4838,6 +4958,12 @@ Style/RegexpLiteral:
|
|
4838
4958
|
# are found in the regexp string.
|
4839
4959
|
AllowInnerSlashes: false
|
4840
4960
|
|
4961
|
+
Style/RequireOrder:
|
4962
|
+
Description: Sort `require` and `require_relative` in alphabetical order.
|
4963
|
+
Enabled: false
|
4964
|
+
SafeAutoCorrect: false
|
4965
|
+
VersionAdded: '1.40'
|
4966
|
+
|
4841
4967
|
Style/RescueModifier:
|
4842
4968
|
Description: 'Avoid using rescue in its modifier form.'
|
4843
4969
|
StyleGuide: '#no-rescue-modifiers'
|
@@ -5122,12 +5248,11 @@ Style/SymbolProc:
|
|
5122
5248
|
Enabled: true
|
5123
5249
|
Safe: false
|
5124
5250
|
VersionAdded: '0.26'
|
5125
|
-
VersionChanged: '1.
|
5251
|
+
VersionChanged: '1.40'
|
5126
5252
|
AllowMethodsWithArguments: false
|
5127
5253
|
# A list of method names to be always allowed by the check.
|
5128
5254
|
# The names should be fairly unique, otherwise you'll end up ignoring lots of code.
|
5129
5255
|
AllowedMethods:
|
5130
|
-
- respond_to
|
5131
5256
|
- define_method
|
5132
5257
|
AllowedPatterns: []
|
5133
5258
|
IgnoredMethods: [] # deprecated
|
@@ -5369,6 +5494,19 @@ Style/YodaCondition:
|
|
5369
5494
|
VersionAdded: '0.49'
|
5370
5495
|
VersionChanged: '0.75'
|
5371
5496
|
|
5497
|
+
Style/YodaExpression:
|
5498
|
+
Description: 'Forbid the use of yoda expressions.'
|
5499
|
+
Enabled: false
|
5500
|
+
Safe: false
|
5501
|
+
VersionAdded: '1.42'
|
5502
|
+
VersionChanged: '1.43'
|
5503
|
+
SupportedOperators:
|
5504
|
+
- '*'
|
5505
|
+
- '+'
|
5506
|
+
- '&'
|
5507
|
+
- '|'
|
5508
|
+
- '^'
|
5509
|
+
|
5372
5510
|
Style/ZeroLengthPredicate:
|
5373
5511
|
Description: 'Use #empty? when testing for objects of length 0.'
|
5374
5512
|
Enabled: true
|
data/exe/rubocop
CHANGED
data/lib/rubocop/cli.rb
CHANGED
@@ -7,7 +7,7 @@ module RuboCop
|
|
7
7
|
STATUS_SUCCESS = 0
|
8
8
|
STATUS_OFFENSES = 1
|
9
9
|
STATUS_ERROR = 2
|
10
|
-
STATUS_INTERRUPTED =
|
10
|
+
STATUS_INTERRUPTED = Signal.list['INT'] + 128
|
11
11
|
DEFAULT_PARALLEL_OPTIONS = %i[
|
12
12
|
color debug display_style_guide display_time display_only_fail_level_offenses
|
13
13
|
display_only_failed except extra_details fail_level fix_layout format
|
@@ -31,6 +31,7 @@ module RuboCop
|
|
31
31
|
|
32
32
|
def initialize(processed_source)
|
33
33
|
@processed_source = processed_source
|
34
|
+
@no_directives = !processed_source.raw_source.include?('rubocop')
|
34
35
|
end
|
35
36
|
|
36
37
|
def cop_enabled_at_line?(cop, line_number)
|
@@ -74,6 +75,8 @@ module RuboCop
|
|
74
75
|
end
|
75
76
|
|
76
77
|
def analyze # rubocop:todo Metrics/AbcSize
|
78
|
+
return {} if @no_directives
|
79
|
+
|
77
80
|
analyses = Hash.new { |hash, key| hash[key] = CopAnalysis.new([], nil) }
|
78
81
|
inject_disabled_cops_directives(analyses)
|
79
82
|
|
@@ -146,6 +149,8 @@ module RuboCop
|
|
146
149
|
end
|
147
150
|
|
148
151
|
def each_directive
|
152
|
+
return if @no_directives
|
153
|
+
|
149
154
|
processed_source.comments.each do |comment|
|
150
155
|
directive = DirectiveComment.new(comment)
|
151
156
|
yield directive if directive.cop_names
|
data/lib/rubocop/config.rb
CHANGED
@@ -21,24 +21,30 @@ module RuboCop
|
|
21
21
|
DEFAULT_RAILS_VERSION = 5.0
|
22
22
|
attr_reader :loaded_path
|
23
23
|
|
24
|
+
def self.create(hash, path, check: true)
|
25
|
+
config = new(hash, path)
|
26
|
+
config.check if check
|
27
|
+
|
28
|
+
config
|
29
|
+
end
|
30
|
+
|
31
|
+
# rubocop:disable Metrics/AbcSize
|
24
32
|
def initialize(hash = {}, loaded_path = nil)
|
25
33
|
@loaded_path = loaded_path
|
26
34
|
@for_cop = Hash.new do |h, cop|
|
27
|
-
|
35
|
+
cop_name = cop.respond_to?(:cop_name) ? cop.cop_name : cop
|
36
|
+
qualified_cop_name = Cop::Registry.qualified_cop_name(cop_name, loaded_path)
|
28
37
|
cop_options = self[qualified_cop_name].dup || {}
|
29
38
|
cop_options['Enabled'] = enable_cop?(qualified_cop_name, cop_options)
|
30
|
-
h[cop] = cop_options
|
39
|
+
h[cop] = h[cop_name] = cop_options
|
31
40
|
end
|
32
41
|
@hash = hash
|
33
42
|
@validator = ConfigValidator.new(self)
|
34
|
-
end
|
35
43
|
|
36
|
-
|
37
|
-
|
38
|
-
config.check if check
|
39
|
-
|
40
|
-
config
|
44
|
+
@badge_config_cache = {}.compare_by_identity
|
45
|
+
@clusivity_config_exists_cache = {}
|
41
46
|
end
|
47
|
+
# rubocop:enable Metrics/AbcSize
|
42
48
|
|
43
49
|
def loaded_features
|
44
50
|
@loaded_features ||= ConfigLoader.loaded_features
|
@@ -116,14 +122,31 @@ module RuboCop
|
|
116
122
|
# Note: the 'Enabled' attribute is calculated according to the department's
|
117
123
|
# and 'AllCops' configuration; other attributes are not inherited.
|
118
124
|
def for_cop(cop)
|
119
|
-
@for_cop[cop
|
125
|
+
@for_cop[cop]
|
120
126
|
end
|
121
127
|
|
122
128
|
# @return [Config] for the given cop merged with that of its department (if any)
|
123
129
|
# Note: the 'Enabled' attribute is same as that returned by `for_cop`
|
124
130
|
def for_badge(badge)
|
125
|
-
|
126
|
-
|
131
|
+
@badge_config_cache[badge] ||= begin
|
132
|
+
department_config = self[badge.department_name]
|
133
|
+
cop_config = for_cop(badge.to_s)
|
134
|
+
if department_config
|
135
|
+
department_config.merge(cop_config)
|
136
|
+
else
|
137
|
+
cop_config
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
# @return [Boolean] whether config for this badge has 'Include' or 'Exclude' keys
|
143
|
+
# @api private
|
144
|
+
def clusivity_config_for_badge?(badge)
|
145
|
+
exists = @clusivity_config_exists_cache[badge.to_s]
|
146
|
+
return exists unless exists.nil?
|
147
|
+
|
148
|
+
cop_config = for_badge(badge)
|
149
|
+
@clusivity_config_exists_cache[badge.to_s] = cop_config['Include'] || cop_config['Exclude']
|
127
150
|
end
|
128
151
|
|
129
152
|
# @return [Config] for the given department name.
|
@@ -215,7 +238,7 @@ module RuboCop
|
|
215
238
|
# directory since that wouldn't work.
|
216
239
|
def base_dir_for_path_parameters
|
217
240
|
@base_dir_for_path_parameters ||=
|
218
|
-
if File.basename(loaded_path).start_with?('.rubocop') &&
|
241
|
+
if loaded_path && File.basename(loaded_path).start_with?('.rubocop') &&
|
219
242
|
loaded_path != File.join(Dir.home, ConfigLoader::DOTFILE)
|
220
243
|
File.expand_path(File.dirname(loaded_path))
|
221
244
|
else
|
@@ -272,9 +295,10 @@ module RuboCop
|
|
272
295
|
return nil unless lock_file_path
|
273
296
|
|
274
297
|
File.foreach(lock_file_path) do |line|
|
275
|
-
# If
|
276
|
-
#
|
277
|
-
|
298
|
+
# If Rails (or one of its frameworks) is in Gemfile.lock or gems.lock, there should be
|
299
|
+
# a line like:
|
300
|
+
# railties (X.X.X)
|
301
|
+
result = line.match(/^\s+railties\s+\((\d+\.\d+)/)
|
278
302
|
return result.captures.first.to_f if result
|
279
303
|
end
|
280
304
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'erb'
|
4
|
-
require 'yaml'
|
5
4
|
require 'pathname'
|
5
|
+
require 'yaml'
|
6
6
|
require_relative 'config_finder'
|
7
7
|
|
8
8
|
module RuboCop
|
@@ -42,18 +42,18 @@ module RuboCop
|
|
42
42
|
|
43
43
|
hash = load_yaml_configuration(path)
|
44
44
|
|
45
|
-
# Resolve requires first in case they define additional cops
|
46
45
|
loaded_features = resolver.resolve_requires(path, hash)
|
47
46
|
add_loaded_features(loaded_features)
|
48
47
|
|
49
|
-
add_missing_namespaces(path, hash)
|
50
|
-
|
51
48
|
resolver.override_department_setting_for_cops({}, hash)
|
52
49
|
resolver.resolve_inheritance_from_gems(hash)
|
53
50
|
resolver.resolve_inheritance(path, hash, file, debug?)
|
54
|
-
|
55
51
|
hash.delete('inherit_from')
|
56
52
|
|
53
|
+
# Adding missing namespaces only after resolving requires & inheritance,
|
54
|
+
# since both can introduce new cops that need to be considered here.
|
55
|
+
add_missing_namespaces(path, hash)
|
56
|
+
|
57
57
|
Config.create(hash, path, check: check)
|
58
58
|
end
|
59
59
|
|
@@ -111,10 +111,17 @@ module RuboCop
|
|
111
111
|
end
|
112
112
|
|
113
113
|
merge_with_default(config, config_file).tap do |merged_config|
|
114
|
-
|
114
|
+
unless possible_new_cops?(merged_config)
|
115
|
+
pending_cops = pending_cops_only_qualified(merged_config.pending_cops)
|
116
|
+
warn_on_pending_cops(pending_cops) unless pending_cops.empty?
|
117
|
+
end
|
115
118
|
end
|
116
119
|
end
|
117
120
|
|
121
|
+
def pending_cops_only_qualified(pending_cops)
|
122
|
+
pending_cops.select { |cop| Cop::Registry.qualified_cop?(cop.name) }
|
123
|
+
end
|
124
|
+
|
118
125
|
def possible_new_cops?(config)
|
119
126
|
disable_pending_cops || enable_pending_cops ||
|
120
127
|
config.disabled_new_cops? || config.enabled_new_cops?
|
@@ -137,6 +144,15 @@ module RuboCop
|
|
137
144
|
end
|
138
145
|
end
|
139
146
|
|
147
|
+
# @api private
|
148
|
+
def inject_defaults!(project_root)
|
149
|
+
path = File.join(project_root, 'config', 'default.yml')
|
150
|
+
config = load_file(path)
|
151
|
+
new_config = ConfigLoader.merge_with_default(config, path)
|
152
|
+
puts "configuration from #{path}" if debug?
|
153
|
+
@default_configuration = new_config
|
154
|
+
end
|
155
|
+
|
140
156
|
# Returns the path RuboCop inferred as the root of the project. No file
|
141
157
|
# searches will go past this directory.
|
142
158
|
# @deprecated Use `RuboCop::ConfigFinder.project_root` instead.
|
@@ -158,8 +174,6 @@ module RuboCop
|
|
158
174
|
BANNER
|
159
175
|
|
160
176
|
def warn_on_pending_cops(pending_cops)
|
161
|
-
return if pending_cops.empty?
|
162
|
-
|
163
177
|
warn Rainbow(PENDING_BANNER).yellow
|
164
178
|
|
165
179
|
pending_cops.each { |cop| warn_pending_cop cop }
|
@@ -232,18 +246,10 @@ module RuboCop
|
|
232
246
|
raise
|
233
247
|
end
|
234
248
|
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
permitted_symbols: [],
|
240
|
-
aliases: true,
|
241
|
-
filename: filename)
|
242
|
-
end
|
243
|
-
else # Ruby < 2.6
|
244
|
-
def yaml_safe_load!(yaml_code, filename)
|
245
|
-
YAML.safe_load(yaml_code, [Regexp, Symbol], [], true, filename)
|
246
|
-
end
|
249
|
+
def yaml_safe_load!(yaml_code, filename)
|
250
|
+
YAML.safe_load(
|
251
|
+
yaml_code, permitted_classes: [Regexp, Symbol], aliases: true, filename: filename
|
252
|
+
)
|
247
253
|
end
|
248
254
|
end
|
249
255
|
|