rubocop 1.72.1 → 1.81.7
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 +22 -18
- data/config/default.yml +240 -65
- data/config/internal_affairs.yml +20 -0
- data/config/obsoletion.yml +8 -3
- data/exe/rubocop +1 -8
- data/lib/rubocop/cli/command/auto_generate_config.rb +2 -2
- data/lib/rubocop/cli.rb +19 -4
- data/lib/rubocop/config.rb +35 -6
- data/lib/rubocop/config_loader.rb +8 -40
- data/lib/rubocop/config_loader_resolver.rb +9 -7
- data/lib/rubocop/config_obsoletion/extracted_cop.rb +4 -3
- data/lib/rubocop/config_obsoletion/renamed_cop.rb +18 -3
- data/lib/rubocop/config_obsoletion.rb +46 -2
- data/lib/rubocop/config_store.rb +5 -0
- data/lib/rubocop/config_validator.rb +7 -6
- data/lib/rubocop/cop/autocorrect_logic.rb +22 -14
- data/lib/rubocop/cop/bundler/ordered_gems.rb +1 -1
- data/lib/rubocop/cop/correctors/alignment_corrector.rb +7 -4
- data/lib/rubocop/cop/correctors/for_to_each_corrector.rb +7 -2
- data/lib/rubocop/cop/correctors/parentheses_corrector.rb +5 -2
- data/lib/rubocop/cop/gemspec/attribute_assignment.rb +91 -0
- data/lib/rubocop/cop/gemspec/duplicated_assignment.rb +37 -15
- data/lib/rubocop/cop/gemspec/ordered_dependencies.rb +1 -1
- data/lib/rubocop/cop/gemspec/require_mfa.rb +15 -1
- data/lib/rubocop/cop/internal_affairs/example_description.rb +9 -5
- data/lib/rubocop/cop/internal_affairs/node_matcher_directive.rb +4 -4
- data/lib/rubocop/cop/internal_affairs/node_pattern_groups.rb +6 -2
- data/lib/rubocop/cop/internal_affairs/node_type_group.rb +92 -0
- data/lib/rubocop/cop/internal_affairs/on_send_without_on_csend.rb +1 -1
- data/lib/rubocop/cop/internal_affairs/redundant_described_class_as_subject.rb +6 -5
- data/lib/rubocop/cop/internal_affairs/undefined_config.rb +6 -1
- data/lib/rubocop/cop/internal_affairs/useless_restrict_on_send.rb +1 -1
- data/lib/rubocop/cop/internal_affairs.rb +1 -0
- data/lib/rubocop/cop/layout/block_alignment.rb +2 -2
- data/lib/rubocop/cop/layout/block_end_newline.rb +1 -0
- data/lib/rubocop/cop/layout/class_structure.rb +36 -1
- data/lib/rubocop/cop/layout/closing_parenthesis_indentation.rb +5 -5
- data/lib/rubocop/cop/layout/def_end_alignment.rb +1 -1
- data/lib/rubocop/cop/layout/dot_position.rb +1 -1
- data/lib/rubocop/cop/layout/else_alignment.rb +1 -1
- data/lib/rubocop/cop/layout/empty_line_after_guard_clause.rb +1 -1
- data/lib/rubocop/cop/layout/empty_line_between_defs.rb +32 -14
- data/lib/rubocop/cop/layout/empty_lines_after_module_inclusion.rb +101 -0
- data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +34 -4
- data/lib/rubocop/cop/layout/empty_lines_around_arguments.rb +8 -29
- data/lib/rubocop/cop/layout/empty_lines_around_block_body.rb +1 -0
- data/lib/rubocop/cop/layout/empty_lines_around_class_body.rb +1 -1
- data/lib/rubocop/cop/layout/first_argument_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/hash_alignment.rb +4 -7
- data/lib/rubocop/cop/layout/indentation_width.rb +1 -0
- data/lib/rubocop/cop/layout/leading_comment_space.rb +13 -1
- data/lib/rubocop/cop/layout/line_length.rb +43 -10
- data/lib/rubocop/cop/layout/multiline_block_layout.rb +1 -0
- data/lib/rubocop/cop/layout/multiline_method_parameter_line_breaks.rb +1 -0
- data/lib/rubocop/cop/layout/multiline_operation_indentation.rb +9 -5
- data/lib/rubocop/cop/layout/redundant_line_break.rb +9 -5
- data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +11 -5
- data/lib/rubocop/cop/layout/space_after_semicolon.rb +10 -0
- data/lib/rubocop/cop/layout/space_around_keyword.rb +6 -1
- data/lib/rubocop/cop/layout/space_around_operators.rb +12 -1
- data/lib/rubocop/cop/layout/space_before_block_braces.rb +1 -0
- data/lib/rubocop/cop/layout/space_before_brackets.rb +5 -38
- data/lib/rubocop/cop/layout/space_inside_array_literal_brackets.rb +12 -3
- data/lib/rubocop/cop/layout/space_inside_block_braces.rb +1 -0
- data/lib/rubocop/cop/layout/space_inside_hash_literal_braces.rb +3 -0
- data/lib/rubocop/cop/layout/trailing_whitespace.rb +1 -1
- data/lib/rubocop/cop/lint/ambiguous_range.rb +5 -0
- data/lib/rubocop/cop/lint/array_literal_in_regexp.rb +2 -3
- data/lib/rubocop/cop/lint/boolean_symbol.rb +1 -1
- data/lib/rubocop/cop/lint/circular_argument_reference.rb +2 -5
- data/lib/rubocop/cop/lint/constant_overwritten_in_rescue.rb +3 -2
- data/lib/rubocop/cop/lint/cop_directive_syntax.rb +13 -7
- data/lib/rubocop/cop/lint/debugger.rb +2 -4
- data/lib/rubocop/cop/lint/deprecated_class_methods.rb +1 -1
- data/lib/rubocop/cop/lint/deprecated_open_ssl_constant.rb +5 -2
- data/lib/rubocop/cop/lint/duplicate_methods.rb +111 -23
- data/lib/rubocop/cop/lint/duplicate_regexp_character_class_element.rb +5 -42
- data/lib/rubocop/cop/lint/empty_conditional_body.rb +14 -64
- data/lib/rubocop/cop/lint/empty_interpolation.rb +14 -1
- data/lib/rubocop/cop/lint/erb_new_arguments.rb +0 -6
- data/lib/rubocop/cop/lint/float_comparison.rb +32 -10
- data/lib/rubocop/cop/lint/identity_comparison.rb +19 -15
- data/lib/rubocop/cop/lint/literal_as_condition.rb +124 -10
- data/lib/rubocop/cop/lint/missing_cop_enable_directive.rb +17 -8
- data/lib/rubocop/cop/lint/mixed_case_range.rb +2 -2
- data/lib/rubocop/cop/lint/nested_method_definition.rb +1 -1
- data/lib/rubocop/cop/lint/non_local_exit_from_iterator.rb +3 -3
- data/lib/rubocop/cop/lint/numeric_operation_with_constant_result.rb +1 -0
- data/lib/rubocop/cop/lint/or_assignment_to_constant.rb +1 -1
- data/lib/rubocop/cop/lint/raise_exception.rb +29 -10
- 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_safe_navigation.rb +101 -2
- data/lib/rubocop/cop/lint/redundant_type_conversion.rb +43 -13
- data/lib/rubocop/cop/lint/redundant_with_index.rb +3 -0
- data/lib/rubocop/cop/lint/redundant_with_object.rb +3 -0
- data/lib/rubocop/cop/lint/require_range_parentheses.rb +1 -1
- data/lib/rubocop/cop/lint/rescue_exception.rb +1 -4
- data/lib/rubocop/cop/lint/rescue_type.rb +1 -1
- data/lib/rubocop/cop/lint/return_in_void_context.rb +9 -11
- data/lib/rubocop/cop/lint/safe_navigation_chain.rb +4 -4
- data/lib/rubocop/cop/lint/self_assignment.rb +31 -5
- data/lib/rubocop/cop/lint/shadowed_argument.rb +7 -7
- data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +13 -1
- data/lib/rubocop/cop/lint/shared_mutable_default.rb +12 -1
- data/lib/rubocop/cop/lint/suppressed_exception.rb +1 -1
- data/lib/rubocop/cop/lint/to_enum_arguments.rb +1 -1
- data/lib/rubocop/cop/lint/top_level_return_with_argument.rb +1 -1
- data/lib/rubocop/cop/lint/unexpected_block_arity.rb +2 -0
- data/lib/rubocop/cop/lint/unreachable_code.rb +1 -0
- data/lib/rubocop/cop/lint/unreachable_loop.rb +5 -5
- data/lib/rubocop/cop/lint/uri_escape_unescape.rb +2 -0
- data/lib/rubocop/cop/lint/useless_access_modifier.rb +30 -4
- data/lib/rubocop/cop/lint/useless_assignment.rb +2 -0
- data/lib/rubocop/cop/lint/useless_constant_scoping.rb +9 -12
- data/lib/rubocop/cop/lint/useless_default_value_argument.rb +90 -0
- data/lib/rubocop/cop/lint/useless_numeric_operation.rb +1 -0
- data/lib/rubocop/cop/lint/useless_or.rb +98 -0
- data/lib/rubocop/cop/lint/useless_rescue.rb +1 -1
- data/lib/rubocop/cop/lint/useless_ruby2_keywords.rb +3 -3
- data/lib/rubocop/cop/lint/utils/nil_receiver_checker.rb +121 -0
- data/lib/rubocop/cop/lint/void.rb +16 -2
- data/lib/rubocop/cop/message_annotator.rb +7 -3
- data/lib/rubocop/cop/metrics/abc_size.rb +1 -1
- data/lib/rubocop/cop/metrics/block_length.rb +1 -0
- data/lib/rubocop/cop/metrics/method_length.rb +1 -0
- data/lib/rubocop/cop/metrics/utils/code_length_calculator.rb +1 -1
- data/lib/rubocop/cop/mixin/alignment.rb +1 -1
- data/lib/rubocop/cop/mixin/allowed_pattern.rb +4 -4
- data/lib/rubocop/cop/mixin/check_line_breakable.rb +3 -3
- data/lib/rubocop/cop/mixin/check_single_line_suitability.rb +2 -2
- data/lib/rubocop/cop/mixin/def_node.rb +1 -1
- data/lib/rubocop/cop/mixin/empty_lines_around_body.rb +1 -1
- data/lib/rubocop/cop/mixin/end_keyword_alignment.rb +1 -7
- data/lib/rubocop/cop/mixin/forbidden_identifiers.rb +20 -0
- data/lib/rubocop/cop/mixin/forbidden_pattern.rb +16 -0
- data/lib/rubocop/cop/mixin/frozen_string_literal.rb +1 -2
- data/lib/rubocop/cop/mixin/gemspec_help.rb +22 -0
- data/lib/rubocop/cop/mixin/hash_alignment_styles.rb +15 -14
- data/lib/rubocop/cop/mixin/hash_subset.rb +19 -4
- data/lib/rubocop/cop/mixin/line_length_help.rb +24 -8
- data/lib/rubocop/cop/mixin/method_complexity.rb +1 -0
- data/lib/rubocop/cop/mixin/multiline_expression_indentation.rb +2 -0
- data/lib/rubocop/cop/mixin/ordered_gem_node.rb +1 -1
- data/lib/rubocop/cop/mixin/range_help.rb +12 -0
- data/lib/rubocop/cop/mixin/target_ruby_version.rb +1 -1
- data/lib/rubocop/cop/mixin/trailing_comma.rb +18 -2
- data/lib/rubocop/cop/naming/block_forwarding.rb +3 -3
- data/lib/rubocop/cop/naming/file_name.rb +2 -2
- data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +1 -1
- data/lib/rubocop/cop/naming/method_name.rb +187 -15
- data/lib/rubocop/cop/naming/predicate_method.rb +319 -0
- data/lib/rubocop/cop/naming/{predicate_name.rb → predicate_prefix.rb} +4 -4
- data/lib/rubocop/cop/naming/variable_name.rb +51 -6
- data/lib/rubocop/cop/registry.rb +9 -6
- data/lib/rubocop/cop/security/eval.rb +2 -1
- data/lib/rubocop/cop/security/json_load.rb +33 -11
- data/lib/rubocop/cop/security/open.rb +1 -0
- data/lib/rubocop/cop/style/access_modifier_declarations.rb +32 -10
- data/lib/rubocop/cop/style/accessor_grouping.rb +32 -6
- data/lib/rubocop/cop/style/arguments_forwarding.rb +21 -24
- data/lib/rubocop/cop/style/array_intersect.rb +113 -38
- data/lib/rubocop/cop/style/array_intersect_with_single_element.rb +47 -0
- data/lib/rubocop/cop/style/bitwise_predicate.rb +8 -1
- data/lib/rubocop/cop/style/block_delimiters.rb +3 -2
- data/lib/rubocop/cop/style/case_like_if.rb +1 -1
- data/lib/rubocop/cop/style/class_and_module_children.rb +48 -10
- data/lib/rubocop/cop/style/class_equality_comparison.rb +1 -1
- data/lib/rubocop/cop/style/collection_methods.rb +1 -0
- data/lib/rubocop/cop/style/collection_querying.rb +167 -0
- data/lib/rubocop/cop/style/combinable_loops.rb +1 -0
- data/lib/rubocop/cop/style/command_literal.rb +1 -1
- data/lib/rubocop/cop/style/commented_keyword.rb +12 -5
- data/lib/rubocop/cop/style/comparable_between.rb +78 -0
- data/lib/rubocop/cop/style/conditional_assignment.rb +26 -8
- data/lib/rubocop/cop/style/constant_visibility.rb +14 -9
- data/lib/rubocop/cop/style/data_inheritance.rb +7 -0
- data/lib/rubocop/cop/style/def_with_parentheses.rb +18 -5
- data/lib/rubocop/cop/style/dig_chain.rb +1 -1
- data/lib/rubocop/cop/style/double_negation.rb +3 -3
- data/lib/rubocop/cop/style/empty_literal.rb +4 -0
- data/lib/rubocop/cop/style/empty_string_inside_interpolation.rb +100 -0
- data/lib/rubocop/cop/style/endless_method.rb +176 -18
- data/lib/rubocop/cop/style/eval_with_location.rb +3 -3
- data/lib/rubocop/cop/style/expand_path_arguments.rb +2 -7
- data/lib/rubocop/cop/style/explicit_block_argument.rb +3 -3
- data/lib/rubocop/cop/style/exponential_notation.rb +5 -4
- data/lib/rubocop/cop/style/fetch_env_var.rb +32 -6
- data/lib/rubocop/cop/style/float_division.rb +15 -1
- data/lib/rubocop/cop/style/for.rb +1 -0
- data/lib/rubocop/cop/style/format_string_token.rb +38 -11
- data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +3 -2
- data/lib/rubocop/cop/style/global_std_stream.rb +3 -0
- data/lib/rubocop/cop/style/guard_clause.rb +2 -1
- data/lib/rubocop/cop/style/hash_conversion.rb +16 -8
- data/lib/rubocop/cop/style/hash_each_methods.rb +3 -2
- data/lib/rubocop/cop/style/hash_fetch_chain.rb +104 -0
- data/lib/rubocop/cop/style/hash_syntax.rb +4 -1
- 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 +3 -3
- data/lib/rubocop/cop/style/if_inside_else.rb +10 -13
- data/lib/rubocop/cop/style/if_unless_modifier.rb +35 -8
- data/lib/rubocop/cop/style/if_unless_modifier_of_if_unless.rb +4 -7
- data/lib/rubocop/cop/style/if_with_boolean_literal_branches.rb +1 -1
- data/lib/rubocop/cop/style/infinite_loop.rb +1 -1
- data/lib/rubocop/cop/style/inverse_methods.rb +10 -6
- data/lib/rubocop/cop/style/invertible_unless_condition.rb +2 -2
- data/lib/rubocop/cop/style/ip_addresses.rb +2 -2
- data/lib/rubocop/cop/style/it_assignment.rb +69 -12
- data/lib/rubocop/cop/style/it_block_parameter.rb +121 -0
- data/lib/rubocop/cop/style/keyword_parameters_order.rb +13 -7
- data/lib/rubocop/cop/style/lambda.rb +1 -0
- data/lib/rubocop/cop/style/lambda_call.rb +7 -2
- data/lib/rubocop/cop/style/line_end_concatenation.rb +10 -4
- data/lib/rubocop/cop/style/map_into_array.rb +4 -1
- data/lib/rubocop/cop/style/map_to_hash.rb +12 -3
- data/lib/rubocop/cop/style/map_to_set.rb +1 -3
- data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +9 -8
- data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +16 -0
- data/lib/rubocop/cop/style/method_called_on_do_end_block.rb +2 -1
- data/lib/rubocop/cop/style/min_max_comparison.rb +13 -5
- data/lib/rubocop/cop/style/multiline_block_chain.rb +2 -1
- data/lib/rubocop/cop/style/multiline_if_modifier.rb +2 -0
- data/lib/rubocop/cop/style/multiline_method_signature.rb +1 -9
- data/lib/rubocop/cop/style/next.rb +44 -0
- data/lib/rubocop/cop/style/nil_comparison.rb +9 -7
- data/lib/rubocop/cop/style/object_then.rb +1 -0
- data/lib/rubocop/cop/style/one_line_conditional.rb +17 -9
- data/lib/rubocop/cop/style/parallel_assignment.rb +32 -20
- data/lib/rubocop/cop/style/percent_q_literals.rb +1 -1
- data/lib/rubocop/cop/style/proc.rb +1 -0
- data/lib/rubocop/cop/style/raise_args.rb +8 -8
- data/lib/rubocop/cop/style/redundant_array_flatten.rb +50 -0
- data/lib/rubocop/cop/style/redundant_begin.rb +35 -0
- data/lib/rubocop/cop/style/redundant_condition.rb +57 -0
- data/lib/rubocop/cop/style/redundant_current_directory_in_path.rb +14 -4
- data/lib/rubocop/cop/style/redundant_exception.rb +1 -1
- data/lib/rubocop/cop/style/redundant_fetch_block.rb +1 -9
- data/lib/rubocop/cop/style/redundant_format.rb +79 -18
- data/lib/rubocop/cop/style/redundant_freeze.rb +2 -2
- data/lib/rubocop/cop/style/redundant_interpolation.rb +12 -3
- data/lib/rubocop/cop/style/redundant_line_continuation.rb +1 -4
- data/lib/rubocop/cop/style/redundant_parentheses.rb +73 -18
- data/lib/rubocop/cop/style/redundant_regexp_argument.rb +4 -0
- data/lib/rubocop/cop/style/redundant_regexp_escape.rb +8 -0
- data/lib/rubocop/cop/style/redundant_self.rb +9 -5
- data/lib/rubocop/cop/style/redundant_self_assignment.rb +1 -1
- data/lib/rubocop/cop/style/redundant_sort_by.rb +17 -1
- data/lib/rubocop/cop/style/regexp_literal.rb +1 -1
- data/lib/rubocop/cop/style/rescue_modifier.rb +3 -0
- data/lib/rubocop/cop/style/return_nil.rb +2 -2
- data/lib/rubocop/cop/style/safe_navigation.rb +61 -14
- data/lib/rubocop/cop/style/select_by_regexp.rb +4 -1
- data/lib/rubocop/cop/style/semicolon.rb +23 -7
- data/lib/rubocop/cop/style/single_line_do_end_block.rb +3 -1
- data/lib/rubocop/cop/style/single_line_methods.rb +10 -7
- data/lib/rubocop/cop/style/sole_nested_conditional.rb +75 -101
- data/lib/rubocop/cop/style/stabby_lambda_parentheses.rb +1 -1
- data/lib/rubocop/cop/style/string_concatenation.rb +18 -15
- data/lib/rubocop/cop/style/struct_inheritance.rb +8 -1
- data/lib/rubocop/cop/style/super_arguments.rb +1 -2
- data/lib/rubocop/cop/style/symbol_array.rb +1 -1
- data/lib/rubocop/cop/style/symbol_proc.rb +3 -1
- data/lib/rubocop/cop/style/top_level_method_definition.rb +1 -0
- data/lib/rubocop/cop/style/trailing_comma_in_arguments.rb +52 -1
- data/lib/rubocop/cop/style/trailing_comma_in_array_literal.rb +47 -6
- data/lib/rubocop/cop/style/trailing_comma_in_block_args.rb +1 -1
- 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/unless_else.rb +10 -9
- data/lib/rubocop/cop/team.rb +1 -1
- data/lib/rubocop/cop/util.rb +1 -1
- data/lib/rubocop/cop/utils/format_string.rb +15 -2
- data/lib/rubocop/cop/variable_force/assignment.rb +7 -3
- data/lib/rubocop/cop/variable_force/scope.rb +1 -1
- data/lib/rubocop/cop/variable_force/variable.rb +3 -8
- data/lib/rubocop/cop/variable_force.rb +26 -9
- data/lib/rubocop/cops_documentation_generator.rb +23 -7
- data/lib/rubocop/directive_comment.rb +1 -1
- data/lib/rubocop/ext/regexp_node.rb +0 -1
- data/lib/rubocop/formatter/disabled_config_formatter.rb +19 -5
- data/lib/rubocop/formatter/fuubar_style_formatter.rb +1 -1
- data/lib/rubocop/formatter/html_formatter.rb +1 -1
- data/lib/rubocop/formatter/markdown_formatter.rb +1 -0
- data/lib/rubocop/formatter/offense_count_formatter.rb +1 -1
- data/lib/rubocop/formatter/pacman_formatter.rb +2 -1
- data/lib/rubocop/lsp/diagnostic.rb +25 -24
- data/lib/rubocop/lsp/routes.rb +65 -9
- data/lib/rubocop/lsp/runtime.rb +5 -5
- data/lib/rubocop/lsp/server.rb +2 -2
- data/lib/rubocop/lsp/stdin_runner.rb +3 -17
- data/lib/rubocop/magic_comment.rb +8 -0
- data/lib/rubocop/pending_cops_reporter.rb +56 -0
- data/lib/rubocop/plugin/configuration_integrator.rb +2 -0
- data/lib/rubocop/plugin/load_error.rb +1 -1
- data/lib/rubocop/plugin.rb +9 -2
- data/lib/rubocop/result_cache.rb +14 -12
- data/lib/rubocop/rspec/cop_helper.rb +6 -1
- data/lib/rubocop/rspec/expect_offense.rb +9 -3
- data/lib/rubocop/rspec/shared_contexts.rb +34 -0
- data/lib/rubocop/rspec/support.rb +3 -0
- data/lib/rubocop/runner.rb +10 -4
- data/lib/rubocop/server/cache.rb +17 -12
- data/lib/rubocop/server/client_command/base.rb +10 -0
- data/lib/rubocop/server/client_command/exec.rb +2 -1
- data/lib/rubocop/server/client_command/start.rb +11 -1
- data/lib/rubocop/target_finder.rb +13 -9
- data/lib/rubocop/target_ruby.rb +11 -2
- data/lib/rubocop/version.rb +14 -7
- data/lib/rubocop.rb +17 -2
- data/lib/ruby_lsp/rubocop/addon.rb +25 -10
- data/lib/ruby_lsp/rubocop/runtime_adapter.rb +57 -5
- metadata +24 -8
- data/lib/rubocop/cop/utils/regexp_ranges.rb +0 -113
|
@@ -6,12 +6,13 @@ module RuboCop
|
|
|
6
6
|
# Checks for trailing comma in array literals.
|
|
7
7
|
# The configuration options are:
|
|
8
8
|
#
|
|
9
|
-
# * `consistent_comma`: Requires a comma after the
|
|
10
|
-
#
|
|
11
|
-
# * `comma`: Requires a comma after last item in an array,
|
|
12
|
-
#
|
|
13
|
-
# * `
|
|
14
|
-
#
|
|
9
|
+
# * `consistent_comma`: Requires a comma after the last item of all non-empty, multiline array
|
|
10
|
+
# literals.
|
|
11
|
+
# * `comma`: Requires a comma after the last item in an array, but only when each item is on
|
|
12
|
+
# its own line.
|
|
13
|
+
# * `diff_comma`: Requires a comma after the last item in an array, but only when that item is
|
|
14
|
+
# followed by an immediate newline, even if there is an inline comment on the same line.
|
|
15
|
+
# * `no_comma`: Does not require a comma after the last item in an array
|
|
15
16
|
#
|
|
16
17
|
# @example EnforcedStyleForMultiline: consistent_comma
|
|
17
18
|
# # bad
|
|
@@ -37,6 +38,14 @@ module RuboCop
|
|
|
37
38
|
# 2,
|
|
38
39
|
# ]
|
|
39
40
|
#
|
|
41
|
+
# # bad
|
|
42
|
+
# a = [1, 2,
|
|
43
|
+
# 3, 4]
|
|
44
|
+
#
|
|
45
|
+
# # good
|
|
46
|
+
# a = [1, 2,
|
|
47
|
+
# 3, 4,]
|
|
48
|
+
#
|
|
40
49
|
# @example EnforcedStyleForMultiline: comma
|
|
41
50
|
# # bad
|
|
42
51
|
# a = [1, 2,]
|
|
@@ -72,6 +81,38 @@ module RuboCop
|
|
|
72
81
|
# 2,
|
|
73
82
|
# ]
|
|
74
83
|
#
|
|
84
|
+
# @example EnforcedStyleForMultiline: diff_comma
|
|
85
|
+
# # bad
|
|
86
|
+
# a = [1, 2,]
|
|
87
|
+
#
|
|
88
|
+
# # good
|
|
89
|
+
# a = [1, 2]
|
|
90
|
+
#
|
|
91
|
+
# # good
|
|
92
|
+
# a = [
|
|
93
|
+
# 1, 2,
|
|
94
|
+
# 3,
|
|
95
|
+
# ]
|
|
96
|
+
#
|
|
97
|
+
# # good
|
|
98
|
+
# a = [
|
|
99
|
+
# 1, 2, 3,
|
|
100
|
+
# ]
|
|
101
|
+
#
|
|
102
|
+
# # good
|
|
103
|
+
# a = [
|
|
104
|
+
# 1,
|
|
105
|
+
# 2,
|
|
106
|
+
# ]
|
|
107
|
+
#
|
|
108
|
+
# # bad
|
|
109
|
+
# a = [1, 2,
|
|
110
|
+
# 3, 4,]
|
|
111
|
+
#
|
|
112
|
+
# # good
|
|
113
|
+
# a = [1, 2,
|
|
114
|
+
# 3, 4]
|
|
115
|
+
#
|
|
75
116
|
# @example EnforcedStyleForMultiline: no_comma (default)
|
|
76
117
|
# # bad
|
|
77
118
|
# a = [1, 2,]
|
|
@@ -6,12 +6,13 @@ module RuboCop
|
|
|
6
6
|
# Checks for trailing comma in hash literals.
|
|
7
7
|
# The configuration options are:
|
|
8
8
|
#
|
|
9
|
-
# * `consistent_comma`: Requires a comma after the
|
|
10
|
-
#
|
|
11
|
-
# * `comma`: Requires a comma after the last item in a hash,
|
|
12
|
-
#
|
|
13
|
-
# * `
|
|
14
|
-
#
|
|
9
|
+
# * `consistent_comma`: Requires a comma after the last item of all non-empty, multiline hash
|
|
10
|
+
# literals.
|
|
11
|
+
# * `comma`: Requires a comma after the last item in a hash, but only when each item is on its
|
|
12
|
+
# own line.
|
|
13
|
+
# * `diff_comma`: Requires a comma after the last item in a hash, but only when that item is
|
|
14
|
+
# followed by an immediate newline, even if there is an inline comment on the same line.
|
|
15
|
+
# * `no_comma`: Does not require a comma after the last item in a hash
|
|
15
16
|
#
|
|
16
17
|
# @example EnforcedStyleForMultiline: consistent_comma
|
|
17
18
|
#
|
|
@@ -38,6 +39,14 @@ module RuboCop
|
|
|
38
39
|
# bar: 2,
|
|
39
40
|
# }
|
|
40
41
|
#
|
|
42
|
+
# # bad
|
|
43
|
+
# a = { foo: 1, bar: 2,
|
|
44
|
+
# baz: 3, qux: 4 }
|
|
45
|
+
#
|
|
46
|
+
# # good
|
|
47
|
+
# a = { foo: 1, bar: 2,
|
|
48
|
+
# baz: 3, qux: 4, }
|
|
49
|
+
#
|
|
41
50
|
# @example EnforcedStyleForMultiline: comma
|
|
42
51
|
#
|
|
43
52
|
# # bad
|
|
@@ -74,6 +83,39 @@ module RuboCop
|
|
|
74
83
|
# bar: 2,
|
|
75
84
|
# }
|
|
76
85
|
#
|
|
86
|
+
# @example EnforcedStyleForMultiline: diff_comma
|
|
87
|
+
#
|
|
88
|
+
# # bad
|
|
89
|
+
# a = { foo: 1, bar: 2, }
|
|
90
|
+
#
|
|
91
|
+
# # good
|
|
92
|
+
# a = { foo: 1, bar: 2 }
|
|
93
|
+
#
|
|
94
|
+
# # good
|
|
95
|
+
# a = {
|
|
96
|
+
# foo: 1, bar: 2,
|
|
97
|
+
# qux: 3,
|
|
98
|
+
# }
|
|
99
|
+
#
|
|
100
|
+
# # good
|
|
101
|
+
# a = {
|
|
102
|
+
# foo: 1, bar: 2, qux: 3,
|
|
103
|
+
# }
|
|
104
|
+
#
|
|
105
|
+
# # good
|
|
106
|
+
# a = {
|
|
107
|
+
# foo: 1,
|
|
108
|
+
# bar: 2,
|
|
109
|
+
# }
|
|
110
|
+
#
|
|
111
|
+
# # bad
|
|
112
|
+
# a = { foo: 1, bar: 2,
|
|
113
|
+
# baz: 3, qux: 4, }
|
|
114
|
+
#
|
|
115
|
+
# # good
|
|
116
|
+
# a = { foo: 1, bar: 2,
|
|
117
|
+
# baz: 3, qux: 4 }
|
|
118
|
+
#
|
|
77
119
|
# @example EnforcedStyleForMultiline: no_comma (default)
|
|
78
120
|
#
|
|
79
121
|
# # bad
|
|
@@ -113,7 +113,7 @@ module RuboCop
|
|
|
113
113
|
private
|
|
114
114
|
|
|
115
115
|
def in_module_or_instance_eval?(node)
|
|
116
|
-
node.each_ancestor(:
|
|
116
|
+
node.each_ancestor(:any_block, :class, :sclass, :module).each do |pnode|
|
|
117
117
|
case pnode.type
|
|
118
118
|
when :class, :sclass
|
|
119
119
|
return false
|
|
@@ -20,7 +20,6 @@ module RuboCop
|
|
|
20
20
|
# # do a different thing...
|
|
21
21
|
# end
|
|
22
22
|
class UnlessElse < Base
|
|
23
|
-
include RangeHelp
|
|
24
23
|
extend AutoCorrector
|
|
25
24
|
|
|
26
25
|
MSG = 'Do not use `unless` with `else`. Rewrite these with the positive case first.'
|
|
@@ -29,25 +28,27 @@ module RuboCop
|
|
|
29
28
|
return unless node.unless? && node.else?
|
|
30
29
|
|
|
31
30
|
add_offense(node) do |corrector|
|
|
32
|
-
body_range = range_between_condition_and_else(node, node.condition)
|
|
33
|
-
else_range = range_between_else_and_end(node)
|
|
34
|
-
|
|
35
31
|
next if part_of_ignored_node?(node)
|
|
36
32
|
|
|
37
33
|
corrector.replace(node.loc.keyword, 'if')
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
|
|
35
|
+
body_range = range_between_condition_and_else(node)
|
|
36
|
+
else_range = range_between_else_and_end(node)
|
|
37
|
+
|
|
38
|
+
corrector.swap(body_range, else_range)
|
|
40
39
|
end
|
|
41
40
|
|
|
42
41
|
ignore_node(node)
|
|
43
42
|
end
|
|
44
43
|
|
|
45
|
-
def range_between_condition_and_else(node
|
|
46
|
-
|
|
44
|
+
def range_between_condition_and_else(node)
|
|
45
|
+
range = node.loc.begin ? node.loc.begin.end : node.condition.source_range
|
|
46
|
+
|
|
47
|
+
range.end.join(node.loc.else.begin)
|
|
47
48
|
end
|
|
48
49
|
|
|
49
50
|
def range_between_else_and_end(node)
|
|
50
|
-
|
|
51
|
+
node.loc.else.end.join(node.loc.end.begin)
|
|
51
52
|
end
|
|
52
53
|
end
|
|
53
54
|
end
|
data/lib/rubocop/cop/team.rb
CHANGED
data/lib/rubocop/cop/util.rb
CHANGED
|
@@ -5,8 +5,11 @@ module RuboCop
|
|
|
5
5
|
module Utils
|
|
6
6
|
# Parses {Kernel#sprintf} format strings.
|
|
7
7
|
class FormatString
|
|
8
|
+
# Escaping the `#` in `INTERPOLATION` and `TEMPLATE_NAME` is necessary to
|
|
9
|
+
# avoid a bug in Ruby 3.2.0
|
|
10
|
+
# See: https://bugs.ruby-lang.org/issues/19379
|
|
8
11
|
DIGIT_DOLLAR = /(?<arg_number>\d+)\$/.freeze
|
|
9
|
-
INTERPOLATION =
|
|
12
|
+
INTERPOLATION = /\#\{.*?\}/.freeze
|
|
10
13
|
FLAG = /[ #0+-]|#{DIGIT_DOLLAR}/.freeze
|
|
11
14
|
NUMBER_ARG = /\*#{DIGIT_DOLLAR}?/.freeze
|
|
12
15
|
NUMBER = /\d+|#{NUMBER_ARG}|#{INTERPOLATION}/.freeze
|
|
@@ -14,7 +17,7 @@ module RuboCop
|
|
|
14
17
|
PRECISION = /\.(?<precision>#{NUMBER}?)/.freeze
|
|
15
18
|
TYPE = /(?<type>[bBdiouxXeEfgGaAcps])/.freeze
|
|
16
19
|
NAME = /<(?<name>\w+)>/.freeze
|
|
17
|
-
TEMPLATE_NAME = /(
|
|
20
|
+
TEMPLATE_NAME = /(?<!\#)\{(?<name>\w+)\}/.freeze
|
|
18
21
|
|
|
19
22
|
SEQUENCE = /
|
|
20
23
|
% (?<type>%)
|
|
@@ -68,6 +71,16 @@ module RuboCop
|
|
|
68
71
|
name && @source.include?('{')
|
|
69
72
|
end
|
|
70
73
|
|
|
74
|
+
def variable_width?
|
|
75
|
+
!!width&.start_with?('*')
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def variable_width_argument_number
|
|
79
|
+
return unless variable_width?
|
|
80
|
+
|
|
81
|
+
width == '*' ? 1 : width.match(DIGIT_DOLLAR)['arg_number'].to_i
|
|
82
|
+
end
|
|
83
|
+
|
|
71
84
|
# Number of arguments required for the format sequence
|
|
72
85
|
def arity
|
|
73
86
|
@source.scan('*').count + 1
|
|
@@ -110,8 +110,13 @@ module RuboCop
|
|
|
110
110
|
end
|
|
111
111
|
|
|
112
112
|
def multiple_assignment_node
|
|
113
|
-
return nil unless node.parent
|
|
114
|
-
|
|
113
|
+
return nil unless (candidate_mlhs_node = node.parent)
|
|
114
|
+
|
|
115
|
+
# In `(foo, bar), *baz`, the splat node must be traversed as well.
|
|
116
|
+
candidate_mlhs_node = candidate_mlhs_node.parent if candidate_mlhs_node.splat_type?
|
|
117
|
+
|
|
118
|
+
return nil unless candidate_mlhs_node.mlhs_type?
|
|
119
|
+
return nil unless (grandparent_node = node.parent.parent)
|
|
115
120
|
if (node = find_multiple_assignment_node(grandparent_node))
|
|
116
121
|
return node
|
|
117
122
|
end
|
|
@@ -139,7 +144,6 @@ module RuboCop
|
|
|
139
144
|
|
|
140
145
|
def find_multiple_assignment_node(grandparent_node)
|
|
141
146
|
return unless grandparent_node.type == MULTIPLE_LEFT_HAND_SIDE_TYPE
|
|
142
|
-
return if grandparent_node.children.any?(&:splat_type?)
|
|
143
147
|
|
|
144
148
|
parent = grandparent_node.parent
|
|
145
149
|
return parent if parent.type == MULTIPLE_ASSIGNMENT_TYPE
|
|
@@ -6,8 +6,6 @@ module RuboCop
|
|
|
6
6
|
# A Variable represents existence of a local variable.
|
|
7
7
|
# This holds a variable declaration node and some states of the variable.
|
|
8
8
|
class Variable
|
|
9
|
-
extend NodePattern::Macros
|
|
10
|
-
|
|
11
9
|
VARIABLE_DECLARATION_TYPES = (VARIABLE_ASSIGNMENT_TYPES + ARGUMENT_DECLARATION_TYPES).freeze
|
|
12
10
|
|
|
13
11
|
attr_reader :name, :declaration_node, :scope, :assignments, :references, :captured_by_block
|
|
@@ -40,14 +38,11 @@ module RuboCop
|
|
|
40
38
|
|
|
41
39
|
def mark_last_as_reassigned!(assignment)
|
|
42
40
|
return if captured_by_block?
|
|
43
|
-
return
|
|
41
|
+
return unless assignment.branch == @assignments.last&.branch
|
|
44
42
|
|
|
45
43
|
@assignments.last&.reassigned!
|
|
46
44
|
end
|
|
47
45
|
|
|
48
|
-
# @!method candidate_condition?(node)
|
|
49
|
-
def_node_matcher :candidate_condition?, '[{if case case_match when}]'
|
|
50
|
-
|
|
51
46
|
def referenced?
|
|
52
47
|
!@references.empty?
|
|
53
48
|
end
|
|
@@ -84,7 +79,7 @@ module RuboCop
|
|
|
84
79
|
parent = parent.parent if parent&.begin_type?
|
|
85
80
|
return false if parent.nil?
|
|
86
81
|
|
|
87
|
-
parent.
|
|
82
|
+
parent.basic_conditional? && parent.modifier_form?
|
|
88
83
|
end
|
|
89
84
|
|
|
90
85
|
def capture_with_block!
|
|
@@ -112,7 +107,7 @@ module RuboCop
|
|
|
112
107
|
end
|
|
113
108
|
|
|
114
109
|
def method_argument?
|
|
115
|
-
argument? &&
|
|
110
|
+
argument? && @scope.node.any_def_type?
|
|
116
111
|
end
|
|
117
112
|
|
|
118
113
|
def block_argument?
|
|
@@ -54,7 +54,7 @@ module RuboCop
|
|
|
54
54
|
|
|
55
55
|
ZERO_ARITY_SUPER_TYPE = :zsuper
|
|
56
56
|
|
|
57
|
-
TWISTED_SCOPE_TYPES = %i[block numblock class sclass defs module].freeze
|
|
57
|
+
TWISTED_SCOPE_TYPES = %i[block numblock itblock class sclass defs module].freeze
|
|
58
58
|
SCOPE_TYPES = (TWISTED_SCOPE_TYPES + [:def]).freeze
|
|
59
59
|
|
|
60
60
|
SEND_TYPE = :send
|
|
@@ -71,6 +71,8 @@ module RuboCop
|
|
|
71
71
|
end
|
|
72
72
|
end
|
|
73
73
|
|
|
74
|
+
BRANCH_NODES = %i[if case case_match rescue].freeze
|
|
75
|
+
|
|
74
76
|
def variable_table
|
|
75
77
|
@variable_table ||= VariableTable.new(self)
|
|
76
78
|
end
|
|
@@ -236,11 +238,16 @@ module RuboCop
|
|
|
236
238
|
end
|
|
237
239
|
|
|
238
240
|
def process_loop(node)
|
|
239
|
-
if
|
|
241
|
+
if node.post_condition_loop?
|
|
240
242
|
# See the comment at the end of file for this behavior.
|
|
241
243
|
condition_node, body_node = *node
|
|
242
244
|
process_node(body_node)
|
|
243
245
|
process_node(condition_node)
|
|
246
|
+
elsif node.for_type?
|
|
247
|
+
# In `for item in items` the rightmost expression is evaluated first.
|
|
248
|
+
process_node(node.collection)
|
|
249
|
+
process_node(node.variable)
|
|
250
|
+
process_node(node.body) if node.body
|
|
244
251
|
else
|
|
245
252
|
process_children(node)
|
|
246
253
|
end
|
|
@@ -296,7 +303,7 @@ module RuboCop
|
|
|
296
303
|
variable_table.accessible_variables.each { |variable| variable.reference!(node) }
|
|
297
304
|
end
|
|
298
305
|
|
|
299
|
-
# Mark
|
|
306
|
+
# Mark last assignments which are referenced in the same loop
|
|
300
307
|
# as referenced by ignoring AST order since they would be referenced
|
|
301
308
|
# in next iteration.
|
|
302
309
|
def mark_assignments_as_referenced_in_loop(node)
|
|
@@ -308,13 +315,12 @@ module RuboCop
|
|
|
308
315
|
# would be skipped here.
|
|
309
316
|
next unless variable
|
|
310
317
|
|
|
311
|
-
variable.assignments.
|
|
312
|
-
|
|
313
|
-
assignment_node.equal?(assignment.node)
|
|
314
|
-
end
|
|
315
|
-
|
|
316
|
-
assignment.reference!(node)
|
|
318
|
+
loop_assignments = variable.assignments.select do |assignment|
|
|
319
|
+
assignment_nodes_in_loop.include?(assignment.node)
|
|
317
320
|
end
|
|
321
|
+
next unless loop_assignments.any?
|
|
322
|
+
|
|
323
|
+
reference_assignments(loop_assignments, node)
|
|
318
324
|
end
|
|
319
325
|
end
|
|
320
326
|
|
|
@@ -354,6 +360,17 @@ module RuboCop
|
|
|
354
360
|
end
|
|
355
361
|
end
|
|
356
362
|
|
|
363
|
+
def reference_assignments(loop_assignments, loop_node)
|
|
364
|
+
# If inside a branching statement, mark all as referenced.
|
|
365
|
+
# Otherwise, mark only the last assignment as referenced.
|
|
366
|
+
# Note that `rescue` must be considered as branching because of
|
|
367
|
+
# the `retry` keyword.
|
|
368
|
+
loop_assignments.each do |assignment|
|
|
369
|
+
assignment.reference!(loop_node) if assignment.node.each_ancestor(*BRANCH_NODES).any?
|
|
370
|
+
end
|
|
371
|
+
loop_assignments.last&.reference!(loop_node)
|
|
372
|
+
end
|
|
373
|
+
|
|
357
374
|
def scanned_node?(node)
|
|
358
375
|
scanned_nodes.include?(node)
|
|
359
376
|
end
|
|
@@ -7,6 +7,7 @@ require 'yard'
|
|
|
7
7
|
# @api private
|
|
8
8
|
class CopsDocumentationGenerator # rubocop:disable Metrics/ClassLength
|
|
9
9
|
include ::RuboCop::Cop::Documentation
|
|
10
|
+
|
|
10
11
|
CopData = Struct.new(
|
|
11
12
|
:cop, :description, :example_objects, :safety_objects, :see_objects, :config, keyword_init: true
|
|
12
13
|
)
|
|
@@ -28,6 +29,12 @@ class CopsDocumentationGenerator # rubocop:disable Metrics/ClassLength
|
|
|
28
29
|
#
|
|
29
30
|
# CopsDocumentationGenerator.new(departments: ['Lint']).call
|
|
30
31
|
#
|
|
32
|
+
# For plugin extensions, specify `:plugin_name` keyword as follows:
|
|
33
|
+
#
|
|
34
|
+
# CopsDocumentationGenerator.new(
|
|
35
|
+
# departments: ['Performance'], plugin_name: 'rubocop-performance'
|
|
36
|
+
# ).call
|
|
37
|
+
#
|
|
31
38
|
# You can append additional information:
|
|
32
39
|
#
|
|
33
40
|
# callback = ->(data) { required_rails_version(data.cop) }
|
|
@@ -36,11 +43,16 @@ class CopsDocumentationGenerator # rubocop:disable Metrics/ClassLength
|
|
|
36
43
|
# This will insert the string returned from the lambda _after_ the section from RuboCop itself.
|
|
37
44
|
# See `CopsDocumentationGenerator::STRUCTURE` for available sections.
|
|
38
45
|
#
|
|
39
|
-
def initialize(departments: [], extra_info: {}, base_dir: Dir.pwd)
|
|
46
|
+
def initialize(departments: [], extra_info: {}, base_dir: Dir.pwd, plugin_name: nil)
|
|
40
47
|
@departments = departments.map(&:to_sym).sort!
|
|
41
48
|
@extra_info = extra_info
|
|
42
49
|
@cops = RuboCop::Cop::Registry.global
|
|
43
50
|
@config = RuboCop::ConfigLoader.default_configuration
|
|
51
|
+
# NOTE: For example, this prevents excessive plugin loading before another task executes,
|
|
52
|
+
# in cases where plugins are already loaded by `internal_investigation`.
|
|
53
|
+
if plugin_name && @config.loaded_plugins.none? { |plugin| plugin.about.name == plugin_name }
|
|
54
|
+
RuboCop::Plugin.integrate_plugins(RuboCop::Config.new, [plugin_name])
|
|
55
|
+
end
|
|
44
56
|
@base_dir = base_dir
|
|
45
57
|
@docs_path = "#{base_dir}/docs/modules/ROOT"
|
|
46
58
|
FileUtils.mkdir_p("#{@docs_path}/pages")
|
|
@@ -182,10 +194,10 @@ class CopsDocumentationGenerator # rubocop:disable Metrics/ClassLength
|
|
|
182
194
|
|
|
183
195
|
def configurations(department, cop, cop_config)
|
|
184
196
|
header = ['Name', 'Default value', 'Configurable values']
|
|
185
|
-
configs = cop_config
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
197
|
+
configs = cop_config.each_key.reject do |key|
|
|
198
|
+
key == 'AllowMultipleStyles' ||
|
|
199
|
+
(key != 'SupportedTypes' && key.start_with?('Supported'))
|
|
200
|
+
end
|
|
189
201
|
return '' if configs.empty?
|
|
190
202
|
|
|
191
203
|
content = configs.map do |name|
|
|
@@ -316,8 +328,12 @@ class CopsDocumentationGenerator # rubocop:disable Metrics/ClassLength
|
|
|
316
328
|
def print_cop_with_doc(cop) # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
|
|
317
329
|
cop_config = config.for_cop(cop)
|
|
318
330
|
non_display_keys = %w[
|
|
319
|
-
|
|
320
|
-
|
|
331
|
+
Enabled
|
|
332
|
+
Description
|
|
333
|
+
StyleGuide
|
|
334
|
+
Reference References
|
|
335
|
+
Safe SafeAutoCorrect AutoCorrect
|
|
336
|
+
VersionAdded VersionChanged
|
|
321
337
|
]
|
|
322
338
|
parameters = cop_config.reject { |k| non_display_keys.include? k }
|
|
323
339
|
description = 'No documentation'
|
|
@@ -12,7 +12,7 @@ module RuboCop
|
|
|
12
12
|
# @api private
|
|
13
13
|
LINT_SYNTAX_COP = "#{LINT_DEPARTMENT}/Syntax"
|
|
14
14
|
# @api private
|
|
15
|
-
COP_NAME_PATTERN = '([A-
|
|
15
|
+
COP_NAME_PATTERN = '([A-Za-z]\w+/)*(?:[A-Za-z]\w+)'
|
|
16
16
|
# @api private
|
|
17
17
|
COP_NAMES_PATTERN = "(?:#{COP_NAME_PATTERN} , )*#{COP_NAME_PATTERN}"
|
|
18
18
|
# @api private
|
|
@@ -4,7 +4,7 @@ module RuboCop
|
|
|
4
4
|
module Formatter
|
|
5
5
|
# This formatter displays a YAML configuration file where all cops that
|
|
6
6
|
# detected any offenses are configured to not detect the offense.
|
|
7
|
-
class DisabledConfigFormatter < BaseFormatter
|
|
7
|
+
class DisabledConfigFormatter < BaseFormatter # rubocop:disable Metrics/ClassLength
|
|
8
8
|
include PathUtil
|
|
9
9
|
|
|
10
10
|
HEADING = <<~COMMENTS
|
|
@@ -17,6 +17,22 @@ module RuboCop
|
|
|
17
17
|
# versions of RuboCop, may require this file to be generated again.
|
|
18
18
|
COMMENTS
|
|
19
19
|
|
|
20
|
+
EXCLUDED_CONFIG_KEYS = %w[
|
|
21
|
+
AutoCorrect
|
|
22
|
+
Description
|
|
23
|
+
Enabled
|
|
24
|
+
Exclude
|
|
25
|
+
Include
|
|
26
|
+
Reference
|
|
27
|
+
References
|
|
28
|
+
Safe
|
|
29
|
+
SafeAutoCorrect
|
|
30
|
+
StyleGuide
|
|
31
|
+
VersionAdded
|
|
32
|
+
VersionChanged
|
|
33
|
+
VersionRemoved
|
|
34
|
+
].freeze
|
|
35
|
+
|
|
20
36
|
@config_to_allow_offenses = {}
|
|
21
37
|
@detected_styles = {}
|
|
22
38
|
|
|
@@ -163,10 +179,7 @@ module RuboCop
|
|
|
163
179
|
end
|
|
164
180
|
|
|
165
181
|
def cop_config_params(default_cfg, cfg)
|
|
166
|
-
default_cfg.keys -
|
|
167
|
-
%w[Description StyleGuide Reference Enabled Exclude Safe
|
|
168
|
-
SafeAutoCorrect VersionAdded VersionChanged VersionRemoved] -
|
|
169
|
-
cfg.keys
|
|
182
|
+
default_cfg.keys - EXCLUDED_CONFIG_KEYS - cfg.keys
|
|
170
183
|
end
|
|
171
184
|
|
|
172
185
|
def output_cop_param_comments(output_buffer, params, default_cfg)
|
|
@@ -178,6 +191,7 @@ module RuboCop
|
|
|
178
191
|
next unless value.is_a?(Array)
|
|
179
192
|
next if value.empty?
|
|
180
193
|
|
|
194
|
+
value.map! { |v| v.nil? ? '~' : v } # Change nil back to ~ as in the YAML file.
|
|
181
195
|
output_buffer.puts "# #{param}: #{value.uniq.join(', ')}"
|
|
182
196
|
end
|
|
183
197
|
end
|
|
@@ -9,6 +9,7 @@ module RuboCop
|
|
|
9
9
|
# https://github.com/go-labs/rspec_pacman_formatter
|
|
10
10
|
class PacmanFormatter < ClangStyleFormatter
|
|
11
11
|
include TextUtil
|
|
12
|
+
|
|
12
13
|
attr_accessor :progress_line
|
|
13
14
|
|
|
14
15
|
FALLBACK_TERMINAL_WIDTH = 80
|
|
@@ -58,7 +59,7 @@ module RuboCop
|
|
|
58
59
|
return pacdots(@total_files) unless @total_files > cols
|
|
59
60
|
return pacdots(cols) unless (@total_files / cols).eql?(@repetitions)
|
|
60
61
|
|
|
61
|
-
pacdots(
|
|
62
|
+
pacdots(@total_files - (cols * @repetitions))
|
|
62
63
|
end
|
|
63
64
|
|
|
64
65
|
def pacdots(number)
|