rubocop 1.18.1 → 1.22.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/config/default.yml +116 -23
- data/lib/rubocop/cli.rb +18 -0
- data/lib/rubocop/config.rb +5 -0
- data/lib/rubocop/config_loader.rb +5 -3
- data/lib/rubocop/config_loader_resolver.rb +22 -7
- data/lib/rubocop/config_validator.rb +27 -6
- data/lib/rubocop/cop/base.rb +3 -3
- data/lib/rubocop/cop/bundler/gem_comment.rb +3 -3
- data/lib/rubocop/cop/bundler/gem_filename.rb +103 -0
- 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/correctors/require_library_corrector.rb +23 -0
- data/lib/rubocop/cop/documentation.rb +1 -1
- 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/inherit_deprecated_cop_class.rb +34 -0
- 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/undefined_config.rb +71 -0
- data/lib/rubocop/cop/internal_affairs.rb +3 -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/block_alignment.rb +3 -3
- data/lib/rubocop/cop/layout/class_structure.rb +7 -2
- data/lib/rubocop/cop/layout/dot_position.rb +34 -5
- data/lib/rubocop/cop/layout/empty_comment.rb +1 -1
- data/lib/rubocop/cop/layout/empty_line_after_guard_clause.rb +9 -0
- data/lib/rubocop/cop/layout/empty_lines_around_exception_handling_keywords.rb +7 -4
- data/lib/rubocop/cop/layout/end_alignment.rb +9 -2
- data/lib/rubocop/cop/layout/first_argument_indentation.rb +1 -1
- 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 +22 -18
- data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +1 -1
- data/lib/rubocop/cop/layout/heredoc_indentation.rb +0 -7
- data/lib/rubocop/cop/layout/indentation_style.rb +2 -2
- data/lib/rubocop/cop/layout/indentation_width.rb +1 -1
- data/lib/rubocop/cop/layout/leading_comment_space.rb +2 -2
- data/lib/rubocop/cop/layout/line_end_string_concatenation_indentation.rb +36 -17
- 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_argument_line_breaks.rb +3 -0
- 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 +23 -10
- 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_around_operators.rb +12 -1
- data/lib/rubocop/cop/layout/space_before_brackets.rb +1 -0
- data/lib/rubocop/cop/layout/space_before_comment.rb +2 -2
- data/lib/rubocop/cop/layout/space_inside_parens.rb +78 -32
- data/lib/rubocop/cop/layout/space_inside_reference_brackets.rb +1 -1
- data/lib/rubocop/cop/layout/trailing_whitespace.rb +24 -1
- data/lib/rubocop/cop/lint/ambiguous_operator_precedence.rb +111 -0
- data/lib/rubocop/cop/lint/ambiguous_range.rb +105 -0
- data/lib/rubocop/cop/lint/ambiguous_regexp_literal.rb +5 -2
- 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 +2 -4
- data/lib/rubocop/cop/lint/deprecated_class_methods.rb +4 -4
- data/lib/rubocop/cop/lint/deprecated_constants.rb +3 -2
- data/lib/rubocop/cop/lint/disjunctive_assignment_in_constructor.rb +24 -1
- data/lib/rubocop/cop/lint/duplicate_branch.rb +2 -1
- data/lib/rubocop/cop/lint/duplicate_methods.rb +8 -5
- 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/shadowed_argument.rb +1 -1
- 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 +5 -4
- 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/annotation_comment.rb +57 -34
- data/lib/rubocop/cop/mixin/check_line_breakable.rb +2 -2
- data/lib/rubocop/cop/mixin/code_length.rb +1 -1
- data/lib/rubocop/cop/mixin/documentation_comment.rb +5 -2
- data/lib/rubocop/cop/mixin/end_keyword_alignment.rb +1 -2
- data/lib/rubocop/cop/mixin/frozen_string_literal.rb +23 -1
- data/lib/rubocop/cop/mixin/hash_transform_method.rb +9 -4
- data/lib/rubocop/cop/mixin/heredoc.rb +5 -0
- 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 +18 -7
- data/lib/rubocop/cop/mixin/preceding_following_alignment.rb +9 -1
- data/lib/rubocop/cop/mixin/require_library.rb +59 -0
- data/lib/rubocop/cop/mixin/space_after_punctuation.rb +1 -1
- data/lib/rubocop/cop/mixin/space_before_punctuation.rb +2 -2
- 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 +27 -10
- 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/block_delimiters.rb +50 -2
- 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/comment_annotation.rb +55 -25
- data/lib/rubocop/cop/style/commented_keyword.rb +9 -3
- data/lib/rubocop/cop/style/conditional_assignment.rb +19 -5
- 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_cop_disable_directive.rb +1 -7
- data/lib/rubocop/cop/style/double_negation.rb +27 -6
- data/lib/rubocop/cop/style/empty_method.rb +1 -1
- data/lib/rubocop/cop/style/encoding.rb +26 -15
- data/lib/rubocop/cop/style/eval_with_location.rb +1 -1
- data/lib/rubocop/cop/style/explicit_block_argument.rb +46 -11
- data/lib/rubocop/cop/style/float_division.rb +10 -2
- data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +14 -3
- data/lib/rubocop/cop/style/global_std_stream.rb +4 -0
- data/lib/rubocop/cop/style/hash_as_last_array_item.rb +11 -0
- data/lib/rubocop/cop/style/hash_each_methods.rb +5 -0
- data/lib/rubocop/cop/style/hash_except.rb +4 -3
- data/lib/rubocop/cop/style/hash_syntax.rb +1 -1
- data/lib/rubocop/cop/style/hash_transform_keys.rb +4 -9
- data/lib/rubocop/cop/style/hash_transform_values.rb +4 -6
- data/lib/rubocop/cop/style/identical_conditional_branches.rb +32 -5
- 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/method_def_parentheses.rb +10 -1
- data/lib/rubocop/cop/style/missing_else.rb +7 -0
- 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 +79 -14
- 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_begin.rb +25 -0
- 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 +4 -4
- 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 +83 -0
- data/lib/rubocop/cop/style/redundant_sort.rb +53 -20
- 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 +139 -0
- data/lib/rubocop/cop/style/semicolon.rb +32 -24
- data/lib/rubocop/cop/style/single_argument_dig.rb +5 -0
- data/lib/rubocop/cop/style/single_line_block_params.rb +3 -1
- data/lib/rubocop/cop/style/single_line_methods.rb +25 -15
- data/lib/rubocop/cop/style/slicing_with_range.rb +13 -0
- data/lib/rubocop/cop/style/sole_nested_conditional.rb +4 -0
- data/lib/rubocop/cop/style/special_global_vars.rb +25 -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 +4 -0
- data/lib/rubocop/cop/style/swap_values.rb +4 -2
- data/lib/rubocop/cop/style/symbol_array.rb +3 -3
- 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/word_array.rb +23 -5
- 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 +22 -6
- data/lib/rubocop/cops_documentation_generator.rb +17 -5
- data/lib/rubocop/formatter/git_hub_actions_formatter.rb +1 -1
- data/lib/rubocop/magic_comment.rb +44 -15
- data/lib/rubocop/options.rb +127 -113
- 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 +14 -2
- metadata +21 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f74b024d0339618cd4782bd451e3bbe8be65eab0a5f3dbfc1d2137c74848c6fa
|
4
|
+
data.tar.gz: ef762c615b2d68f52d5aac425abea13a40d097f1b7885cd1558a991dd23c136d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfdba4bbc01e69d2a0873272815dc9c03d5e95f2dce5f02186b38f2f9e1e28ae34df246e6b548cdccf0831bace4f02bfad334f59548b2bf67430431b5760731b
|
7
|
+
data.tar.gz: 662e06452c13b66a949e7a8035bc6b4b31e7af7a3cf161b9802634365a53a0b2452aeb7741ab13387186483cdf9027dc5cca736734d5d3022f78362bfabf9a5c
|
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
|
@@ -174,6 +174,20 @@ Bundler/GemComment:
|
|
174
174
|
IgnoredGems: []
|
175
175
|
OnlyFor: []
|
176
176
|
|
177
|
+
Bundler/GemFilename:
|
178
|
+
Description: 'Enforces the filename for managing gems.'
|
179
|
+
Enabled: true
|
180
|
+
VersionAdded: '1.20'
|
181
|
+
EnforcedStyle: 'Gemfile'
|
182
|
+
SupportedStyles:
|
183
|
+
- 'Gemfile'
|
184
|
+
- 'gems.rb'
|
185
|
+
Include:
|
186
|
+
- '**/Gemfile'
|
187
|
+
- '**/gems.rb'
|
188
|
+
- '**/Gemfile.lock'
|
189
|
+
- '**/gems.locked'
|
190
|
+
|
177
191
|
Bundler/GemVersion:
|
178
192
|
Description: 'Requires or forbids specifying gem versions.'
|
179
193
|
Enabled: false
|
@@ -195,6 +209,7 @@ Bundler/InsecureProtocolSource:
|
|
195
209
|
'https://rubygems.org' if possible, or 'http://rubygems.org' if not.
|
196
210
|
Enabled: true
|
197
211
|
VersionAdded: '0.50'
|
212
|
+
AllowHttpProtocol: true
|
198
213
|
Include:
|
199
214
|
- '**/*.gemfile'
|
200
215
|
- '**/Gemfile'
|
@@ -247,7 +262,7 @@ Gemspec/RequiredRubyVersion:
|
|
247
262
|
Description: 'Checks that `required_ruby_version` of gemspec is specified and equal to `TargetRubyVersion` of .rubocop.yml.'
|
248
263
|
Enabled: true
|
249
264
|
VersionAdded: '0.52'
|
250
|
-
VersionChanged: '
|
265
|
+
VersionChanged: '1.22'
|
251
266
|
Include:
|
252
267
|
- '**/*.gemspec'
|
253
268
|
|
@@ -943,7 +958,6 @@ Layout/LineLength:
|
|
943
958
|
Enabled: true
|
944
959
|
VersionAdded: '0.25'
|
945
960
|
VersionChanged: '1.4'
|
946
|
-
AutoCorrect: true
|
947
961
|
Max: 120
|
948
962
|
# To make it possible to copy or click on URIs in the code, we allow lines
|
949
963
|
# containing a URI to be longer than Max.
|
@@ -1347,10 +1361,11 @@ Layout/SpaceInsideParens:
|
|
1347
1361
|
StyleGuide: '#spaces-braces'
|
1348
1362
|
Enabled: true
|
1349
1363
|
VersionAdded: '0.49'
|
1350
|
-
VersionChanged: '
|
1364
|
+
VersionChanged: '1.22'
|
1351
1365
|
EnforcedStyle: no_space
|
1352
1366
|
SupportedStyles:
|
1353
1367
|
- space
|
1368
|
+
- compact
|
1354
1369
|
- no_space
|
1355
1370
|
|
1356
1371
|
Layout/SpaceInsidePercentLiteralDelimiters:
|
@@ -1434,6 +1449,20 @@ Lint/AmbiguousOperator:
|
|
1434
1449
|
VersionAdded: '0.17'
|
1435
1450
|
VersionChanged: '0.83'
|
1436
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
|
+
|
1459
|
+
Lint/AmbiguousRange:
|
1460
|
+
Description: Checks for ranges with ambiguous boundaries.
|
1461
|
+
Enabled: pending
|
1462
|
+
VersionAdded: '1.19'
|
1463
|
+
SafeAutoCorrect: false
|
1464
|
+
RequireParenthesesForMethodChains: false
|
1465
|
+
|
1437
1466
|
Lint/AmbiguousRegexpLiteral:
|
1438
1467
|
Description: >-
|
1439
1468
|
Checks for ambiguous regexp literals in the first argument of
|
@@ -1464,9 +1493,9 @@ Lint/BinaryOperatorWithIdenticalOperands:
|
|
1464
1493
|
Lint/BooleanSymbol:
|
1465
1494
|
Description: 'Check for `:true` and `:false` symbols.'
|
1466
1495
|
Enabled: true
|
1467
|
-
|
1496
|
+
SafeAutoCorrect: false
|
1468
1497
|
VersionAdded: '0.50'
|
1469
|
-
VersionChanged: '
|
1498
|
+
VersionChanged: '1.22'
|
1470
1499
|
|
1471
1500
|
Lint/CircularArgumentReference:
|
1472
1501
|
Description: "Default values in optional keyword arguments and optional ordinal arguments should not refer back to the name of the argument."
|
@@ -1512,6 +1541,11 @@ Lint/Debugger:
|
|
1512
1541
|
Capybara:
|
1513
1542
|
- save_and_open_page
|
1514
1543
|
- save_and_open_screenshot
|
1544
|
+
debug.rb:
|
1545
|
+
- binding.b
|
1546
|
+
- binding.break
|
1547
|
+
- Kernel.binding.b
|
1548
|
+
- Kernel.binding.break
|
1515
1549
|
Pry:
|
1516
1550
|
- binding.pry
|
1517
1551
|
- binding.remote_pry
|
@@ -1520,6 +1554,8 @@ Lint/Debugger:
|
|
1520
1554
|
Rails:
|
1521
1555
|
- debugger
|
1522
1556
|
- Kernel.debugger
|
1557
|
+
RubyJard:
|
1558
|
+
- jard
|
1523
1559
|
WebConsole:
|
1524
1560
|
- binding.console
|
1525
1561
|
|
@@ -1532,6 +1568,7 @@ Lint/DeprecatedConstants:
|
|
1532
1568
|
Description: 'Checks for deprecated constants.'
|
1533
1569
|
Enabled: pending
|
1534
1570
|
VersionAdded: '1.8'
|
1571
|
+
VersionChanged: '1.22'
|
1535
1572
|
# You can configure deprecated constants.
|
1536
1573
|
# If there is an alternative method, you can set alternative value as `Alternative`.
|
1537
1574
|
# And you can set the deprecated version as `DeprecatedVersion`.
|
@@ -1552,6 +1589,9 @@ Lint/DeprecatedConstants:
|
|
1552
1589
|
'FALSE':
|
1553
1590
|
Alternative: 'false'
|
1554
1591
|
DeprecatedVersion: '2.4'
|
1592
|
+
'Net::HTTPServerException':
|
1593
|
+
Alternative: 'Net::HTTPClientException'
|
1594
|
+
DeprecatedVersion: '2.6'
|
1555
1595
|
'Random::DEFAULT':
|
1556
1596
|
Alternative: 'Random.new'
|
1557
1597
|
DeprecatedVersion: '3.0'
|
@@ -1743,6 +1783,11 @@ Lint/ImplicitStringConcatenation:
|
|
1743
1783
|
Enabled: true
|
1744
1784
|
VersionAdded: '0.36'
|
1745
1785
|
|
1786
|
+
Lint/IncompatibleIoSelectWithFiberScheduler:
|
1787
|
+
Description: 'Checks for `IO.select` that is incompatible with Fiber Scheduler.'
|
1788
|
+
Enabled: pending
|
1789
|
+
VersionAdded: '1.21'
|
1790
|
+
|
1746
1791
|
Lint/IneffectiveAccessModifier:
|
1747
1792
|
Description: >-
|
1748
1793
|
Checks for attempts to use `private` or `protected` to set
|
@@ -1809,7 +1854,7 @@ Lint/MissingCopEnableDirective:
|
|
1809
1854
|
Lint/MissingSuper:
|
1810
1855
|
Description: >-
|
1811
1856
|
This cop checks for the presence of constructors and lifecycle callbacks
|
1812
|
-
without calls to `super
|
1857
|
+
without calls to `super`.
|
1813
1858
|
Enabled: true
|
1814
1859
|
VersionAdded: '0.89'
|
1815
1860
|
VersionChanged: '1.4'
|
@@ -1824,7 +1869,6 @@ Lint/MultipleComparison:
|
|
1824
1869
|
Enabled: true
|
1825
1870
|
VersionAdded: '0.47'
|
1826
1871
|
VersionChanged: '1.1'
|
1827
|
-
AllowMethodComparison: true
|
1828
1872
|
|
1829
1873
|
Lint/NestedMethodDefinition:
|
1830
1874
|
Description: 'Do not use nested method definitions.'
|
@@ -2007,6 +2051,11 @@ Lint/RequireParentheses:
|
|
2007
2051
|
Enabled: true
|
2008
2052
|
VersionAdded: '0.18'
|
2009
2053
|
|
2054
|
+
Lint/RequireRelativeSelfPath:
|
2055
|
+
Description: 'Checks for uses a file requiring itself with `require_relative`.'
|
2056
|
+
Enabled: pending
|
2057
|
+
VersionAdded: '1.22'
|
2058
|
+
|
2010
2059
|
Lint/RescueException:
|
2011
2060
|
Description: 'Avoid rescuing the Exception class.'
|
2012
2061
|
StyleGuide: '#no-blind-rescues'
|
@@ -2536,8 +2585,9 @@ Naming/HeredocDelimiterNaming:
|
|
2536
2585
|
|
2537
2586
|
Naming/InclusiveLanguage:
|
2538
2587
|
Description: 'Recommend the use of inclusive language instead of problematic terms.'
|
2539
|
-
Enabled:
|
2588
|
+
Enabled: false
|
2540
2589
|
VersionAdded: '1.18'
|
2590
|
+
VersionChanged: '1.21'
|
2541
2591
|
CheckIdentifiers: true
|
2542
2592
|
CheckConstants: true
|
2543
2593
|
CheckVariables: true
|
@@ -2557,6 +2607,7 @@ Naming/InclusiveLanguage:
|
|
2557
2607
|
- denylist
|
2558
2608
|
- block
|
2559
2609
|
slave:
|
2610
|
+
WholeWord: true
|
2560
2611
|
Suggestions: ['replica', 'secondary', 'follower']
|
2561
2612
|
|
2562
2613
|
Naming/MemoizedInstanceVariableName:
|
@@ -2692,6 +2743,14 @@ Security/Eval:
|
|
2692
2743
|
Enabled: true
|
2693
2744
|
VersionAdded: '0.47'
|
2694
2745
|
|
2746
|
+
Security/IoMethods:
|
2747
|
+
Description: >-
|
2748
|
+
Checks for the first argument to `IO.read`, `IO.binread`, `IO.write`, `IO.binwrite`,
|
2749
|
+
`IO.foreach`, and `IO.readlines`.
|
2750
|
+
Enabled: pending
|
2751
|
+
Safe: false
|
2752
|
+
VersionAdded: '1.22'
|
2753
|
+
|
2695
2754
|
Security/JSONLoad:
|
2696
2755
|
Description: >-
|
2697
2756
|
Prefer usage of `JSON.parse` over `JSON.load` due to potential
|
@@ -2699,10 +2758,9 @@ Security/JSONLoad:
|
|
2699
2758
|
Reference: 'https://ruby-doc.org/stdlib-2.7.0/libdoc/json/rdoc/JSON.html#method-i-load'
|
2700
2759
|
Enabled: true
|
2701
2760
|
VersionAdded: '0.43'
|
2702
|
-
VersionChanged: '
|
2761
|
+
VersionChanged: '1.22'
|
2703
2762
|
# Autocorrect here will change to a method that may cause crashes depending
|
2704
2763
|
# on the value of the argument.
|
2705
|
-
AutoCorrect: false
|
2706
2764
|
SafeAutoCorrect: false
|
2707
2765
|
|
2708
2766
|
Security/MarshalLoad:
|
@@ -2768,8 +2826,9 @@ Style/AndOr:
|
|
2768
2826
|
Description: 'Use &&/|| instead of and/or.'
|
2769
2827
|
StyleGuide: '#no-and-or-or'
|
2770
2828
|
Enabled: true
|
2829
|
+
SafeAutoCorrect: false
|
2771
2830
|
VersionAdded: '0.9'
|
2772
|
-
VersionChanged: '
|
2831
|
+
VersionChanged: '1.21'
|
2773
2832
|
# Whether `and` and `or` are banned only in conditionals (conditionals)
|
2774
2833
|
# or completely (always).
|
2775
2834
|
EnforcedStyle: conditionals
|
@@ -2803,9 +2862,9 @@ Style/ArrayJoin:
|
|
2803
2862
|
Style/AsciiComments:
|
2804
2863
|
Description: 'Use only ascii symbols in comments.'
|
2805
2864
|
StyleGuide: '#english-comments'
|
2806
|
-
Enabled:
|
2865
|
+
Enabled: false
|
2807
2866
|
VersionAdded: '0.9'
|
2808
|
-
VersionChanged: '
|
2867
|
+
VersionChanged: '1.21'
|
2809
2868
|
AllowedChars:
|
2810
2869
|
- ©
|
2811
2870
|
|
@@ -2967,7 +3026,7 @@ Style/CaseEquality:
|
|
2967
3026
|
Enabled: true
|
2968
3027
|
VersionAdded: '0.9'
|
2969
3028
|
VersionChanged: '0.89'
|
2970
|
-
# If AllowOnConstant is enabled, the cop will ignore violations when the receiver of
|
3029
|
+
# If `AllowOnConstant` option is enabled, the cop will ignore violations when the receiver of
|
2971
3030
|
# the case equality operator is a constant.
|
2972
3031
|
#
|
2973
3032
|
# # bad
|
@@ -3142,7 +3201,7 @@ Style/CommentAnnotation:
|
|
3142
3201
|
StyleGuide: '#annotate-keywords'
|
3143
3202
|
Enabled: true
|
3144
3203
|
VersionAdded: '0.10'
|
3145
|
-
VersionChanged: '1.
|
3204
|
+
VersionChanged: '1.20'
|
3146
3205
|
Keywords:
|
3147
3206
|
- TODO
|
3148
3207
|
- FIXME
|
@@ -3150,12 +3209,14 @@ Style/CommentAnnotation:
|
|
3150
3209
|
- HACK
|
3151
3210
|
- REVIEW
|
3152
3211
|
- NOTE
|
3212
|
+
RequireColon: true
|
3153
3213
|
|
3154
3214
|
Style/CommentedKeyword:
|
3155
3215
|
Description: 'Do not place comments on the same line as certain keywords.'
|
3156
3216
|
Enabled: true
|
3217
|
+
SafeAutoCorrect: false
|
3157
3218
|
VersionAdded: '0.51'
|
3158
|
-
VersionChanged: '1.
|
3219
|
+
VersionChanged: '1.19'
|
3159
3220
|
|
3160
3221
|
Style/ConditionalAssignment:
|
3161
3222
|
Description: >-
|
@@ -3602,8 +3663,9 @@ Style/IdenticalConditionalBranches:
|
|
3602
3663
|
line at the end of each branch, which can validly be moved
|
3603
3664
|
out of the conditional.
|
3604
3665
|
Enabled: true
|
3666
|
+
SafeAutoCorrect: false
|
3605
3667
|
VersionAdded: '0.36'
|
3606
|
-
VersionChanged: '1.
|
3668
|
+
VersionChanged: '1.19'
|
3607
3669
|
|
3608
3670
|
Style/IfInsideElse:
|
3609
3671
|
Description: 'Finds if nodes inside else, which can be converted to elsif.'
|
@@ -3659,7 +3721,7 @@ Style/InPatternThen:
|
|
3659
3721
|
Style/InfiniteLoop:
|
3660
3722
|
Description: >-
|
3661
3723
|
Use Kernel#loop for infinite loops.
|
3662
|
-
This cop is unsafe
|
3724
|
+
This cop is unsafe if the body may raise a `StopIteration` exception.
|
3663
3725
|
Safe: false
|
3664
3726
|
StyleGuide: '#infinite-loop'
|
3665
3727
|
Enabled: true
|
@@ -3928,6 +3990,7 @@ Style/MultipleComparison:
|
|
3928
3990
|
Enabled: true
|
3929
3991
|
VersionAdded: '0.49'
|
3930
3992
|
VersionChanged: '1.1'
|
3993
|
+
AllowMethodComparison: true
|
3931
3994
|
|
3932
3995
|
Style/MutableConstant:
|
3933
3996
|
Description: 'Do not assign mutable objects to constants.'
|
@@ -4084,6 +4147,21 @@ Style/Not:
|
|
4084
4147
|
VersionAdded: '0.9'
|
4085
4148
|
VersionChanged: '0.20'
|
4086
4149
|
|
4150
|
+
Style/NumberedParameters:
|
4151
|
+
Description: 'Restrict the usage of numbered parameters.'
|
4152
|
+
Enabled: pending
|
4153
|
+
VersionAdded: '1.22'
|
4154
|
+
EnforcedStyle: allow_single_line
|
4155
|
+
SupportedStyles:
|
4156
|
+
- allow_single_line
|
4157
|
+
- disallow
|
4158
|
+
|
4159
|
+
Style/NumberedParametersLimit:
|
4160
|
+
Description: 'Avoid excessive numbered params in a single block.'
|
4161
|
+
Enabled: pending
|
4162
|
+
VersionAdded: '1.22'
|
4163
|
+
Max: 1
|
4164
|
+
|
4087
4165
|
Style/NumericLiteralPrefix:
|
4088
4166
|
Description: 'Use smallcase prefixes for numeric literals.'
|
4089
4167
|
StyleGuide: '#numeric-literal-prefixes'
|
@@ -4094,7 +4172,6 @@ Style/NumericLiteralPrefix:
|
|
4094
4172
|
- zero_with_o
|
4095
4173
|
- zero_only
|
4096
4174
|
|
4097
|
-
|
4098
4175
|
Style/NumericLiterals:
|
4099
4176
|
Description: >-
|
4100
4177
|
Add underscores to large numeric literals to improve their
|
@@ -4151,6 +4228,7 @@ Style/OptionHash:
|
|
4151
4228
|
- args
|
4152
4229
|
- params
|
4153
4230
|
- parameters
|
4231
|
+
Allowlist: []
|
4154
4232
|
|
4155
4233
|
Style/OptionalArguments:
|
4156
4234
|
Description: >-
|
@@ -4403,12 +4481,19 @@ Style/RedundantSelfAssignment:
|
|
4403
4481
|
Safe: false
|
4404
4482
|
VersionAdded: '0.90'
|
4405
4483
|
|
4484
|
+
Style/RedundantSelfAssignmentBranch:
|
4485
|
+
Description: 'Checks for places where conditional branch makes redundant self-assignment.'
|
4486
|
+
Enabled: pending
|
4487
|
+
VersionAdded: '1.19'
|
4488
|
+
|
4406
4489
|
Style/RedundantSort:
|
4407
4490
|
Description: >-
|
4408
4491
|
Use `min` instead of `sort.first`,
|
4409
4492
|
`max_by` instead of `sort_by...last`, etc.
|
4410
4493
|
Enabled: true
|
4411
4494
|
VersionAdded: '0.76'
|
4495
|
+
VersionChanged: '1.22'
|
4496
|
+
Safe: false
|
4412
4497
|
|
4413
4498
|
Style/RedundantSortBy:
|
4414
4499
|
Description: 'Use `sort` instead of `sort_by { |x| x }`.'
|
@@ -4489,6 +4574,12 @@ Style/Sample:
|
|
4489
4574
|
Enabled: true
|
4490
4575
|
VersionAdded: '0.30'
|
4491
4576
|
|
4577
|
+
Style/SelectByRegexp:
|
4578
|
+
Description: 'Prefer grep/grep_v to select/reject with a regexp match.'
|
4579
|
+
Enabled: pending
|
4580
|
+
SafeAutoCorrect: false
|
4581
|
+
VersionAdded: '1.22'
|
4582
|
+
|
4492
4583
|
Style/SelfAssignment:
|
4493
4584
|
Description: >-
|
4494
4585
|
Checks for places where self-assignment shorthand should have
|
@@ -4574,6 +4665,7 @@ Style/SpecialGlobalVars:
|
|
4574
4665
|
VersionAdded: '0.13'
|
4575
4666
|
VersionChanged: '0.36'
|
4576
4667
|
SafeAutoCorrect: false
|
4668
|
+
RequireEnglish: true
|
4577
4669
|
EnforcedStyle: use_english_names
|
4578
4670
|
SupportedStyles:
|
4579
4671
|
- use_perl_names
|
@@ -4674,8 +4766,9 @@ Style/StructInheritance:
|
|
4674
4766
|
Description: 'Checks for inheritance from Struct.new.'
|
4675
4767
|
StyleGuide: '#no-extend-struct-new'
|
4676
4768
|
Enabled: true
|
4769
|
+
SafeAutoCorrect: false
|
4677
4770
|
VersionAdded: '0.29'
|
4678
|
-
VersionChanged: '
|
4771
|
+
VersionChanged: '1.20'
|
4679
4772
|
|
4680
4773
|
Style/SwapValues:
|
4681
4774
|
Description: 'This cop enforces the use of shorthand-style swapping of 2 variables.'
|
@@ -4894,7 +4987,7 @@ Style/VariableInterpolation:
|
|
4894
4987
|
|
4895
4988
|
Style/WhenThen:
|
4896
4989
|
Description: 'Use when x then ... for one-line cases.'
|
4897
|
-
StyleGuide: '#
|
4990
|
+
StyleGuide: '#no-when-semicolons'
|
4898
4991
|
Enabled: true
|
4899
4992
|
VersionAdded: '0.9'
|
4900
4993
|
|
@@ -4918,7 +5011,7 @@ Style/WordArray:
|
|
4918
5011
|
StyleGuide: '#percent-w'
|
4919
5012
|
Enabled: true
|
4920
5013
|
VersionAdded: '0.9'
|
4921
|
-
VersionChanged: '
|
5014
|
+
VersionChanged: '1.19'
|
4922
5015
|
EnforcedStyle: percent
|
4923
5016
|
SupportedStyles:
|
4924
5017
|
# percent style: %w(word1 word2)
|
data/lib/rubocop/cli.rb
CHANGED
@@ -8,6 +8,11 @@ module RuboCop
|
|
8
8
|
STATUS_OFFENSES = 1
|
9
9
|
STATUS_ERROR = 2
|
10
10
|
STATUS_INTERRUPTED = 128 + Signal.list['INT']
|
11
|
+
DEFAULT_PARALLEL_OPTIONS = %i[
|
12
|
+
color debug display_style_guide display_time display_only_fail_level_offenses
|
13
|
+
display_only_failed except extra_details fail_level fix_layout format
|
14
|
+
ignore_disable_comments lint only only_guide_cops require safe
|
15
|
+
].freeze
|
11
16
|
|
12
17
|
class Finished < RuntimeError; end
|
13
18
|
|
@@ -37,6 +42,7 @@ module RuboCop
|
|
37
42
|
else
|
38
43
|
act_on_options
|
39
44
|
validate_options_vs_config
|
45
|
+
parallel_by_default!
|
40
46
|
apply_default_formatter
|
41
47
|
execute_runners
|
42
48
|
end
|
@@ -84,6 +90,18 @@ module RuboCop
|
|
84
90
|
'with AllCops: UseCache: false is not allowed.'
|
85
91
|
end
|
86
92
|
|
93
|
+
def parallel_by_default!
|
94
|
+
# See https://github.com/rubocop/rubocop/pull/4537 for JRuby and Windows constraints.
|
95
|
+
return if RUBY_ENGINE != 'ruby' || RuboCop::Platform.windows?
|
96
|
+
|
97
|
+
if (@options.keys - DEFAULT_PARALLEL_OPTIONS).empty? &&
|
98
|
+
@config_store.for_pwd.for_all_cops['UseCache'] != false
|
99
|
+
puts 'Use parallel by default.' if @options[:debug]
|
100
|
+
|
101
|
+
@options[:parallel] = true
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
87
105
|
def act_on_options
|
88
106
|
set_options_to_config_loader
|
89
107
|
|
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
|
@@ -143,7 +145,7 @@ module RuboCop
|
|
143
145
|
PENDING_BANNER = <<~BANNER
|
144
146
|
The following cops were added to RuboCop, but are not configured. Please set Enabled to either `true` or `false` in your `.rubocop.yml` file.
|
145
147
|
|
146
|
-
Please also note that can
|
148
|
+
Please also note that you can opt-in to new cops by default by adding this to your config:
|
147
149
|
AllCops:
|
148
150
|
NewCops: enable
|
149
151
|
BANNER
|
@@ -161,7 +163,7 @@ module RuboCop
|
|
161
163
|
def warn_pending_cop(cop)
|
162
164
|
version = cop.metadata['VersionAdded'] || 'N/A'
|
163
165
|
|
164
|
-
warn Rainbow("#{cop.name}: #
|
166
|
+
warn Rainbow("#{cop.name}: # new in #{version}").yellow
|
165
167
|
warn Rainbow(' Enabled: true').yellow
|
166
168
|
end
|
167
169
|
|
@@ -23,7 +23,7 @@ module RuboCop
|
|
23
23
|
def resolve_inheritance(path, hash, file, debug) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
24
24
|
inherited_files = Array(hash['inherit_from'])
|
25
25
|
base_configs(path, inherited_files, file)
|
26
|
-
.
|
26
|
+
.each_with_index.reverse_each do |base_config, index|
|
27
27
|
override_department_setting_for_cops(base_config, hash)
|
28
28
|
override_enabled_for_disabled_departments(base_config, hash)
|
29
29
|
|
@@ -108,7 +108,7 @@ module RuboCop
|
|
108
108
|
result.delete(key)
|
109
109
|
elsif merge_hashes?(base_hash, derived_hash, key)
|
110
110
|
result[key] = merge(base_hash[key], derived_hash[key], **opts)
|
111
|
-
elsif should_union?(
|
111
|
+
elsif should_union?(derived_hash, base_hash, opts[:inherit_mode], key)
|
112
112
|
result[key] = base_hash[key] | derived_hash[key]
|
113
113
|
elsif opts[:debug]
|
114
114
|
warn_on_duplicate_setting(base_hash, derived_hash, key, **opts)
|
@@ -183,11 +183,26 @@ module RuboCop
|
|
183
183
|
local_inherit || hash['inherit_mode'] || {}
|
184
184
|
end
|
185
185
|
|
186
|
-
def should_union?(base_hash,
|
187
|
-
base_hash[key].is_a?(Array)
|
188
|
-
|
189
|
-
|
190
|
-
|
186
|
+
def should_union?(derived_hash, base_hash, root_mode, key)
|
187
|
+
return false unless base_hash[key].is_a?(Array)
|
188
|
+
|
189
|
+
derived_mode = derived_hash['inherit_mode']
|
190
|
+
return false if should_override?(derived_mode, key)
|
191
|
+
return true if should_merge?(derived_mode, key)
|
192
|
+
|
193
|
+
base_mode = base_hash['inherit_mode']
|
194
|
+
return false if should_override?(base_mode, key)
|
195
|
+
return true if should_merge?(base_mode, key)
|
196
|
+
|
197
|
+
should_merge?(root_mode, key)
|
198
|
+
end
|
199
|
+
|
200
|
+
def should_merge?(mode, key)
|
201
|
+
mode && mode['merge'] && mode['merge'].include?(key)
|
202
|
+
end
|
203
|
+
|
204
|
+
def should_override?(mode, key)
|
205
|
+
mode && mode['override'] && mode['override'].include?(key)
|
191
206
|
end
|
192
207
|
|
193
208
|
def merge_hashes?(base_hash, derived_hash, key)
|
@@ -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
|
@@ -104,12 +112,9 @@ module RuboCop
|
|
104
112
|
# to do so than to pass the value around to various methods.
|
105
113
|
next if name == 'inherit_mode'
|
106
114
|
|
107
|
-
suggestions = NameSimilarity.find_similar_names(name, Cop::Registry.global.map(&:cop_name))
|
108
|
-
suggestion = "Did you mean `#{suggestions.join('`, `')}`?" if suggestions.any?
|
109
|
-
|
110
115
|
message = <<~MESSAGE.rstrip
|
111
|
-
unrecognized cop #{name} found in #{smart_loaded_path}
|
112
|
-
#{suggestion}
|
116
|
+
unrecognized cop or department #{name} found in #{smart_loaded_path}
|
117
|
+
#{suggestion(name)}
|
113
118
|
MESSAGE
|
114
119
|
|
115
120
|
unknown_cops << message
|
@@ -117,6 +122,22 @@ module RuboCop
|
|
117
122
|
raise ValidationError, unknown_cops.join("\n") if unknown_cops.any?
|
118
123
|
end
|
119
124
|
|
125
|
+
def suggestion(name)
|
126
|
+
registry = Cop::Registry.global
|
127
|
+
departments = registry.departments.map(&:to_s)
|
128
|
+
suggestions = NameSimilarity.find_similar_names(name, departments + registry.map(&:cop_name))
|
129
|
+
if suggestions.any?
|
130
|
+
"Did you mean `#{suggestions.join('`, `')}`?"
|
131
|
+
else
|
132
|
+
# Department names can contain slashes, e.g. Chef/Correctness, but there's no support for
|
133
|
+
# the concept of higher level departments in RuboCop. It's a flat structure. So if the user
|
134
|
+
# tries to configure a "top level department", we hint that it's the bottom level
|
135
|
+
# departments that should be configured.
|
136
|
+
suggestions = departments.select { |department| department.start_with?("#{name}/") }
|
137
|
+
"#{name} is not a department. Use `#{suggestions.join('`, `')}`." if suggestions.any?
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
120
141
|
def validate_syntax_cop
|
121
142
|
syntax_config = @config['Lint/Syntax']
|
122
143
|
default_config = ConfigLoader.default_configuration['Lint/Syntax']
|
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)
|