rubocop 1.69.2 → 1.73.1
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/LICENSE.txt +1 -1
- data/README.md +4 -4
- data/config/default.yml +90 -13
- data/config/internal_affairs.yml +16 -0
- data/lib/rubocop/cli/command/execute_runner.rb +3 -3
- data/lib/rubocop/cli/command/show_cops.rb +24 -2
- data/lib/rubocop/cli/command/suggest_extensions.rb +7 -1
- data/lib/rubocop/comment_config.rb +2 -2
- data/lib/rubocop/config.rb +17 -4
- data/lib/rubocop/config_loader.rb +48 -8
- data/lib/rubocop/config_loader_resolver.rb +35 -10
- data/lib/rubocop/config_validator.rb +19 -9
- data/lib/rubocop/cop/autocorrect_logic.rb +1 -1
- data/lib/rubocop/cop/base.rb +6 -0
- data/lib/rubocop/cop/bundler/duplicated_gem.rb +1 -1
- data/lib/rubocop/cop/bundler/gem_comment.rb +1 -1
- data/lib/rubocop/cop/internal_affairs/cop_enabled.rb +85 -0
- data/lib/rubocop/cop/internal_affairs/example_description.rb +4 -2
- data/lib/rubocop/cop/internal_affairs/location_exists.rb +116 -0
- data/lib/rubocop/cop/internal_affairs/location_expression.rb +2 -1
- data/lib/rubocop/cop/internal_affairs/node_first_or_last_argument.rb +3 -2
- data/lib/rubocop/cop/internal_affairs/node_matcher_directive.rb +1 -1
- data/lib/rubocop/cop/internal_affairs/node_pattern_groups/ast_processor.rb +63 -0
- data/lib/rubocop/cop/internal_affairs/node_pattern_groups/ast_walker.rb +131 -0
- data/lib/rubocop/cop/internal_affairs/node_pattern_groups.rb +229 -0
- data/lib/rubocop/cop/internal_affairs/node_type_multiple_predicates.rb +126 -0
- data/lib/rubocop/cop/internal_affairs/node_type_predicate.rb +4 -3
- data/lib/rubocop/cop/internal_affairs/on_send_without_on_csend.rb +90 -0
- data/lib/rubocop/cop/internal_affairs/plugin.rb +33 -0
- data/lib/rubocop/cop/internal_affairs/redundant_source_range.rb +3 -1
- data/lib/rubocop/cop/internal_affairs/single_line_comparison.rb +5 -4
- data/lib/rubocop/cop/internal_affairs/undefined_config.rb +7 -1
- data/lib/rubocop/cop/internal_affairs.rb +5 -16
- data/lib/rubocop/cop/layout/access_modifier_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/argument_alignment.rb +2 -8
- data/lib/rubocop/cop/layout/block_alignment.rb +3 -1
- data/lib/rubocop/cop/layout/class_structure.rb +9 -9
- data/lib/rubocop/cop/layout/closing_parenthesis_indentation.rb +4 -4
- data/lib/rubocop/cop/layout/dot_position.rb +1 -1
- data/lib/rubocop/cop/layout/else_alignment.rb +2 -2
- data/lib/rubocop/cop/layout/empty_line_after_guard_clause.rb +1 -1
- data/lib/rubocop/cop/layout/empty_line_between_defs.rb +7 -11
- data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +27 -1
- data/lib/rubocop/cop/layout/empty_lines_around_exception_handling_keywords.rb +1 -1
- data/lib/rubocop/cop/layout/empty_lines_around_method_body.rb +22 -2
- data/lib/rubocop/cop/layout/end_alignment.rb +1 -1
- data/lib/rubocop/cop/layout/extra_spacing.rb +1 -1
- data/lib/rubocop/cop/layout/first_argument_indentation.rb +3 -8
- data/lib/rubocop/cop/layout/first_array_element_indentation.rb +2 -7
- data/lib/rubocop/cop/layout/first_hash_element_indentation.rb +2 -7
- data/lib/rubocop/cop/layout/first_hash_element_line_break.rb +1 -1
- data/lib/rubocop/cop/layout/first_parameter_indentation.rb +2 -2
- data/lib/rubocop/cop/layout/hash_alignment.rb +6 -4
- data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +2 -1
- data/lib/rubocop/cop/layout/line_continuation_spacing.rb +7 -1
- data/lib/rubocop/cop/layout/line_end_string_concatenation_indentation.rb +2 -2
- data/lib/rubocop/cop/layout/line_length.rb +4 -3
- data/lib/rubocop/cop/layout/multiline_hash_key_line_breaks.rb +1 -1
- data/lib/rubocop/cop/layout/multiline_method_argument_line_breaks.rb +25 -0
- data/lib/rubocop/cop/layout/multiline_method_call_brace_layout.rb +1 -0
- data/lib/rubocop/cop/layout/multiline_method_call_indentation.rb +4 -4
- data/lib/rubocop/cop/layout/redundant_line_break.rb +7 -6
- data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +1 -1
- data/lib/rubocop/cop/layout/single_line_block_chain.rb +1 -1
- data/lib/rubocop/cop/layout/space_after_colon.rb +2 -2
- data/lib/rubocop/cop/layout/space_after_comma.rb +1 -1
- data/lib/rubocop/cop/layout/space_after_method_name.rb +1 -1
- data/lib/rubocop/cop/layout/space_after_semicolon.rb +1 -1
- data/lib/rubocop/cop/layout/space_around_keyword.rb +1 -0
- data/lib/rubocop/cop/layout/space_around_method_call_operator.rb +1 -1
- data/lib/rubocop/cop/layout/space_around_operators.rb +3 -3
- data/lib/rubocop/cop/layout/space_before_comma.rb +1 -1
- data/lib/rubocop/cop/layout/space_before_semicolon.rb +1 -1
- data/lib/rubocop/cop/layout/trailing_whitespace.rb +5 -3
- data/lib/rubocop/cop/lint/ambiguous_block_association.rb +1 -1
- data/lib/rubocop/cop/lint/array_literal_in_regexp.rb +119 -0
- data/lib/rubocop/cop/lint/assignment_in_condition.rb +1 -3
- data/lib/rubocop/cop/lint/binary_operator_with_identical_operands.rb +1 -1
- data/lib/rubocop/cop/lint/constant_definition_in_block.rb +3 -3
- data/lib/rubocop/cop/lint/constant_reassignment.rb +148 -0
- data/lib/rubocop/cop/lint/cop_directive_syntax.rb +84 -0
- data/lib/rubocop/cop/lint/debugger.rb +1 -1
- data/lib/rubocop/cop/lint/duplicate_match_pattern.rb +1 -1
- data/lib/rubocop/cop/lint/duplicate_methods.rb +0 -14
- data/lib/rubocop/cop/lint/duplicate_regexp_character_class_element.rb +1 -1
- data/lib/rubocop/cop/lint/duplicate_set_element.rb +20 -7
- data/lib/rubocop/cop/lint/empty_conditional_body.rb +10 -5
- data/lib/rubocop/cop/lint/empty_expression.rb +0 -2
- data/lib/rubocop/cop/lint/float_comparison.rb +6 -8
- data/lib/rubocop/cop/lint/float_out_of_range.rb +1 -1
- data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +2 -2
- data/lib/rubocop/cop/lint/implicit_string_concatenation.rb +1 -1
- data/lib/rubocop/cop/lint/literal_as_condition.rb +99 -9
- data/lib/rubocop/cop/lint/literal_in_interpolation.rb +24 -6
- data/lib/rubocop/cop/lint/missing_super.rb +2 -2
- data/lib/rubocop/cop/lint/mixed_case_range.rb +3 -3
- data/lib/rubocop/cop/lint/mixed_regexp_capture_types.rb +1 -1
- data/lib/rubocop/cop/lint/nested_method_definition.rb +8 -4
- data/lib/rubocop/cop/lint/next_without_accumulator.rb +1 -1
- data/lib/rubocop/cop/lint/non_atomic_file_operation.rb +4 -3
- data/lib/rubocop/cop/lint/non_local_exit_from_iterator.rb +1 -1
- data/lib/rubocop/cop/lint/numeric_operation_with_constant_result.rb +18 -31
- data/lib/rubocop/cop/lint/out_of_range_regexp_ref.rb +2 -1
- data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +1 -5
- data/lib/rubocop/cop/lint/redundant_regexp_quantifiers.rb +1 -1
- data/lib/rubocop/cop/lint/redundant_require_statement.rb +0 -21
- data/lib/rubocop/cop/lint/redundant_string_coercion.rb +2 -2
- data/lib/rubocop/cop/lint/redundant_type_conversion.rb +252 -0
- data/lib/rubocop/cop/lint/rescue_exception.rb +1 -1
- data/lib/rubocop/cop/lint/safe_navigation_chain.rb +8 -1
- data/lib/rubocop/cop/lint/shared_mutable_default.rb +65 -0
- data/lib/rubocop/cop/lint/suppressed_exception.rb +1 -1
- data/lib/rubocop/cop/lint/suppressed_exception_in_number_conversion.rb +111 -0
- data/lib/rubocop/cop/lint/symbol_conversion.rb +1 -1
- data/lib/rubocop/cop/lint/syntax.rb +4 -1
- data/lib/rubocop/cop/lint/unescaped_bracket_in_regexp.rb +1 -4
- data/lib/rubocop/cop/lint/unexpected_block_arity.rb +1 -1
- data/lib/rubocop/cop/lint/unmodified_reduce_accumulator.rb +1 -1
- data/lib/rubocop/cop/lint/unreachable_code.rb +1 -1
- data/lib/rubocop/cop/lint/unreachable_loop.rb +1 -1
- data/lib/rubocop/cop/lint/useless_access_modifier.rb +4 -4
- data/lib/rubocop/cop/lint/useless_assignment.rb +1 -1
- data/lib/rubocop/cop/lint/useless_constant_scoping.rb +80 -0
- data/lib/rubocop/cop/lint/useless_method_definition.rb +1 -1
- data/lib/rubocop/cop/lint/useless_numeric_operation.rb +2 -1
- data/lib/rubocop/cop/lint/useless_ruby2_keywords.rb +2 -2
- data/lib/rubocop/cop/lint/void.rb +11 -9
- data/lib/rubocop/cop/metrics/block_nesting.rb +1 -1
- data/lib/rubocop/cop/metrics/collection_literal_length.rb +7 -0
- data/lib/rubocop/cop/metrics/cyclomatic_complexity.rb +1 -1
- data/lib/rubocop/cop/metrics/method_length.rb +8 -1
- data/lib/rubocop/cop/metrics/module_length.rb +1 -1
- data/lib/rubocop/cop/metrics/perceived_complexity.rb +1 -1
- data/lib/rubocop/cop/metrics/utils/repeated_attribute_discount.rb +7 -7
- data/lib/rubocop/cop/mixin/alignment.rb +2 -2
- data/lib/rubocop/cop/mixin/allowed_pattern.rb +4 -4
- data/lib/rubocop/cop/mixin/check_line_breakable.rb +11 -11
- data/lib/rubocop/cop/mixin/comments_help.rb +4 -2
- data/lib/rubocop/cop/mixin/dig_help.rb +1 -1
- data/lib/rubocop/cop/mixin/frozen_string_literal.rb +1 -1
- data/lib/rubocop/cop/mixin/hash_shorthand_syntax.rb +22 -22
- data/lib/rubocop/cop/mixin/hash_subset.rb +203 -0
- data/lib/rubocop/cop/mixin/hash_transform_method.rb +74 -74
- data/lib/rubocop/cop/mixin/method_complexity.rb +1 -1
- data/lib/rubocop/cop/mixin/percent_literal.rb +1 -1
- data/lib/rubocop/cop/mixin/preceding_following_alignment.rb +48 -24
- data/lib/rubocop/cop/mixin/range_help.rb +3 -3
- data/lib/rubocop/cop/mixin/space_before_punctuation.rb +1 -1
- data/lib/rubocop/cop/mixin/statement_modifier.rb +8 -3
- data/lib/rubocop/cop/mixin/string_help.rb +2 -2
- data/lib/rubocop/cop/mixin/string_literals_help.rb +1 -1
- data/lib/rubocop/cop/mixin/trailing_comma.rb +15 -3
- data/lib/rubocop/cop/naming/block_forwarding.rb +19 -15
- data/lib/rubocop/cop/naming/predicate_name.rb +44 -0
- data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +3 -3
- data/lib/rubocop/cop/naming/variable_name.rb +64 -6
- data/lib/rubocop/cop/security/compound_hash.rb +1 -0
- data/lib/rubocop/cop/style/access_modifier_declarations.rb +34 -5
- data/lib/rubocop/cop/style/accessor_grouping.rb +19 -5
- data/lib/rubocop/cop/style/and_or.rb +1 -1
- data/lib/rubocop/cop/style/arguments_forwarding.rb +39 -23
- data/lib/rubocop/cop/style/array_first_last.rb +18 -2
- data/lib/rubocop/cop/style/block_delimiters.rb +7 -20
- data/lib/rubocop/cop/style/class_and_module_children.rb +6 -3
- data/lib/rubocop/cop/style/collection_methods.rb +1 -1
- data/lib/rubocop/cop/style/combinable_defined.rb +1 -1
- data/lib/rubocop/cop/style/combinable_loops.rb +2 -2
- data/lib/rubocop/cop/style/commented_keyword.rb +1 -1
- data/lib/rubocop/cop/style/concat_array_literals.rb +1 -1
- data/lib/rubocop/cop/style/conditional_assignment.rb +6 -4
- data/lib/rubocop/cop/style/documentation.rb +1 -1
- data/lib/rubocop/cop/style/double_negation.rb +3 -3
- data/lib/rubocop/cop/style/each_for_simple_loop.rb +4 -7
- data/lib/rubocop/cop/style/each_with_object.rb +2 -3
- data/lib/rubocop/cop/style/empty_else.rb +4 -2
- data/lib/rubocop/cop/style/empty_literal.rb +1 -1
- data/lib/rubocop/cop/style/empty_method.rb +1 -1
- data/lib/rubocop/cop/style/endless_method.rb +163 -18
- data/lib/rubocop/cop/style/eval_with_location.rb +1 -1
- data/lib/rubocop/cop/style/exact_regexp_match.rb +3 -10
- data/lib/rubocop/cop/style/explicit_block_argument.rb +15 -2
- data/lib/rubocop/cop/style/exponential_notation.rb +1 -1
- data/lib/rubocop/cop/style/fetch_env_var.rb +1 -1
- data/lib/rubocop/cop/style/float_division.rb +8 -4
- data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +1 -1
- data/lib/rubocop/cop/style/hash_each_methods.rb +3 -6
- data/lib/rubocop/cop/style/hash_except.rb +24 -148
- data/lib/rubocop/cop/style/hash_slice.rb +80 -0
- data/lib/rubocop/cop/style/hash_syntax.rb +6 -3
- data/lib/rubocop/cop/style/identical_conditional_branches.rb +22 -3
- data/lib/rubocop/cop/style/if_unless_modifier.rb +3 -3
- data/lib/rubocop/cop/style/if_with_boolean_literal_branches.rb +1 -1
- data/lib/rubocop/cop/style/if_with_semicolon.rb +2 -2
- data/lib/rubocop/cop/style/infinite_loop.rb +1 -1
- data/lib/rubocop/cop/style/inverse_methods.rb +6 -6
- data/lib/rubocop/cop/style/it_assignment.rb +36 -0
- data/lib/rubocop/cop/style/keyword_parameters_order.rb +1 -1
- data/lib/rubocop/cop/style/line_end_concatenation.rb +10 -4
- data/lib/rubocop/cop/style/map_into_array.rb +1 -1
- data/lib/rubocop/cop/style/map_to_hash.rb +1 -1
- data/lib/rubocop/cop/style/map_to_set.rb +3 -2
- data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +19 -12
- data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +2 -0
- data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +2 -1
- data/lib/rubocop/cop/style/method_called_on_do_end_block.rb +2 -4
- data/lib/rubocop/cop/style/method_def_parentheses.rb +1 -1
- data/lib/rubocop/cop/style/missing_else.rb +2 -0
- data/lib/rubocop/cop/style/multiline_block_chain.rb +1 -1
- data/lib/rubocop/cop/style/multiple_comparison.rb +26 -20
- data/lib/rubocop/cop/style/mutable_constant.rb +3 -3
- data/lib/rubocop/cop/style/negated_if_else_condition.rb +1 -1
- data/lib/rubocop/cop/style/nested_parenthesized_calls.rb +1 -1
- data/lib/rubocop/cop/style/object_then.rb +13 -15
- data/lib/rubocop/cop/style/open_struct_use.rb +5 -5
- data/lib/rubocop/cop/style/parallel_assignment.rb +1 -5
- data/lib/rubocop/cop/style/parentheses_around_condition.rb +2 -2
- data/lib/rubocop/cop/style/percent_literal_delimiters.rb +1 -1
- data/lib/rubocop/cop/style/proc.rb +1 -2
- data/lib/rubocop/cop/style/quoted_symbols.rb +1 -1
- data/lib/rubocop/cop/style/raise_args.rb +6 -4
- data/lib/rubocop/cop/style/random_with_offset.rb +3 -3
- data/lib/rubocop/cop/style/redundant_begin.rb +1 -1
- data/lib/rubocop/cop/style/redundant_condition.rb +48 -2
- data/lib/rubocop/cop/style/redundant_current_directory_in_path.rb +2 -1
- data/lib/rubocop/cop/style/redundant_double_splat_hash_braces.rb +6 -10
- data/lib/rubocop/cop/style/redundant_each.rb +1 -1
- data/lib/rubocop/cop/style/redundant_exception.rb +2 -2
- data/lib/rubocop/cop/style/redundant_format.rb +250 -0
- data/lib/rubocop/cop/style/redundant_freeze.rb +2 -2
- data/lib/rubocop/cop/style/redundant_initialize.rb +12 -3
- data/lib/rubocop/cop/style/redundant_line_continuation.rb +34 -13
- data/lib/rubocop/cop/style/redundant_parentheses.rb +28 -14
- data/lib/rubocop/cop/style/redundant_regexp_argument.rb +3 -0
- data/lib/rubocop/cop/style/redundant_regexp_character_class.rb +1 -1
- data/lib/rubocop/cop/style/redundant_regexp_escape.rb +1 -1
- data/lib/rubocop/cop/style/redundant_self_assignment.rb +14 -28
- data/lib/rubocop/cop/style/redundant_sort.rb +2 -2
- data/lib/rubocop/cop/style/redundant_string_escape.rb +2 -2
- data/lib/rubocop/cop/style/return_nil.rb +1 -1
- data/lib/rubocop/cop/style/safe_navigation.rb +2 -2
- data/lib/rubocop/cop/style/semicolon.rb +1 -1
- data/lib/rubocop/cop/style/send_with_literal_method_name.rb +2 -1
- data/lib/rubocop/cop/style/single_line_block_params.rb +1 -1
- data/lib/rubocop/cop/style/single_line_do_end_block.rb +1 -2
- data/lib/rubocop/cop/style/single_line_methods.rb +6 -7
- data/lib/rubocop/cop/style/slicing_with_range.rb +40 -11
- data/lib/rubocop/cop/style/sole_nested_conditional.rb +2 -2
- data/lib/rubocop/cop/style/string_concatenation.rb +2 -2
- data/lib/rubocop/cop/style/string_literals.rb +1 -1
- data/lib/rubocop/cop/style/string_methods.rb +1 -1
- data/lib/rubocop/cop/style/super_arguments.rb +65 -17
- data/lib/rubocop/cop/style/ternary_parentheses.rb +1 -1
- data/lib/rubocop/cop/style/top_level_method_definition.rb +1 -1
- data/lib/rubocop/cop/style/trailing_comma_in_arguments.rb +4 -1
- data/lib/rubocop/cop/style/trailing_comma_in_array_literal.rb +47 -6
- data/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb +48 -6
- data/lib/rubocop/cop/style/trivial_accessors.rb +1 -1
- data/lib/rubocop/cop/style/while_until_modifier.rb +0 -1
- data/lib/rubocop/cop/style/yoda_condition.rb +8 -4
- data/lib/rubocop/cop/style/yoda_expression.rb +2 -1
- data/lib/rubocop/cop/util.rb +12 -5
- data/lib/rubocop/cop/utils/format_string.rb +7 -5
- data/lib/rubocop/cop/variable_force/variable.rb +14 -2
- data/lib/rubocop/cop/variable_force/variable_table.rb +3 -3
- data/lib/rubocop/cops_documentation_generator.rb +25 -14
- data/lib/rubocop/directive_comment.rb +44 -10
- data/lib/rubocop/formatter/formatter_set.rb +1 -1
- data/lib/rubocop/lsp/diagnostic.rb +189 -0
- data/lib/rubocop/lsp/logger.rb +2 -2
- data/lib/rubocop/lsp/routes.rb +7 -23
- data/lib/rubocop/lsp/runtime.rb +17 -49
- data/lib/rubocop/lsp/server.rb +0 -2
- data/lib/rubocop/lsp/stdin_runner.rb +83 -0
- data/lib/rubocop/options.rb +28 -12
- data/lib/rubocop/path_util.rb +15 -8
- data/lib/rubocop/plugin/configuration_integrator.rb +143 -0
- data/lib/rubocop/plugin/load_error.rb +26 -0
- data/lib/rubocop/plugin/loader.rb +100 -0
- data/lib/rubocop/plugin/not_supported_error.rb +29 -0
- data/lib/rubocop/plugin.rb +46 -0
- data/lib/rubocop/rake_task.rb +4 -1
- data/lib/rubocop/result_cache.rb +13 -13
- data/lib/rubocop/rspec/cop_helper.rb +9 -0
- data/lib/rubocop/rspec/expect_offense.rb +6 -2
- data/lib/rubocop/rspec/shared_contexts.rb +19 -1
- data/lib/rubocop/rspec/support.rb +2 -2
- data/lib/rubocop/runner.rb +5 -6
- data/lib/rubocop/server/cache.rb +35 -2
- data/lib/rubocop/server/cli.rb +2 -2
- data/lib/rubocop/target_finder.rb +1 -0
- data/lib/rubocop/target_ruby.rb +15 -0
- data/lib/rubocop/version.rb +17 -2
- data/lib/rubocop.rb +11 -1
- data/lib/ruby_lsp/rubocop/addon.rb +75 -0
- data/lib/ruby_lsp/rubocop/runtime_adapter.rb +47 -0
- metadata +53 -16
- data/lib/rubocop/cop/utils/regexp_ranges.rb +0 -113
- data/lib/rubocop/rspec/host_environment_simulation_helper.rb +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4215b7d095dfd177a36af3bdf5d5aecd786877a6feca3480078d9cb1a5917ad
|
4
|
+
data.tar.gz: fc20be6f63f1a0e3c06cd2fc13f8619f872e9a81642dfa833f90f88f70997857
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aee7de1fa54b8b7108f5ad7f29c3fbc1818547f28507010dca91adc0f648b02ce519c96846d2ad98407d8f8847047cd8f88547e7d5c81028d0f54cfafb44500b
|
7
|
+
data.tar.gz: afc90ab7e887e183ddfac0bf49e9f644c04564e7fd605423d29f2848f6cc509f2394fd642eccd8870d105b21055a5cb4d0dea051b92ba47ef3befbf5b7d3dad5
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -52,7 +52,7 @@ To prevent an unwanted RuboCop update you might want to use a conservative versi
|
|
52
52
|
in your `Gemfile`:
|
53
53
|
|
54
54
|
```rb
|
55
|
-
gem 'rubocop', '~> 1.
|
55
|
+
gem 'rubocop', '~> 1.73', require: false
|
56
56
|
```
|
57
57
|
|
58
58
|
See [our versioning policy](https://docs.rubocop.org/rubocop/versioning.html) for further details.
|
@@ -241,11 +241,11 @@ Become a sponsor and get your logo on our README on GitHub with a link to your s
|
|
241
241
|
<a href="https://opencollective.com/rubocop/organization/28/website" target="_blank"><img src="https://opencollective.com/rubocop/organization/28/avatar.svg"></a>
|
242
242
|
<a href="https://opencollective.com/rubocop/organization/29/website" target="_blank"><img src="https://opencollective.com/rubocop/organization/29/avatar.svg"></a>
|
243
243
|
|
244
|
-
##
|
244
|
+
## Release Notes
|
245
245
|
|
246
|
-
RuboCop's
|
246
|
+
RuboCop's release notes are available [here](https://github.com/rubocop/rubocop/releases).
|
247
247
|
|
248
248
|
## Copyright
|
249
249
|
|
250
|
-
Copyright (c) 2012-
|
250
|
+
Copyright (c) 2012-2025 Bozhidar Batsov. See [LICENSE.txt](LICENSE.txt) for
|
251
251
|
further details.
|
data/config/default.yml
CHANGED
@@ -1616,6 +1616,12 @@ Lint/AmbiguousRegexpLiteral:
|
|
1616
1616
|
VersionAdded: '0.17'
|
1617
1617
|
VersionChanged: '0.83'
|
1618
1618
|
|
1619
|
+
Lint/ArrayLiteralInRegexp:
|
1620
|
+
Description: 'Checks for an array literal interpolated inside a regexp.'
|
1621
|
+
Enabled: pending
|
1622
|
+
VersionAdded: '1.71'
|
1623
|
+
SafeAutoCorrect: false
|
1624
|
+
|
1619
1625
|
Lint/AssignmentInCondition:
|
1620
1626
|
Description: "Don't use assignment in conditions."
|
1621
1627
|
StyleGuide: '#safe-assignment-in-condition'
|
@@ -1665,6 +1671,11 @@ Lint/ConstantOverwrittenInRescue:
|
|
1665
1671
|
Enabled: pending
|
1666
1672
|
VersionAdded: '1.31'
|
1667
1673
|
|
1674
|
+
Lint/ConstantReassignment:
|
1675
|
+
Description: 'Checks for constant reassignments.'
|
1676
|
+
Enabled: pending
|
1677
|
+
VersionAdded: '1.70'
|
1678
|
+
|
1668
1679
|
Lint/ConstantResolution:
|
1669
1680
|
Description: 'Check that constants are fully qualified with `::`.'
|
1670
1681
|
Enabled: false
|
@@ -1674,6 +1685,11 @@ Lint/ConstantResolution:
|
|
1674
1685
|
# Restrict this cop from only looking at certain names
|
1675
1686
|
Ignore: []
|
1676
1687
|
|
1688
|
+
Lint/CopDirectiveSyntax:
|
1689
|
+
Description: 'Checks that `# rubocop:` directives are strictly formatted.'
|
1690
|
+
Enabled: pending
|
1691
|
+
VersionAdded: '1.72'
|
1692
|
+
|
1677
1693
|
Lint/Debugger:
|
1678
1694
|
Description: 'Check for debugger calls.'
|
1679
1695
|
Enabled: true
|
@@ -2030,6 +2046,7 @@ Lint/LambdaWithoutLiteralBlock:
|
|
2030
2046
|
Lint/LiteralAsCondition:
|
2031
2047
|
Description: 'Checks of literals used in conditions.'
|
2032
2048
|
Enabled: true
|
2049
|
+
AutoCorrect: contextual
|
2033
2050
|
VersionAdded: '0.51'
|
2034
2051
|
|
2035
2052
|
Lint/LiteralAssignmentInCondition:
|
@@ -2243,9 +2260,8 @@ Lint/RedundantRegexpQuantifiers:
|
|
2243
2260
|
Lint/RedundantRequireStatement:
|
2244
2261
|
Description: 'Checks for unnecessary `require` statement.'
|
2245
2262
|
Enabled: true
|
2246
|
-
SafeAutoCorrect: false
|
2247
2263
|
VersionAdded: '0.76'
|
2248
|
-
VersionChanged: '1.
|
2264
|
+
VersionChanged: '1.73'
|
2249
2265
|
|
2250
2266
|
Lint/RedundantSafeNavigation:
|
2251
2267
|
Description: 'Checks for redundant safe navigation calls.'
|
@@ -2274,6 +2290,11 @@ Lint/RedundantStringCoercion:
|
|
2274
2290
|
VersionAdded: '0.19'
|
2275
2291
|
VersionChanged: '0.77'
|
2276
2292
|
|
2293
|
+
Lint/RedundantTypeConversion:
|
2294
|
+
Description: 'Checks for redundantly converting a literal to the same type.'
|
2295
|
+
Enabled: pending
|
2296
|
+
VersionAdded: '1.72'
|
2297
|
+
|
2277
2298
|
Lint/RedundantWithIndex:
|
2278
2299
|
Description: 'Checks for redundant `with_index`.'
|
2279
2300
|
Enabled: true
|
@@ -2402,6 +2423,12 @@ Lint/ShadowingOuterLocalVariable:
|
|
2402
2423
|
Enabled: true
|
2403
2424
|
VersionAdded: '0.9'
|
2404
2425
|
|
2426
|
+
Lint/SharedMutableDefault:
|
2427
|
+
Description: 'Checks for mutable literals used as default arguments during Hash initialization.'
|
2428
|
+
StyleGuide: '#no-mutable-defaults'
|
2429
|
+
Enabled: pending
|
2430
|
+
VersionAdded: '1.70'
|
2431
|
+
|
2405
2432
|
Lint/StructNewOverride:
|
2406
2433
|
Description: 'Disallow overriding the `Struct` built-in methods via `Struct.new`.'
|
2407
2434
|
Enabled: true
|
@@ -2416,6 +2443,12 @@ Lint/SuppressedException:
|
|
2416
2443
|
VersionAdded: '0.9'
|
2417
2444
|
VersionChanged: '1.12'
|
2418
2445
|
|
2446
|
+
Lint/SuppressedExceptionInNumberConversion:
|
2447
|
+
Description: 'Checks for cases where exceptions unrelated to the numeric constructors may be unintentionally swallowed.'
|
2448
|
+
Enabled: pending
|
2449
|
+
SafeAutoCorrect: false
|
2450
|
+
VersionAdded: '1.72'
|
2451
|
+
|
2419
2452
|
Lint/SymbolConversion:
|
2420
2453
|
Description: 'Checks for unnecessary symbol conversions.'
|
2421
2454
|
Enabled: pending
|
@@ -2571,6 +2604,11 @@ Lint/UselessAssignment:
|
|
2571
2604
|
VersionAdded: '0.11'
|
2572
2605
|
VersionChanged: '1.66'
|
2573
2606
|
|
2607
|
+
Lint/UselessConstantScoping:
|
2608
|
+
Description: 'Checks for useless constant scoping.'
|
2609
|
+
Enabled: pending
|
2610
|
+
VersionAdded: '1.72'
|
2611
|
+
|
2574
2612
|
Lint/UselessDefined:
|
2575
2613
|
Description: 'Checks for calls to `defined?` with strings and symbols. The result of such a call will always be truthy.'
|
2576
2614
|
Enabled: pending
|
@@ -3024,6 +3062,8 @@ Naming/PredicateName:
|
|
3024
3062
|
MethodDefinitionMacros:
|
3025
3063
|
- define_method
|
3026
3064
|
- define_singleton_method
|
3065
|
+
# Use Sorbet's T::Boolean return type to detect predicate methods.
|
3066
|
+
UseSorbetSigs: false
|
3027
3067
|
# Exclude Rspec specs because there is a strong convention to write spec
|
3028
3068
|
# helpers in the form of `have_something` or `be_something`.
|
3029
3069
|
Exclude:
|
@@ -3041,13 +3081,15 @@ Naming/VariableName:
|
|
3041
3081
|
StyleGuide: '#snake-case-symbols-methods-vars'
|
3042
3082
|
Enabled: true
|
3043
3083
|
VersionAdded: '0.50'
|
3044
|
-
VersionChanged: '1.
|
3084
|
+
VersionChanged: '1.73'
|
3045
3085
|
EnforcedStyle: snake_case
|
3046
3086
|
SupportedStyles:
|
3047
3087
|
- snake_case
|
3048
3088
|
- camelCase
|
3049
3089
|
AllowedIdentifiers: []
|
3050
3090
|
AllowedPatterns: []
|
3091
|
+
ForbiddenIdentifiers: []
|
3092
|
+
ForbiddenPatterns: []
|
3051
3093
|
|
3052
3094
|
Naming/VariableNumber:
|
3053
3095
|
Description: 'Use the configured style when numbering symbols, methods and variables.'
|
@@ -3136,13 +3178,14 @@ Style/AccessModifierDeclarations:
|
|
3136
3178
|
Description: 'Checks style of how access modifiers are used.'
|
3137
3179
|
Enabled: true
|
3138
3180
|
VersionAdded: '0.57'
|
3139
|
-
VersionChanged: '
|
3181
|
+
VersionChanged: '1.70'
|
3140
3182
|
EnforcedStyle: group
|
3141
3183
|
SupportedStyles:
|
3142
3184
|
- inline
|
3143
3185
|
- group
|
3144
3186
|
AllowModifiersOnSymbols: true
|
3145
3187
|
AllowModifiersOnAttrs: true
|
3188
|
+
AllowModifiersOnAliasMethod: true
|
3146
3189
|
SafeAutoCorrect: false
|
3147
3190
|
|
3148
3191
|
Style/AccessorGrouping:
|
@@ -3881,6 +3924,8 @@ Style/EndlessMethod:
|
|
3881
3924
|
- allow_single_line
|
3882
3925
|
- allow_always
|
3883
3926
|
- disallow
|
3927
|
+
- require_single_line
|
3928
|
+
- require_always
|
3884
3929
|
|
3885
3930
|
Style/EnvHome:
|
3886
3931
|
Description: "Checks for consistent usage of `ENV['HOME']`."
|
@@ -4051,6 +4096,9 @@ Style/FrozenStringLiteralComment:
|
|
4051
4096
|
# exist in a file.
|
4052
4097
|
- never
|
4053
4098
|
SafeAutoCorrect: false
|
4099
|
+
Exclude:
|
4100
|
+
# Prevent the Ruby warning: `'frozen_string_literal' is ignored after any tokens` when using Active Admin.
|
4101
|
+
- '**/*.arb'
|
4054
4102
|
|
4055
4103
|
Style/GlobalStdStream:
|
4056
4104
|
Description: 'Enforces the use of `$stdout/$stderr/$stdin` instead of `STDOUT/STDERR/STDIN`.'
|
@@ -4129,6 +4177,14 @@ Style/HashLikeCase:
|
|
4129
4177
|
# to trigger this cop
|
4130
4178
|
MinBranchesCount: 3
|
4131
4179
|
|
4180
|
+
Style/HashSlice:
|
4181
|
+
Description: >-
|
4182
|
+
Checks for usages of `Hash#reject`, `Hash#select`, and `Hash#filter` methods
|
4183
|
+
that can be replaced with `Hash#slice` method.
|
4184
|
+
Enabled: pending
|
4185
|
+
Safe: false
|
4186
|
+
VersionAdded: '1.71'
|
4187
|
+
|
4132
4188
|
Style/HashSyntax:
|
4133
4189
|
Description: >-
|
4134
4190
|
Prefer Ruby 1.9 hash syntax { a: 1, b: 2 } over 1.8 syntax
|
@@ -4316,6 +4372,11 @@ Style/IpAddresses:
|
|
4316
4372
|
- '**/gems.rb'
|
4317
4373
|
- '**/*.gemspec'
|
4318
4374
|
|
4375
|
+
Style/ItAssignment:
|
4376
|
+
Description: 'Checks for assignment to `it` inside a block.'
|
4377
|
+
Enabled: pending
|
4378
|
+
VersionAdded: '1.70'
|
4379
|
+
|
4319
4380
|
Style/KeywordArgumentsMerging:
|
4320
4381
|
Description: >-
|
4321
4382
|
When passing an existing hash as keyword arguments, provide additional arguments
|
@@ -5047,6 +5108,9 @@ Style/RedundantCondition:
|
|
5047
5108
|
Description: 'Checks for unnecessary conditional expressions.'
|
5048
5109
|
Enabled: true
|
5049
5110
|
VersionAdded: '0.76'
|
5111
|
+
VersionChanged: '1.73'
|
5112
|
+
AllowedMethods:
|
5113
|
+
- nonzero?
|
5050
5114
|
|
5051
5115
|
Style/RedundantConditional:
|
5052
5116
|
Description: "Don't return true/false from a conditional."
|
@@ -5059,7 +5123,7 @@ Style/RedundantConstantBase:
|
|
5059
5123
|
VersionAdded: '1.40'
|
5060
5124
|
|
5061
5125
|
Style/RedundantCurrentDirectoryInPath:
|
5062
|
-
Description: 'Checks for
|
5126
|
+
Description: 'Checks for a redundant current directory in a path given to `require_relative`.'
|
5063
5127
|
Enabled: pending
|
5064
5128
|
VersionAdded: '1.53'
|
5065
5129
|
|
@@ -5111,6 +5175,13 @@ Style/RedundantFilterChain:
|
|
5111
5175
|
VersionAdded: '1.52'
|
5112
5176
|
VersionChanged: '1.57'
|
5113
5177
|
|
5178
|
+
Style/RedundantFormat:
|
5179
|
+
Description: 'Checks for usages of `Kernel#format` or `Kernel#sprintf` with only a single argument.'
|
5180
|
+
Enabled: pending
|
5181
|
+
SafeAutoCorrect: false
|
5182
|
+
VersionAdded: '1.72'
|
5183
|
+
VersionChanged: '1.72'
|
5184
|
+
|
5114
5185
|
Style/RedundantFreeze:
|
5115
5186
|
Description: "Checks usages of Object#freeze on immutable objects."
|
5116
5187
|
Enabled: true
|
@@ -5637,14 +5708,17 @@ Style/TrailingCommaInArrayLiteral:
|
|
5637
5708
|
StyleGuide: '#no-trailing-array-commas'
|
5638
5709
|
Enabled: true
|
5639
5710
|
VersionAdded: '0.53'
|
5640
|
-
# If `comma`, the cop requires a comma after the last item in an array,
|
5641
|
-
#
|
5642
|
-
# If `consistent_comma`, the cop requires a comma after the last item of all
|
5643
|
-
#
|
5711
|
+
# If `comma`, the cop requires a comma after the last item in an array, but only when each item is
|
5712
|
+
# on its own line.
|
5713
|
+
# If `consistent_comma`, the cop requires a comma after the last item of all non-empty, multiline
|
5714
|
+
# array literals.
|
5715
|
+
# If `diff_comma`, the cop requires a comma after the last item of all non-empty, multiline array
|
5716
|
+
# literals, but only when that last item immediately precedes a newline.
|
5644
5717
|
EnforcedStyleForMultiline: no_comma
|
5645
5718
|
SupportedStylesForMultiline:
|
5646
5719
|
- comma
|
5647
5720
|
- consistent_comma
|
5721
|
+
- diff_comma
|
5648
5722
|
- no_comma
|
5649
5723
|
|
5650
5724
|
Style/TrailingCommaInBlockArgs:
|
@@ -5656,14 +5730,17 @@ Style/TrailingCommaInBlockArgs:
|
|
5656
5730
|
Style/TrailingCommaInHashLiteral:
|
5657
5731
|
Description: 'Checks for trailing comma in hash literals.'
|
5658
5732
|
Enabled: true
|
5659
|
-
# If `comma`, the cop requires a comma after the last item in a hash,
|
5660
|
-
#
|
5661
|
-
# If `consistent_comma`, the cop requires a comma after the last item of all
|
5662
|
-
#
|
5733
|
+
# If `comma`, the cop requires a comma after the last item in a hash, but only when each item is
|
5734
|
+
# on its own line.
|
5735
|
+
# If `consistent_comma`, the cop requires a comma after the last item of all non-empty, multiline
|
5736
|
+
# hash literals.
|
5737
|
+
# If `diff_comma`, the cop requires a comma after the last item of all non-empty, multiline hash
|
5738
|
+
# literals, but only when that last item immediately precedes a newline.
|
5663
5739
|
EnforcedStyleForMultiline: no_comma
|
5664
5740
|
SupportedStylesForMultiline:
|
5665
5741
|
- comma
|
5666
5742
|
- consistent_comma
|
5743
|
+
- diff_comma
|
5667
5744
|
- no_comma
|
5668
5745
|
VersionAdded: '0.53'
|
5669
5746
|
|
data/config/internal_affairs.yml
CHANGED
@@ -6,6 +6,22 @@ InternalAffairs/CopDescription:
|
|
6
6
|
Include:
|
7
7
|
- 'lib/rubocop/cop/**/*.rb'
|
8
8
|
|
9
|
+
InternalAffairs/ExampleHeredocDelimiter:
|
10
|
+
Include:
|
11
|
+
- 'spec/rubocop/cop/**/*.rb'
|
12
|
+
|
13
|
+
InternalAffairs/ExampleDescription:
|
14
|
+
Include:
|
15
|
+
- 'spec/rubocop/cop/**/*.rb'
|
16
|
+
|
17
|
+
InternalAffairs/OnSendWithoutOnCSend:
|
18
|
+
Include:
|
19
|
+
- 'lib/rubocop/cop/**/*.rb'
|
20
|
+
|
21
|
+
InternalAffairs/UndefinedConfig:
|
22
|
+
Include:
|
23
|
+
- 'lib/rubocop/cop/**/*.rb'
|
24
|
+
|
9
25
|
InternalAffairs/UselessMessageAssertion:
|
10
26
|
Include:
|
11
27
|
- '**/*_spec.rb'
|
@@ -71,11 +71,11 @@ module RuboCop
|
|
71
71
|
|
72
72
|
warn Rainbow("\n#{pluralize(errors.size, 'error')} occurred:").red
|
73
73
|
|
74
|
-
errors.each { |error| warn error }
|
74
|
+
errors.each { |error| warn Rainbow(error).red }
|
75
75
|
|
76
|
-
warn <<~WARNING
|
76
|
+
warn Rainbow(<<~WARNING.strip).yellow
|
77
77
|
Errors are usually caused by RuboCop bugs.
|
78
|
-
Please,
|
78
|
+
Please, update to the latest RuboCop version if not already in use, and report a bug if the issue still occurs on this version.
|
79
79
|
#{bug_tracker_uri}
|
80
80
|
Mention the following information in the issue report:
|
81
81
|
#{RuboCop::Version.verbose}
|
@@ -9,11 +9,31 @@ module RuboCop
|
|
9
9
|
class ShowCops < Base
|
10
10
|
self.command_name = :show_cops
|
11
11
|
|
12
|
+
ExactMatcher = Struct.new(:pattern) do
|
13
|
+
def match?(name)
|
14
|
+
name == pattern
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
WildcardMatcher = Struct.new(:pattern) do
|
19
|
+
def match?(name)
|
20
|
+
File.fnmatch(pattern, name, File::FNM_PATHNAME)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
12
24
|
def initialize(env)
|
13
25
|
super
|
14
26
|
|
15
27
|
# Load the configs so the require()s are done for custom cops
|
16
28
|
@config = @config_store.for(Dir.pwd)
|
29
|
+
|
30
|
+
@cop_matchers = @options[:show_cops].map do |pattern|
|
31
|
+
if pattern.include?('*')
|
32
|
+
WildcardMatcher.new(pattern)
|
33
|
+
else
|
34
|
+
ExactMatcher.new(pattern)
|
35
|
+
end
|
36
|
+
end
|
17
37
|
end
|
18
38
|
|
19
39
|
def run
|
@@ -24,7 +44,7 @@ module RuboCop
|
|
24
44
|
|
25
45
|
def print_available_cops
|
26
46
|
registry = Cop::Registry.global
|
27
|
-
show_all = @
|
47
|
+
show_all = @cop_matchers.empty?
|
28
48
|
|
29
49
|
puts "# Available cops (#{registry.length}) + config for #{Dir.pwd}: " if show_all
|
30
50
|
|
@@ -56,7 +76,9 @@ module RuboCop
|
|
56
76
|
|
57
77
|
def selected_cops_of_department(cops, department)
|
58
78
|
cops_of_department(cops, department).select do |cop|
|
59
|
-
@
|
79
|
+
@cop_matchers.any? do |matcher|
|
80
|
+
matcher.match?(cop.cop_name)
|
81
|
+
end
|
60
82
|
end
|
61
83
|
end
|
62
84
|
|
@@ -97,7 +97,13 @@ module RuboCop
|
|
97
97
|
end
|
98
98
|
|
99
99
|
def loaded_extensions
|
100
|
-
@config_store.for_pwd
|
100
|
+
rubocop_config = @config_store.for_pwd
|
101
|
+
|
102
|
+
plugin_names = rubocop_config.loaded_plugins.map do |plugin|
|
103
|
+
plugin.about.name
|
104
|
+
end
|
105
|
+
|
106
|
+
plugin_names + rubocop_config.loaded_features.to_a
|
101
107
|
end
|
102
108
|
|
103
109
|
def installed_and_not_loaded_extensions
|
@@ -87,7 +87,7 @@ module RuboCop
|
|
87
87
|
next unless directive.enabled?
|
88
88
|
next if directive.all_cops?
|
89
89
|
|
90
|
-
cops.merge(directive.
|
90
|
+
cops.merge(directive.raw_cop_names)
|
91
91
|
end
|
92
92
|
cops
|
93
93
|
end
|
@@ -205,7 +205,7 @@ module RuboCop
|
|
205
205
|
directive.cop_names.each do |name|
|
206
206
|
if directive.disabled?
|
207
207
|
names[name] += 1
|
208
|
-
elsif
|
208
|
+
elsif names[name].positive?
|
209
209
|
names[name] -= 1
|
210
210
|
else
|
211
211
|
extras[directive.comment] << name
|
data/lib/rubocop/config.rb
CHANGED
@@ -16,6 +16,7 @@ module RuboCop
|
|
16
16
|
|
17
17
|
CopConfig = Struct.new(:name, :metadata)
|
18
18
|
|
19
|
+
EMPTY_CONFIG = {}.freeze
|
19
20
|
DEFAULT_RAILS_VERSION = 5.0
|
20
21
|
attr_reader :loaded_path
|
21
22
|
|
@@ -44,6 +45,10 @@ module RuboCop
|
|
44
45
|
end
|
45
46
|
# rubocop:enable Metrics/AbcSize
|
46
47
|
|
48
|
+
def loaded_plugins
|
49
|
+
@loaded_plugins ||= ConfigLoader.loaded_plugins
|
50
|
+
end
|
51
|
+
|
47
52
|
def loaded_features
|
48
53
|
@loaded_features ||= ConfigLoader.loaded_features
|
49
54
|
end
|
@@ -80,10 +85,7 @@ module RuboCop
|
|
80
85
|
|
81
86
|
def make_excludes_absolute
|
82
87
|
each_key do |key|
|
83
|
-
|
84
|
-
next unless self[key]['Exclude']
|
85
|
-
|
86
|
-
self[key]['Exclude'].map! do |exclude_elem|
|
88
|
+
dig(key, 'Exclude')&.map! do |exclude_elem|
|
87
89
|
if exclude_elem.is_a?(String) && !absolute?(exclude_elem)
|
88
90
|
File.expand_path(File.join(base_dir_for_path_parameters, exclude_elem))
|
89
91
|
else
|
@@ -123,6 +125,13 @@ module RuboCop
|
|
123
125
|
@for_cop[cop]
|
124
126
|
end
|
125
127
|
|
128
|
+
# @return [Config, Hash] for the given cop / cop name.
|
129
|
+
# If the given cop is enabled, returns its configuration hash.
|
130
|
+
# Otherwise, returns an empty hash.
|
131
|
+
def for_enabled_cop(cop)
|
132
|
+
cop_enabled?(cop) ? for_cop(cop) : EMPTY_CONFIG
|
133
|
+
end
|
134
|
+
|
126
135
|
# @return [Config] for the given cop merged with that of its department (if any)
|
127
136
|
# Note: the 'Enabled' attribute is same as that returned by `for_cop`
|
128
137
|
def for_badge(badge)
|
@@ -159,6 +168,10 @@ module RuboCop
|
|
159
168
|
@for_all_cops ||= self['AllCops'] || {}
|
160
169
|
end
|
161
170
|
|
171
|
+
def cop_enabled?(name)
|
172
|
+
!!for_cop(name)['Enabled']
|
173
|
+
end
|
174
|
+
|
162
175
|
def disabled_new_cops?
|
163
176
|
for_all_cops['NewCops'] == 'disable'
|
164
177
|
end
|
@@ -33,22 +33,33 @@ module RuboCop
|
|
33
33
|
attr_accessor :debug, :ignore_parent_exclusion, :disable_pending_cops, :enable_pending_cops,
|
34
34
|
:ignore_unrecognized_cops
|
35
35
|
attr_writer :default_configuration
|
36
|
-
attr_reader :loaded_features
|
36
|
+
attr_reader :loaded_plugins, :loaded_features
|
37
37
|
|
38
38
|
alias debug? debug
|
39
39
|
alias ignore_parent_exclusion? ignore_parent_exclusion
|
40
40
|
|
41
41
|
def clear_options
|
42
42
|
@debug = nil
|
43
|
+
@loaded_plugins = Set.new
|
43
44
|
@loaded_features = Set.new
|
45
|
+
@disable_pending_cops = nil
|
46
|
+
@enable_pending_cops = nil
|
47
|
+
@ignore_parent_exclusion = nil
|
48
|
+
@ignore_unrecognized_cops = nil
|
44
49
|
FileFinder.root_level = nil
|
45
50
|
end
|
46
51
|
|
52
|
+
# rubocop:disable Metrics/AbcSize
|
47
53
|
def load_file(file, check: true)
|
48
54
|
path = file_path(file)
|
49
55
|
|
50
56
|
hash = load_yaml_configuration(path)
|
51
57
|
|
58
|
+
rubocop_config = Config.create(hash, path, check: false)
|
59
|
+
plugins = hash.delete('plugins')
|
60
|
+
loaded_plugins = resolver.resolve_plugins(rubocop_config, plugins)
|
61
|
+
add_loaded_plugins(loaded_plugins)
|
62
|
+
|
52
63
|
loaded_features = resolver.resolve_requires(path, hash)
|
53
64
|
add_loaded_features(loaded_features)
|
54
65
|
|
@@ -63,6 +74,7 @@ module RuboCop
|
|
63
74
|
|
64
75
|
Config.create(hash, path, check: check)
|
65
76
|
end
|
77
|
+
# rubocop:enable Metrics/AbcSize
|
66
78
|
|
67
79
|
def load_yaml_configuration(absolute_path)
|
68
80
|
file_contents = read_file(absolute_path)
|
@@ -151,14 +163,35 @@ module RuboCop
|
|
151
163
|
end
|
152
164
|
end
|
153
165
|
|
154
|
-
#
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
166
|
+
# This API is primarily intended for testing and documenting plugins.
|
167
|
+
# When testing a plugin using `rubocop/rspec/support`, the plugin is loaded automatically,
|
168
|
+
# so this API is usually not needed. It is intended to be used only when implementing tests
|
169
|
+
# that do not use `rubocop/rspec/support`.
|
170
|
+
# rubocop:disable Metrics/MethodLength
|
171
|
+
def inject_defaults!(config_yml_path)
|
172
|
+
if Pathname(config_yml_path).directory?
|
173
|
+
# TODO: Since the warning noise is expected to be high until some time after the release,
|
174
|
+
# warnings will only be issued when `RUBYOPT=-w` is specified.
|
175
|
+
# To proceed step by step, the next step is to remove `$VERBOSE` and always issue warning.
|
176
|
+
# Eventually, `project_root` will no longer be accepted.
|
177
|
+
if $VERBOSE
|
178
|
+
warn Rainbow(<<~MESSAGE).yellow, uplevel: 1
|
179
|
+
Use config YAML file path instead of project root directory.
|
180
|
+
e.g., `path/to/config/default.yml`
|
181
|
+
MESSAGE
|
182
|
+
end
|
183
|
+
# NOTE: For compatibility.
|
184
|
+
project_root = config_yml_path
|
185
|
+
path = File.join(project_root, 'config', 'default.yml')
|
186
|
+
config = load_file(path)
|
187
|
+
else
|
188
|
+
hash = ConfigLoader.load_yaml_configuration(config_yml_path.to_s)
|
189
|
+
config = Config.new(hash, config_yml_path).tap(&:make_excludes_absolute)
|
190
|
+
end
|
191
|
+
|
192
|
+
@default_configuration = ConfigLoader.merge_with_default(config, path)
|
161
193
|
end
|
194
|
+
# rubocop:enable Metrics/MethodLength
|
162
195
|
|
163
196
|
# Returns the path RuboCop inferred as the root of the project. No file
|
164
197
|
# searches will go past this directory.
|
@@ -192,6 +225,13 @@ module RuboCop
|
|
192
225
|
resolver.merge_with_default(config, config_file, unset_nil: unset_nil)
|
193
226
|
end
|
194
227
|
|
228
|
+
# @api private
|
229
|
+
# Used to add plugins that were required inside a config or from
|
230
|
+
# the CLI using `--plugin`.
|
231
|
+
def add_loaded_plugins(loaded_plugins)
|
232
|
+
@loaded_plugins.merge(Array(loaded_plugins))
|
233
|
+
end
|
234
|
+
|
195
235
|
# @api private
|
196
236
|
# Used to add features that were required inside a config or from
|
197
237
|
# the CLI using `--require`.
|