rubocop 1.50.2 → 1.59.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +5 -3
- data/config/default.yml +153 -16
- 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 +13 -10
- 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 +3 -3
- 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/deprecated_attribute_assignment.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/method_name_equal.rb +19 -20
- data/lib/rubocop/cop/internal_affairs/node_first_or_last_argument.rb +53 -0
- data/lib/rubocop/cop/internal_affairs/node_matcher_directive.rb +7 -7
- 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/internal_affairs.rb +1 -0
- data/lib/rubocop/cop/layout/argument_alignment.rb +1 -1
- 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/extra_spacing.rb +4 -10
- data/lib/rubocop/cop/layout/first_array_element_indentation.rb +6 -6
- data/lib/rubocop/cop/layout/first_parameter_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +4 -4
- data/lib/rubocop/cop/layout/heredoc_indentation.rb +4 -1
- 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 +16 -5
- data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +4 -4
- data/lib/rubocop/cop/layout/single_line_block_chain.rb +5 -0
- 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 +53 -21
- 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/assignment_in_condition.rb +4 -4
- data/lib/rubocop/cop/lint/binary_operator_with_identical_operands.rb +2 -2
- data/lib/rubocop/cop/lint/constant_overwritten_in_rescue.rb +1 -1
- data/lib/rubocop/cop/lint/debugger.rb +19 -5
- data/lib/rubocop/cop/lint/duplicate_hash_key.rb +2 -1
- data/lib/rubocop/cop/lint/duplicate_methods.rb +1 -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 +6 -7
- data/lib/rubocop/cop/lint/float_comparison.rb +10 -0
- data/lib/rubocop/cop/lint/hash_compare_by_identity.rb +2 -1
- 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/it_without_arguments_in_block.rb +56 -0
- data/lib/rubocop/cop/lint/lambda_without_literal_block.rb +1 -1
- data/lib/rubocop/cop/lint/literal_assignment_in_condition.rb +78 -0
- 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/next_without_accumulator.rb +6 -21
- data/lib/rubocop/cop/lint/non_atomic_file_operation.rb +10 -7
- data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +3 -5
- data/lib/rubocop/cop/lint/number_conversion.rb +14 -4
- 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 +63 -4
- data/lib/rubocop/cop/lint/redundant_string_coercion.rb +1 -1
- data/lib/rubocop/cop/lint/redundant_with_index.rb +2 -2
- data/lib/rubocop/cop/lint/redundant_with_object.rb +2 -2
- data/lib/rubocop/cop/lint/safe_navigation_chain.rb +14 -8
- data/lib/rubocop/cop/lint/self_assignment.rb +38 -0
- 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 +8 -3
- 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/trailing_comma_in_attribute_declaration.rb +1 -1
- data/lib/rubocop/cop/lint/unmodified_reduce_accumulator.rb +2 -2
- data/lib/rubocop/cop/lint/useless_access_modifier.rb +2 -2
- data/lib/rubocop/cop/lint/useless_assignment.rb +94 -10
- data/lib/rubocop/cop/lint/useless_times.rb +1 -1
- data/lib/rubocop/cop/lint/void.rb +92 -11
- data/lib/rubocop/cop/metrics/abc_size.rb +3 -3
- 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/check_line_breakable.rb +1 -1
- 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 +6 -8
- 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/string_help.rb +4 -2
- data/lib/rubocop/cop/mixin/trailing_comma.rb +1 -1
- data/lib/rubocop/cop/naming/block_forwarding.rb +3 -3
- data/lib/rubocop/cop/naming/constant_name.rb +2 -3
- 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 +26 -11
- 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/access_modifier_declarations.rb +2 -2
- data/lib/rubocop/cop/style/accessor_grouping.rb +6 -2
- data/lib/rubocop/cop/style/alias.rb +9 -8
- data/lib/rubocop/cop/style/arguments_forwarding.rb +342 -63
- data/lib/rubocop/cop/style/array_first_last.rb +64 -0
- data/lib/rubocop/cop/style/array_intersect.rb +13 -5
- data/lib/rubocop/cop/style/attr.rb +11 -1
- data/lib/rubocop/cop/style/auto_resource_cleanup.rb +21 -14
- data/lib/rubocop/cop/style/begin_block.rb +1 -2
- data/lib/rubocop/cop/style/bisected_attr_accessor.rb +2 -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/case_like_if.rb +4 -4
- data/lib/rubocop/cop/style/class_and_module_children.rb +1 -1
- data/lib/rubocop/cop/style/class_check.rb +1 -0
- data/lib/rubocop/cop/style/class_equality_comparison.rb +24 -39
- data/lib/rubocop/cop/style/collection_compact.rb +22 -11
- 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 +36 -8
- data/lib/rubocop/cop/style/concat_array_literals.rb +2 -1
- data/lib/rubocop/cop/style/conditional_assignment.rb +6 -4
- data/lib/rubocop/cop/style/copyright.rb +5 -2
- data/lib/rubocop/cop/style/date_time.rb +5 -4
- 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/each_with_object.rb +2 -2
- data/lib/rubocop/cop/style/empty_case_condition.rb +6 -1
- data/lib/rubocop/cop/style/empty_literal.rb +1 -1
- data/lib/rubocop/cop/style/eval_with_location.rb +8 -8
- data/lib/rubocop/cop/style/exact_regexp_match.rb +69 -0
- data/lib/rubocop/cop/style/explicit_block_argument.rb +2 -2
- 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 +84 -32
- data/lib/rubocop/cop/style/hash_except.rb +21 -9
- 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/inverse_methods.rb +6 -5
- 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/map_compact_with_conditional_block.rb +3 -2
- data/lib/rubocop/cop/style/map_to_hash.rb +10 -4
- data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +12 -5
- data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +1 -1
- data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +20 -0
- data/lib/rubocop/cop/style/method_def_parentheses.rb +1 -1
- data/lib/rubocop/cop/style/missing_respond_to_missing.rb +2 -2
- 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/next.rb +1 -1
- 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 +8 -2
- 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 +9 -3
- 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_fetch_block.rb +3 -3
- data/lib/rubocop/cop/style/redundant_filter_chain.rb +118 -0
- data/lib/rubocop/cop/style/redundant_line_continuation.rb +9 -3
- data/lib/rubocop/cop/style/redundant_parentheses.rb +54 -21
- 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 +8 -3
- data/lib/rubocop/cop/style/redundant_self.rb +17 -2
- data/lib/rubocop/cop/style/redundant_self_assignment_branch.rb +8 -1
- data/lib/rubocop/cop/style/redundant_sort.rb +10 -9
- data/lib/rubocop/cop/style/redundant_sort_by.rb +2 -2
- data/lib/rubocop/cop/style/redundant_string_escape.rb +3 -1
- 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/sample.rb +2 -1
- data/lib/rubocop/cop/style/select_by_regexp.rb +22 -11
- data/lib/rubocop/cop/style/self_assignment.rb +1 -1
- data/lib/rubocop/cop/style/semicolon.rb +20 -4
- data/lib/rubocop/cop/style/signal_exception.rb +1 -1
- data/lib/rubocop/cop/style/single_argument_dig.rb +7 -3
- 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/slicing_with_range.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_chars.rb +1 -0
- data/lib/rubocop/cop/style/string_literals_in_interpolation.rb +30 -5
- data/lib/rubocop/cop/style/strip.rb +7 -4
- data/lib/rubocop/cop/style/super_with_args_parentheses.rb +35 -0
- data/lib/rubocop/cop/style/symbol_array.rb +35 -15
- data/lib/rubocop/cop/style/unpack_first.rb +11 -14
- 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 +5 -4
- 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 -2
- data/lib/rubocop/rspec/cop_helper.rb +1 -1
- data/lib/rubocop/rspec/shared_contexts.rb +2 -3
- data/lib/rubocop/runner.rb +6 -4
- 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 +19 -0
- metadata +54 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 236fd46f4a118eb34ff38fce1a147a116b2d30a7bf849ca809ece40aecabc694
|
4
|
+
data.tar.gz: 550ecc4682d191a6a429a6af299212a42aa459e0aee04d5f7cb6a20ded419ff4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c7cfaa0f6573e566bbbac89a993889cd0f0944ab5c012e0286da61021e2d3da6ed51f68fbbf6c71afd4b6d81c577d15228b7a6a2d93aed59d2dfcba61a9be63
|
7
|
+
data.tar.gz: 5cbb4256ff218ab5744fc3065f56061e5b0eab787d21dc30f3ded5972b789ffc2c24cd977fbaf3acbcc84abf36c5e3537a2eeb328dabb3becf29268eccaa81f8
|
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.59', 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 server](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
|
@@ -1334,6 +1351,10 @@ Layout/SpaceAroundOperators:
|
|
1334
1351
|
SupportedStylesForExponentOperator:
|
1335
1352
|
- space
|
1336
1353
|
- no_space
|
1354
|
+
EnforcedStyleForRationalLiterals: no_space
|
1355
|
+
SupportedStylesForRationalLiterals:
|
1356
|
+
- space
|
1357
|
+
- no_space
|
1337
1358
|
|
1338
1359
|
Layout/SpaceBeforeBlockBraces:
|
1339
1360
|
Description: >-
|
@@ -1529,7 +1550,6 @@ Lint/AmbiguousBlockAssociation:
|
|
1529
1550
|
Description: >-
|
1530
1551
|
Checks for ambiguous block association with method when param passed without
|
1531
1552
|
parentheses.
|
1532
|
-
StyleGuide: '#syntax'
|
1533
1553
|
Enabled: true
|
1534
1554
|
VersionAdded: '0.48'
|
1535
1555
|
VersionChanged: '1.13'
|
@@ -1943,6 +1963,12 @@ Lint/InterpolationCheck:
|
|
1943
1963
|
VersionAdded: '0.50'
|
1944
1964
|
VersionChanged: '1.40'
|
1945
1965
|
|
1966
|
+
Lint/ItWithoutArgumentsInBlock:
|
1967
|
+
Description: 'Checks uses of `it` calls without arguments in block.'
|
1968
|
+
Reference: 'https://bugs.ruby-lang.org/issues/18980'
|
1969
|
+
Enabled: pending
|
1970
|
+
VersionAdded: '1.59'
|
1971
|
+
|
1946
1972
|
Lint/LambdaWithoutLiteralBlock:
|
1947
1973
|
Description: 'Checks uses of lambda without a literal block.'
|
1948
1974
|
Enabled: pending
|
@@ -1953,6 +1979,11 @@ Lint/LiteralAsCondition:
|
|
1953
1979
|
Enabled: true
|
1954
1980
|
VersionAdded: '0.51'
|
1955
1981
|
|
1982
|
+
Lint/LiteralAssignmentInCondition:
|
1983
|
+
Description: 'Checks for literal assignments in the conditions.'
|
1984
|
+
Enabled: pending
|
1985
|
+
VersionAdded: '1.58'
|
1986
|
+
|
1956
1987
|
Lint/LiteralInInterpolation:
|
1957
1988
|
Description: 'Checks for literals used in interpolation.'
|
1958
1989
|
Enabled: true
|
@@ -1987,9 +2018,16 @@ Lint/MissingSuper:
|
|
1987
2018
|
Checks for the presence of constructors and lifecycle callbacks
|
1988
2019
|
without calls to `super`.
|
1989
2020
|
Enabled: true
|
2021
|
+
AllowedParentClasses: []
|
1990
2022
|
VersionAdded: '0.89'
|
1991
2023
|
VersionChanged: '1.4'
|
1992
2024
|
|
2025
|
+
Lint/MixedCaseRange:
|
2026
|
+
Description: 'Checks for mixed-case character ranges since they include likely unintended characters.'
|
2027
|
+
Enabled: pending
|
2028
|
+
SafeAutoCorrect: false
|
2029
|
+
VersionAdded: '1.53'
|
2030
|
+
|
1993
2031
|
Lint/MixedRegexpCaptureTypes:
|
1994
2032
|
Description: 'Do not mix named captures and numbered captures in a Regexp literal.'
|
1995
2033
|
Enabled: true
|
@@ -2139,10 +2177,17 @@ Lint/RedundantDirGlobSort:
|
|
2139
2177
|
VersionChanged: '1.26'
|
2140
2178
|
SafeAutoCorrect: false
|
2141
2179
|
|
2180
|
+
Lint/RedundantRegexpQuantifiers:
|
2181
|
+
Description: 'Checks for redundant quantifiers in Regexps.'
|
2182
|
+
Enabled: pending
|
2183
|
+
VersionAdded: '1.53'
|
2184
|
+
|
2142
2185
|
Lint/RedundantRequireStatement:
|
2143
2186
|
Description: 'Checks for unnecessary `require` statement.'
|
2144
2187
|
Enabled: true
|
2188
|
+
SafeAutoCorrect: false
|
2145
2189
|
VersionAdded: '0.76'
|
2190
|
+
VersionChanged: '1.57'
|
2146
2191
|
|
2147
2192
|
Lint/RedundantSafeNavigation:
|
2148
2193
|
Description: 'Checks for redundant safe navigation calls.'
|
@@ -2343,6 +2388,9 @@ Lint/TopLevelReturnWithArgument:
|
|
2343
2388
|
Description: 'Detects top level return statements with argument.'
|
2344
2389
|
Enabled: true
|
2345
2390
|
VersionAdded: '0.89'
|
2391
|
+
# These codes are `eval`-ed in method and their return values may be used.
|
2392
|
+
Exclude:
|
2393
|
+
- '**/*.jb'
|
2346
2394
|
|
2347
2395
|
Lint/TrailingCommaInAttributeDeclaration:
|
2348
2396
|
Description: 'Checks for trailing commas in attribute declarations.'
|
@@ -2451,6 +2499,8 @@ Lint/UselessAssignment:
|
|
2451
2499
|
StyleGuide: '#underscore-unused-vars'
|
2452
2500
|
Enabled: true
|
2453
2501
|
VersionAdded: '0.11'
|
2502
|
+
VersionChanged: '1.51'
|
2503
|
+
SafeAutoCorrect: false
|
2454
2504
|
|
2455
2505
|
Lint/UselessElseWithoutRescue:
|
2456
2506
|
Description: 'Checks for useless `else` in `begin..end` without `rescue`.'
|
@@ -2478,10 +2528,9 @@ Lint/UselessRuby2Keywords:
|
|
2478
2528
|
Lint/UselessSetterCall:
|
2479
2529
|
Description: 'Checks for useless setter call to a local variable.'
|
2480
2530
|
Enabled: true
|
2481
|
-
|
2531
|
+
Safe: false
|
2482
2532
|
VersionAdded: '0.13'
|
2483
2533
|
VersionChanged: '1.2'
|
2484
|
-
Safe: false
|
2485
2534
|
|
2486
2535
|
Lint/UselessTimes:
|
2487
2536
|
Description: 'Checks for useless `Integer#times` calls.'
|
@@ -2942,7 +2991,9 @@ Naming/VariableNumber:
|
|
2942
2991
|
Security/CompoundHash:
|
2943
2992
|
Description: 'When overwriting Object#hash to combine values, prefer delegating to Array#hash over writing a custom implementation.'
|
2944
2993
|
Enabled: pending
|
2994
|
+
Safe: false
|
2945
2995
|
VersionAdded: '1.28'
|
2996
|
+
VersionChanged: '1.51'
|
2946
2997
|
|
2947
2998
|
Security/Eval:
|
2948
2999
|
Description: 'The use of eval represents a serious security risk.'
|
@@ -3048,7 +3099,20 @@ Style/ArgumentsForwarding:
|
|
3048
3099
|
StyleGuide: '#arguments-forwarding'
|
3049
3100
|
Enabled: pending
|
3050
3101
|
AllowOnlyRestArgument: true
|
3102
|
+
UseAnonymousForwarding: true
|
3103
|
+
RedundantRestArgumentNames:
|
3104
|
+
- args
|
3105
|
+
- arguments
|
3106
|
+
RedundantKeywordRestArgumentNames:
|
3107
|
+
- kwargs
|
3108
|
+
- options
|
3109
|
+
- opts
|
3110
|
+
RedundantBlockArgumentNames:
|
3111
|
+
- blk
|
3112
|
+
- block
|
3113
|
+
- proc
|
3051
3114
|
VersionAdded: '1.1'
|
3115
|
+
VersionChanged: '1.58'
|
3052
3116
|
|
3053
3117
|
Style/ArrayCoercion:
|
3054
3118
|
Description: >-
|
@@ -3059,6 +3123,13 @@ Style/ArrayCoercion:
|
|
3059
3123
|
Enabled: false
|
3060
3124
|
VersionAdded: '0.88'
|
3061
3125
|
|
3126
|
+
Style/ArrayFirstLast:
|
3127
|
+
Description: 'Use `arr.first` and `arr.last` instead of `arr[0]` and `arr[-1]`.'
|
3128
|
+
Reference: '#first-and-last'
|
3129
|
+
Enabled: false
|
3130
|
+
VersionAdded: '1.58'
|
3131
|
+
Safe: false
|
3132
|
+
|
3062
3133
|
Style/ArrayIntersect:
|
3063
3134
|
Description: 'Use `array1.intersect?(array2)` instead of `(array1 & array2).any?`.'
|
3064
3135
|
Enabled: 'pending'
|
@@ -3319,7 +3390,9 @@ Style/ClassEqualityComparison:
|
|
3319
3390
|
Description: 'Enforces the use of `Object#instance_of?` instead of class comparison for equality.'
|
3320
3391
|
StyleGuide: '#instance-of-vs-class-comparison'
|
3321
3392
|
Enabled: true
|
3393
|
+
SafeAutoCorrect: false
|
3322
3394
|
VersionAdded: '0.93'
|
3395
|
+
VersionChanged: '1.57'
|
3323
3396
|
AllowedMethods:
|
3324
3397
|
- ==
|
3325
3398
|
- equal?
|
@@ -3355,6 +3428,7 @@ Style/CollectionCompact:
|
|
3355
3428
|
Safe: false
|
3356
3429
|
VersionAdded: '1.2'
|
3357
3430
|
VersionChanged: '1.3'
|
3431
|
+
AllowedReceivers: []
|
3358
3432
|
|
3359
3433
|
# Align with the style guide.
|
3360
3434
|
Style/CollectionMethods:
|
@@ -3373,6 +3447,7 @@ Style/CollectionMethods:
|
|
3373
3447
|
PreferredMethods:
|
3374
3448
|
collect: 'map'
|
3375
3449
|
collect!: 'map!'
|
3450
|
+
collect_concat: 'flat_map'
|
3376
3451
|
inject: 'reduce'
|
3377
3452
|
detect: 'find'
|
3378
3453
|
find_all: 'select'
|
@@ -3515,7 +3590,9 @@ Style/DataInheritance:
|
|
3515
3590
|
Description: 'Checks for inheritance from Data.define.'
|
3516
3591
|
StyleGuide: '#no-extend-data-define'
|
3517
3592
|
Enabled: pending
|
3593
|
+
SafeAutoCorrect: false
|
3518
3594
|
VersionAdded: '1.49'
|
3595
|
+
VersionChanged: '1.51'
|
3519
3596
|
|
3520
3597
|
Style/DateTime:
|
3521
3598
|
Description: 'Use Time over DateTime.'
|
@@ -3706,6 +3783,11 @@ Style/EvenOdd:
|
|
3706
3783
|
VersionAdded: '0.12'
|
3707
3784
|
VersionChanged: '0.29'
|
3708
3785
|
|
3786
|
+
Style/ExactRegexpMatch:
|
3787
|
+
Description: 'Checks for exact regexp match inside Regexp literals.'
|
3788
|
+
Enabled: pending
|
3789
|
+
VersionAdded: '1.51'
|
3790
|
+
|
3709
3791
|
Style/ExpandPathArguments:
|
3710
3792
|
Description: "Use `expand_path(__dir__)` instead of `expand_path('..', __FILE__)`."
|
3711
3793
|
Enabled: true
|
@@ -3884,8 +3966,9 @@ Style/HashConversion:
|
|
3884
3966
|
Description: 'Avoid Hash[] in favor of ary.to_h or literal hashes.'
|
3885
3967
|
StyleGuide: '#avoid-hash-constructor'
|
3886
3968
|
Enabled: pending
|
3969
|
+
SafeAutoCorrect: false
|
3887
3970
|
VersionAdded: '1.10'
|
3888
|
-
VersionChanged: '1.
|
3971
|
+
VersionChanged: '1.55'
|
3889
3972
|
AllowSplatArgument: true
|
3890
3973
|
|
3891
3974
|
Style/HashEachMethods:
|
@@ -4086,14 +4169,6 @@ Style/InvertibleUnlessCondition:
|
|
4086
4169
|
:none?: :any?
|
4087
4170
|
:even?: :odd?
|
4088
4171
|
: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
4172
|
|
4098
4173
|
Style/IpAddresses:
|
4099
4174
|
Description: "Don't include literal IP addresses in code."
|
@@ -4370,6 +4445,7 @@ Style/MultipleComparison:
|
|
4370
4445
|
VersionAdded: '0.49'
|
4371
4446
|
VersionChanged: '1.1'
|
4372
4447
|
AllowMethodComparison: true
|
4448
|
+
ComparisonsThreshold: 2
|
4373
4449
|
|
4374
4450
|
Style/MutableConstant:
|
4375
4451
|
Description: 'Do not assign mutable objects to constants.'
|
@@ -4624,7 +4700,9 @@ Style/OpenStructUse:
|
|
4624
4700
|
- https://docs.ruby-lang.org/en/3.0.0/OpenStruct.html#class-OpenStruct-label-Caveats
|
4625
4701
|
|
4626
4702
|
Enabled: pending
|
4703
|
+
Safe: false
|
4627
4704
|
VersionAdded: '1.23'
|
4705
|
+
VersionChanged: '1.51'
|
4628
4706
|
|
4629
4707
|
Style/OperatorMethodCall:
|
4630
4708
|
Description: 'Checks for redundant dot before operator method call.'
|
@@ -4777,12 +4855,16 @@ Style/RedundantArgument:
|
|
4777
4855
|
Enabled: pending
|
4778
4856
|
Safe: false
|
4779
4857
|
VersionAdded: '1.4'
|
4780
|
-
VersionChanged: '1.
|
4858
|
+
VersionChanged: '1.55'
|
4781
4859
|
Methods:
|
4782
4860
|
# Array#join
|
4783
4861
|
join: ''
|
4784
4862
|
# Array#sum
|
4785
4863
|
sum: 0
|
4864
|
+
# Kernel.#exit
|
4865
|
+
exit: true
|
4866
|
+
# Kernel.#exit!
|
4867
|
+
exit!: false
|
4786
4868
|
# String#split
|
4787
4869
|
split: ' '
|
4788
4870
|
# String#chomp
|
@@ -4790,6 +4872,11 @@ Style/RedundantArgument:
|
|
4790
4872
|
# String#chomp!
|
4791
4873
|
chomp!: "\n"
|
4792
4874
|
|
4875
|
+
Style/RedundantArrayConstructor:
|
4876
|
+
Description: 'Checks for the instantiation of array using redundant `Array` constructor.'
|
4877
|
+
Enabled: pending
|
4878
|
+
VersionAdded: '1.52'
|
4879
|
+
|
4793
4880
|
Style/RedundantAssignment:
|
4794
4881
|
Description: 'Checks for redundant assignment before returning.'
|
4795
4882
|
Enabled: true
|
@@ -4822,6 +4909,11 @@ Style/RedundantConstantBase:
|
|
4822
4909
|
Enabled: pending
|
4823
4910
|
VersionAdded: '1.40'
|
4824
4911
|
|
4912
|
+
Style/RedundantCurrentDirectoryInPath:
|
4913
|
+
Description: 'Checks for uses a redundant current directory in path.'
|
4914
|
+
Enabled: pending
|
4915
|
+
VersionAdded: '1.53'
|
4916
|
+
|
4825
4917
|
Style/RedundantDoubleSplatHashBraces:
|
4826
4918
|
Description: 'Checks for redundant uses of double splat hash braces.'
|
4827
4919
|
Enabled: pending
|
@@ -4844,7 +4936,7 @@ Style/RedundantFetchBlock:
|
|
4844
4936
|
Description: >-
|
4845
4937
|
Use `fetch(key, value)` instead of `fetch(key) { value }`
|
4846
4938
|
when value has Numeric, Rational, Complex, Symbol or String type, `false`, `true`, `nil` or is a constant.
|
4847
|
-
Reference: 'https://github.com/
|
4939
|
+
Reference: 'https://github.com/fastruby/fast-ruby#hashfetch-with-argument-vs-hashfetch--block-code'
|
4848
4940
|
Enabled: true
|
4849
4941
|
Safe: false
|
4850
4942
|
# If enabled, this cop will autocorrect usages of
|
@@ -4861,6 +4953,15 @@ Style/RedundantFileExtensionInRequire:
|
|
4861
4953
|
Enabled: true
|
4862
4954
|
VersionAdded: '0.88'
|
4863
4955
|
|
4956
|
+
Style/RedundantFilterChain:
|
4957
|
+
Description: >-
|
4958
|
+
Identifies usages of `any?`, `empty?`, `none?` or `one?` predicate methods chained to
|
4959
|
+
`select`/`filter`/`find_all` and change them to use predicate method instead.
|
4960
|
+
Enabled: pending
|
4961
|
+
SafeAutoCorrect: false
|
4962
|
+
VersionAdded: '1.52'
|
4963
|
+
VersionChanged: '1.57'
|
4964
|
+
|
4864
4965
|
Style/RedundantFreeze:
|
4865
4966
|
Description: "Checks usages of Object#freeze on immutable objects."
|
4866
4967
|
Enabled: true
|
@@ -4903,11 +5004,21 @@ Style/RedundantPercentQ:
|
|
4903
5004
|
Enabled: true
|
4904
5005
|
VersionAdded: '0.76'
|
4905
5006
|
|
5007
|
+
Style/RedundantRegexpArgument:
|
5008
|
+
Description: 'Identifies places where argument can be replaced from a deterministic regexp to a string.'
|
5009
|
+
Enabled: pending
|
5010
|
+
VersionAdded: '1.53'
|
5011
|
+
|
4906
5012
|
Style/RedundantRegexpCharacterClass:
|
4907
5013
|
Description: 'Checks for unnecessary single-element Regexp character classes.'
|
4908
5014
|
Enabled: true
|
4909
5015
|
VersionAdded: '0.85'
|
4910
5016
|
|
5017
|
+
Style/RedundantRegexpConstructor:
|
5018
|
+
Description: 'Checks for the instantiation of regexp using redundant `Regexp.new` or `Regexp.compile`.'
|
5019
|
+
Enabled: pending
|
5020
|
+
VersionAdded: '1.52'
|
5021
|
+
|
4911
5022
|
Style/RedundantRegexpEscape:
|
4912
5023
|
Description: 'Checks for redundant escapes in Regexps.'
|
4913
5024
|
Enabled: true
|
@@ -5010,6 +5121,15 @@ Style/ReturnNil:
|
|
5010
5121
|
- return_nil
|
5011
5122
|
VersionAdded: '0.50'
|
5012
5123
|
|
5124
|
+
Style/ReturnNilInPredicateMethodDefinition:
|
5125
|
+
Description: 'Checks if uses of `return` or `return nil` in predicate method definition.'
|
5126
|
+
StyleGuide: '#bool-methods-qmark'
|
5127
|
+
Enabled: pending
|
5128
|
+
SafeAutoCorrect: false
|
5129
|
+
AllowedMethods: []
|
5130
|
+
AllowedPatterns: []
|
5131
|
+
VersionAdded: '1.53'
|
5132
|
+
|
5013
5133
|
Style/SafeNavigation:
|
5014
5134
|
Description: >-
|
5015
5135
|
Transforms usages of a method call safeguarded by
|
@@ -5037,7 +5157,7 @@ Style/Sample:
|
|
5037
5157
|
Description: >-
|
5038
5158
|
Use `sample` instead of `shuffle.first`,
|
5039
5159
|
`shuffle.last`, and `shuffle[Integer]`.
|
5040
|
-
Reference: 'https://github.com/
|
5160
|
+
Reference: 'https://github.com/fastruby/fast-ruby#arrayshufflefirst-vs-arraysample-code'
|
5041
5161
|
Enabled: true
|
5042
5162
|
VersionAdded: '0.30'
|
5043
5163
|
|
@@ -5102,6 +5222,12 @@ Style/SingleLineBlockParams:
|
|
5102
5222
|
- acc
|
5103
5223
|
- elem
|
5104
5224
|
|
5225
|
+
Style/SingleLineDoEndBlock:
|
5226
|
+
Description: 'Checks for single-line `do`...`end` blocks.'
|
5227
|
+
StyleGuide: '#single-line-do-end-block'
|
5228
|
+
Enabled: pending
|
5229
|
+
VersionAdded: '1.57'
|
5230
|
+
|
5105
5231
|
Style/SingleLineMethods:
|
5106
5232
|
Description: 'Avoid single-line methods.'
|
5107
5233
|
StyleGuide: '#no-single-line-methods'
|
@@ -5238,6 +5364,12 @@ Style/StructInheritance:
|
|
5238
5364
|
VersionAdded: '0.29'
|
5239
5365
|
VersionChanged: '1.20'
|
5240
5366
|
|
5367
|
+
Style/SuperWithArgsParentheses:
|
5368
|
+
Description: 'Use parentheses for `super` with arguments.'
|
5369
|
+
StyleGuide: '#super-with-args'
|
5370
|
+
Enabled: pending
|
5371
|
+
VersionAdded: '1.58'
|
5372
|
+
|
5241
5373
|
Style/SwapValues:
|
5242
5374
|
Description: 'Enforces the use of shorthand-style swapping of 2 variables.'
|
5243
5375
|
StyleGuide: '#values-swapping'
|
@@ -5494,6 +5626,11 @@ Style/WordArray:
|
|
5494
5626
|
# The regular expression `WordRegex` decides what is considered a word.
|
5495
5627
|
WordRegex: !ruby/regexp '/\A(?:\p{Word}|\p{Word}-\p{Word}|\n|\t)+\z/'
|
5496
5628
|
|
5629
|
+
Style/YAMLFileRead:
|
5630
|
+
Description: 'Checks for the use of `YAML.load`, `YAML.safe_load`, and `YAML.parse` with `File.read` argument.'
|
5631
|
+
Enabled: pending
|
5632
|
+
VersionAdded: '1.53'
|
5633
|
+
|
5497
5634
|
Style/YodaCondition:
|
5498
5635
|
Description: 'Forbid or enforce yoda conditions.'
|
5499
5636
|
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
|