rubocop 1.20.0 → 1.22.2
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 +1 -1
- data/config/default.yml +64 -15
- data/lib/rubocop/config.rb +5 -0
- data/lib/rubocop/config_loader.rb +3 -1
- data/lib/rubocop/config_validator.rb +9 -1
- data/lib/rubocop/cop/base.rb +3 -3
- data/lib/rubocop/cop/bundler/gem_comment.rb +3 -3
- data/lib/rubocop/cop/bundler/insecure_protocol_source.rb +45 -21
- data/lib/rubocop/cop/bundler/ordered_gems.rb +3 -12
- data/lib/rubocop/cop/correctors/lambda_literal_to_method_corrector.rb +2 -2
- data/lib/rubocop/cop/correctors/line_break_corrector.rb +1 -1
- data/lib/rubocop/cop/correctors/ordered_gem_corrector.rb +11 -10
- data/lib/rubocop/cop/gemspec/ordered_dependencies.rb +3 -12
- data/lib/rubocop/cop/gemspec/required_ruby_version.rb +31 -24
- data/lib/rubocop/cop/generator.rb +14 -8
- data/lib/rubocop/cop/internal_affairs/location_line_equality_comparison.rb +60 -0
- data/lib/rubocop/cop/internal_affairs/node_matcher_directive.rb +1 -1
- data/lib/rubocop/cop/internal_affairs.rb +1 -0
- data/lib/rubocop/cop/layout/argument_alignment.rb +1 -1
- data/lib/rubocop/cop/layout/assignment_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/class_structure.rb +2 -1
- data/lib/rubocop/cop/layout/dot_position.rb +30 -5
- data/lib/rubocop/cop/layout/empty_comment.rb +1 -1
- data/lib/rubocop/cop/layout/empty_lines_around_exception_handling_keywords.rb +7 -4
- data/lib/rubocop/cop/layout/end_alignment.rb +2 -3
- data/lib/rubocop/cop/layout/first_array_element_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/first_hash_element_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/first_parameter_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/hash_alignment.rb +1 -1
- data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +1 -1
- data/lib/rubocop/cop/layout/indentation_width.rb +1 -1
- data/lib/rubocop/cop/layout/leading_comment_space.rb +1 -1
- data/lib/rubocop/cop/layout/line_length.rb +9 -7
- data/lib/rubocop/cop/layout/multiline_assignment_layout.rb +1 -1
- data/lib/rubocop/cop/layout/multiline_block_layout.rb +3 -3
- data/lib/rubocop/cop/layout/multiline_method_call_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/redundant_line_break.rb +1 -0
- data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +1 -1
- data/lib/rubocop/cop/layout/single_line_block_chain.rb +15 -4
- data/lib/rubocop/cop/layout/space_after_not.rb +1 -0
- data/lib/rubocop/cop/layout/space_around_equals_in_parameter_default.rb +2 -1
- data/lib/rubocop/cop/layout/space_around_keyword.rb +2 -2
- data/lib/rubocop/cop/layout/space_before_brackets.rb +1 -0
- data/lib/rubocop/cop/layout/space_before_comment.rb +1 -1
- data/lib/rubocop/cop/layout/space_inside_parens.rb +74 -28
- data/lib/rubocop/cop/layout/space_inside_reference_brackets.rb +1 -1
- data/lib/rubocop/cop/lint/ambiguous_operator_precedence.rb +111 -0
- data/lib/rubocop/cop/lint/ambiguous_range.rb +9 -9
- data/lib/rubocop/cop/lint/assignment_in_condition.rb +7 -5
- data/lib/rubocop/cop/lint/binary_operator_with_identical_operands.rb +18 -5
- data/lib/rubocop/cop/lint/boolean_symbol.rb +5 -0
- data/lib/rubocop/cop/lint/debugger.rb +0 -2
- data/lib/rubocop/cop/lint/deprecated_class_methods.rb +4 -4
- data/lib/rubocop/cop/lint/disjunctive_assignment_in_constructor.rb +24 -1
- data/lib/rubocop/cop/lint/else_layout.rb +10 -6
- data/lib/rubocop/cop/lint/empty_in_pattern.rb +1 -1
- data/lib/rubocop/cop/lint/erb_new_arguments.rb +1 -1
- data/lib/rubocop/cop/lint/float_out_of_range.rb +1 -1
- data/lib/rubocop/cop/lint/hash_compare_by_identity.rb +12 -3
- data/lib/rubocop/cop/lint/incompatible_io_select_with_fiber_scheduler.rb +67 -0
- data/lib/rubocop/cop/lint/interpolation_check.rb +5 -0
- data/lib/rubocop/cop/lint/loop.rb +4 -3
- data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +5 -1
- data/lib/rubocop/cop/lint/number_conversion.rb +12 -1
- data/lib/rubocop/cop/lint/numbered_parameter_assignment.rb +1 -1
- data/lib/rubocop/cop/lint/or_assignment_to_constant.rb +4 -2
- data/lib/rubocop/cop/lint/out_of_range_regexp_ref.rb +17 -0
- data/lib/rubocop/cop/lint/percent_string_array.rb +10 -0
- data/lib/rubocop/cop/lint/raise_exception.rb +4 -0
- data/lib/rubocop/cop/lint/redundant_safe_navigation.rb +5 -4
- data/lib/rubocop/cop/lint/require_relative_self_path.rb +50 -0
- data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +1 -1
- data/lib/rubocop/cop/lint/symbol_conversion.rb +1 -1
- data/lib/rubocop/cop/lint/triple_quotes.rb +1 -1
- data/lib/rubocop/cop/lint/unexpected_block_arity.rb +8 -3
- data/lib/rubocop/cop/lint/unused_method_argument.rb +2 -3
- data/lib/rubocop/cop/lint/useless_method_definition.rb +3 -2
- data/lib/rubocop/cop/lint/useless_setter_call.rb +7 -4
- data/lib/rubocop/cop/lint/useless_times.rb +4 -3
- data/lib/rubocop/cop/metrics/abc_size.rb +6 -0
- data/lib/rubocop/cop/metrics/parameter_lists.rb +5 -2
- data/lib/rubocop/cop/metrics/perceived_complexity.rb +1 -1
- data/lib/rubocop/cop/metrics/utils/abc_size_calculator.rb +1 -1
- data/lib/rubocop/cop/metrics/utils/code_length_calculator.rb +1 -1
- data/lib/rubocop/cop/mixin/code_length.rb +1 -1
- data/lib/rubocop/cop/mixin/end_keyword_alignment.rb +1 -2
- data/lib/rubocop/cop/mixin/frozen_string_literal.rb +15 -6
- data/lib/rubocop/cop/mixin/hash_transform_method.rb +3 -3
- data/lib/rubocop/cop/mixin/heredoc.rb +1 -3
- data/lib/rubocop/cop/mixin/multiline_element_indentation.rb +1 -1
- data/lib/rubocop/cop/mixin/multiline_expression_indentation.rb +2 -2
- data/lib/rubocop/cop/mixin/multiline_literal_brace_layout.rb +1 -1
- data/lib/rubocop/cop/mixin/ordered_gem_node.rb +9 -1
- data/lib/rubocop/cop/mixin/percent_array.rb +6 -1
- data/lib/rubocop/cop/mixin/preceding_following_alignment.rb +9 -1
- data/lib/rubocop/cop/mixin/space_after_punctuation.rb +1 -1
- data/lib/rubocop/cop/mixin/space_before_punctuation.rb +1 -1
- data/lib/rubocop/cop/mixin/statement_modifier.rb +1 -1
- data/lib/rubocop/cop/mixin/string_literals_help.rb +5 -1
- data/lib/rubocop/cop/mixin/trailing_body.rb +1 -1
- data/lib/rubocop/cop/naming/ascii_identifiers.rb +0 -3
- data/lib/rubocop/cop/naming/block_parameter_name.rb +1 -1
- data/lib/rubocop/cop/naming/constant_name.rb +1 -1
- data/lib/rubocop/cop/naming/inclusive_language.rb +9 -9
- data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +5 -4
- data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +7 -0
- data/lib/rubocop/cop/security/io_methods.rb +49 -0
- data/lib/rubocop/cop/security/json_load.rb +8 -7
- data/lib/rubocop/cop/security/open.rb +4 -0
- data/lib/rubocop/cop/security/yaml_load.rb +4 -0
- data/lib/rubocop/cop/style/accessor_grouping.rb +2 -2
- data/lib/rubocop/cop/style/and_or.rb +5 -0
- data/lib/rubocop/cop/style/arguments_forwarding.rb +13 -2
- data/lib/rubocop/cop/style/array_coercion.rb +21 -3
- data/lib/rubocop/cop/style/ascii_comments.rb +0 -3
- data/lib/rubocop/cop/style/case_equality.rb +6 -9
- data/lib/rubocop/cop/style/case_like_if.rb +5 -0
- data/lib/rubocop/cop/style/class_and_module_children.rb +9 -0
- data/lib/rubocop/cop/style/collection_compact.rb +7 -5
- data/lib/rubocop/cop/style/collection_methods.rb +8 -6
- data/lib/rubocop/cop/style/combinable_loops.rb +3 -2
- data/lib/rubocop/cop/style/commented_keyword.rb +9 -4
- data/lib/rubocop/cop/style/date_time.rb +5 -0
- data/lib/rubocop/cop/style/document_dynamic_eval_definition.rb +1 -1
- data/lib/rubocop/cop/style/documentation.rb +23 -8
- data/lib/rubocop/cop/style/double_negation.rb +15 -5
- data/lib/rubocop/cop/style/empty_method.rb +1 -1
- data/lib/rubocop/cop/style/explicit_block_argument.rb +21 -11
- data/lib/rubocop/cop/style/float_division.rb +10 -2
- data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +6 -1
- data/lib/rubocop/cop/style/global_std_stream.rb +4 -0
- data/lib/rubocop/cop/style/hash_each_methods.rb +5 -0
- data/lib/rubocop/cop/style/hash_transform_keys.rb +4 -6
- data/lib/rubocop/cop/style/hash_transform_values.rb +4 -6
- data/lib/rubocop/cop/style/identical_conditional_branches.rb +18 -16
- data/lib/rubocop/cop/style/if_with_boolean_literal_branches.rb +18 -4
- data/lib/rubocop/cop/style/infinite_loop.rb +4 -3
- data/lib/rubocop/cop/style/inverse_methods.rb +9 -2
- data/lib/rubocop/cop/style/lambda_call.rb +1 -1
- data/lib/rubocop/cop/style/line_end_concatenation.rb +14 -1
- data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +6 -6
- data/lib/rubocop/cop/style/module_function.rb +8 -9
- data/lib/rubocop/cop/style/multiline_in_pattern_then.rb +1 -1
- data/lib/rubocop/cop/style/multiline_when_then.rb +1 -1
- data/lib/rubocop/cop/style/mutable_constant.rb +13 -8
- data/lib/rubocop/cop/style/negated_if.rb +1 -1
- data/lib/rubocop/cop/style/negated_unless.rb +1 -1
- data/lib/rubocop/cop/style/non_nil_check.rb +2 -2
- data/lib/rubocop/cop/style/not.rb +2 -2
- data/lib/rubocop/cop/style/numbered_parameters.rb +46 -0
- data/lib/rubocop/cop/style/numbered_parameters_limit.rb +50 -0
- data/lib/rubocop/cop/style/numeric_literals.rb +7 -8
- data/lib/rubocop/cop/style/numeric_predicate.rb +5 -0
- data/lib/rubocop/cop/style/optional_arguments.rb +4 -0
- data/lib/rubocop/cop/style/optional_boolean_parameter.rb +14 -4
- data/lib/rubocop/cop/style/parallel_assignment.rb +1 -1
- data/lib/rubocop/cop/style/percent_q_literals.rb +2 -2
- data/lib/rubocop/cop/style/preferred_hash_methods.rb +9 -4
- data/lib/rubocop/cop/style/quoted_symbols.rb +10 -6
- data/lib/rubocop/cop/style/raise_args.rb +1 -1
- data/lib/rubocop/cop/style/redundant_argument.rb +19 -9
- data/lib/rubocop/cop/style/redundant_condition.rb +2 -3
- data/lib/rubocop/cop/style/redundant_fetch_block.rb +4 -0
- data/lib/rubocop/cop/style/redundant_file_extension_in_require.rb +12 -3
- data/lib/rubocop/cop/style/redundant_freeze.rb +0 -1
- data/lib/rubocop/cop/style/redundant_interpolation.rb +1 -1
- data/lib/rubocop/cop/style/redundant_percent_q.rb +2 -3
- data/lib/rubocop/cop/style/redundant_self.rb +10 -0
- data/lib/rubocop/cop/style/redundant_self_assignment.rb +4 -3
- data/lib/rubocop/cop/style/redundant_self_assignment_branch.rb +1 -1
- data/lib/rubocop/cop/style/redundant_sort.rb +51 -18
- data/lib/rubocop/cop/style/regexp_literal.rb +3 -3
- data/lib/rubocop/cop/style/return_nil.rb +2 -1
- data/lib/rubocop/cop/style/safe_navigation.rb +13 -2
- data/lib/rubocop/cop/style/select_by_regexp.rb +138 -0
- data/lib/rubocop/cop/style/single_argument_dig.rb +5 -0
- data/lib/rubocop/cop/style/slicing_with_range.rb +13 -0
- data/lib/rubocop/cop/style/special_global_vars.rb +4 -0
- data/lib/rubocop/cop/style/static_class.rb +5 -5
- data/lib/rubocop/cop/style/string_chars.rb +4 -2
- data/lib/rubocop/cop/style/string_concatenation.rb +5 -1
- data/lib/rubocop/cop/style/string_hash_keys.rb +4 -0
- data/lib/rubocop/cop/style/struct_inheritance.rb +3 -2
- data/lib/rubocop/cop/style/swap_values.rb +4 -2
- data/lib/rubocop/cop/style/symbol_proc.rb +26 -0
- data/lib/rubocop/cop/style/trailing_comma_in_block_args.rb +19 -0
- data/lib/rubocop/cop/style/trivial_accessors.rb +1 -1
- data/lib/rubocop/cop/style/yoda_condition.rb +24 -7
- data/lib/rubocop/cop/style/zero_length_predicate.rb +6 -0
- data/lib/rubocop/cop/util.rb +15 -4
- data/lib/rubocop/cops_documentation_generator.rb +17 -5
- data/lib/rubocop/options.rb +126 -112
- data/lib/rubocop/rake_task.rb +1 -1
- data/lib/rubocop/result_cache.rb +3 -3
- data/lib/rubocop/rspec/cop_helper.rb +1 -1
- data/lib/rubocop/rspec/expect_offense.rb +6 -2
- data/lib/rubocop/rspec/parallel_formatter.rb +90 -0
- data/lib/rubocop/rspec/support.rb +1 -0
- data/lib/rubocop/runner.rb +2 -3
- data/lib/rubocop/target_finder.rb +1 -1
- data/lib/rubocop/version.rb +1 -1
- data/lib/rubocop.rb +8 -1
- metadata +14 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55ba084f7d7ade15b0310d7ba6fcaf66b56f06a8123a0e57ddff0defb95316f9
|
4
|
+
data.tar.gz: 520b506f7d36904c76d3f9fee9075ba7550e203f06fae95c21c0fc5b54ebb00c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dde07235d238fc9dd8c0f67c710e06d77a9ce3b5efc24de4eda8b1885ff5540f9c1ad4197d1bb09a74e73e2cf12caaaaa684c07f86fef1350ef9731896d4e04e
|
7
|
+
data.tar.gz: 68a466978d9621ea6a269bd03ec159844d6cb6b6180085190f781d659048937b3ee9a756ab53399992415fd3128dc0d472d65dcd8f0aab8989ebdcdf369cb04c
|
data/README.md
CHANGED
@@ -54,7 +54,7 @@ To prevent an unwanted RuboCop update you might want to use a conservative versi
|
|
54
54
|
in your `Gemfile`:
|
55
55
|
|
56
56
|
```rb
|
57
|
-
gem 'rubocop', '~> 1.
|
57
|
+
gem 'rubocop', '~> 1.22', require: false
|
58
58
|
```
|
59
59
|
|
60
60
|
See [our versioning policy](https://docs.rubocop.org/rubocop/versioning.html) for further details.
|
data/config/default.yml
CHANGED
@@ -130,7 +130,7 @@ AllCops:
|
|
130
130
|
# What MRI version of the Ruby interpreter is the inspected code intended to
|
131
131
|
# run on? (If there is more than one, set this to the lowest version.)
|
132
132
|
# If a value is specified for TargetRubyVersion then it is used. Acceptable
|
133
|
-
# values are
|
133
|
+
# values are specified as a float (i.e. 3.0); the teeny version of Ruby
|
134
134
|
# should not be included. If the project specifies a Ruby version in the
|
135
135
|
# .tool-versions or .ruby-version files, Gemfile or gems.rb file, RuboCop will
|
136
136
|
# try to determine the desired version of Ruby by inspecting the
|
@@ -209,6 +209,7 @@ Bundler/InsecureProtocolSource:
|
|
209
209
|
'https://rubygems.org' if possible, or 'http://rubygems.org' if not.
|
210
210
|
Enabled: true
|
211
211
|
VersionAdded: '0.50'
|
212
|
+
AllowHttpProtocol: true
|
212
213
|
Include:
|
213
214
|
- '**/*.gemfile'
|
214
215
|
- '**/Gemfile'
|
@@ -261,7 +262,7 @@ Gemspec/RequiredRubyVersion:
|
|
261
262
|
Description: 'Checks that `required_ruby_version` of gemspec is specified and equal to `TargetRubyVersion` of .rubocop.yml.'
|
262
263
|
Enabled: true
|
263
264
|
VersionAdded: '0.52'
|
264
|
-
VersionChanged: '
|
265
|
+
VersionChanged: '1.22'
|
265
266
|
Include:
|
266
267
|
- '**/*.gemspec'
|
267
268
|
|
@@ -957,7 +958,6 @@ Layout/LineLength:
|
|
957
958
|
Enabled: true
|
958
959
|
VersionAdded: '0.25'
|
959
960
|
VersionChanged: '1.4'
|
960
|
-
AutoCorrect: true
|
961
961
|
Max: 120
|
962
962
|
# To make it possible to copy or click on URIs in the code, we allow lines
|
963
963
|
# containing a URI to be longer than Max.
|
@@ -1361,10 +1361,11 @@ Layout/SpaceInsideParens:
|
|
1361
1361
|
StyleGuide: '#spaces-braces'
|
1362
1362
|
Enabled: true
|
1363
1363
|
VersionAdded: '0.49'
|
1364
|
-
VersionChanged: '
|
1364
|
+
VersionChanged: '1.22'
|
1365
1365
|
EnforcedStyle: no_space
|
1366
1366
|
SupportedStyles:
|
1367
1367
|
- space
|
1368
|
+
- compact
|
1368
1369
|
- no_space
|
1369
1370
|
|
1370
1371
|
Layout/SpaceInsidePercentLiteralDelimiters:
|
@@ -1448,6 +1449,13 @@ Lint/AmbiguousOperator:
|
|
1448
1449
|
VersionAdded: '0.17'
|
1449
1450
|
VersionChanged: '0.83'
|
1450
1451
|
|
1452
|
+
Lint/AmbiguousOperatorPrecedence:
|
1453
|
+
Description: >-
|
1454
|
+
Checks for expressions containing multiple binary operations with
|
1455
|
+
ambiguous precedence.
|
1456
|
+
Enabled: pending
|
1457
|
+
VersionAdded: '1.21'
|
1458
|
+
|
1451
1459
|
Lint/AmbiguousRange:
|
1452
1460
|
Description: Checks for ranges with ambiguous boundaries.
|
1453
1461
|
Enabled: pending
|
@@ -1485,9 +1493,9 @@ Lint/BinaryOperatorWithIdenticalOperands:
|
|
1485
1493
|
Lint/BooleanSymbol:
|
1486
1494
|
Description: 'Check for `:true` and `:false` symbols.'
|
1487
1495
|
Enabled: true
|
1488
|
-
|
1496
|
+
SafeAutoCorrect: false
|
1489
1497
|
VersionAdded: '0.50'
|
1490
|
-
VersionChanged: '
|
1498
|
+
VersionChanged: '1.22'
|
1491
1499
|
|
1492
1500
|
Lint/CircularArgumentReference:
|
1493
1501
|
Description: "Default values in optional keyword arguments and optional ordinal arguments should not refer back to the name of the argument."
|
@@ -1771,6 +1779,11 @@ Lint/ImplicitStringConcatenation:
|
|
1771
1779
|
Enabled: true
|
1772
1780
|
VersionAdded: '0.36'
|
1773
1781
|
|
1782
|
+
Lint/IncompatibleIoSelectWithFiberScheduler:
|
1783
|
+
Description: 'Checks for `IO.select` that is incompatible with Fiber Scheduler.'
|
1784
|
+
Enabled: pending
|
1785
|
+
VersionAdded: '1.21'
|
1786
|
+
|
1774
1787
|
Lint/IneffectiveAccessModifier:
|
1775
1788
|
Description: >-
|
1776
1789
|
Checks for attempts to use `private` or `protected` to set
|
@@ -2034,6 +2047,11 @@ Lint/RequireParentheses:
|
|
2034
2047
|
Enabled: true
|
2035
2048
|
VersionAdded: '0.18'
|
2036
2049
|
|
2050
|
+
Lint/RequireRelativeSelfPath:
|
2051
|
+
Description: 'Checks for uses a file requiring itself with `require_relative`.'
|
2052
|
+
Enabled: pending
|
2053
|
+
VersionAdded: '1.22'
|
2054
|
+
|
2037
2055
|
Lint/RescueException:
|
2038
2056
|
Description: 'Avoid rescuing the Exception class.'
|
2039
2057
|
StyleGuide: '#no-blind-rescues'
|
@@ -2563,8 +2581,9 @@ Naming/HeredocDelimiterNaming:
|
|
2563
2581
|
|
2564
2582
|
Naming/InclusiveLanguage:
|
2565
2583
|
Description: 'Recommend the use of inclusive language instead of problematic terms.'
|
2566
|
-
Enabled:
|
2584
|
+
Enabled: false
|
2567
2585
|
VersionAdded: '1.18'
|
2586
|
+
VersionChanged: '1.21'
|
2568
2587
|
CheckIdentifiers: true
|
2569
2588
|
CheckConstants: true
|
2570
2589
|
CheckVariables: true
|
@@ -2720,6 +2739,14 @@ Security/Eval:
|
|
2720
2739
|
Enabled: true
|
2721
2740
|
VersionAdded: '0.47'
|
2722
2741
|
|
2742
|
+
Security/IoMethods:
|
2743
|
+
Description: >-
|
2744
|
+
Checks for the first argument to `IO.read`, `IO.binread`, `IO.write`, `IO.binwrite`,
|
2745
|
+
`IO.foreach`, and `IO.readlines`.
|
2746
|
+
Enabled: pending
|
2747
|
+
Safe: false
|
2748
|
+
VersionAdded: '1.22'
|
2749
|
+
|
2723
2750
|
Security/JSONLoad:
|
2724
2751
|
Description: >-
|
2725
2752
|
Prefer usage of `JSON.parse` over `JSON.load` due to potential
|
@@ -2727,10 +2754,9 @@ Security/JSONLoad:
|
|
2727
2754
|
Reference: 'https://ruby-doc.org/stdlib-2.7.0/libdoc/json/rdoc/JSON.html#method-i-load'
|
2728
2755
|
Enabled: true
|
2729
2756
|
VersionAdded: '0.43'
|
2730
|
-
VersionChanged: '
|
2757
|
+
VersionChanged: '1.22'
|
2731
2758
|
# Autocorrect here will change to a method that may cause crashes depending
|
2732
2759
|
# on the value of the argument.
|
2733
|
-
AutoCorrect: false
|
2734
2760
|
SafeAutoCorrect: false
|
2735
2761
|
|
2736
2762
|
Security/MarshalLoad:
|
@@ -2796,8 +2822,9 @@ Style/AndOr:
|
|
2796
2822
|
Description: 'Use &&/|| instead of and/or.'
|
2797
2823
|
StyleGuide: '#no-and-or-or'
|
2798
2824
|
Enabled: true
|
2825
|
+
SafeAutoCorrect: false
|
2799
2826
|
VersionAdded: '0.9'
|
2800
|
-
VersionChanged: '
|
2827
|
+
VersionChanged: '1.21'
|
2801
2828
|
# Whether `and` and `or` are banned only in conditionals (conditionals)
|
2802
2829
|
# or completely (always).
|
2803
2830
|
EnforcedStyle: conditionals
|
@@ -2831,9 +2858,9 @@ Style/ArrayJoin:
|
|
2831
2858
|
Style/AsciiComments:
|
2832
2859
|
Description: 'Use only ascii symbols in comments.'
|
2833
2860
|
StyleGuide: '#english-comments'
|
2834
|
-
Enabled:
|
2861
|
+
Enabled: false
|
2835
2862
|
VersionAdded: '0.9'
|
2836
|
-
VersionChanged: '
|
2863
|
+
VersionChanged: '1.21'
|
2837
2864
|
AllowedChars:
|
2838
2865
|
- ©
|
2839
2866
|
|
@@ -2995,7 +3022,7 @@ Style/CaseEquality:
|
|
2995
3022
|
Enabled: true
|
2996
3023
|
VersionAdded: '0.9'
|
2997
3024
|
VersionChanged: '0.89'
|
2998
|
-
# If AllowOnConstant is enabled, the cop will ignore violations when the receiver of
|
3025
|
+
# If `AllowOnConstant` option is enabled, the cop will ignore violations when the receiver of
|
2999
3026
|
# the case equality operator is a constant.
|
3000
3027
|
#
|
3001
3028
|
# # bad
|
@@ -3690,7 +3717,7 @@ Style/InPatternThen:
|
|
3690
3717
|
Style/InfiniteLoop:
|
3691
3718
|
Description: >-
|
3692
3719
|
Use Kernel#loop for infinite loops.
|
3693
|
-
This cop is unsafe
|
3720
|
+
This cop is unsafe if the body may raise a `StopIteration` exception.
|
3694
3721
|
Safe: false
|
3695
3722
|
StyleGuide: '#infinite-loop'
|
3696
3723
|
Enabled: true
|
@@ -4116,6 +4143,21 @@ Style/Not:
|
|
4116
4143
|
VersionAdded: '0.9'
|
4117
4144
|
VersionChanged: '0.20'
|
4118
4145
|
|
4146
|
+
Style/NumberedParameters:
|
4147
|
+
Description: 'Restrict the usage of numbered parameters.'
|
4148
|
+
Enabled: pending
|
4149
|
+
VersionAdded: '1.22'
|
4150
|
+
EnforcedStyle: allow_single_line
|
4151
|
+
SupportedStyles:
|
4152
|
+
- allow_single_line
|
4153
|
+
- disallow
|
4154
|
+
|
4155
|
+
Style/NumberedParametersLimit:
|
4156
|
+
Description: 'Avoid excessive numbered params in a single block.'
|
4157
|
+
Enabled: pending
|
4158
|
+
VersionAdded: '1.22'
|
4159
|
+
Max: 1
|
4160
|
+
|
4119
4161
|
Style/NumericLiteralPrefix:
|
4120
4162
|
Description: 'Use smallcase prefixes for numeric literals.'
|
4121
4163
|
StyleGuide: '#numeric-literal-prefixes'
|
@@ -4126,7 +4168,6 @@ Style/NumericLiteralPrefix:
|
|
4126
4168
|
- zero_with_o
|
4127
4169
|
- zero_only
|
4128
4170
|
|
4129
|
-
|
4130
4171
|
Style/NumericLiterals:
|
4131
4172
|
Description: >-
|
4132
4173
|
Add underscores to large numeric literals to improve their
|
@@ -4447,6 +4488,8 @@ Style/RedundantSort:
|
|
4447
4488
|
`max_by` instead of `sort_by...last`, etc.
|
4448
4489
|
Enabled: true
|
4449
4490
|
VersionAdded: '0.76'
|
4491
|
+
VersionChanged: '1.22'
|
4492
|
+
Safe: false
|
4450
4493
|
|
4451
4494
|
Style/RedundantSortBy:
|
4452
4495
|
Description: 'Use `sort` instead of `sort_by { |x| x }`.'
|
@@ -4527,6 +4570,12 @@ Style/Sample:
|
|
4527
4570
|
Enabled: true
|
4528
4571
|
VersionAdded: '0.30'
|
4529
4572
|
|
4573
|
+
Style/SelectByRegexp:
|
4574
|
+
Description: 'Prefer grep/grep_v to select/reject with a regexp match.'
|
4575
|
+
Enabled: pending
|
4576
|
+
SafeAutoCorrect: false
|
4577
|
+
VersionAdded: '1.22'
|
4578
|
+
|
4530
4579
|
Style/SelfAssignment:
|
4531
4580
|
Description: >-
|
4532
4581
|
Checks for places where self-assignment shorthand should have
|
data/lib/rubocop/config.rb
CHANGED
@@ -51,6 +51,11 @@ module RuboCop
|
|
51
51
|
self
|
52
52
|
end
|
53
53
|
|
54
|
+
def validate_after_resolution
|
55
|
+
@validator.validate_after_resolution
|
56
|
+
self
|
57
|
+
end
|
58
|
+
|
54
59
|
def_delegators :@hash, :[], :[]=, :delete, :dig, :each, :key?, :keys, :each_key,
|
55
60
|
:fetch, :map, :merge, :replace, :to_h, :to_hash, :transform_values
|
56
61
|
def_delegators :@validator, :validate, :target_ruby_version
|
@@ -101,6 +101,8 @@ module RuboCop
|
|
101
101
|
return default_configuration if config_file == DEFAULT_FILE
|
102
102
|
|
103
103
|
config = load_file(config_file, check: check)
|
104
|
+
config.validate_after_resolution if check
|
105
|
+
|
104
106
|
if ignore_parent_exclusion?
|
105
107
|
print 'Ignoring AllCops/Exclude from parent folders' if debug?
|
106
108
|
else
|
@@ -134,7 +136,7 @@ module RuboCop
|
|
134
136
|
end
|
135
137
|
end
|
136
138
|
|
137
|
-
# Returns the path
|
139
|
+
# Returns the path RuboCop inferred as the root of the project. No file
|
138
140
|
# searches will go past this directory.
|
139
141
|
def project_root
|
140
142
|
@project_root ||= find_project_root
|
@@ -44,7 +44,6 @@ module RuboCop
|
|
44
44
|
check_obsoletions
|
45
45
|
|
46
46
|
alert_about_unrecognized_cops(invalid_cop_names)
|
47
|
-
check_target_ruby
|
48
47
|
validate_new_cops_parameter
|
49
48
|
validate_parameter_names(valid_cop_names)
|
50
49
|
validate_enforced_styles(valid_cop_names)
|
@@ -52,6 +51,15 @@ module RuboCop
|
|
52
51
|
reject_mutually_exclusive_defaults
|
53
52
|
end
|
54
53
|
|
54
|
+
# Validations that should only be run after all config resolving has
|
55
|
+
# taken place:
|
56
|
+
# * The target ruby version is only checked once the entire inheritance
|
57
|
+
# chain has been loaded so that only the final value is validated, and
|
58
|
+
# any obsolete but overridden values are ignored.
|
59
|
+
def validate_after_resolution
|
60
|
+
check_target_ruby
|
61
|
+
end
|
62
|
+
|
55
63
|
def target_ruby_version
|
56
64
|
target_ruby.version
|
57
65
|
end
|
data/lib/rubocop/cop/base.rb
CHANGED
@@ -24,7 +24,7 @@ module RuboCop
|
|
24
24
|
# `add_global_offense`. Use the `processed_source` method to
|
25
25
|
# get the currently processed source being investigated.
|
26
26
|
#
|
27
|
-
# In case of invalid syntax /
|
27
|
+
# In case of invalid syntax / unparsable content,
|
28
28
|
# the callback `on_other_file` is called instead of all the other
|
29
29
|
# `on_...` callbacks.
|
30
30
|
#
|
@@ -222,8 +222,8 @@ module RuboCop
|
|
222
222
|
|
223
223
|
def relevant_file?(file)
|
224
224
|
file == RuboCop::AST::ProcessedSource::STRING_SOURCE_NAME ||
|
225
|
-
file_name_matches_any?(file, 'Include', true) &&
|
226
|
-
!file_name_matches_any?(file, 'Exclude', false)
|
225
|
+
(file_name_matches_any?(file, 'Include', true) &&
|
226
|
+
!file_name_matches_any?(file, 'Exclude', false))
|
227
227
|
end
|
228
228
|
|
229
229
|
def excluded_file?(file)
|
@@ -88,7 +88,7 @@ module RuboCop
|
|
88
88
|
CHECKED_OPTIONS_CONFIG = 'OnlyFor'
|
89
89
|
VERSION_SPECIFIERS_OPTION = 'version_specifiers'
|
90
90
|
RESTRICTIVE_VERSION_SPECIFIERS_OPTION = 'restrictive_version_specifiers'
|
91
|
-
RESTRICTIVE_VERSION_PATTERN =
|
91
|
+
RESTRICTIVE_VERSION_PATTERN = /\A\s*(?:<|~>|\d|=)/.freeze
|
92
92
|
RESTRICT_ON_SEND = %i[gem].freeze
|
93
93
|
|
94
94
|
def on_send(node)
|
@@ -152,8 +152,8 @@ module RuboCop
|
|
152
152
|
def restrictive_version_specified_gem?(node)
|
153
153
|
return unless version_specified_gem?(node)
|
154
154
|
|
155
|
-
node.arguments
|
156
|
-
.any? { |arg| arg&.str_type? && RESTRICTIVE_VERSION_PATTERN.match?(arg.
|
155
|
+
node.arguments[1..-1]
|
156
|
+
.any? { |arg| arg&.str_type? && RESTRICTIVE_VERSION_PATTERN.match?(arg.value) }
|
157
157
|
end
|
158
158
|
|
159
159
|
def contains_checked_options?(node)
|
@@ -3,18 +3,21 @@
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
5
|
module Bundler
|
6
|
-
#
|
7
|
-
#
|
8
|
-
# 'https://rubygems.org' if possible, or 'http://rubygems.org' if not.
|
6
|
+
# Passing symbol arguments to `source` (e.g. `source :rubygems`) is
|
7
|
+
# deprecated because they default to using HTTP requests. Instead, specify
|
8
|
+
# `'https://rubygems.org'` if possible, or `'http://rubygems.org'` if not.
|
9
9
|
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
# most use cases HTTPS will be fine.
|
10
|
+
# When autocorrecting, this cop will replace symbol arguments with
|
11
|
+
# `'https://rubygems.org'`.
|
13
12
|
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
13
|
+
# This cop will not replace existing sources that use `http://`. This may
|
14
|
+
# be necessary where HTTPS is not available. For example, where using an
|
15
|
+
# internal gem server via an intranet, or where HTTPS is prohibited.
|
16
|
+
# However, you should strongly prefer `https://` where possible, as it is
|
17
|
+
# more secure.
|
18
|
+
#
|
19
|
+
# If you don't allow `http://`, please set `false` to `AllowHttpProtocol`.
|
20
|
+
# This option is `true` by default for safe autocorrection.
|
18
21
|
#
|
19
22
|
# @example
|
20
23
|
# # bad
|
@@ -24,7 +27,17 @@ module RuboCop
|
|
24
27
|
#
|
25
28
|
# # good
|
26
29
|
# source 'https://rubygems.org' # strongly recommended
|
30
|
+
#
|
31
|
+
# @example AllowHttpProtocol: true (default)
|
32
|
+
#
|
33
|
+
# # good
|
34
|
+
# source 'http://rubygems.org' # use only if HTTPS is unavailable
|
35
|
+
#
|
36
|
+
# @example AllowHttpProtocol: false
|
37
|
+
#
|
38
|
+
# # bad
|
27
39
|
# source 'http://rubygems.org'
|
40
|
+
#
|
28
41
|
class InsecureProtocolSource < Base
|
29
42
|
include RangeHelp
|
30
43
|
extend AutoCorrector
|
@@ -33,29 +46,40 @@ module RuboCop
|
|
33
46
|
'are insecure. ' \
|
34
47
|
"Please change your source to 'https://rubygems.org' " \
|
35
48
|
"if possible, or 'http://rubygems.org' if not."
|
49
|
+
MSG_HTTP_PROTOCOL = 'Use `https://rubygems.org` instead of `http://rubygems.org`.'
|
36
50
|
|
37
51
|
RESTRICT_ON_SEND = %i[source].freeze
|
38
52
|
|
39
53
|
# @!method insecure_protocol_source?(node)
|
40
54
|
def_node_matcher :insecure_protocol_source?, <<~PATTERN
|
41
55
|
(send nil? :source
|
42
|
-
$(sym
|
56
|
+
${(sym :gemcutter) (sym :rubygems) (sym :rubyforge) (:str "http://rubygems.org")})
|
43
57
|
PATTERN
|
44
58
|
|
45
59
|
def on_send(node)
|
46
|
-
insecure_protocol_source?(node) do |source_node
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
60
|
+
insecure_protocol_source?(node) do |source_node|
|
61
|
+
source = source_node.value
|
62
|
+
use_http_protocol = source == 'http://rubygems.org'
|
63
|
+
|
64
|
+
return if allow_http_protocol? && use_http_protocol
|
65
|
+
|
66
|
+
message = if use_http_protocol
|
67
|
+
MSG_HTTP_PROTOCOL
|
68
|
+
else
|
69
|
+
format(MSG, source: source)
|
70
|
+
end
|
71
|
+
|
72
|
+
add_offense(source_node, message: message) do |corrector|
|
73
|
+
corrector.replace(source_node, "'https://rubygems.org'")
|
56
74
|
end
|
57
75
|
end
|
58
76
|
end
|
77
|
+
|
78
|
+
private
|
79
|
+
|
80
|
+
def allow_http_protocol?
|
81
|
+
cop_config.fetch('AllowHttpProtocol', true)
|
82
|
+
end
|
59
83
|
end
|
60
84
|
end
|
61
85
|
end
|
@@ -24,15 +24,15 @@ module RuboCop
|
|
24
24
|
# gem 'rubocop'
|
25
25
|
# # For tests
|
26
26
|
# gem 'rspec'
|
27
|
-
class OrderedGems <
|
28
|
-
|
27
|
+
class OrderedGems < Base
|
28
|
+
extend AutoCorrector
|
29
29
|
include OrderedGemNode
|
30
30
|
|
31
31
|
MSG = 'Gems should be sorted in an alphabetical order within their '\
|
32
32
|
'section of the Gemfile. '\
|
33
33
|
'Gem `%<previous>s` should appear before `%<current>s`.'
|
34
34
|
|
35
|
-
def
|
35
|
+
def on_new_investigation
|
36
36
|
return if processed_source.blank?
|
37
37
|
|
38
38
|
gem_declarations(processed_source.ast)
|
@@ -44,15 +44,6 @@ module RuboCop
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
def autocorrect(node)
|
48
|
-
OrderedGemCorrector.correct(
|
49
|
-
processed_source,
|
50
|
-
node,
|
51
|
-
previous_declaration(node),
|
52
|
-
treat_comments_as_separators
|
53
|
-
)
|
54
|
-
end
|
55
|
-
|
56
47
|
private
|
57
48
|
|
58
49
|
def previous_declaration(node)
|
@@ -87,8 +87,8 @@ module RuboCop
|
|
87
87
|
end
|
88
88
|
|
89
89
|
def needs_separating_space?
|
90
|
-
block_begin.begin_pos == arguments_end_pos &&
|
91
|
-
selector_end.end_pos == arguments_begin_pos ||
|
90
|
+
(block_begin.begin_pos == arguments_end_pos &&
|
91
|
+
selector_end.end_pos == arguments_begin_pos) ||
|
92
92
|
block_begin.begin_pos == selector_end.end_pos
|
93
93
|
end
|
94
94
|
|
@@ -4,9 +4,10 @@ module RuboCop
|
|
4
4
|
module Cop
|
5
5
|
# This auto-corrects gem dependency order
|
6
6
|
class OrderedGemCorrector
|
7
|
-
extend OrderedGemNode
|
8
|
-
|
9
7
|
class << self
|
8
|
+
include OrderedGemNode
|
9
|
+
include RangeHelp
|
10
|
+
|
10
11
|
attr_reader :processed_source, :comments_as_separators
|
11
12
|
|
12
13
|
def correct(processed_source, node,
|
@@ -17,24 +18,24 @@ module RuboCop
|
|
17
18
|
current_range = declaration_with_comment(node)
|
18
19
|
previous_range = declaration_with_comment(previous_declaration)
|
19
20
|
|
20
|
-
->(corrector)
|
21
|
+
->(corrector) { swap_range(corrector, current_range, previous_range) }
|
21
22
|
end
|
22
23
|
|
23
24
|
private
|
24
25
|
|
25
26
|
def declaration_with_comment(node)
|
26
27
|
buffer = processed_source.buffer
|
27
|
-
begin_pos = get_source_range(node, comments_as_separators).begin_pos
|
28
|
+
begin_pos = range_by_whole_lines(get_source_range(node, comments_as_separators)).begin_pos
|
28
29
|
end_line = buffer.line_for_position(node.loc.expression.end_pos)
|
29
|
-
end_pos = buffer.line_range(end_line)
|
30
|
-
|
30
|
+
end_pos = range_by_whole_lines(buffer.line_range(end_line),
|
31
|
+
include_final_newline: true).end_pos
|
32
|
+
|
33
|
+
range_between(begin_pos, end_pos)
|
31
34
|
end
|
32
35
|
|
33
36
|
def swap_range(corrector, range1, range2)
|
34
|
-
|
35
|
-
|
36
|
-
corrector.replace(range1, src2)
|
37
|
-
corrector.replace(range2, src1)
|
37
|
+
corrector.insert_before(range2, range1.source)
|
38
|
+
corrector.remove(range1)
|
38
39
|
end
|
39
40
|
end
|
40
41
|
end
|
@@ -50,15 +50,15 @@ module RuboCop
|
|
50
50
|
# spec.add_dependency 'rubocop'
|
51
51
|
# # For tests
|
52
52
|
# spec.add_dependency 'rspec'
|
53
|
-
class OrderedDependencies <
|
54
|
-
|
53
|
+
class OrderedDependencies < Base
|
54
|
+
extend AutoCorrector
|
55
55
|
include OrderedGemNode
|
56
56
|
|
57
57
|
MSG = 'Dependencies should be sorted in an alphabetical order within ' \
|
58
58
|
'their section of the gemspec. '\
|
59
59
|
'Dependency `%<previous>s` should appear before `%<current>s`.'
|
60
60
|
|
61
|
-
def
|
61
|
+
def on_new_investigation
|
62
62
|
return if processed_source.blank?
|
63
63
|
|
64
64
|
dependency_declarations(processed_source.ast)
|
@@ -71,15 +71,6 @@ module RuboCop
|
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
|
-
def autocorrect(node)
|
75
|
-
OrderedGemCorrector.correct(
|
76
|
-
processed_source,
|
77
|
-
node,
|
78
|
-
previous_declaration(node),
|
79
|
-
treat_comments_as_separators
|
80
|
-
)
|
81
|
-
end
|
82
|
-
|
83
74
|
private
|
84
75
|
|
85
76
|
def previous_declaration(node)
|