rubocop 1.79.2 → 1.87.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/LICENSE.txt +1 -1
- data/README.md +2 -2
- data/config/default.yml +185 -20
- data/config/obsoletion.yml +9 -0
- data/exe/rubocop +1 -8
- data/lib/rubocop/cache_config.rb +29 -0
- data/lib/rubocop/cli/command/auto_generate_config.rb +30 -4
- data/lib/rubocop/cli/command/list_enabled_cops_for.rb +40 -0
- data/lib/rubocop/cli/command/lsp.rb +1 -1
- data/lib/rubocop/cli/command/mcp.rb +19 -0
- data/lib/rubocop/cli/command/show_cops.rb +2 -2
- data/lib/rubocop/cli/command/show_docs_url.rb +4 -8
- data/lib/rubocop/cli/command/suggest_extensions.rb +1 -1
- data/lib/rubocop/cli.rb +35 -9
- data/lib/rubocop/comment_config.rb +59 -17
- data/lib/rubocop/config.rb +14 -10
- data/lib/rubocop/config_finder.rb +1 -1
- data/lib/rubocop/config_loader.rb +37 -23
- data/lib/rubocop/config_loader_resolver.rb +20 -10
- data/lib/rubocop/config_obsoletion/extracted_cop.rb +4 -2
- data/lib/rubocop/config_store.rb +7 -2
- data/lib/rubocop/config_validator.rb +1 -1
- data/lib/rubocop/cop/autocorrect_logic.rb +10 -5
- data/lib/rubocop/cop/base.rb +8 -2
- data/lib/rubocop/cop/bundler/gem_version.rb +28 -28
- data/lib/rubocop/cop/bundler/ordered_gems.rb +1 -2
- data/lib/rubocop/cop/correctors/alignment_corrector.rb +26 -7
- data/lib/rubocop/cop/correctors/condition_corrector.rb +1 -1
- data/lib/rubocop/cop/correctors/for_to_each_corrector.rb +7 -2
- data/lib/rubocop/cop/correctors/multiline_literal_brace_corrector.rb +1 -5
- data/lib/rubocop/cop/correctors/parentheses_corrector.rb +33 -2
- data/lib/rubocop/cop/correctors/percent_literal_corrector.rb +2 -2
- data/lib/rubocop/cop/correctors.rb +28 -0
- data/lib/rubocop/cop/documentation.rb +2 -3
- data/lib/rubocop/cop/exclude_limit.rb +31 -5
- data/lib/rubocop/cop/gemspec/duplicated_assignment.rb +2 -2
- data/lib/rubocop/cop/gemspec/ordered_dependencies.rb +1 -2
- data/lib/rubocop/cop/gemspec/require_mfa.rb +5 -5
- data/lib/rubocop/cop/gemspec/ruby_version_globals_usage.rb +12 -7
- data/lib/rubocop/cop/internal_affairs/example_heredoc_delimiter.rb +8 -8
- data/lib/rubocop/cop/internal_affairs/itblock_handler.rb +69 -0
- data/lib/rubocop/cop/internal_affairs/location_exists.rb +28 -2
- data/lib/rubocop/cop/internal_affairs/location_line_equality_comparison.rb +1 -0
- data/lib/rubocop/cop/internal_affairs/node_matcher_directive.rb +9 -9
- data/lib/rubocop/cop/internal_affairs/node_pattern_groups/ast_processor.rb +1 -1
- data/lib/rubocop/cop/internal_affairs/node_pattern_groups.rb +3 -1
- data/lib/rubocop/cop/internal_affairs/on_send_without_on_csend.rb +1 -1
- data/lib/rubocop/cop/internal_affairs/useless_message_assertion.rb +4 -4
- data/lib/rubocop/cop/internal_affairs.rb +1 -0
- data/lib/rubocop/cop/layout/argument_alignment.rb +2 -2
- data/lib/rubocop/cop/layout/array_alignment.rb +1 -1
- data/lib/rubocop/cop/layout/begin_end_alignment.rb +1 -1
- data/lib/rubocop/cop/layout/case_indentation.rb +3 -1
- data/lib/rubocop/cop/layout/class_structure.rb +14 -7
- data/lib/rubocop/cop/layout/dot_position.rb +2 -2
- data/lib/rubocop/cop/layout/empty_line_after_guard_clause.rb +26 -7
- data/lib/rubocop/cop/layout/empty_line_between_defs.rb +31 -13
- data/lib/rubocop/cop/layout/empty_lines_after_module_inclusion.rb +2 -2
- data/lib/rubocop/cop/layout/empty_lines_around_attribute_accessor.rb +1 -0
- data/lib/rubocop/cop/layout/empty_lines_around_block_body.rb +12 -2
- data/lib/rubocop/cop/layout/empty_lines_around_class_body.rb +16 -2
- data/lib/rubocop/cop/layout/empty_lines_around_module_body.rb +16 -2
- data/lib/rubocop/cop/layout/end_alignment.rb +10 -3
- data/lib/rubocop/cop/layout/first_argument_indentation.rb +34 -1
- data/lib/rubocop/cop/layout/first_array_element_line_break.rb +26 -0
- data/lib/rubocop/cop/layout/first_hash_element_indentation.rb +7 -1
- data/lib/rubocop/cop/layout/first_hash_element_line_break.rb +25 -25
- data/lib/rubocop/cop/layout/hash_alignment.rb +3 -6
- data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +2 -2
- data/lib/rubocop/cop/layout/heredoc_indentation.rb +33 -3
- data/lib/rubocop/cop/layout/indentation_style.rb +1 -1
- data/lib/rubocop/cop/layout/indentation_width.rb +123 -7
- data/lib/rubocop/cop/layout/line_continuation_spacing.rb +1 -1
- data/lib/rubocop/cop/layout/line_length.rb +26 -9
- data/lib/rubocop/cop/layout/multiline_array_brace_layout.rb +57 -57
- data/lib/rubocop/cop/layout/multiline_assignment_layout.rb +9 -2
- data/lib/rubocop/cop/layout/multiline_block_layout.rb +2 -0
- data/lib/rubocop/cop/layout/multiline_hash_brace_layout.rb +56 -56
- data/lib/rubocop/cop/layout/multiline_method_call_brace_layout.rb +1 -1
- data/lib/rubocop/cop/layout/multiline_method_call_indentation.rb +229 -39
- data/lib/rubocop/cop/layout/multiline_operation_indentation.rb +8 -4
- data/lib/rubocop/cop/layout/parameter_alignment.rb +1 -1
- data/lib/rubocop/cop/layout/redundant_line_break.rb +3 -1
- data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +13 -3
- data/lib/rubocop/cop/layout/space_after_comma.rb +2 -10
- data/lib/rubocop/cop/layout/space_after_semicolon.rb +1 -1
- data/lib/rubocop/cop/layout/space_around_block_parameters.rb +1 -1
- data/lib/rubocop/cop/layout/space_around_keyword.rb +4 -2
- data/lib/rubocop/cop/layout/space_before_brackets.rb +1 -1
- data/lib/rubocop/cop/layout/space_in_lambda_literal.rb +9 -8
- data/lib/rubocop/cop/layout/trailing_whitespace.rb +1 -1
- data/lib/rubocop/cop/lint/ambiguous_block_association.rb +1 -1
- data/lib/rubocop/cop/lint/circular_argument_reference.rb +47 -3
- data/lib/rubocop/cop/lint/constant_overwritten_in_rescue.rb +4 -3
- data/lib/rubocop/cop/lint/constant_reassignment.rb +93 -11
- data/lib/rubocop/cop/lint/constant_resolution.rb +6 -6
- data/lib/rubocop/cop/lint/cop_directive_syntax.rb +14 -8
- data/lib/rubocop/cop/lint/data_define_override.rb +63 -0
- data/lib/rubocop/cop/lint/debugger.rb +0 -2
- data/lib/rubocop/cop/lint/deprecated_constants.rb +1 -1
- data/lib/rubocop/cop/lint/deprecated_open_ssl_constant.rb +4 -1
- data/lib/rubocop/cop/lint/duplicate_match_pattern.rb +4 -4
- data/lib/rubocop/cop/lint/duplicate_methods.rb +111 -12
- data/lib/rubocop/cop/lint/duplicate_regexp_character_class_element.rb +5 -42
- data/lib/rubocop/cop/lint/else_layout.rb +19 -0
- data/lib/rubocop/cop/lint/empty_block.rb +1 -1
- data/lib/rubocop/cop/lint/empty_conditional_body.rb +6 -1
- data/lib/rubocop/cop/lint/empty_in_pattern.rb +8 -1
- data/lib/rubocop/cop/lint/empty_interpolation.rb +11 -0
- data/lib/rubocop/cop/lint/empty_when.rb +8 -1
- data/lib/rubocop/cop/lint/erb_new_arguments.rb +1 -1
- data/lib/rubocop/cop/lint/float_comparison.rb +1 -1
- data/lib/rubocop/cop/lint/interpolation_check.rb +7 -2
- data/lib/rubocop/cop/lint/literal_as_condition.rb +5 -1
- data/lib/rubocop/cop/lint/literal_in_interpolation.rb +1 -1
- data/lib/rubocop/cop/lint/missing_cop_enable_directive.rb +18 -9
- data/lib/rubocop/cop/lint/multiple_comparison.rb +2 -2
- data/lib/rubocop/cop/lint/next_without_accumulator.rb +2 -0
- data/lib/rubocop/cop/lint/no_return_in_begin_end_blocks.rb +4 -0
- data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +4 -2
- data/lib/rubocop/cop/lint/number_conversion.rb +6 -6
- data/lib/rubocop/cop/lint/numbered_parameter_assignment.rb +1 -1
- data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +3 -13
- data/lib/rubocop/cop/lint/redundant_cop_disable_directive.rb +23 -9
- data/lib/rubocop/cop/lint/redundant_cop_enable_directive.rb +2 -11
- data/lib/rubocop/cop/lint/redundant_require_statement.rb +4 -2
- data/lib/rubocop/cop/lint/redundant_safe_navigation.rb +23 -6
- data/lib/rubocop/cop/lint/redundant_splat_expansion.rb +8 -2
- data/lib/rubocop/cop/lint/redundant_type_conversion.rb +3 -3
- data/lib/rubocop/cop/lint/require_relative_self_path.rb +3 -1
- data/lib/rubocop/cop/lint/rescue_exception.rb +1 -4
- data/lib/rubocop/cop/lint/safe_navigation_chain.rb +17 -0
- data/lib/rubocop/cop/lint/safe_navigation_consistency.rb +7 -1
- data/lib/rubocop/cop/lint/self_assignment.rb +15 -6
- data/lib/rubocop/cop/lint/shadowed_argument.rb +7 -7
- data/lib/rubocop/cop/lint/shadowed_exception.rb +1 -1
- data/lib/rubocop/cop/lint/struct_new_override.rb +17 -1
- data/lib/rubocop/cop/lint/syntax.rb +25 -1
- data/lib/rubocop/cop/lint/to_json.rb +12 -16
- data/lib/rubocop/cop/lint/trailing_comma_in_attribute_declaration.rb +1 -0
- data/lib/rubocop/cop/lint/unescaped_bracket_in_regexp.rb +1 -1
- data/lib/rubocop/cop/lint/unmodified_reduce_accumulator.rb +1 -0
- data/lib/rubocop/cop/lint/unreachable_code.rb +7 -5
- data/lib/rubocop/cop/lint/unreachable_pattern_branch.rb +113 -0
- data/lib/rubocop/cop/lint/unused_method_argument.rb +10 -0
- data/lib/rubocop/cop/lint/uri_escape_unescape.rb +2 -0
- data/lib/rubocop/cop/lint/useless_assignment.rb +48 -25
- data/lib/rubocop/cop/lint/useless_constant_scoping.rb +4 -4
- data/lib/rubocop/cop/lint/useless_default_value_argument.rb +2 -0
- data/lib/rubocop/cop/lint/useless_or.rb +15 -2
- data/lib/rubocop/cop/lint/useless_ruby2_keywords.rb +1 -1
- data/lib/rubocop/cop/lint/utils/nil_receiver_checker.rb +37 -11
- data/lib/rubocop/cop/lint/void.rb +39 -12
- data/lib/rubocop/cop/message_annotator.rb +1 -1
- data/lib/rubocop/cop/metrics/block_length.rb +1 -1
- data/lib/rubocop/cop/metrics/block_nesting.rb +23 -0
- data/lib/rubocop/cop/metrics/method_length.rb +1 -1
- data/lib/rubocop/cop/metrics/utils/abc_size_calculator.rb +4 -3
- data/lib/rubocop/cop/metrics/utils/iterating_block.rb +1 -1
- data/lib/rubocop/cop/migration/department_name.rb +12 -1
- data/lib/rubocop/cop/mixin/check_line_breakable.rb +2 -2
- data/lib/rubocop/cop/mixin/check_single_line_suitability.rb +4 -6
- data/lib/rubocop/cop/mixin/code_length.rb +1 -1
- data/lib/rubocop/cop/mixin/configurable_max.rb +6 -5
- data/lib/rubocop/cop/mixin/end_keyword_alignment.rb +1 -7
- data/lib/rubocop/cop/mixin/hash_shorthand_syntax.rb +5 -5
- data/lib/rubocop/cop/mixin/hash_transform_method/autocorrection.rb +63 -0
- data/lib/rubocop/cop/mixin/hash_transform_method.rb +10 -60
- data/lib/rubocop/cop/mixin/line_length_help.rb +21 -2
- data/lib/rubocop/cop/mixin/method_complexity.rb +1 -1
- data/lib/rubocop/cop/mixin/multiline_expression_indentation.rb +1 -1
- data/lib/rubocop/cop/mixin/multiline_literal_brace_layout.rb +1 -1
- data/lib/rubocop/cop/mixin/project_index_help.rb +48 -0
- data/lib/rubocop/cop/mixin/space_after_punctuation.rb +5 -4
- data/lib/rubocop/cop/mixin/statement_modifier.rb +0 -6
- data/lib/rubocop/cop/mixin/trailing_comma.rb +8 -5
- data/lib/rubocop/cop/mixin.rb +86 -0
- data/lib/rubocop/cop/naming/binary_operator_parameter_name.rb +1 -1
- data/lib/rubocop/cop/naming/block_parameter_name.rb +1 -1
- data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +1 -1
- data/lib/rubocop/cop/naming/method_name.rb +5 -3
- data/lib/rubocop/cop/naming/predicate_method.rb +32 -8
- data/lib/rubocop/cop/naming/predicate_prefix.rb +12 -12
- data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +1 -1
- data/lib/rubocop/cop/offense.rb +17 -1
- data/lib/rubocop/cop/registry.rb +62 -38
- data/lib/rubocop/cop/security/eval.rb +15 -2
- data/lib/rubocop/cop/security/io_methods.rb +1 -1
- data/lib/rubocop/cop/security/json_load.rb +33 -11
- data/lib/rubocop/cop/style/access_modifier_declarations.rb +15 -4
- data/lib/rubocop/cop/style/accessor_grouping.rb +4 -2
- data/lib/rubocop/cop/style/alias.rb +14 -2
- data/lib/rubocop/cop/style/and_or.rb +1 -0
- data/lib/rubocop/cop/style/arguments_forwarding.rb +25 -7
- data/lib/rubocop/cop/style/array_intersect.rb +46 -12
- data/lib/rubocop/cop/style/array_intersect_with_single_element.rb +47 -0
- data/lib/rubocop/cop/style/array_join.rb +4 -2
- data/lib/rubocop/cop/style/ascii_comments.rb +6 -3
- data/lib/rubocop/cop/style/attr.rb +5 -2
- data/lib/rubocop/cop/style/bare_percent_literals.rb +4 -3
- data/lib/rubocop/cop/style/begin_block.rb +3 -1
- data/lib/rubocop/cop/style/bitwise_predicate.rb +8 -1
- data/lib/rubocop/cop/style/block_delimiters.rb +27 -34
- data/lib/rubocop/cop/style/case_equality.rb +15 -13
- data/lib/rubocop/cop/style/character_literal.rb +2 -2
- data/lib/rubocop/cop/style/class_and_module_children.rb +19 -2
- data/lib/rubocop/cop/style/collection_compact.rb +36 -16
- data/lib/rubocop/cop/style/colon_method_call.rb +3 -1
- data/lib/rubocop/cop/style/concat_array_literals.rb +2 -0
- data/lib/rubocop/cop/style/conditional_assignment.rb +8 -18
- data/lib/rubocop/cop/style/constant_visibility.rb +17 -12
- data/lib/rubocop/cop/style/copyright.rb +22 -11
- data/lib/rubocop/cop/style/date_time.rb +2 -2
- data/lib/rubocop/cop/style/disable_cops_within_source_code_directive.rb +1 -1
- data/lib/rubocop/cop/style/document_dynamic_eval_definition.rb +6 -1
- data/lib/rubocop/cop/style/documentation.rb +6 -6
- data/lib/rubocop/cop/style/documentation_method.rb +8 -8
- data/lib/rubocop/cop/style/double_negation.rb +1 -1
- data/lib/rubocop/cop/style/each_for_simple_loop.rb +1 -1
- data/lib/rubocop/cop/style/each_with_object.rb +2 -0
- data/lib/rubocop/cop/style/empty_block_parameter.rb +1 -1
- data/lib/rubocop/cop/style/empty_class_definition.rb +119 -0
- data/lib/rubocop/cop/style/empty_lambda_parameter.rb +1 -1
- data/lib/rubocop/cop/style/empty_method.rb +0 -6
- data/lib/rubocop/cop/style/encoding.rb +7 -1
- data/lib/rubocop/cop/style/end_block.rb +3 -1
- data/lib/rubocop/cop/style/endless_method.rb +23 -5
- data/lib/rubocop/cop/style/explicit_block_argument.rb +1 -1
- data/lib/rubocop/cop/style/file_open.rb +84 -0
- data/lib/rubocop/cop/style/file_write.rb +18 -16
- data/lib/rubocop/cop/style/float_division.rb +15 -1
- data/lib/rubocop/cop/style/for.rb +3 -0
- data/lib/rubocop/cop/style/format_string.rb +4 -3
- data/lib/rubocop/cop/style/format_string_token.rb +49 -5
- data/lib/rubocop/cop/style/global_vars.rb +5 -2
- data/lib/rubocop/cop/style/guard_clause.rb +27 -22
- data/lib/rubocop/cop/style/hash_as_last_array_item.rb +27 -9
- data/lib/rubocop/cop/style/hash_conversion.rb +1 -1
- data/lib/rubocop/cop/style/hash_lookup_method.rb +106 -0
- data/lib/rubocop/cop/style/hash_syntax.rb +1 -1
- data/lib/rubocop/cop/style/hash_transform_keys.rb +17 -7
- data/lib/rubocop/cop/style/hash_transform_values.rb +17 -7
- data/lib/rubocop/cop/style/if_inside_else.rb +16 -7
- data/lib/rubocop/cop/style/if_unless_modifier.rb +57 -17
- data/lib/rubocop/cop/style/if_unless_modifier_of_if_unless.rb +12 -12
- data/lib/rubocop/cop/style/if_with_boolean_literal_branches.rb +4 -1
- data/lib/rubocop/cop/style/if_with_semicolon.rb +7 -5
- data/lib/rubocop/cop/style/infinite_loop.rb +1 -1
- data/lib/rubocop/cop/style/inline_comment.rb +4 -1
- data/lib/rubocop/cop/style/ip_addresses.rb +1 -2
- data/lib/rubocop/cop/style/lambda_call.rb +8 -8
- data/lib/rubocop/cop/style/magic_comment_format.rb +3 -3
- data/lib/rubocop/cop/style/map_join.rb +123 -0
- data/lib/rubocop/cop/style/method_call_with_args_parentheses/require_parentheses.rb +15 -2
- data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +17 -4
- data/lib/rubocop/cop/style/method_def_parentheses.rb +2 -4
- data/lib/rubocop/cop/style/min_max_comparison.rb +1 -1
- data/lib/rubocop/cop/style/module_member_existence_check.rb +110 -0
- data/lib/rubocop/cop/style/multiline_if_then.rb +4 -4
- data/lib/rubocop/cop/style/multiline_method_signature.rb +2 -4
- data/lib/rubocop/cop/style/mutable_constant.rb +1 -1
- data/lib/rubocop/cop/style/negative_array_index.rb +220 -0
- data/lib/rubocop/cop/style/nil_comparison.rb +11 -10
- data/lib/rubocop/cop/style/nil_lambda.rb +1 -1
- data/lib/rubocop/cop/style/non_nil_check.rb +5 -11
- data/lib/rubocop/cop/style/not.rb +2 -0
- data/lib/rubocop/cop/style/numeric_literals.rb +3 -2
- data/lib/rubocop/cop/style/one_class_per_file.rb +115 -0
- data/lib/rubocop/cop/style/one_line_conditional.rb +21 -12
- data/lib/rubocop/cop/style/operator_method_call.rb +11 -2
- data/lib/rubocop/cop/style/parallel_assignment.rb +6 -2
- data/lib/rubocop/cop/style/partition_instead_of_double_select.rb +270 -0
- data/lib/rubocop/cop/style/percent_literal_delimiters.rb +2 -0
- data/lib/rubocop/cop/style/predicate_with_kind.rb +84 -0
- data/lib/rubocop/cop/style/preferred_hash_methods.rb +12 -12
- data/lib/rubocop/cop/style/proc.rb +3 -2
- data/lib/rubocop/cop/style/raise_args.rb +1 -1
- data/lib/rubocop/cop/style/reduce_to_hash.rb +200 -0
- data/lib/rubocop/cop/style/redundant_argument.rb +2 -0
- data/lib/rubocop/cop/style/redundant_array_constructor.rb +2 -2
- data/lib/rubocop/cop/style/redundant_begin.rb +37 -3
- data/lib/rubocop/cop/style/redundant_condition.rb +6 -3
- data/lib/rubocop/cop/style/redundant_constant_base.rb +5 -5
- data/lib/rubocop/cop/style/redundant_each.rb +3 -3
- data/lib/rubocop/cop/style/redundant_exception.rb +1 -1
- data/lib/rubocop/cop/style/redundant_fetch_block.rb +1 -1
- data/lib/rubocop/cop/style/redundant_format.rb +26 -5
- data/lib/rubocop/cop/style/redundant_interpolation.rb +11 -2
- data/lib/rubocop/cop/style/redundant_interpolation_unfreeze.rb +26 -10
- data/lib/rubocop/cop/style/redundant_line_continuation.rb +16 -0
- data/lib/rubocop/cop/style/redundant_min_max_by.rb +93 -0
- data/lib/rubocop/cop/style/redundant_parentheses.rb +36 -30
- data/lib/rubocop/cop/style/redundant_percent_q.rb +5 -3
- data/lib/rubocop/cop/style/redundant_regexp_argument.rb +9 -0
- data/lib/rubocop/cop/style/redundant_regexp_constructor.rb +2 -2
- data/lib/rubocop/cop/style/redundant_regexp_escape.rb +8 -0
- data/lib/rubocop/cop/style/redundant_return.rb +3 -1
- data/lib/rubocop/cop/style/redundant_self.rb +2 -2
- data/lib/rubocop/cop/style/redundant_self_assignment_branch.rb +0 -5
- data/lib/rubocop/cop/style/redundant_sort.rb +7 -7
- data/lib/rubocop/cop/style/redundant_struct_keyword_init.rb +114 -0
- data/lib/rubocop/cop/style/regexp_literal.rb +31 -2
- data/lib/rubocop/cop/style/rescue_modifier.rb +3 -3
- data/lib/rubocop/cop/style/reverse_find.rb +51 -0
- data/lib/rubocop/cop/style/safe_navigation.rb +25 -8
- data/lib/rubocop/cop/style/select_by_kind.rb +158 -0
- data/lib/rubocop/cop/style/select_by_range.rb +197 -0
- data/lib/rubocop/cop/style/select_by_regexp.rb +51 -21
- data/lib/rubocop/cop/style/self_assignment.rb +1 -1
- data/lib/rubocop/cop/style/semicolon.rb +25 -7
- data/lib/rubocop/cop/style/single_line_block_params.rb +2 -2
- data/lib/rubocop/cop/style/single_line_do_end_block.rb +1 -1
- data/lib/rubocop/cop/style/single_line_methods.rb +3 -1
- data/lib/rubocop/cop/style/sole_nested_conditional.rb +12 -3
- data/lib/rubocop/cop/style/special_global_vars.rb +6 -1
- data/lib/rubocop/cop/style/string_concatenation.rb +17 -13
- data/lib/rubocop/cop/style/struct_inheritance.rb +13 -0
- data/lib/rubocop/cop/style/super_arguments.rb +2 -2
- data/lib/rubocop/cop/style/symbol_array.rb +1 -1
- data/lib/rubocop/cop/style/symbol_proc.rb +7 -6
- data/lib/rubocop/cop/style/tally_method.rb +181 -0
- data/lib/rubocop/cop/style/top_level_method_definition.rb +2 -2
- data/lib/rubocop/cop/style/trailing_comma_in_arguments.rb +45 -0
- data/lib/rubocop/cop/style/trailing_comma_in_block_args.rb +1 -1
- data/lib/rubocop/cop/style/trailing_method_end_statement.rb +1 -0
- data/lib/rubocop/cop/style/trailing_underscore_variable.rb +11 -11
- data/lib/rubocop/cop/style/unless_else.rb +10 -9
- data/lib/rubocop/cop/style/unless_logical_operators.rb +3 -3
- data/lib/rubocop/cop/style/while_until_modifier.rb +16 -0
- data/lib/rubocop/cop/style/yoda_condition.rb +1 -1
- data/lib/rubocop/cop/style/yoda_expression.rb +1 -1
- data/lib/rubocop/cop/team.rb +87 -36
- data/lib/rubocop/cop/util.rb +2 -3
- data/lib/rubocop/cop/utils/format_string.rb +10 -0
- data/lib/rubocop/cop/variable_force/branch.rb +30 -6
- data/lib/rubocop/cop/variable_force/variable.rb +1 -1
- data/lib/rubocop/cop/variable_force.rb +9 -7
- data/lib/rubocop/cops_documentation_generator.rb +4 -4
- data/lib/rubocop/directive_comment.rb +48 -4
- data/lib/rubocop/file_patterns.rb +9 -1
- data/lib/rubocop/formatter/clang_style_formatter.rb +5 -2
- data/lib/rubocop/formatter/disabled_config_formatter.rb +24 -7
- data/lib/rubocop/formatter/formatter_set.rb +2 -2
- data/lib/rubocop/formatter/junit_formatter.rb +1 -1
- data/lib/rubocop/formatter/simple_text_formatter.rb +0 -2
- data/lib/rubocop/formatter/tap_formatter.rb +5 -2
- data/lib/rubocop/formatter/worst_offenders_formatter.rb +1 -1
- data/lib/rubocop/formatter.rb +22 -21
- data/lib/rubocop/lsp/diagnostic.rb +18 -33
- data/lib/rubocop/lsp/disable_comment_edits.rb +135 -0
- data/lib/rubocop/lsp/routes.rb +43 -7
- data/lib/rubocop/lsp/runtime.rb +13 -4
- data/lib/rubocop/lsp/stdin_runner.rb +8 -17
- data/lib/rubocop/magic_comment.rb +20 -0
- data/lib/rubocop/mcp/server.rb +200 -0
- data/lib/rubocop/options.rb +35 -4
- data/lib/rubocop/path_util.rb +14 -2
- data/lib/rubocop/plugin/loader.rb +1 -1
- data/lib/rubocop/project_index_loader.rb +66 -0
- data/lib/rubocop/rake_task.rb +1 -1
- data/lib/rubocop/remote_config.rb +10 -8
- data/lib/rubocop/result_cache.rb +61 -38
- data/lib/rubocop/rspec/cop_helper.rb +8 -0
- data/lib/rubocop/rspec/shared_contexts.rb +39 -5
- data/lib/rubocop/rspec/support.rb +2 -1
- data/lib/rubocop/runner.rb +134 -57
- data/lib/rubocop/server/cache.rb +6 -29
- data/lib/rubocop/server/core.rb +2 -0
- data/lib/rubocop/target_finder.rb +17 -10
- data/lib/rubocop/target_ruby.rb +31 -14
- data/lib/rubocop/version.rb +21 -3
- data/lib/rubocop.rb +28 -96
- data/lib/ruby_lsp/rubocop/addon.rb +23 -8
- data/lib/ruby_lsp/rubocop/runtime_adapter.rb +49 -15
- metadata +38 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9386e7f8b3fc90e4096eb5436a4d35612586e27dd1ff46ba40e1051a7909fd52
|
|
4
|
+
data.tar.gz: 615ec2ec69759dce081efc1fddb8469a7ddf6a72223fea741368b501f333bce0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c07cb70ee9d4c997a85c079361624d43574b78e6c364e8d0ff939b4d826c19b0e1ef2aad9569aea4f2f247b9b792ae9b21a776f69161da1c9a193e2f3de74d40
|
|
7
|
+
data.tar.gz: f6b44267bdfeba1237e06af52009143f13a7c0419a5ccaddf47dc9701c328f2b2ef6d87811ae5c8f05ece533ca236425e599c77a5a283ba44c641de09fc1b7e6
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
|
@@ -51,7 +51,7 @@ To prevent an unwanted RuboCop update you might want to use a conservative versi
|
|
|
51
51
|
in your `Gemfile`:
|
|
52
52
|
|
|
53
53
|
```rb
|
|
54
|
-
gem 'rubocop', '~> 1.
|
|
54
|
+
gem 'rubocop', '~> 1.82', require: false
|
|
55
55
|
```
|
|
56
56
|
|
|
57
57
|
See [our versioning policy](https://docs.rubocop.org/rubocop/versioning.html) for further details.
|
|
@@ -251,5 +251,5 @@ RuboCop's release notes are available [here](https://github.com/rubocop/rubocop/
|
|
|
251
251
|
|
|
252
252
|
## Copyright
|
|
253
253
|
|
|
254
|
-
Copyright (c) 2012-
|
|
254
|
+
Copyright (c) 2012-2026 Bozhidar Batsov. See [LICENSE.txt](LICENSE.txt) for
|
|
255
255
|
further details.
|
data/config/default.yml
CHANGED
|
@@ -3,20 +3,16 @@
|
|
|
3
3
|
AllCops:
|
|
4
4
|
RubyInterpreters:
|
|
5
5
|
- ruby
|
|
6
|
-
- macruby
|
|
7
6
|
- rake
|
|
8
7
|
- jruby
|
|
9
|
-
- rbx
|
|
10
8
|
# Include common Ruby source files.
|
|
11
9
|
Include:
|
|
12
10
|
- '**/*.rb'
|
|
13
11
|
- '**/*.arb'
|
|
14
12
|
- '**/*.axlsx'
|
|
15
13
|
- '**/*.builder'
|
|
16
|
-
- '**/*.fcgi'
|
|
17
14
|
- '**/*.gemfile'
|
|
18
15
|
- '**/*.gemspec'
|
|
19
|
-
- '**/*.god'
|
|
20
16
|
- '**/*.jb'
|
|
21
17
|
- '**/*.jbuilder'
|
|
22
18
|
- '**/*.mspec'
|
|
@@ -25,15 +21,12 @@ AllCops:
|
|
|
25
21
|
- '**/*.podspec'
|
|
26
22
|
- '**/*.rabl'
|
|
27
23
|
- '**/*.rake'
|
|
28
|
-
- '**/*.rbuild'
|
|
29
24
|
- '**/*.rbw'
|
|
30
|
-
- '**/*.rbx'
|
|
31
25
|
- '**/*.ru'
|
|
32
26
|
- '**/*.ruby'
|
|
33
27
|
- '**/*.schema'
|
|
34
28
|
- '**/*.spec'
|
|
35
29
|
- '**/*.thor'
|
|
36
|
-
- '**/*.watchr'
|
|
37
30
|
- '**/.irbrc'
|
|
38
31
|
- '**/.pryrc'
|
|
39
32
|
- '**/.simplecov'
|
|
@@ -43,7 +36,6 @@ AllCops:
|
|
|
43
36
|
- '**/Brewfile'
|
|
44
37
|
- '**/Buildfile'
|
|
45
38
|
- '**/Capfile'
|
|
46
|
-
- '**/Cheffile'
|
|
47
39
|
- '**/Dangerfile'
|
|
48
40
|
- '**/Deliverfile'
|
|
49
41
|
- '**/Fastfile'
|
|
@@ -60,7 +52,6 @@ AllCops:
|
|
|
60
52
|
- '**/Snapfile'
|
|
61
53
|
- '**/Steepfile'
|
|
62
54
|
- '**/Thorfile'
|
|
63
|
-
- '**/Vagabondfile'
|
|
64
55
|
- '**/Vagrantfile'
|
|
65
56
|
Exclude:
|
|
66
57
|
- 'node_modules/**/*'
|
|
@@ -113,11 +104,17 @@ AllCops:
|
|
|
113
104
|
# When `NewCops` is `disable`, pending cops are disabled in bulk. Can be overridden by
|
|
114
105
|
# the `--disable-pending-cops` command-line option.
|
|
115
106
|
NewCops: pending
|
|
107
|
+
# When `true`, RuboCop builds a project index (a project-wide map of declarations and references)
|
|
108
|
+
# once per run and makes it available to cops that opt in.
|
|
109
|
+
# The project index is implemented by the optional `rubydex` gem; when `rubydex` is not installed,
|
|
110
|
+
# a warning is shown and the flag has no effect.
|
|
111
|
+
# The default `false` preserves RuboCop's traditional file-local analysis.
|
|
112
|
+
UseProjectIndex: false
|
|
116
113
|
# Enables the result cache if `true`. Can be overridden by the `--cache` command
|
|
117
114
|
# line option.
|
|
118
115
|
UseCache: true
|
|
119
116
|
# Threshold for how many files can be stored in the result cache before some
|
|
120
|
-
# of the files are automatically removed.
|
|
117
|
+
# of the files are automatically removed. Set to false to disable cache pruning.
|
|
121
118
|
MaxFilesInCache: 20000
|
|
122
119
|
# The cache will be stored in "rubocop_cache" under this directory. If
|
|
123
120
|
# CacheRootDirectory is ~ (nil), which it is by default, the root will be
|
|
@@ -275,7 +272,7 @@ Gemspec/AddRuntimeDependency:
|
|
|
275
272
|
Description: 'Prefer `add_dependency` over `add_runtime_dependency`.'
|
|
276
273
|
StyleGuide: '#add_dependency_vs_add_runtime_dependency'
|
|
277
274
|
References:
|
|
278
|
-
- https://github.com/
|
|
275
|
+
- https://github.com/ruby/rubygems/issues/7799#issuecomment-2192720316
|
|
279
276
|
Enabled: pending
|
|
280
277
|
VersionAdded: '1.65'
|
|
281
278
|
Include:
|
|
@@ -538,6 +535,10 @@ Layout/ClosingParenthesisIndentation:
|
|
|
538
535
|
Description: 'Checks the indentation of hanging closing parentheses.'
|
|
539
536
|
Enabled: true
|
|
540
537
|
VersionAdded: '0.49'
|
|
538
|
+
VersionChanged: '1.86'
|
|
539
|
+
# By default the indentation width from `Layout/IndentationWidth` is used,
|
|
540
|
+
# but it can be overridden by setting this parameter.
|
|
541
|
+
IndentationWidth: ~
|
|
541
542
|
|
|
542
543
|
Layout/CommentIndentation:
|
|
543
544
|
Description: 'Indentation of comments.'
|
|
@@ -546,7 +547,10 @@ Layout/CommentIndentation:
|
|
|
546
547
|
# with a comment on the preceding line.
|
|
547
548
|
AllowForAlignment: false
|
|
548
549
|
VersionAdded: '0.49'
|
|
549
|
-
VersionChanged: '1.
|
|
550
|
+
VersionChanged: '1.86'
|
|
551
|
+
# By default the indentation width from `Layout/IndentationWidth` is used,
|
|
552
|
+
# but it can be overridden by setting this parameter.
|
|
553
|
+
IndentationWidth: ~
|
|
550
554
|
|
|
551
555
|
Layout/ConditionPosition:
|
|
552
556
|
Description: >-
|
|
@@ -835,6 +839,7 @@ Layout/FirstArrayElementLineBreak:
|
|
|
835
839
|
multi-line array.
|
|
836
840
|
Enabled: false
|
|
837
841
|
VersionAdded: '0.49'
|
|
842
|
+
AllowImplicitArrayLiterals: false
|
|
838
843
|
AllowMultilineFinalElement: false
|
|
839
844
|
|
|
840
845
|
Layout/FirstHashElementIndentation:
|
|
@@ -1037,6 +1042,15 @@ Layout/IndentationWidth:
|
|
|
1037
1042
|
VersionAdded: '0.49'
|
|
1038
1043
|
# Number of spaces for each indentation level.
|
|
1039
1044
|
Width: 2
|
|
1045
|
+
# Block body indentation for method chain blocks.
|
|
1046
|
+
# The value `start_of_line` means that block bodies are indented
|
|
1047
|
+
# relative to the start of the line where the block starts.
|
|
1048
|
+
# The value `relative_to_receiver` means that block bodies are indented
|
|
1049
|
+
# relative to the method call position in the chain.
|
|
1050
|
+
EnforcedStyleAlignWith: start_of_line
|
|
1051
|
+
SupportedStylesAlignWith:
|
|
1052
|
+
- start_of_line
|
|
1053
|
+
- relative_to_receiver
|
|
1040
1054
|
AllowedPatterns: []
|
|
1041
1055
|
|
|
1042
1056
|
Layout/InitialIndentation:
|
|
@@ -1102,7 +1116,7 @@ Layout/LineLength:
|
|
|
1102
1116
|
StyleGuide: '#max-line-length'
|
|
1103
1117
|
Enabled: true
|
|
1104
1118
|
VersionAdded: '0.25'
|
|
1105
|
-
VersionChanged: '1.
|
|
1119
|
+
VersionChanged: '1.82'
|
|
1106
1120
|
Max: 120
|
|
1107
1121
|
AllowHeredoc: true
|
|
1108
1122
|
# To make it possible to copy or click on URIs in the code, we allow lines
|
|
@@ -1112,9 +1126,12 @@ Layout/LineLength:
|
|
|
1112
1126
|
URISchemes:
|
|
1113
1127
|
- http
|
|
1114
1128
|
- https
|
|
1115
|
-
# The
|
|
1129
|
+
# The AllowRBSInlineAnnotation option makes LineLength allow RBS::Inline annotations
|
|
1130
|
+
# such as `#: (?date: Date) -> Foo` when calculating line length.
|
|
1131
|
+
AllowRBSInlineAnnotation: false
|
|
1132
|
+
# The AllowCopDirectives option causes the LineLength rule to ignore cop
|
|
1116
1133
|
# directives like '# rubocop: enable ...' when calculating a line's length.
|
|
1117
|
-
|
|
1134
|
+
AllowCopDirectives: true
|
|
1118
1135
|
# The AllowedPatterns option is a list of !ruby/regexp and/or string
|
|
1119
1136
|
# elements. Strings will be converted to Regexp objects. A line that matches
|
|
1120
1137
|
# any regular expression listed in this option will be ignored by LineLength.
|
|
@@ -1692,6 +1709,7 @@ Lint/ConstantReassignment:
|
|
|
1692
1709
|
Description: 'Checks for constant reassignments.'
|
|
1693
1710
|
Enabled: pending
|
|
1694
1711
|
VersionAdded: '1.70'
|
|
1712
|
+
VersionChanged: '1.87'
|
|
1695
1713
|
|
|
1696
1714
|
Lint/ConstantResolution:
|
|
1697
1715
|
Description: 'Checks that constants are fully qualified with `::`.'
|
|
@@ -1707,6 +1725,11 @@ Lint/CopDirectiveSyntax:
|
|
|
1707
1725
|
Enabled: pending
|
|
1708
1726
|
VersionAdded: '1.72'
|
|
1709
1727
|
|
|
1728
|
+
Lint/DataDefineOverride:
|
|
1729
|
+
Description: 'Disallow overriding the `Data` built-in methods via `Data.define`.'
|
|
1730
|
+
Enabled: pending
|
|
1731
|
+
VersionAdded: '1.85'
|
|
1732
|
+
|
|
1710
1733
|
Lint/Debugger:
|
|
1711
1734
|
Description: 'Checks for debugger calls.'
|
|
1712
1735
|
Enabled: true
|
|
@@ -2396,8 +2419,9 @@ Lint/SafeNavigationConsistency:
|
|
|
2396
2419
|
consistent and appropriate safe navigation, without excess or deficiency,
|
|
2397
2420
|
is used for all method calls on the same object.
|
|
2398
2421
|
Enabled: true
|
|
2422
|
+
SafeAutoCorrect: false
|
|
2399
2423
|
VersionAdded: '0.55'
|
|
2400
|
-
VersionChanged: '
|
|
2424
|
+
VersionChanged: '1.85'
|
|
2401
2425
|
AllowedMethods:
|
|
2402
2426
|
- present?
|
|
2403
2427
|
- blank?
|
|
@@ -2574,6 +2598,11 @@ Lint/UnreachableLoop:
|
|
|
2574
2598
|
# eg. `exactly(2).times`
|
|
2575
2599
|
- !ruby/regexp /(exactly|at_least|at_most)\(\d+\)\.times/
|
|
2576
2600
|
|
|
2601
|
+
Lint/UnreachablePatternBranch:
|
|
2602
|
+
Description: 'Checks for unreachable `in` pattern branches after an unconditional catch-all pattern.'
|
|
2603
|
+
Enabled: pending
|
|
2604
|
+
VersionAdded: '1.85'
|
|
2605
|
+
|
|
2577
2606
|
Lint/UnusedBlockArgument:
|
|
2578
2607
|
Description: 'Checks for unused block arguments.'
|
|
2579
2608
|
StyleGuide: '#underscore-unused-vars'
|
|
@@ -2669,7 +2698,10 @@ Lint/UselessNumericOperation:
|
|
|
2669
2698
|
Lint/UselessOr:
|
|
2670
2699
|
Description: 'Checks for useless OR expressions.'
|
|
2671
2700
|
Enabled: pending
|
|
2701
|
+
SafeAutoCorrect: false
|
|
2702
|
+
AutoCorrect: contextual
|
|
2672
2703
|
VersionAdded: '1.76'
|
|
2704
|
+
VersionChanged: '1.82'
|
|
2673
2705
|
|
|
2674
2706
|
Lint/UselessRescue:
|
|
2675
2707
|
Description: 'Checks for useless `rescue`s.'
|
|
@@ -3097,6 +3129,7 @@ Naming/PredicateMethod:
|
|
|
3097
3129
|
AllowBangMethods: false
|
|
3098
3130
|
# Methods that are known to not return a boolean value, despite ending in `?`.
|
|
3099
3131
|
WaywardPredicates:
|
|
3132
|
+
- infinite?
|
|
3100
3133
|
- nonzero?
|
|
3101
3134
|
|
|
3102
3135
|
Naming/PredicatePrefix:
|
|
@@ -3207,6 +3240,7 @@ Security/JSONLoad:
|
|
|
3207
3240
|
security issues. See reference for more information.
|
|
3208
3241
|
References:
|
|
3209
3242
|
- 'https://ruby-doc.org/stdlib-2.7.0/libdoc/json/rdoc/JSON.html#method-i-load'
|
|
3243
|
+
- 'https://bugs.ruby-lang.org/issues/19528'
|
|
3210
3244
|
Enabled: true
|
|
3211
3245
|
VersionAdded: '0.43'
|
|
3212
3246
|
VersionChanged: '1.22'
|
|
@@ -3280,7 +3314,7 @@ Style/Alias:
|
|
|
3280
3314
|
|
|
3281
3315
|
Style/AmbiguousEndlessMethodDefinition:
|
|
3282
3316
|
Description: 'Checks for endless methods inside operators of lower precedence.'
|
|
3283
|
-
StyleGuide: '#ambiguous-endless-method-
|
|
3317
|
+
StyleGuide: '#ambiguous-endless-method-definitions'
|
|
3284
3318
|
Enabled: pending
|
|
3285
3319
|
VersionAdded: '1.68'
|
|
3286
3320
|
|
|
@@ -3341,6 +3375,12 @@ Style/ArrayIntersect:
|
|
|
3341
3375
|
Safe: false
|
|
3342
3376
|
VersionAdded: '1.40'
|
|
3343
3377
|
|
|
3378
|
+
Style/ArrayIntersectWithSingleElement:
|
|
3379
|
+
Description: 'Use `include?(element)` instead of `intersect?([element])`.'
|
|
3380
|
+
Enabled: 'pending'
|
|
3381
|
+
Safe: false
|
|
3382
|
+
VersionAdded: '1.81'
|
|
3383
|
+
|
|
3344
3384
|
Style/ArrayJoin:
|
|
3345
3385
|
Description: 'Use Array#join instead of Array#*.'
|
|
3346
3386
|
StyleGuide: '#array-join'
|
|
@@ -3518,9 +3558,11 @@ Style/BlockDelimiters:
|
|
|
3518
3558
|
BracesRequiredMethods: []
|
|
3519
3559
|
|
|
3520
3560
|
Style/CaseEquality:
|
|
3521
|
-
Description: 'Avoid explicit use of the case equality operator(
|
|
3561
|
+
Description: 'Avoid explicit use of the case equality operator (`===`).'
|
|
3522
3562
|
StyleGuide: '#no-case-equality'
|
|
3523
3563
|
Enabled: true
|
|
3564
|
+
References:
|
|
3565
|
+
- 'https://docs.rubocop.org/rubocop-performance/cops_performance.html#performanceregexpmatch'
|
|
3524
3566
|
VersionAdded: '0.9'
|
|
3525
3567
|
VersionChanged: '0.89'
|
|
3526
3568
|
# If `AllowOnConstant` option is enabled, the cop will ignore violations when the receiver of
|
|
@@ -3952,6 +3994,18 @@ Style/EmptyCaseCondition:
|
|
|
3952
3994
|
Enabled: true
|
|
3953
3995
|
VersionAdded: '0.40'
|
|
3954
3996
|
|
|
3997
|
+
Style/EmptyClassDefinition:
|
|
3998
|
+
Description: 'Enforces consistent style for empty class definitions.'
|
|
3999
|
+
Enabled: pending
|
|
4000
|
+
VersionAdded: '1.84'
|
|
4001
|
+
VersionChanged: '1.86'
|
|
4002
|
+
EnforcedStyle: class_keyword
|
|
4003
|
+
SupportedStyles:
|
|
4004
|
+
- class_keyword
|
|
4005
|
+
- class_new
|
|
4006
|
+
- class_definition # Deprecated.
|
|
4007
|
+
AllowedParentClasses: []
|
|
4008
|
+
|
|
3955
4009
|
Style/EmptyElse:
|
|
3956
4010
|
Description: 'Avoid empty else-clauses.'
|
|
3957
4011
|
Enabled: true
|
|
@@ -4110,6 +4164,12 @@ Style/FileNull:
|
|
|
4110
4164
|
SafeAutoCorrect: false
|
|
4111
4165
|
VersionAdded: '1.69'
|
|
4112
4166
|
|
|
4167
|
+
Style/FileOpen:
|
|
4168
|
+
Description: 'Checks for `File.open` without a block, which can leak file descriptors.'
|
|
4169
|
+
Enabled: pending
|
|
4170
|
+
Safe: false
|
|
4171
|
+
VersionAdded: '1.85'
|
|
4172
|
+
|
|
4113
4173
|
Style/FileRead:
|
|
4114
4174
|
Description: 'Favor `File.(bin)read` convenience methods.'
|
|
4115
4175
|
StyleGuide: '#file-read'
|
|
@@ -4303,6 +4363,16 @@ Style/HashLikeCase:
|
|
|
4303
4363
|
# to trigger this cop
|
|
4304
4364
|
MinBranchesCount: 3
|
|
4305
4365
|
|
|
4366
|
+
Style/HashLookupMethod:
|
|
4367
|
+
Description: 'Enforces the use of either `Hash#[]` or `Hash#fetch` for hash lookup.'
|
|
4368
|
+
Enabled: false
|
|
4369
|
+
Safe: false
|
|
4370
|
+
VersionAdded: '1.84'
|
|
4371
|
+
EnforcedStyle: brackets
|
|
4372
|
+
SupportedStyles:
|
|
4373
|
+
- brackets
|
|
4374
|
+
- fetch
|
|
4375
|
+
|
|
4306
4376
|
Style/HashSlice:
|
|
4307
4377
|
Description: >-
|
|
4308
4378
|
Checks for usages of `Hash#reject`, `Hash#select`, and `Hash#filter` methods
|
|
@@ -4400,6 +4470,7 @@ Style/IfWithBooleanLiteralBranches:
|
|
|
4400
4470
|
VersionAdded: '1.9'
|
|
4401
4471
|
SafeAutoCorrect: false
|
|
4402
4472
|
AllowedMethods:
|
|
4473
|
+
- infinite?
|
|
4403
4474
|
- nonzero?
|
|
4404
4475
|
|
|
4405
4476
|
Style/IfWithSemicolon:
|
|
@@ -4546,8 +4617,9 @@ Style/LambdaCall:
|
|
|
4546
4617
|
Description: 'Use lambda.call(...) instead of lambda.(...).'
|
|
4547
4618
|
StyleGuide: '#proc-call'
|
|
4548
4619
|
Enabled: true
|
|
4620
|
+
AutoCorrect: contextual
|
|
4549
4621
|
VersionAdded: '0.13'
|
|
4550
|
-
VersionChanged: '
|
|
4622
|
+
VersionChanged: '1.81'
|
|
4551
4623
|
EnforcedStyle: call
|
|
4552
4624
|
SupportedStyles:
|
|
4553
4625
|
- call
|
|
@@ -4595,6 +4667,12 @@ Style/MapIntoArray:
|
|
|
4595
4667
|
VersionChanged: '1.67'
|
|
4596
4668
|
Safe: false
|
|
4597
4669
|
|
|
4670
|
+
Style/MapJoin:
|
|
4671
|
+
Description: 'Checks for redundant `map(&:to_s)` before `join`.'
|
|
4672
|
+
Enabled: pending
|
|
4673
|
+
Safe: false
|
|
4674
|
+
VersionAdded: '1.85'
|
|
4675
|
+
|
|
4598
4676
|
Style/MapToHash:
|
|
4599
4677
|
Description: 'Prefer `to_h` with a block over `map.to_h`.'
|
|
4600
4678
|
Enabled: pending
|
|
@@ -4617,6 +4695,7 @@ Style/MethodCallWithArgsParentheses:
|
|
|
4617
4695
|
AllowedMethods: []
|
|
4618
4696
|
AllowedPatterns: []
|
|
4619
4697
|
IncludedMacros: []
|
|
4698
|
+
IncludedMacroPatterns: []
|
|
4620
4699
|
AllowParenthesesInMultilineCall: false
|
|
4621
4700
|
AllowParenthesesInChaining: false
|
|
4622
4701
|
AllowParenthesesInCamelCaseMethod: false
|
|
@@ -4727,6 +4806,11 @@ Style/ModuleFunction:
|
|
|
4727
4806
|
Autocorrect: false
|
|
4728
4807
|
SafeAutoCorrect: false
|
|
4729
4808
|
|
|
4809
|
+
Style/ModuleMemberExistenceCheck:
|
|
4810
|
+
Description: 'Checks for usage of `Module` methods returning arrays that can be replaced with equivalent predicates.'
|
|
4811
|
+
Enabled: pending
|
|
4812
|
+
VersionAdded: '1.82'
|
|
4813
|
+
|
|
4730
4814
|
Style/MultilineBlockChain:
|
|
4731
4815
|
Description: 'Avoid multi-line chains of blocks.'
|
|
4732
4816
|
StyleGuide: '#single-line-blocks'
|
|
@@ -4854,6 +4938,14 @@ Style/NegatedWhile:
|
|
|
4854
4938
|
Enabled: true
|
|
4855
4939
|
VersionAdded: '0.20'
|
|
4856
4940
|
|
|
4941
|
+
Style/NegativeArrayIndex:
|
|
4942
|
+
Description: >-
|
|
4943
|
+
Use negative array indices instead of calculating array length minus a value.
|
|
4944
|
+
Also handles range patterns with length calculations. Recognizes preserving methods
|
|
4945
|
+
and their combinations, allowing safe replacement when the receiver matches.
|
|
4946
|
+
Enabled: pending
|
|
4947
|
+
VersionAdded: '1.84'
|
|
4948
|
+
|
|
4857
4949
|
Style/NestedFileDirname:
|
|
4858
4950
|
Description: 'Checks for nested `File.dirname`.'
|
|
4859
4951
|
Enabled: pending
|
|
@@ -5029,6 +5121,16 @@ Style/ObjectThen:
|
|
|
5029
5121
|
- then
|
|
5030
5122
|
- yield_self
|
|
5031
5123
|
|
|
5124
|
+
Style/OneClassPerFile:
|
|
5125
|
+
Description: 'Checks that each source file defines at most one top-level class or module.'
|
|
5126
|
+
Enabled: pending
|
|
5127
|
+
VersionAdded: '1.85'
|
|
5128
|
+
VersionChanged: '1.86'
|
|
5129
|
+
AllowedClasses: []
|
|
5130
|
+
Exclude:
|
|
5131
|
+
- 'spec/**/*'
|
|
5132
|
+
- 'test/**/*'
|
|
5133
|
+
|
|
5032
5134
|
Style/OneLineConditional:
|
|
5033
5135
|
Description: >-
|
|
5034
5136
|
Favor the ternary operator (?:) or multi-line constructs over
|
|
@@ -5117,6 +5219,14 @@ Style/ParenthesesAroundCondition:
|
|
|
5117
5219
|
AllowSafeAssignment: true
|
|
5118
5220
|
AllowInMultilineConditions: false
|
|
5119
5221
|
|
|
5222
|
+
Style/PartitionInsteadOfDoubleSelect:
|
|
5223
|
+
Description: >-
|
|
5224
|
+
Checks for consecutive `select`/`filter`/`find_all` and `reject` calls
|
|
5225
|
+
on the same receiver with the same block body.
|
|
5226
|
+
Enabled: pending
|
|
5227
|
+
Safe: false
|
|
5228
|
+
VersionAdded: '1.85'
|
|
5229
|
+
|
|
5120
5230
|
Style/PercentLiteralDelimiters:
|
|
5121
5231
|
Description: 'Use `%`-literal delimiters consistently.'
|
|
5122
5232
|
StyleGuide: '#percent-literal-braces'
|
|
@@ -5149,6 +5259,12 @@ Style/PerlBackrefs:
|
|
|
5149
5259
|
Enabled: true
|
|
5150
5260
|
VersionAdded: '0.13'
|
|
5151
5261
|
|
|
5262
|
+
Style/PredicateWithKind:
|
|
5263
|
+
Description: 'Prefer `any?(Klass)` to `any? { |x| x.is_a?(Klass) }`.'
|
|
5264
|
+
Enabled: pending
|
|
5265
|
+
SafeAutoCorrect: false
|
|
5266
|
+
VersionAdded: '1.85'
|
|
5267
|
+
|
|
5152
5268
|
Style/PreferredHashMethods:
|
|
5153
5269
|
Description: 'Checks use of `has_key?` and `has_value?` Hash methods.'
|
|
5154
5270
|
StyleGuide: '#hash-key'
|
|
@@ -5199,6 +5315,12 @@ Style/RandomWithOffset:
|
|
|
5199
5315
|
Enabled: true
|
|
5200
5316
|
VersionAdded: '0.52'
|
|
5201
5317
|
|
|
5318
|
+
Style/ReduceToHash:
|
|
5319
|
+
Description: 'Use `to_h { ... }` instead of `each_with_object`, `inject`, or `reduce` to build a hash.'
|
|
5320
|
+
Enabled: pending
|
|
5321
|
+
Safe: false
|
|
5322
|
+
VersionAdded: '1.85'
|
|
5323
|
+
|
|
5202
5324
|
Style/RedundantArgument:
|
|
5203
5325
|
Description: 'Checks for a redundant argument passed to certain methods.'
|
|
5204
5326
|
Enabled: pending
|
|
@@ -5214,6 +5336,8 @@ Style/RedundantArgument:
|
|
|
5214
5336
|
exit: true
|
|
5215
5337
|
# Kernel.#exit!
|
|
5216
5338
|
exit!: false
|
|
5339
|
+
# String#to_i
|
|
5340
|
+
to_i: 10
|
|
5217
5341
|
# String#split
|
|
5218
5342
|
split: ' '
|
|
5219
5343
|
# String#chomp
|
|
@@ -5255,6 +5379,7 @@ Style/RedundantCondition:
|
|
|
5255
5379
|
VersionAdded: '0.76'
|
|
5256
5380
|
VersionChanged: '1.73'
|
|
5257
5381
|
AllowedMethods:
|
|
5382
|
+
- infinite?
|
|
5258
5383
|
- nonzero?
|
|
5259
5384
|
|
|
5260
5385
|
Style/RedundantConditional:
|
|
@@ -5365,6 +5490,11 @@ Style/RedundantLineContinuation:
|
|
|
5365
5490
|
Enabled: pending
|
|
5366
5491
|
VersionAdded: '1.49'
|
|
5367
5492
|
|
|
5493
|
+
Style/RedundantMinMaxBy:
|
|
5494
|
+
Description: 'Identifies places where `max_by`/`min_by` can be replaced by `max`/`min`.'
|
|
5495
|
+
Enabled: pending
|
|
5496
|
+
VersionAdded: '1.85'
|
|
5497
|
+
|
|
5368
5498
|
Style/RedundantParentheses:
|
|
5369
5499
|
Description: "Checks for parentheses that seem not to serve any purpose."
|
|
5370
5500
|
Enabled: true
|
|
@@ -5442,6 +5572,13 @@ Style/RedundantStringEscape:
|
|
|
5442
5572
|
Enabled: pending
|
|
5443
5573
|
VersionAdded: '1.37'
|
|
5444
5574
|
|
|
5575
|
+
Style/RedundantStructKeywordInit:
|
|
5576
|
+
Description: 'Checks for redundant `keyword_init` option for `Struct.new`.'
|
|
5577
|
+
Enabled: false
|
|
5578
|
+
SafeAutoCorrect: false
|
|
5579
|
+
VersionAdded: '1.85'
|
|
5580
|
+
VersionChanged: '1.86'
|
|
5581
|
+
|
|
5445
5582
|
Style/RegexpLiteral:
|
|
5446
5583
|
Description: 'Use / or %r around regular expressions.'
|
|
5447
5584
|
StyleGuide: '#percent-r'
|
|
@@ -5503,6 +5640,12 @@ Style/ReturnNilInPredicateMethodDefinition:
|
|
|
5503
5640
|
VersionAdded: '1.53'
|
|
5504
5641
|
VersionChanged: '1.67'
|
|
5505
5642
|
|
|
5643
|
+
Style/ReverseFind:
|
|
5644
|
+
Description: 'Use `array.rfind` instead of `array.reverse.find`.'
|
|
5645
|
+
Enabled: pending
|
|
5646
|
+
Safe: false
|
|
5647
|
+
VersionAdded: '1.84'
|
|
5648
|
+
|
|
5506
5649
|
Style/SafeNavigation:
|
|
5507
5650
|
Description: >-
|
|
5508
5651
|
Transforms usages of a method call safeguarded by
|
|
@@ -5542,8 +5685,20 @@ Style/Sample:
|
|
|
5542
5685
|
Enabled: true
|
|
5543
5686
|
VersionAdded: '0.30'
|
|
5544
5687
|
|
|
5688
|
+
Style/SelectByKind:
|
|
5689
|
+
Description: 'Prefer grep/grep_v to select/reject/find/detect with a kind check.'
|
|
5690
|
+
Enabled: pending
|
|
5691
|
+
SafeAutoCorrect: false
|
|
5692
|
+
VersionAdded: '1.85'
|
|
5693
|
+
|
|
5694
|
+
Style/SelectByRange:
|
|
5695
|
+
Description: 'Prefer grep/grep_v to select/reject/find/detect with a range check.'
|
|
5696
|
+
Enabled: pending
|
|
5697
|
+
SafeAutoCorrect: false
|
|
5698
|
+
VersionAdded: '1.85'
|
|
5699
|
+
|
|
5545
5700
|
Style/SelectByRegexp:
|
|
5546
|
-
Description: 'Prefer grep/grep_v to select/reject with a regexp match.'
|
|
5701
|
+
Description: 'Prefer grep/grep_v to select/reject/find/detect with a regexp match.'
|
|
5547
5702
|
Enabled: pending
|
|
5548
5703
|
SafeAutoCorrect: false
|
|
5549
5704
|
VersionAdded: '1.22'
|
|
@@ -5802,6 +5957,12 @@ Style/SymbolProc:
|
|
|
5802
5957
|
AllowedPatterns: []
|
|
5803
5958
|
AllowComments: false
|
|
5804
5959
|
|
|
5960
|
+
Style/TallyMethod:
|
|
5961
|
+
Description: 'Prefer `Enumerable#tally` over manual counting patterns.'
|
|
5962
|
+
Enabled: pending
|
|
5963
|
+
Safe: false
|
|
5964
|
+
VersionAdded: '1.85'
|
|
5965
|
+
|
|
5805
5966
|
Style/TernaryParentheses:
|
|
5806
5967
|
Description: 'Checks for use of parentheses around ternary conditions.'
|
|
5807
5968
|
Enabled: true
|
|
@@ -5844,10 +6005,14 @@ Style/TrailingCommaInArguments:
|
|
|
5844
6005
|
# parenthesized method calls where each argument is on its own line.
|
|
5845
6006
|
# If `consistent_comma`, the cop requires a comma after the last argument,
|
|
5846
6007
|
# for all parenthesized method calls with arguments.
|
|
6008
|
+
# If `diff_comma`, the cop requires a comma after the last argument, but only
|
|
6009
|
+
# when that argument is followed by an immediate newline, even if
|
|
6010
|
+
# there is an inline comment.
|
|
5847
6011
|
EnforcedStyleForMultiline: no_comma
|
|
5848
6012
|
SupportedStylesForMultiline:
|
|
5849
6013
|
- comma
|
|
5850
6014
|
- consistent_comma
|
|
6015
|
+
- diff_comma
|
|
5851
6016
|
- no_comma
|
|
5852
6017
|
|
|
5853
6018
|
Style/TrailingCommaInArrayLiteral:
|
data/config/obsoletion.yml
CHANGED
|
@@ -145,6 +145,10 @@ changed_parameters:
|
|
|
145
145
|
- cops: Layout/CaseIndentation
|
|
146
146
|
parameters: IndentWhenRelativeTo
|
|
147
147
|
alternative: EnforcedStyle
|
|
148
|
+
- cops: Layout/LineLength
|
|
149
|
+
parameters: IgnoreCopDirectives
|
|
150
|
+
alternative: AllowCopDirectives
|
|
151
|
+
severity: warning
|
|
148
152
|
- cops:
|
|
149
153
|
- Lint/BlockAlignment
|
|
150
154
|
- Layout/BlockAlignment
|
|
@@ -241,3 +245,8 @@ changed_enforced_styles:
|
|
|
241
245
|
parameters: EnforcedStyle
|
|
242
246
|
value: rails
|
|
243
247
|
alternative: indented_internal_methods
|
|
248
|
+
- cops: Style/EmptyClassDefinition
|
|
249
|
+
parameters: EnforcedStyle
|
|
250
|
+
value: class_definition
|
|
251
|
+
alternative: class_keyword
|
|
252
|
+
severity: warning
|
data/exe/rubocop
CHANGED
|
@@ -12,13 +12,6 @@ if RuboCop::Server.running?
|
|
|
12
12
|
exit_status = RuboCop::Server::ClientCommand::Exec.new.run
|
|
13
13
|
else
|
|
14
14
|
require 'rubocop'
|
|
15
|
-
|
|
16
|
-
cli = RuboCop::CLI.new
|
|
17
|
-
|
|
18
|
-
time_start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
19
|
-
exit_status = cli.run
|
|
20
|
-
elapsed_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) - time_start
|
|
21
|
-
|
|
22
|
-
puts "Finished in #{elapsed_time} seconds" if cli.options[:debug] || cli.options[:display_time]
|
|
15
|
+
exit_status = RuboCop::CLI.new.run
|
|
23
16
|
end
|
|
24
17
|
exit exit_status
|
data/lib/rubocop/cache_config.rb
CHANGED
|
@@ -25,5 +25,34 @@ module RuboCop
|
|
|
25
25
|
|
|
26
26
|
File.join(root, 'rubocop_cache')
|
|
27
27
|
end
|
|
28
|
+
|
|
29
|
+
# Lightweight cache root computation that reads CacheRootDirectory from
|
|
30
|
+
# the toplevel config file and environment variables without going through
|
|
31
|
+
# the full ConfigStore/ConfigLoader. This method can be used, for example,
|
|
32
|
+
# before loading configuration files. Please note that this method doesn't
|
|
33
|
+
# take into account any `inherit_from` dependencies.
|
|
34
|
+
def self.root_dir_from_toplevel_config(cache_root_override = nil)
|
|
35
|
+
root_dir do
|
|
36
|
+
next cache_root_override if cache_root_override
|
|
37
|
+
|
|
38
|
+
config_path = ConfigFinder.find_config_path(PathUtil.pwd)
|
|
39
|
+
file_contents = File.read(config_path)
|
|
40
|
+
|
|
41
|
+
# Returns early if `CacheRootDirectory` is not used before requiring `erb` or `yaml`.
|
|
42
|
+
next unless file_contents.include?('CacheRootDirectory')
|
|
43
|
+
|
|
44
|
+
require 'erb'
|
|
45
|
+
require 'yaml'
|
|
46
|
+
yaml_code = ERB.new(file_contents).result
|
|
47
|
+
config_yaml = YAML.safe_load(yaml_code, permitted_classes: [Regexp, Symbol], aliases: true)
|
|
48
|
+
|
|
49
|
+
# For compatibility with Ruby 3.0 or lower.
|
|
50
|
+
if Gem::Version.new(Psych::VERSION) < Gem::Version.new('4.0.0')
|
|
51
|
+
config_yaml == false ? nil : config_yaml
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
config_yaml&.dig('AllCops', 'CacheRootDirectory')
|
|
55
|
+
end
|
|
56
|
+
end
|
|
28
57
|
end
|
|
29
58
|
end
|
|
@@ -24,13 +24,39 @@ module RuboCop
|
|
|
24
24
|
|
|
25
25
|
def run
|
|
26
26
|
add_formatter
|
|
27
|
+
use_temporary_cache
|
|
28
|
+
reset_auto_gen_tmp_dir
|
|
27
29
|
reset_config_and_auto_gen_file
|
|
28
30
|
line_length_contents = maybe_run_line_length_cop
|
|
29
|
-
run_all_cops(line_length_contents)
|
|
31
|
+
result = run_all_cops(line_length_contents)
|
|
32
|
+
reset_auto_gen_tmp_dir
|
|
33
|
+
result
|
|
30
34
|
end
|
|
31
35
|
|
|
32
36
|
private
|
|
33
37
|
|
|
38
|
+
def use_temporary_cache
|
|
39
|
+
# Use a separate cache directory to ensure MinDigits and Max values are calculated.
|
|
40
|
+
# This allows parallel execution (which requires cache) while ensuring MinDigits
|
|
41
|
+
# and Max values are computed, since the cache starts empty.
|
|
42
|
+
@options[:cache_root] = auto_gen_tmp_dir.join('cache').to_s
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def reset_auto_gen_tmp_dir
|
|
46
|
+
auto_gen_tmp_dir.rmtree if auto_gen_tmp_dir.exist?
|
|
47
|
+
auto_gen_tmp_dir.mkpath
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def auto_gen_tmp_dir
|
|
51
|
+
@auto_gen_tmp_dir ||= Pathname.new(
|
|
52
|
+
RuboCop::CacheConfig.root_dir_from_toplevel_config
|
|
53
|
+
).join('auto-gen-tmp').tap do |path|
|
|
54
|
+
path.mkpath
|
|
55
|
+
# Set the temp directory path for ExcludeLimit to use
|
|
56
|
+
RuboCop::ExcludeLimit.tmp_dir = path
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
34
60
|
def maybe_run_line_length_cop
|
|
35
61
|
if only_exclude?
|
|
36
62
|
skip_line_length_cop(PHASE_1_SKIPPED_ONLY_EXCLUDE)
|
|
@@ -83,7 +109,7 @@ module RuboCop
|
|
|
83
109
|
execute_runner
|
|
84
110
|
@options.delete(:only)
|
|
85
111
|
@config_store = ConfigStore.new
|
|
86
|
-
@config_store.
|
|
112
|
+
@config_store.apply_options!(@options)
|
|
87
113
|
# Save the todo configuration of the LineLength cop.
|
|
88
114
|
File.read(AUTO_GENERATED_FILE).lines.drop_while { |line| line.start_with?('#') }.join
|
|
89
115
|
end
|
|
@@ -99,7 +125,7 @@ module RuboCop
|
|
|
99
125
|
|
|
100
126
|
def reset_config_and_auto_gen_file
|
|
101
127
|
@config_store = ConfigStore.new
|
|
102
|
-
@config_store.
|
|
128
|
+
@config_store.apply_options!(@options)
|
|
103
129
|
File.open(AUTO_GENERATED_FILE, 'w') {} # create or truncate if exists
|
|
104
130
|
add_inheritance_from_auto_generated_file(@options[:config])
|
|
105
131
|
end
|
|
@@ -153,7 +179,7 @@ module RuboCop
|
|
|
153
179
|
def relative_path_to_todo_from_options_config
|
|
154
180
|
return AUTO_GENERATED_FILE unless @options[:config]
|
|
155
181
|
|
|
156
|
-
base = Pathname.new(
|
|
182
|
+
base = Pathname.new(PathUtil.pwd)
|
|
157
183
|
config_dir = Pathname.new(@options[:config]).realpath.dirname
|
|
158
184
|
|
|
159
185
|
# Don't have the path start with `/`
|