rubocop 1.50.2 → 1.57.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -3
- data/config/default.yml +110 -14
- data/config/obsoletion.yml +5 -0
- data/lib/rubocop/cli/command/auto_generate_config.rb +10 -5
- data/lib/rubocop/cli/command/lsp.rb +19 -0
- data/lib/rubocop/cli.rb +4 -1
- data/lib/rubocop/config.rb +4 -0
- data/lib/rubocop/config_finder.rb +2 -2
- data/lib/rubocop/config_loader_resolver.rb +4 -3
- data/lib/rubocop/config_obsoletion/parameter_rule.rb +9 -1
- data/lib/rubocop/config_obsoletion.rb +2 -2
- data/lib/rubocop/cop/autocorrect_logic.rb +3 -1
- data/lib/rubocop/cop/base.rb +6 -2
- data/lib/rubocop/cop/bundler/duplicated_gem.rb +1 -0
- data/lib/rubocop/cop/bundler/duplicated_group.rb +127 -0
- data/lib/rubocop/cop/bundler/gem_comment.rb +1 -1
- data/lib/rubocop/cop/bundler/gem_version.rb +2 -2
- data/lib/rubocop/cop/bundler/ordered_gems.rb +9 -1
- data/lib/rubocop/cop/correctors/alignment_corrector.rb +1 -1
- data/lib/rubocop/cop/correctors/lambda_literal_to_method_corrector.rb +7 -4
- data/lib/rubocop/cop/gemspec/dependency_version.rb +2 -2
- data/lib/rubocop/cop/gemspec/development_dependencies.rb +1 -1
- data/lib/rubocop/cop/gemspec/ordered_dependencies.rb +9 -1
- data/lib/rubocop/cop/generator/require_file_injector.rb +1 -1
- data/lib/rubocop/cop/internal_affairs/cop_description.rb +32 -8
- data/lib/rubocop/cop/internal_affairs/example_description.rb +42 -21
- data/lib/rubocop/cop/internal_affairs/location_line_equality_comparison.rb +3 -1
- data/lib/rubocop/cop/internal_affairs/node_matcher_directive.rb +5 -5
- data/lib/rubocop/cop/internal_affairs/redundant_method_dispatch_node.rb +11 -2
- data/lib/rubocop/cop/internal_affairs/useless_message_assertion.rb +2 -0
- data/lib/rubocop/cop/layout/class_structure.rb +7 -0
- data/lib/rubocop/cop/layout/closing_heredoc_indentation.rb +1 -2
- data/lib/rubocop/cop/layout/dot_position.rb +1 -5
- data/lib/rubocop/cop/layout/empty_line_after_guard_clause.rb +42 -9
- data/lib/rubocop/cop/layout/empty_line_between_defs.rb +27 -4
- data/lib/rubocop/cop/layout/empty_lines_around_exception_handling_keywords.rb +2 -0
- data/lib/rubocop/cop/layout/end_alignment.rb +7 -1
- data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +2 -2
- data/lib/rubocop/cop/layout/heredoc_indentation.rb +3 -0
- data/lib/rubocop/cop/layout/indentation_style.rb +1 -1
- data/lib/rubocop/cop/layout/indentation_width.rb +3 -3
- data/lib/rubocop/cop/layout/leading_comment_space.rb +1 -1
- data/lib/rubocop/cop/layout/line_continuation_leading_space.rb +17 -9
- data/lib/rubocop/cop/layout/line_continuation_spacing.rb +1 -1
- data/lib/rubocop/cop/layout/line_end_string_concatenation_indentation.rb +2 -0
- data/lib/rubocop/cop/layout/multiline_method_call_indentation.rb +18 -3
- data/lib/rubocop/cop/layout/redundant_line_break.rb +14 -4
- data/lib/rubocop/cop/layout/space_after_comma.rb +9 -1
- data/lib/rubocop/cop/layout/space_after_not.rb +1 -1
- data/lib/rubocop/cop/layout/space_around_method_call_operator.rb +2 -2
- data/lib/rubocop/cop/layout/space_around_operators.rb +3 -1
- data/lib/rubocop/cop/layout/space_inside_block_braces.rb +2 -0
- data/lib/rubocop/cop/layout/space_inside_parens.rb +1 -1
- data/lib/rubocop/cop/layout/space_inside_range_literal.rb +1 -1
- data/lib/rubocop/cop/layout/trailing_empty_lines.rb +5 -0
- data/lib/rubocop/cop/lint/ambiguous_block_association.rb +13 -1
- data/lib/rubocop/cop/lint/debugger.rb +18 -5
- data/lib/rubocop/cop/lint/duplicate_hash_key.rb +2 -1
- data/lib/rubocop/cop/lint/duplicate_regexp_character_class_element.rb +46 -19
- data/lib/rubocop/cop/lint/empty_block.rb +1 -1
- data/lib/rubocop/cop/lint/erb_new_arguments.rb +3 -4
- data/lib/rubocop/cop/lint/heredoc_method_call_position.rb +1 -1
- data/lib/rubocop/cop/lint/identity_comparison.rb +0 -1
- data/lib/rubocop/cop/lint/incompatible_io_select_with_fiber_scheduler.rb +5 -3
- data/lib/rubocop/cop/lint/inherit_exception.rb +9 -0
- data/lib/rubocop/cop/lint/lambda_without_literal_block.rb +1 -1
- data/lib/rubocop/cop/lint/literal_in_interpolation.rb +1 -1
- data/lib/rubocop/cop/lint/missing_super.rb +34 -5
- data/lib/rubocop/cop/lint/mixed_case_range.rb +111 -0
- data/lib/rubocop/cop/lint/non_atomic_file_operation.rb +10 -7
- data/lib/rubocop/cop/lint/number_conversion.rb +5 -0
- data/lib/rubocop/cop/lint/numbered_parameter_assignment.rb +2 -2
- data/lib/rubocop/cop/lint/ordered_magic_comments.rb +0 -1
- data/lib/rubocop/cop/lint/out_of_range_regexp_ref.rb +2 -2
- data/lib/rubocop/cop/lint/redundant_regexp_quantifiers.rb +130 -0
- data/lib/rubocop/cop/lint/redundant_require_statement.rb +12 -3
- data/lib/rubocop/cop/lint/redundant_safe_navigation.rb +20 -4
- data/lib/rubocop/cop/lint/redundant_string_coercion.rb +1 -1
- data/lib/rubocop/cop/lint/safe_navigation_chain.rb +11 -4
- data/lib/rubocop/cop/lint/send_with_mixin_argument.rb +1 -2
- data/lib/rubocop/cop/lint/shadowed_exception.rb +5 -11
- data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +7 -1
- data/lib/rubocop/cop/lint/struct_new_override.rb +12 -12
- data/lib/rubocop/cop/lint/suppressed_exception.rb +2 -2
- data/lib/rubocop/cop/lint/symbol_conversion.rb +1 -1
- data/lib/rubocop/cop/lint/to_enum_arguments.rb +5 -3
- data/lib/rubocop/cop/lint/top_level_return_with_argument.rb +23 -9
- data/lib/rubocop/cop/lint/useless_assignment.rb +94 -10
- data/lib/rubocop/cop/lint/void.rb +78 -10
- data/lib/rubocop/cop/metrics/block_length.rb +1 -1
- data/lib/rubocop/cop/metrics/class_length.rb +8 -3
- data/lib/rubocop/cop/metrics/method_length.rb +1 -1
- data/lib/rubocop/cop/metrics/utils/abc_size_calculator.rb +1 -2
- data/lib/rubocop/cop/metrics/utils/code_length_calculator.rb +32 -4
- data/lib/rubocop/cop/migration/department_name.rb +2 -2
- data/lib/rubocop/cop/mixin/allowed_receivers.rb +34 -0
- data/lib/rubocop/cop/mixin/comments_help.rb +19 -11
- data/lib/rubocop/cop/mixin/def_node.rb +1 -1
- data/lib/rubocop/cop/mixin/end_keyword_alignment.rb +1 -1
- data/lib/rubocop/cop/mixin/hash_shorthand_syntax.rb +14 -11
- data/lib/rubocop/cop/mixin/heredoc.rb +6 -2
- data/lib/rubocop/cop/mixin/multiline_expression_indentation.rb +3 -2
- data/lib/rubocop/cop/mixin/percent_literal.rb +1 -1
- data/lib/rubocop/cop/mixin/preceding_following_alignment.rb +5 -7
- data/lib/rubocop/cop/mixin/space_after_punctuation.rb +1 -1
- data/lib/rubocop/cop/mixin/string_help.rb +4 -2
- data/lib/rubocop/cop/mixin/trailing_comma.rb +1 -1
- data/lib/rubocop/cop/naming/block_forwarding.rb +1 -1
- data/lib/rubocop/cop/naming/constant_name.rb +1 -1
- data/lib/rubocop/cop/naming/file_name.rb +1 -1
- data/lib/rubocop/cop/naming/heredoc_delimiter_naming.rb +3 -1
- data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +25 -10
- data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +11 -3
- data/lib/rubocop/cop/naming/variable_name.rb +6 -1
- data/lib/rubocop/cop/style/accessor_grouping.rb +5 -1
- data/lib/rubocop/cop/style/alias.rb +9 -8
- data/lib/rubocop/cop/style/arguments_forwarding.rb +280 -63
- data/lib/rubocop/cop/style/array_intersect.rb +13 -5
- data/lib/rubocop/cop/style/attr.rb +11 -1
- data/lib/rubocop/cop/style/begin_block.rb +1 -2
- data/lib/rubocop/cop/style/block_comments.rb +1 -1
- data/lib/rubocop/cop/style/block_delimiters.rb +5 -4
- data/lib/rubocop/cop/style/class_and_module_children.rb +1 -1
- data/lib/rubocop/cop/style/class_equality_comparison.rb +24 -39
- data/lib/rubocop/cop/style/collection_compact.rb +16 -6
- data/lib/rubocop/cop/style/collection_methods.rb +2 -0
- data/lib/rubocop/cop/style/colon_method_call.rb +2 -2
- data/lib/rubocop/cop/style/combinable_loops.rb +30 -8
- data/lib/rubocop/cop/style/concat_array_literals.rb +1 -1
- data/lib/rubocop/cop/style/conditional_assignment.rb +5 -3
- data/lib/rubocop/cop/style/copyright.rb +5 -2
- data/lib/rubocop/cop/style/dir.rb +1 -1
- data/lib/rubocop/cop/style/dir_empty.rb +8 -14
- data/lib/rubocop/cop/style/document_dynamic_eval_definition.rb +1 -1
- data/lib/rubocop/cop/style/documentation.rb +1 -1
- data/lib/rubocop/cop/style/empty_case_condition.rb +6 -1
- data/lib/rubocop/cop/style/eval_with_location.rb +5 -5
- data/lib/rubocop/cop/style/exact_regexp_match.rb +68 -0
- data/lib/rubocop/cop/style/file_read.rb +2 -2
- data/lib/rubocop/cop/style/for.rb +1 -1
- data/lib/rubocop/cop/style/format_string.rb +24 -3
- data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +3 -1
- data/lib/rubocop/cop/style/guard_clause.rb +28 -0
- data/lib/rubocop/cop/style/hash_conversion.rb +10 -0
- data/lib/rubocop/cop/style/hash_each_methods.rb +1 -22
- data/lib/rubocop/cop/style/hash_except.rb +19 -8
- data/lib/rubocop/cop/style/hash_transform_keys.rb +2 -2
- data/lib/rubocop/cop/style/hash_transform_values.rb +2 -2
- data/lib/rubocop/cop/style/identical_conditional_branches.rb +31 -5
- data/lib/rubocop/cop/style/if_inside_else.rb +6 -0
- data/lib/rubocop/cop/style/if_unless_modifier.rb +3 -0
- data/lib/rubocop/cop/style/if_with_semicolon.rb +2 -2
- data/lib/rubocop/cop/style/invertible_unless_condition.rb +10 -6
- data/lib/rubocop/cop/style/lambda.rb +3 -3
- data/lib/rubocop/cop/style/lambda_call.rb +5 -0
- data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +11 -5
- data/lib/rubocop/cop/style/mixin_grouping.rb +1 -1
- data/lib/rubocop/cop/style/multiline_block_chain.rb +1 -1
- data/lib/rubocop/cop/style/multiline_ternary_operator.rb +1 -1
- data/lib/rubocop/cop/style/multiple_comparison.rb +14 -0
- data/lib/rubocop/cop/style/nested_ternary_operator.rb +3 -11
- data/lib/rubocop/cop/style/numeric_literals.rb +1 -1
- data/lib/rubocop/cop/style/open_struct_use.rb +1 -1
- data/lib/rubocop/cop/style/operator_method_call.rb +6 -0
- data/lib/rubocop/cop/style/percent_literal_delimiters.rb +1 -1
- data/lib/rubocop/cop/style/preferred_hash_methods.rb +1 -1
- data/lib/rubocop/cop/style/redundant_argument.rb +6 -1
- data/lib/rubocop/cop/style/redundant_array_constructor.rb +77 -0
- data/lib/rubocop/cop/style/redundant_begin.rb +10 -2
- data/lib/rubocop/cop/style/redundant_conditional.rb +2 -10
- data/lib/rubocop/cop/style/redundant_current_directory_in_path.rb +38 -0
- data/lib/rubocop/cop/style/redundant_double_splat_hash_braces.rb +93 -5
- data/lib/rubocop/cop/style/redundant_exception.rb +32 -12
- data/lib/rubocop/cop/style/redundant_filter_chain.rb +118 -0
- data/lib/rubocop/cop/style/redundant_line_continuation.rb +7 -3
- data/lib/rubocop/cop/style/redundant_parentheses.rb +42 -16
- data/lib/rubocop/cop/style/redundant_regexp_argument.rb +100 -0
- data/lib/rubocop/cop/style/redundant_regexp_constructor.rb +46 -0
- data/lib/rubocop/cop/style/redundant_regexp_escape.rb +2 -1
- data/lib/rubocop/cop/style/redundant_return.rb +7 -2
- data/lib/rubocop/cop/style/redundant_self_assignment_branch.rb +8 -1
- data/lib/rubocop/cop/style/redundant_sort.rb +1 -1
- data/lib/rubocop/cop/style/redundant_string_escape.rb +2 -0
- data/lib/rubocop/cop/style/regexp_literal.rb +11 -2
- data/lib/rubocop/cop/style/require_order.rb +11 -5
- data/lib/rubocop/cop/style/rescue_modifier.rb +1 -3
- data/lib/rubocop/cop/style/return_nil.rb +6 -2
- data/lib/rubocop/cop/style/return_nil_in_predicate_method_definition.rb +95 -0
- data/lib/rubocop/cop/style/select_by_regexp.rb +15 -5
- data/lib/rubocop/cop/style/semicolon.rb +12 -4
- data/lib/rubocop/cop/style/signal_exception.rb +1 -1
- data/lib/rubocop/cop/style/single_argument_dig.rb +2 -1
- data/lib/rubocop/cop/style/single_line_do_end_block.rb +67 -0
- data/lib/rubocop/cop/style/single_line_methods.rb +1 -1
- data/lib/rubocop/cop/style/sole_nested_conditional.rb +6 -2
- data/lib/rubocop/cop/style/special_global_vars.rb +3 -4
- data/lib/rubocop/cop/style/string_literals_in_interpolation.rb +30 -5
- data/lib/rubocop/cop/style/symbol_array.rb +35 -15
- data/lib/rubocop/cop/style/yaml_file_read.rb +66 -0
- data/lib/rubocop/cop/style/yoda_condition.rb +4 -2
- data/lib/rubocop/cop/style/yoda_expression.rb +8 -7
- data/lib/rubocop/cop/team.rb +1 -1
- data/lib/rubocop/cop/util.rb +1 -1
- data/lib/rubocop/cop/utils/regexp_ranges.rb +113 -0
- data/lib/rubocop/cop/variable_force/assignment.rb +45 -4
- data/lib/rubocop/cop/variable_force/variable_table.rb +2 -2
- data/lib/rubocop/cop/variable_force.rb +1 -0
- data/lib/rubocop/cops_documentation_generator.rb +1 -1
- data/lib/rubocop/ext/regexp_parser.rb +4 -1
- data/lib/rubocop/file_finder.rb +4 -7
- data/lib/rubocop/formatter/html_formatter.rb +4 -2
- data/lib/rubocop/formatter/junit_formatter.rb +1 -1
- data/lib/rubocop/lsp/logger.rb +22 -0
- data/lib/rubocop/lsp/routes.rb +246 -0
- data/lib/rubocop/lsp/runtime.rb +99 -0
- data/lib/rubocop/lsp/server.rb +68 -0
- data/lib/rubocop/lsp/severity.rb +27 -0
- data/lib/rubocop/magic_comment.rb +12 -10
- data/lib/rubocop/options.rb +11 -1
- data/lib/rubocop/result_cache.rb +5 -1
- data/lib/rubocop/rspec/cop_helper.rb +1 -1
- data/lib/rubocop/rspec/shared_contexts.rb +2 -3
- data/lib/rubocop/runner.rb +5 -3
- data/lib/rubocop/server/cache.rb +1 -0
- data/lib/rubocop/server/client_command/exec.rb +3 -2
- data/lib/rubocop/string_interpreter.rb +3 -3
- data/lib/rubocop/target_finder.rb +7 -3
- data/lib/rubocop/target_ruby.rb +12 -7
- data/lib/rubocop/version.rb +10 -6
- data/lib/rubocop.rb +15 -0
- metadata +45 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: adf1db90b03283f492e0e10f234d54d6efc215a8b182965087313e3954d533dd
|
4
|
+
data.tar.gz: fa84dfd9d61e4834df9287e0ba0619622f4b7eb9e229e8de1172bc1742c04df5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44a683eed5e4b9d26caf4d0c775a6f4ba00960b6aaeee29c3f610320d1471326d650e8fc41ee2725af07b4e6a50bf17d442232134522709ebb2a46ec5b80bf40
|
7
|
+
data.tar.gz: d4f5dda0dbf7689c55b39de3922c2bd1a0c40aa62ac1046f06c98a19e7f2719cfea11babd480ba4e9b9ff2203d20422a51f096165d5919bf564e009c3a91c087
|
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.57', require: false
|
57
57
|
```
|
58
58
|
|
59
59
|
See [our versioning policy](https://docs.rubocop.org/rubocop/versioning.html) for further details.
|
@@ -67,6 +67,8 @@ $ cd my/cool/ruby/project
|
|
67
67
|
$ rubocop
|
68
68
|
```
|
69
69
|
|
70
|
+
You can also use this magic in your favorite editor with RuboCop's [built-in LSP](https://docs.rubocop.org/rubocop/usage/lsp.html).
|
71
|
+
|
70
72
|
## Documentation
|
71
73
|
|
72
74
|
You can read a lot more about RuboCop in its [official docs](https://docs.rubocop.org).
|
@@ -75,8 +77,8 @@ You can read a lot more about RuboCop in its [official docs](https://docs.ruboco
|
|
75
77
|
|
76
78
|
RuboCop officially supports the following runtime Ruby implementations:
|
77
79
|
|
78
|
-
* MRI 2.
|
79
|
-
* JRuby 9.
|
80
|
+
* MRI 2.7+
|
81
|
+
* JRuby 9.4+
|
80
82
|
|
81
83
|
Targets Ruby 2.0+ code analysis.
|
82
84
|
|
data/config/default.yml
CHANGED
@@ -30,6 +30,7 @@ AllCops:
|
|
30
30
|
- '**/*.rbx'
|
31
31
|
- '**/*.ru'
|
32
32
|
- '**/*.ruby'
|
33
|
+
- '**/*.schema'
|
33
34
|
- '**/*.spec'
|
34
35
|
- '**/*.thor'
|
35
36
|
- '**/*.watchr'
|
@@ -55,6 +56,7 @@ AllCops:
|
|
55
56
|
- '**/Puppetfile'
|
56
57
|
- '**/Rakefile'
|
57
58
|
- '**/rakefile'
|
59
|
+
- '**/Schemafile'
|
58
60
|
- '**/Snapfile'
|
59
61
|
- '**/Steepfile'
|
60
62
|
- '**/Thorfile'
|
@@ -140,7 +142,7 @@ AllCops:
|
|
140
142
|
# or gems.locked file. (Although the Ruby version is specified in the Gemfile
|
141
143
|
# or gems.rb file, RuboCop reads the final value from the lock file.) If the
|
142
144
|
# Ruby version is still unresolved, RuboCop will use the oldest officially
|
143
|
-
# supported Ruby version (currently Ruby 2.
|
145
|
+
# supported Ruby version (currently Ruby 2.7).
|
144
146
|
TargetRubyVersion: ~
|
145
147
|
# Determines if a notification for extension libraries should be shown when
|
146
148
|
# rubocop is run. Keys are the name of the extension, and values are an array
|
@@ -154,6 +156,7 @@ AllCops:
|
|
154
156
|
rubocop-rake: [rake]
|
155
157
|
rubocop-graphql: [graphql]
|
156
158
|
rubocop-capybara: [capybara]
|
159
|
+
rubocop-factory_bot: [factory_bot, factory_bot_rails]
|
157
160
|
# Enable/Disable checking the methods extended by Active Support.
|
158
161
|
ActiveSupportExtensionsEnabled: false
|
159
162
|
|
@@ -170,6 +173,16 @@ Bundler/DuplicatedGem:
|
|
170
173
|
- '**/Gemfile'
|
171
174
|
- '**/gems.rb'
|
172
175
|
|
176
|
+
Bundler/DuplicatedGroup:
|
177
|
+
Description: 'Checks for duplicate group entries in Gemfile.'
|
178
|
+
Enabled: true
|
179
|
+
Severity: warning
|
180
|
+
VersionAdded: '1.56'
|
181
|
+
Include:
|
182
|
+
- '**/*.gemfile'
|
183
|
+
- '**/Gemfile'
|
184
|
+
- '**/gems.rb'
|
185
|
+
|
173
186
|
Bundler/GemComment:
|
174
187
|
Description: 'Add a comment describing each gem.'
|
175
188
|
Enabled: false
|
@@ -466,7 +479,9 @@ Layout/ClassStructure:
|
|
466
479
|
Description: 'Enforces a configured order of definitions within a class body.'
|
467
480
|
StyleGuide: '#consistent-classes'
|
468
481
|
Enabled: false
|
482
|
+
SafeAutoCorrect: false
|
469
483
|
VersionAdded: '0.52'
|
484
|
+
VersionChanged: '1.53'
|
470
485
|
Categories:
|
471
486
|
module_inclusion:
|
472
487
|
- include
|
@@ -574,6 +589,8 @@ Layout/EmptyLineBetweenDefs:
|
|
574
589
|
EmptyLineBetweenMethodDefs: true
|
575
590
|
EmptyLineBetweenClassDefs: true
|
576
591
|
EmptyLineBetweenModuleDefs: true
|
592
|
+
# `DefLikeMacros` takes the name of any macro that you want to treat like a def.
|
593
|
+
DefLikeMacros: []
|
577
594
|
# `AllowAdjacentOneLineDefs` means that single line method definitions don't
|
578
595
|
# need an empty line between them. `true` by default.
|
579
596
|
AllowAdjacentOneLineDefs: true
|
@@ -1529,7 +1546,6 @@ Lint/AmbiguousBlockAssociation:
|
|
1529
1546
|
Description: >-
|
1530
1547
|
Checks for ambiguous block association with method when param passed without
|
1531
1548
|
parentheses.
|
1532
|
-
StyleGuide: '#syntax'
|
1533
1549
|
Enabled: true
|
1534
1550
|
VersionAdded: '0.48'
|
1535
1551
|
VersionChanged: '1.13'
|
@@ -1987,9 +2003,16 @@ Lint/MissingSuper:
|
|
1987
2003
|
Checks for the presence of constructors and lifecycle callbacks
|
1988
2004
|
without calls to `super`.
|
1989
2005
|
Enabled: true
|
2006
|
+
AllowedParentClasses: []
|
1990
2007
|
VersionAdded: '0.89'
|
1991
2008
|
VersionChanged: '1.4'
|
1992
2009
|
|
2010
|
+
Lint/MixedCaseRange:
|
2011
|
+
Description: 'Checks for mixed-case character ranges since they include likely unintended characters.'
|
2012
|
+
Enabled: pending
|
2013
|
+
SafeAutoCorrect: false
|
2014
|
+
VersionAdded: '1.53'
|
2015
|
+
|
1993
2016
|
Lint/MixedRegexpCaptureTypes:
|
1994
2017
|
Description: 'Do not mix named captures and numbered captures in a Regexp literal.'
|
1995
2018
|
Enabled: true
|
@@ -2139,10 +2162,17 @@ Lint/RedundantDirGlobSort:
|
|
2139
2162
|
VersionChanged: '1.26'
|
2140
2163
|
SafeAutoCorrect: false
|
2141
2164
|
|
2165
|
+
Lint/RedundantRegexpQuantifiers:
|
2166
|
+
Description: 'Checks for redundant quantifiers in Regexps.'
|
2167
|
+
Enabled: pending
|
2168
|
+
VersionAdded: '1.53'
|
2169
|
+
|
2142
2170
|
Lint/RedundantRequireStatement:
|
2143
2171
|
Description: 'Checks for unnecessary `require` statement.'
|
2144
2172
|
Enabled: true
|
2173
|
+
SafeAutoCorrect: false
|
2145
2174
|
VersionAdded: '0.76'
|
2175
|
+
VersionChanged: '1.57'
|
2146
2176
|
|
2147
2177
|
Lint/RedundantSafeNavigation:
|
2148
2178
|
Description: 'Checks for redundant safe navigation calls.'
|
@@ -2343,6 +2373,9 @@ Lint/TopLevelReturnWithArgument:
|
|
2343
2373
|
Description: 'Detects top level return statements with argument.'
|
2344
2374
|
Enabled: true
|
2345
2375
|
VersionAdded: '0.89'
|
2376
|
+
# These codes are `eval`-ed in method and their return values may be used.
|
2377
|
+
Exclude:
|
2378
|
+
- '**/*.jb'
|
2346
2379
|
|
2347
2380
|
Lint/TrailingCommaInAttributeDeclaration:
|
2348
2381
|
Description: 'Checks for trailing commas in attribute declarations.'
|
@@ -2451,6 +2484,8 @@ Lint/UselessAssignment:
|
|
2451
2484
|
StyleGuide: '#underscore-unused-vars'
|
2452
2485
|
Enabled: true
|
2453
2486
|
VersionAdded: '0.11'
|
2487
|
+
VersionChanged: '1.51'
|
2488
|
+
SafeAutoCorrect: false
|
2454
2489
|
|
2455
2490
|
Lint/UselessElseWithoutRescue:
|
2456
2491
|
Description: 'Checks for useless `else` in `begin..end` without `rescue`.'
|
@@ -2478,10 +2513,9 @@ Lint/UselessRuby2Keywords:
|
|
2478
2513
|
Lint/UselessSetterCall:
|
2479
2514
|
Description: 'Checks for useless setter call to a local variable.'
|
2480
2515
|
Enabled: true
|
2481
|
-
|
2516
|
+
Safe: false
|
2482
2517
|
VersionAdded: '0.13'
|
2483
2518
|
VersionChanged: '1.2'
|
2484
|
-
Safe: false
|
2485
2519
|
|
2486
2520
|
Lint/UselessTimes:
|
2487
2521
|
Description: 'Checks for useless `Integer#times` calls.'
|
@@ -2942,7 +2976,9 @@ Naming/VariableNumber:
|
|
2942
2976
|
Security/CompoundHash:
|
2943
2977
|
Description: 'When overwriting Object#hash to combine values, prefer delegating to Array#hash over writing a custom implementation.'
|
2944
2978
|
Enabled: pending
|
2979
|
+
Safe: false
|
2945
2980
|
VersionAdded: '1.28'
|
2981
|
+
VersionChanged: '1.51'
|
2946
2982
|
|
2947
2983
|
Security/Eval:
|
2948
2984
|
Description: 'The use of eval represents a serious security risk.'
|
@@ -3048,6 +3084,7 @@ Style/ArgumentsForwarding:
|
|
3048
3084
|
StyleGuide: '#arguments-forwarding'
|
3049
3085
|
Enabled: pending
|
3050
3086
|
AllowOnlyRestArgument: true
|
3087
|
+
UseAnonymousForwarding: true
|
3051
3088
|
VersionAdded: '1.1'
|
3052
3089
|
|
3053
3090
|
Style/ArrayCoercion:
|
@@ -3319,7 +3356,9 @@ Style/ClassEqualityComparison:
|
|
3319
3356
|
Description: 'Enforces the use of `Object#instance_of?` instead of class comparison for equality.'
|
3320
3357
|
StyleGuide: '#instance-of-vs-class-comparison'
|
3321
3358
|
Enabled: true
|
3359
|
+
SafeAutoCorrect: false
|
3322
3360
|
VersionAdded: '0.93'
|
3361
|
+
VersionChanged: '1.57'
|
3323
3362
|
AllowedMethods:
|
3324
3363
|
- ==
|
3325
3364
|
- equal?
|
@@ -3355,6 +3394,7 @@ Style/CollectionCompact:
|
|
3355
3394
|
Safe: false
|
3356
3395
|
VersionAdded: '1.2'
|
3357
3396
|
VersionChanged: '1.3'
|
3397
|
+
AllowedReceivers: []
|
3358
3398
|
|
3359
3399
|
# Align with the style guide.
|
3360
3400
|
Style/CollectionMethods:
|
@@ -3373,6 +3413,7 @@ Style/CollectionMethods:
|
|
3373
3413
|
PreferredMethods:
|
3374
3414
|
collect: 'map'
|
3375
3415
|
collect!: 'map!'
|
3416
|
+
collect_concat: 'flat_map'
|
3376
3417
|
inject: 'reduce'
|
3377
3418
|
detect: 'find'
|
3378
3419
|
find_all: 'select'
|
@@ -3515,7 +3556,9 @@ Style/DataInheritance:
|
|
3515
3556
|
Description: 'Checks for inheritance from Data.define.'
|
3516
3557
|
StyleGuide: '#no-extend-data-define'
|
3517
3558
|
Enabled: pending
|
3559
|
+
SafeAutoCorrect: false
|
3518
3560
|
VersionAdded: '1.49'
|
3561
|
+
VersionChanged: '1.51'
|
3519
3562
|
|
3520
3563
|
Style/DateTime:
|
3521
3564
|
Description: 'Use Time over DateTime.'
|
@@ -3706,6 +3749,11 @@ Style/EvenOdd:
|
|
3706
3749
|
VersionAdded: '0.12'
|
3707
3750
|
VersionChanged: '0.29'
|
3708
3751
|
|
3752
|
+
Style/ExactRegexpMatch:
|
3753
|
+
Description: 'Checks for exact regexp match inside Regexp literals.'
|
3754
|
+
Enabled: pending
|
3755
|
+
VersionAdded: '1.51'
|
3756
|
+
|
3709
3757
|
Style/ExpandPathArguments:
|
3710
3758
|
Description: "Use `expand_path(__dir__)` instead of `expand_path('..', __FILE__)`."
|
3711
3759
|
Enabled: true
|
@@ -3884,8 +3932,9 @@ Style/HashConversion:
|
|
3884
3932
|
Description: 'Avoid Hash[] in favor of ary.to_h or literal hashes.'
|
3885
3933
|
StyleGuide: '#avoid-hash-constructor'
|
3886
3934
|
Enabled: pending
|
3935
|
+
SafeAutoCorrect: false
|
3887
3936
|
VersionAdded: '1.10'
|
3888
|
-
VersionChanged: '1.
|
3937
|
+
VersionChanged: '1.55'
|
3889
3938
|
AllowSplatArgument: true
|
3890
3939
|
|
3891
3940
|
Style/HashEachMethods:
|
@@ -4086,14 +4135,6 @@ Style/InvertibleUnlessCondition:
|
|
4086
4135
|
:none?: :any?
|
4087
4136
|
:even?: :odd?
|
4088
4137
|
:odd?: :even?
|
4089
|
-
# `ActiveSupport` defines some common inverse methods. They are listed below,
|
4090
|
-
# and not enabled by default.
|
4091
|
-
# :present?: :blank?
|
4092
|
-
# :blank?: :present?
|
4093
|
-
# :include?: :exclude?
|
4094
|
-
# :exclude?: :include?
|
4095
|
-
# :one?: :many?
|
4096
|
-
# :many?: :one?
|
4097
4138
|
|
4098
4139
|
Style/IpAddresses:
|
4099
4140
|
Description: "Don't include literal IP addresses in code."
|
@@ -4370,6 +4411,7 @@ Style/MultipleComparison:
|
|
4370
4411
|
VersionAdded: '0.49'
|
4371
4412
|
VersionChanged: '1.1'
|
4372
4413
|
AllowMethodComparison: true
|
4414
|
+
ComparisonsThreshold: 2
|
4373
4415
|
|
4374
4416
|
Style/MutableConstant:
|
4375
4417
|
Description: 'Do not assign mutable objects to constants.'
|
@@ -4624,7 +4666,9 @@ Style/OpenStructUse:
|
|
4624
4666
|
- https://docs.ruby-lang.org/en/3.0.0/OpenStruct.html#class-OpenStruct-label-Caveats
|
4625
4667
|
|
4626
4668
|
Enabled: pending
|
4669
|
+
Safe: false
|
4627
4670
|
VersionAdded: '1.23'
|
4671
|
+
VersionChanged: '1.51'
|
4628
4672
|
|
4629
4673
|
Style/OperatorMethodCall:
|
4630
4674
|
Description: 'Checks for redundant dot before operator method call.'
|
@@ -4777,12 +4821,16 @@ Style/RedundantArgument:
|
|
4777
4821
|
Enabled: pending
|
4778
4822
|
Safe: false
|
4779
4823
|
VersionAdded: '1.4'
|
4780
|
-
VersionChanged: '1.
|
4824
|
+
VersionChanged: '1.55'
|
4781
4825
|
Methods:
|
4782
4826
|
# Array#join
|
4783
4827
|
join: ''
|
4784
4828
|
# Array#sum
|
4785
4829
|
sum: 0
|
4830
|
+
# Kernel.#exit
|
4831
|
+
exit: true
|
4832
|
+
# Kernel.#exit!
|
4833
|
+
exit!: false
|
4786
4834
|
# String#split
|
4787
4835
|
split: ' '
|
4788
4836
|
# String#chomp
|
@@ -4790,6 +4838,11 @@ Style/RedundantArgument:
|
|
4790
4838
|
# String#chomp!
|
4791
4839
|
chomp!: "\n"
|
4792
4840
|
|
4841
|
+
Style/RedundantArrayConstructor:
|
4842
|
+
Description: 'Checks for the instantiation of array using redundant `Array` constructor.'
|
4843
|
+
Enabled: pending
|
4844
|
+
VersionAdded: '1.52'
|
4845
|
+
|
4793
4846
|
Style/RedundantAssignment:
|
4794
4847
|
Description: 'Checks for redundant assignment before returning.'
|
4795
4848
|
Enabled: true
|
@@ -4822,6 +4875,11 @@ Style/RedundantConstantBase:
|
|
4822
4875
|
Enabled: pending
|
4823
4876
|
VersionAdded: '1.40'
|
4824
4877
|
|
4878
|
+
Style/RedundantCurrentDirectoryInPath:
|
4879
|
+
Description: 'Checks for uses a redundant current directory in path.'
|
4880
|
+
Enabled: pending
|
4881
|
+
VersionAdded: '1.53'
|
4882
|
+
|
4825
4883
|
Style/RedundantDoubleSplatHashBraces:
|
4826
4884
|
Description: 'Checks for redundant uses of double splat hash braces.'
|
4827
4885
|
Enabled: pending
|
@@ -4861,6 +4919,15 @@ Style/RedundantFileExtensionInRequire:
|
|
4861
4919
|
Enabled: true
|
4862
4920
|
VersionAdded: '0.88'
|
4863
4921
|
|
4922
|
+
Style/RedundantFilterChain:
|
4923
|
+
Description: >-
|
4924
|
+
Identifies usages of `any?`, `empty?`, `none?` or `one?` predicate methods chained to
|
4925
|
+
`select`/`filter`/`find_all` and change them to use predicate method instead.
|
4926
|
+
Enabled: pending
|
4927
|
+
SafeAutoCorrect: false
|
4928
|
+
VersionAdded: '1.52'
|
4929
|
+
VersionChanged: '1.57'
|
4930
|
+
|
4864
4931
|
Style/RedundantFreeze:
|
4865
4932
|
Description: "Checks usages of Object#freeze on immutable objects."
|
4866
4933
|
Enabled: true
|
@@ -4903,11 +4970,21 @@ Style/RedundantPercentQ:
|
|
4903
4970
|
Enabled: true
|
4904
4971
|
VersionAdded: '0.76'
|
4905
4972
|
|
4973
|
+
Style/RedundantRegexpArgument:
|
4974
|
+
Description: 'Identifies places where argument can be replaced from a deterministic regexp to a string.'
|
4975
|
+
Enabled: pending
|
4976
|
+
VersionAdded: '1.53'
|
4977
|
+
|
4906
4978
|
Style/RedundantRegexpCharacterClass:
|
4907
4979
|
Description: 'Checks for unnecessary single-element Regexp character classes.'
|
4908
4980
|
Enabled: true
|
4909
4981
|
VersionAdded: '0.85'
|
4910
4982
|
|
4983
|
+
Style/RedundantRegexpConstructor:
|
4984
|
+
Description: 'Checks for the instantiation of regexp using redundant `Regexp.new` or `Regexp.compile`.'
|
4985
|
+
Enabled: pending
|
4986
|
+
VersionAdded: '1.52'
|
4987
|
+
|
4911
4988
|
Style/RedundantRegexpEscape:
|
4912
4989
|
Description: 'Checks for redundant escapes in Regexps.'
|
4913
4990
|
Enabled: true
|
@@ -5010,6 +5087,15 @@ Style/ReturnNil:
|
|
5010
5087
|
- return_nil
|
5011
5088
|
VersionAdded: '0.50'
|
5012
5089
|
|
5090
|
+
Style/ReturnNilInPredicateMethodDefinition:
|
5091
|
+
Description: 'Checks if uses of `return` or `return nil` in predicate method definition.'
|
5092
|
+
StyleGuide: '#bool-methods-qmark'
|
5093
|
+
Enabled: pending
|
5094
|
+
SafeAutoCorrect: false
|
5095
|
+
AllowedMethods: []
|
5096
|
+
AllowedPatterns: []
|
5097
|
+
VersionAdded: '1.53'
|
5098
|
+
|
5013
5099
|
Style/SafeNavigation:
|
5014
5100
|
Description: >-
|
5015
5101
|
Transforms usages of a method call safeguarded by
|
@@ -5102,6 +5188,11 @@ Style/SingleLineBlockParams:
|
|
5102
5188
|
- acc
|
5103
5189
|
- elem
|
5104
5190
|
|
5191
|
+
Style/SingleLineDoEndBlock:
|
5192
|
+
Description: 'Checks for single-line `do`...`end` blocks.'
|
5193
|
+
Enabled: pending
|
5194
|
+
VersionAdded: '1.57'
|
5195
|
+
|
5105
5196
|
Style/SingleLineMethods:
|
5106
5197
|
Description: 'Avoid single-line methods.'
|
5107
5198
|
StyleGuide: '#no-single-line-methods'
|
@@ -5494,6 +5585,11 @@ Style/WordArray:
|
|
5494
5585
|
# The regular expression `WordRegex` decides what is considered a word.
|
5495
5586
|
WordRegex: !ruby/regexp '/\A(?:\p{Word}|\p{Word}-\p{Word}|\n|\t)+\z/'
|
5496
5587
|
|
5588
|
+
Style/YAMLFileRead:
|
5589
|
+
Description: 'Checks for the use of `YAML.load`, `YAML.safe_load`, and `YAML.parse` with `File.read` argument.'
|
5590
|
+
Enabled: pending
|
5591
|
+
VersionAdded: '1.53'
|
5592
|
+
|
5497
5593
|
Style/YodaCondition:
|
5498
5594
|
Description: 'Forbid or enforce yoda conditions.'
|
5499
5595
|
Reference: 'https://en.wikipedia.org/wiki/Yoda_conditions'
|
data/config/obsoletion.yml
CHANGED
@@ -224,6 +224,11 @@ changed_parameters:
|
|
224
224
|
- AllowedMethods
|
225
225
|
- AllowedPatterns
|
226
226
|
severity: warning
|
227
|
+
- cops: Style/ArgumentsForwarding
|
228
|
+
parameters: AllowOnlyRestArgument
|
229
|
+
reason: "`AllowOnlyRestArgument` has no effect with TargetRubyVersion >= 3.2."
|
230
|
+
severity: warning
|
231
|
+
minimum_ruby_version: 3.2
|
227
232
|
|
228
233
|
# Enforced styles that have been removed or replaced
|
229
234
|
changed_enforced_styles:
|
@@ -10,6 +10,7 @@ module RuboCop
|
|
10
10
|
|
11
11
|
AUTO_GENERATED_FILE = '.rubocop_todo.yml'
|
12
12
|
YAML_OPTIONAL_DOC_START = /\A---(\s+#|\s*\z)/.freeze
|
13
|
+
PLACEHOLDER = '###rubocop:inherit_here'
|
13
14
|
|
14
15
|
PHASE_1 = 'Phase 1 of 2: run Layout/LineLength cop'
|
15
16
|
PHASE_2 = 'Phase 2 of 2: run all cops'
|
@@ -125,15 +126,19 @@ module RuboCop
|
|
125
126
|
|
126
127
|
def existing_configuration(config_file)
|
127
128
|
File.read(config_file, encoding: Encoding::UTF_8)
|
128
|
-
.sub(/^inherit_from: *[^\n]+/,
|
129
|
-
.sub(/^inherit_from: *(\n *- *[^\n]+)+/,
|
129
|
+
.sub(/^inherit_from: *[^\n]+/, PLACEHOLDER)
|
130
|
+
.sub(/^inherit_from: *(\n *- *[^\n]+)+/, PLACEHOLDER)
|
130
131
|
end
|
131
132
|
|
132
133
|
def write_config_file(file_name, file_string, rubocop_yml_contents)
|
133
134
|
lines = /\S/.match?(rubocop_yml_contents) ? rubocop_yml_contents.split("\n", -1) : []
|
134
|
-
|
135
|
-
|
136
|
-
|
135
|
+
unless rubocop_yml_contents&.include?(PLACEHOLDER)
|
136
|
+
doc_start_index = lines.index { |line| YAML_OPTIONAL_DOC_START.match?(line) } || -1
|
137
|
+
lines.insert(doc_start_index + 1, PLACEHOLDER)
|
138
|
+
end
|
139
|
+
File.write(file_name, lines.join("\n")
|
140
|
+
.sub(/#{PLACEHOLDER}\n*/o, "inherit_from:#{file_string}\n\n")
|
141
|
+
.sub(/\n\n+\Z/, "\n"))
|
137
142
|
end
|
138
143
|
|
139
144
|
def relative_path_to_todo_from_options_config
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../lsp/server'
|
4
|
+
|
5
|
+
module RuboCop
|
6
|
+
class CLI
|
7
|
+
module Command
|
8
|
+
# Start Language Server Protocol of RuboCop.
|
9
|
+
# @api private
|
10
|
+
class Lsp < Base
|
11
|
+
self.command_name = :lsp
|
12
|
+
|
13
|
+
def run
|
14
|
+
RuboCop::Lsp::Server.new(@config_store).start
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/rubocop/cli.rb
CHANGED
@@ -11,7 +11,7 @@ module RuboCop
|
|
11
11
|
STATUS_ERROR = 2
|
12
12
|
STATUS_INTERRUPTED = Signal.list['INT'] + 128
|
13
13
|
DEFAULT_PARALLEL_OPTIONS = %i[
|
14
|
-
color debug display_style_guide display_time display_only_fail_level_offenses
|
14
|
+
color config debug display_style_guide display_time display_only_fail_level_offenses
|
15
15
|
display_only_failed except extra_details fail_level fix_layout format
|
16
16
|
ignore_disable_comments lint only only_guide_cops require safe
|
17
17
|
autocorrect safe_autocorrect autocorrect_all
|
@@ -174,14 +174,17 @@ module RuboCop
|
|
174
174
|
ConfigLoader.ignore_unrecognized_cops = @options[:ignore_unrecognized_cops]
|
175
175
|
end
|
176
176
|
|
177
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
177
178
|
def handle_exiting_options
|
178
179
|
return unless Options::EXITING_OPTIONS.any? { |o| @options.key? o }
|
179
180
|
|
180
181
|
run_command(:version) if @options[:version] || @options[:verbose_version]
|
181
182
|
run_command(:show_cops) if @options[:show_cops]
|
182
183
|
run_command(:show_docs_url) if @options[:show_docs_url]
|
184
|
+
run_command(:lsp) if @options[:lsp]
|
183
185
|
raise Finished
|
184
186
|
end
|
187
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
185
188
|
|
186
189
|
def apply_default_formatter
|
187
190
|
# This must be done after the options have already been processed,
|
data/lib/rubocop/config.rb
CHANGED
@@ -46,14 +46,14 @@ module RuboCop
|
|
46
46
|
|
47
47
|
file = File.join(Dir.home, DOTFILE)
|
48
48
|
|
49
|
-
|
49
|
+
file if File.exist?(file)
|
50
50
|
end
|
51
51
|
|
52
52
|
def find_user_xdg_config
|
53
53
|
xdg_config_home = expand_path(ENV.fetch('XDG_CONFIG_HOME', '~/.config'))
|
54
54
|
xdg_config = File.join(xdg_config_home, 'rubocop', XDG_CONFIG)
|
55
55
|
|
56
|
-
|
56
|
+
xdg_config if File.exist?(xdg_config)
|
57
57
|
end
|
58
58
|
|
59
59
|
def expand_path(path)
|
@@ -33,7 +33,7 @@ module RuboCop
|
|
33
33
|
inherit_mode: determine_inherit_mode(hash, k))
|
34
34
|
end
|
35
35
|
hash[k] = v
|
36
|
-
fix_include_paths(base_config.loaded_path, hash, k, v) if v.key?('Include')
|
36
|
+
fix_include_paths(base_config.loaded_path, hash, path, k, v) if v.key?('Include')
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
@@ -42,12 +42,13 @@ module RuboCop
|
|
42
42
|
# base configuration are relative to the directory where the base configuration file is. For the
|
43
43
|
# derived configuration, we need to make those paths relative to where the derived configuration
|
44
44
|
# file is.
|
45
|
-
def fix_include_paths(base_config_path, hash, key, value)
|
45
|
+
def fix_include_paths(base_config_path, hash, path, key, value)
|
46
46
|
return unless File.basename(base_config_path).start_with?('.rubocop')
|
47
47
|
|
48
48
|
base_dir = File.dirname(base_config_path)
|
49
|
+
derived_dir = File.dirname(path)
|
49
50
|
hash[key]['Include'] = value['Include'].map do |include_path|
|
50
|
-
PathUtil.relative_path(File.join(base_dir, include_path),
|
51
|
+
PathUtil.relative_path(File.join(base_dir, include_path), derived_dir)
|
51
52
|
end
|
52
53
|
end
|
53
54
|
|
@@ -19,7 +19,7 @@ module RuboCop
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def violated?
|
22
|
-
config[cop]&.key?(parameter)
|
22
|
+
applies_to_current_ruby_version? && config[cop]&.key?(parameter)
|
23
23
|
end
|
24
24
|
|
25
25
|
def warning?
|
@@ -28,6 +28,14 @@ module RuboCop
|
|
28
28
|
|
29
29
|
private
|
30
30
|
|
31
|
+
def applies_to_current_ruby_version?
|
32
|
+
minimum_ruby_version = metadata['minimum_ruby_version']
|
33
|
+
|
34
|
+
return true unless minimum_ruby_version
|
35
|
+
|
36
|
+
config.target_ruby_version >= minimum_ruby_version
|
37
|
+
end
|
38
|
+
|
31
39
|
def alternative
|
32
40
|
metadata['alternative']
|
33
41
|
end
|
@@ -68,11 +68,11 @@ module RuboCop
|
|
68
68
|
# Cop rules are keyed by the name of the original cop
|
69
69
|
def load_cop_rules(rules)
|
70
70
|
rules.flat_map do |rule_type, data|
|
71
|
-
data.
|
71
|
+
data.filter_map do |cop_name, configuration|
|
72
72
|
next unless configuration # allow configurations to be disabled with `CopName: ~`
|
73
73
|
|
74
74
|
COP_RULE_CLASSES[rule_type].new(@config, cop_name, configuration)
|
75
|
-
end
|
75
|
+
end
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
@@ -82,7 +82,9 @@ module RuboCop
|
|
82
82
|
node.array_type? && node.percent_literal?
|
83
83
|
end
|
84
84
|
|
85
|
-
percent_array.map(&:source_range).find
|
85
|
+
percent_array.map(&:source_range).find do |range|
|
86
|
+
offense_range.begin_pos > range.begin_pos && range.overlaps?(offense_range)
|
87
|
+
end
|
86
88
|
end
|
87
89
|
|
88
90
|
def range_of_first_line(range)
|
data/lib/rubocop/cop/base.rb
CHANGED
@@ -53,7 +53,7 @@ module RuboCop
|
|
53
53
|
# List of cops that should not try to autocorrect at the same
|
54
54
|
# time as this cop
|
55
55
|
#
|
56
|
-
# @return [Array<RuboCop::Cop::
|
56
|
+
# @return [Array<RuboCop::Cop::Base>]
|
57
57
|
#
|
58
58
|
# @api public
|
59
59
|
def self.autocorrect_incompatible_with
|
@@ -284,7 +284,7 @@ module RuboCop
|
|
284
284
|
# @api private
|
285
285
|
def self.callbacks_needed
|
286
286
|
@callbacks_needed ||= public_instance_methods.select do |m|
|
287
|
-
m.
|
287
|
+
m.start_with?(/on_|after_/) &&
|
288
288
|
!Base.method_defined?(m) # exclude standard "callbacks" like 'on_begin_investigation'
|
289
289
|
end
|
290
290
|
end
|
@@ -305,6 +305,10 @@ module RuboCop
|
|
305
305
|
@current_original = original
|
306
306
|
end
|
307
307
|
|
308
|
+
def inspect # :nodoc:
|
309
|
+
"#<#{self.class.name}:#{object_id} @config=#{@config} @options=#{@options}>"
|
310
|
+
end
|
311
|
+
|
308
312
|
private
|
309
313
|
|
310
314
|
### Reserved for Cop::Cop
|