rubocop 1.66.1 → 1.72.2
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 +162 -14
- data/config/internal_affairs.yml +11 -0
- data/lib/rubocop/cached_data.rb +12 -4
- data/lib/rubocop/cli/command/auto_generate_config.rb +6 -7
- data/lib/rubocop/cli/command/execute_runner.rb +4 -4
- data/lib/rubocop/cli/command/lsp.rb +2 -2
- data/lib/rubocop/cli/command/show_cops.rb +24 -2
- data/lib/rubocop/cli/command/suggest_extensions.rb +7 -1
- data/lib/rubocop/cli/command/version.rb +2 -2
- 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 +36 -11
- data/lib/rubocop/config_validator.rb +20 -9
- data/lib/rubocop/cop/autocorrect_logic.rb +36 -19
- data/lib/rubocop/cop/base.rb +13 -3
- data/lib/rubocop/cop/bundler/duplicated_gem.rb +2 -2
- data/lib/rubocop/cop/bundler/gem_comment.rb +1 -1
- data/lib/rubocop/cop/bundler/gem_filename.rb +0 -1
- data/lib/rubocop/cop/bundler/gem_version.rb +1 -0
- data/lib/rubocop/cop/bundler/insecure_protocol_source.rb +0 -1
- data/lib/rubocop/cop/cop.rb +8 -0
- data/lib/rubocop/cop/correctors/alignment_corrector.rb +1 -12
- data/lib/rubocop/cop/correctors/for_to_each_corrector.rb +1 -1
- data/lib/rubocop/cop/correctors/parentheses_corrector.rb +1 -1
- data/lib/rubocop/cop/correctors/percent_literal_corrector.rb +10 -0
- data/lib/rubocop/cop/gemspec/deprecated_attribute_assignment.rb +1 -2
- data/lib/rubocop/cop/gemspec/required_ruby_version.rb +0 -2
- data/lib/rubocop/cop/generator.rb +6 -0
- data/lib/rubocop/cop/internal_affairs/cop_description.rb +0 -4
- 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/location_line_equality_comparison.rb +3 -4
- 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/numblock_handler.rb +1 -1
- data/lib/rubocop/cop/internal_affairs/on_send_without_on_csend.rb +90 -0
- data/lib/rubocop/cop/internal_affairs/operator_keyword.rb +48 -0
- data/lib/rubocop/cop/internal_affairs/plugin.rb +33 -0
- data/lib/rubocop/cop/internal_affairs/redundant_message_argument.rb +6 -21
- data/lib/rubocop/cop/internal_affairs/redundant_source_range.rb +11 -2
- data/lib/rubocop/cop/internal_affairs/single_line_comparison.rb +5 -4
- data/lib/rubocop/cop/internal_affairs/style_detected_api_use.rb +0 -2
- data/lib/rubocop/cop/internal_affairs/undefined_config.rb +7 -1
- data/lib/rubocop/cop/internal_affairs/useless_message_assertion.rb +0 -5
- data/lib/rubocop/cop/internal_affairs.rb +6 -0
- data/lib/rubocop/cop/layout/access_modifier_indentation.rb +6 -2
- data/lib/rubocop/cop/layout/argument_alignment.rb +2 -9
- data/lib/rubocop/cop/layout/array_alignment.rb +1 -1
- data/lib/rubocop/cop/layout/begin_end_alignment.rb +0 -1
- data/lib/rubocop/cop/layout/block_alignment.rb +3 -2
- data/lib/rubocop/cop/layout/class_structure.rb +9 -9
- 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 +2 -2
- data/lib/rubocop/cop/layout/empty_line_after_guard_clause.rb +3 -3
- data/lib/rubocop/cop/layout/empty_line_between_defs.rb +7 -11
- data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +3 -3
- data/lib/rubocop/cop/layout/empty_lines_around_begin_body.rb +5 -6
- data/lib/rubocop/cop/layout/empty_lines_around_exception_handling_keywords.rb +4 -5
- data/lib/rubocop/cop/layout/empty_lines_around_method_body.rb +23 -1
- 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_method_argument_line_break.rb +8 -0
- 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/indentation_width.rb +11 -12
- data/lib/rubocop/cop/layout/leading_comment_space.rb +71 -1
- data/lib/rubocop/cop/layout/line_continuation_leading_space.rb +11 -2
- 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 +119 -4
- 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 +2 -1
- data/lib/rubocop/cop/layout/multiline_method_call_indentation.rb +4 -4
- data/lib/rubocop/cop/layout/multiline_method_definition_brace_layout.rb +1 -1
- data/lib/rubocop/cop/layout/multiline_operation_indentation.rb +2 -3
- data/lib/rubocop/cop/layout/parameter_alignment.rb +3 -4
- data/lib/rubocop/cop/layout/redundant_line_break.rb +10 -41
- data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +4 -3
- 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 +2 -1
- data/lib/rubocop/cop/layout/space_around_method_call_operator.rb +1 -1
- data/lib/rubocop/cop/layout/space_around_operators.rb +19 -20
- data/lib/rubocop/cop/layout/space_before_brackets.rb +5 -5
- 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/space_inside_array_literal_brackets.rb +6 -0
- data/lib/rubocop/cop/layout/space_inside_block_braces.rb +4 -0
- data/lib/rubocop/cop/layout/space_inside_hash_literal_braces.rb +4 -0
- data/lib/rubocop/cop/layout/space_inside_string_interpolation.rb +0 -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/ambiguous_range.rb +4 -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/big_decimal_new.rb +4 -7
- data/lib/rubocop/cop/lint/binary_operator_with_identical_operands.rb +10 -12
- data/lib/rubocop/cop/lint/boolean_symbol.rb +1 -1
- data/lib/rubocop/cop/lint/circular_argument_reference.rb +6 -0
- 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/deprecated_open_ssl_constant.rb +2 -1
- data/lib/rubocop/cop/lint/duplicate_branch.rb +39 -4
- data/lib/rubocop/cop/lint/duplicate_match_pattern.rb +1 -1
- data/lib/rubocop/cop/lint/duplicate_regexp_character_class_element.rb +1 -1
- data/lib/rubocop/cop/lint/duplicate_set_element.rb +87 -0
- data/lib/rubocop/cop/lint/empty_ensure.rb +1 -1
- data/lib/rubocop/cop/lint/empty_expression.rb +0 -2
- data/lib/rubocop/cop/lint/empty_file.rb +0 -2
- data/lib/rubocop/cop/lint/ensure_return.rb +1 -4
- data/lib/rubocop/cop/lint/erb_new_arguments.rb +1 -1
- data/lib/rubocop/cop/lint/float_comparison.rb +20 -9
- data/lib/rubocop/cop/lint/float_out_of_range.rb +2 -4
- data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +2 -2
- data/lib/rubocop/cop/lint/hash_new_with_keyword_arguments_as_default.rb +55 -0
- data/lib/rubocop/cop/lint/implicit_string_concatenation.rb +11 -5
- data/lib/rubocop/cop/lint/interpolation_check.rb +9 -0
- data/lib/rubocop/cop/lint/it_without_arguments_in_block.rb +8 -14
- data/lib/rubocop/cop/lint/literal_as_condition.rb +1 -0
- data/lib/rubocop/cop/lint/literal_assignment_in_condition.rb +1 -1
- data/lib/rubocop/cop/lint/literal_in_interpolation.rb +49 -8
- data/lib/rubocop/cop/lint/missing_super.rb +2 -2
- data/lib/rubocop/cop/lint/mixed_case_range.rb +3 -6
- data/lib/rubocop/cop/lint/mixed_regexp_capture_types.rb +1 -1
- data/lib/rubocop/cop/lint/nested_method_definition.rb +9 -5
- data/lib/rubocop/cop/lint/next_without_accumulator.rb +1 -1
- data/lib/rubocop/cop/lint/no_return_in_begin_end_blocks.rb +2 -2
- data/lib/rubocop/cop/lint/non_atomic_file_operation.rb +12 -3
- data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +3 -3
- data/lib/rubocop/cop/lint/non_local_exit_from_iterator.rb +1 -1
- data/lib/rubocop/cop/lint/number_conversion.rb +0 -1
- data/lib/rubocop/cop/lint/numbered_parameter_assignment.rb +1 -2
- data/lib/rubocop/cop/lint/numeric_operation_with_constant_result.rb +93 -0
- data/lib/rubocop/cop/lint/or_assignment_to_constant.rb +1 -2
- data/lib/rubocop/cop/lint/out_of_range_regexp_ref.rb +3 -2
- data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +6 -11
- data/lib/rubocop/cop/lint/redundant_cop_enable_directive.rb +1 -1
- data/lib/rubocop/cop/lint/redundant_regexp_quantifiers.rb +1 -1
- data/lib/rubocop/cop/lint/redundant_safe_navigation.rb +13 -8
- data/lib/rubocop/cop/lint/redundant_splat_expansion.rb +8 -7
- data/lib/rubocop/cop/lint/redundant_string_coercion.rb +2 -2
- data/lib/rubocop/cop/lint/redundant_type_conversion.rb +231 -0
- data/lib/rubocop/cop/lint/refinement_import_methods.rb +1 -1
- data/lib/rubocop/cop/lint/regexp_as_condition.rb +0 -1
- data/lib/rubocop/cop/lint/rescue_exception.rb +1 -1
- data/lib/rubocop/cop/lint/rescue_type.rb +3 -7
- data/lib/rubocop/cop/lint/safe_navigation_chain.rb +17 -1
- data/lib/rubocop/cop/lint/safe_navigation_consistency.rb +109 -41
- data/lib/rubocop/cop/lint/self_assignment.rb +8 -10
- data/lib/rubocop/cop/lint/shadowed_exception.rb +1 -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 +2 -2
- data/lib/rubocop/cop/lint/syntax.rb +4 -1
- data/lib/rubocop/cop/lint/unescaped_bracket_in_regexp.rb +88 -0
- 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 +51 -2
- data/lib/rubocop/cop/lint/unreachable_loop.rb +1 -1
- data/lib/rubocop/cop/lint/unused_method_argument.rb +18 -2
- data/lib/rubocop/cop/lint/uri_regexp.rb +25 -7
- 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_defined.rb +55 -0
- data/lib/rubocop/cop/lint/useless_else_without_rescue.rb +4 -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_rescue.rb +1 -1
- data/lib/rubocop/cop/lint/useless_ruby2_keywords.rb +2 -2
- data/lib/rubocop/cop/lint/useless_setter_call.rb +14 -25
- data/lib/rubocop/cop/lint/void.rb +8 -11
- data/lib/rubocop/cop/metrics/block_nesting.rb +1 -1
- data/lib/rubocop/cop/metrics/class_length.rb +9 -9
- data/lib/rubocop/cop/metrics/collection_literal_length.rb +7 -0
- data/lib/rubocop/cop/metrics/cyclomatic_complexity.rb +5 -2
- 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/abc_size_calculator.rb +1 -1
- data/lib/rubocop/cop/metrics/utils/code_length_calculator.rb +2 -3
- 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_assignment.rb +4 -12
- data/lib/rubocop/cop/mixin/check_line_breakable.rb +20 -10
- data/lib/rubocop/cop/mixin/check_single_line_suitability.rb +49 -0
- data/lib/rubocop/cop/mixin/comments_help.rb +8 -3
- data/lib/rubocop/cop/mixin/dig_help.rb +27 -0
- data/lib/rubocop/cop/mixin/endless_method_rewriter.rb +24 -0
- data/lib/rubocop/cop/mixin/frozen_string_literal.rb +4 -2
- data/lib/rubocop/cop/mixin/hash_shorthand_syntax.rb +22 -22
- data/lib/rubocop/cop/mixin/hash_subset.rb +188 -0
- data/lib/rubocop/cop/mixin/hash_transform_method.rb +74 -74
- data/lib/rubocop/cop/mixin/line_length_help.rb +5 -4
- data/lib/rubocop/cop/mixin/method_complexity.rb +1 -1
- data/lib/rubocop/cop/mixin/multiline_expression_indentation.rb +5 -9
- data/lib/rubocop/cop/mixin/percent_array.rb +1 -1
- data/lib/rubocop/cop/mixin/percent_literal.rb +1 -1
- data/lib/rubocop/cop/mixin/preceding_following_alignment.rb +68 -30
- data/lib/rubocop/cop/mixin/range_help.rb +3 -4
- data/lib/rubocop/cop/mixin/space_before_punctuation.rb +1 -1
- data/lib/rubocop/cop/mixin/statement_modifier.rb +11 -5
- 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/target_ruby_version.rb +17 -1
- data/lib/rubocop/cop/mixin/trailing_comma.rb +3 -3
- data/lib/rubocop/cop/naming/accessor_method_name.rb +6 -6
- data/lib/rubocop/cop/naming/block_forwarding.rb +20 -16
- data/lib/rubocop/cop/naming/constant_name.rb +6 -7
- data/lib/rubocop/cop/naming/file_name.rb +0 -2
- data/lib/rubocop/cop/naming/inclusive_language.rb +12 -3
- data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +11 -12
- data/lib/rubocop/cop/naming/predicate_name.rb +45 -1
- data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +6 -14
- data/lib/rubocop/cop/naming/variable_name.rb +3 -4
- data/lib/rubocop/cop/naming/variable_number.rb +2 -3
- data/lib/rubocop/cop/offense.rb +4 -5
- data/lib/rubocop/cop/security/compound_hash.rb +2 -0
- data/lib/rubocop/cop/security/yaml_load.rb +3 -2
- data/lib/rubocop/cop/style/access_modifier_declarations.rb +96 -28
- data/lib/rubocop/cop/style/accessor_grouping.rb +10 -2
- data/lib/rubocop/cop/style/ambiguous_endless_method_definition.rb +79 -0
- data/lib/rubocop/cop/style/and_or.rb +1 -1
- data/lib/rubocop/cop/style/arguments_forwarding.rb +78 -22
- data/lib/rubocop/cop/style/array_first_last.rb +18 -2
- data/lib/rubocop/cop/style/array_intersect.rb +5 -4
- data/lib/rubocop/cop/style/bitwise_predicate.rb +100 -0
- data/lib/rubocop/cop/style/block_delimiters.rb +49 -19
- data/lib/rubocop/cop/style/case_like_if.rb +8 -11
- data/lib/rubocop/cop/style/class_and_module_children.rb +6 -3
- data/lib/rubocop/cop/style/collection_compact.rb +10 -10
- data/lib/rubocop/cop/style/collection_methods.rb +1 -1
- data/lib/rubocop/cop/style/combinable_defined.rb +115 -0
- data/lib/rubocop/cop/style/combinable_loops.rb +9 -2
- data/lib/rubocop/cop/style/commented_keyword.rb +17 -1
- data/lib/rubocop/cop/style/concat_array_literals.rb +1 -1
- data/lib/rubocop/cop/style/conditional_assignment.rb +26 -26
- data/lib/rubocop/cop/style/constant_visibility.rb +3 -12
- data/lib/rubocop/cop/style/data_inheritance.rb +1 -1
- data/lib/rubocop/cop/style/dig_chain.rb +89 -0
- 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 +1 -14
- data/lib/rubocop/cop/style/eval_with_location.rb +2 -2
- data/lib/rubocop/cop/style/exact_regexp_match.rb +2 -3
- 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 +2 -1
- data/lib/rubocop/cop/style/file_null.rb +89 -0
- data/lib/rubocop/cop/style/file_touch.rb +75 -0
- data/lib/rubocop/cop/style/float_division.rb +8 -4
- data/lib/rubocop/cop/style/for.rb +0 -1
- data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +1 -1
- data/lib/rubocop/cop/style/global_vars.rb +1 -3
- data/lib/rubocop/cop/style/guard_clause.rb +16 -3
- data/lib/rubocop/cop/style/hash_conversion.rb +1 -2
- data/lib/rubocop/cop/style/hash_each_methods.rb +9 -6
- data/lib/rubocop/cop/style/hash_except.rb +35 -147
- data/lib/rubocop/cop/style/hash_slice.rb +80 -0
- data/lib/rubocop/cop/style/hash_syntax.rb +8 -5
- data/lib/rubocop/cop/style/identical_conditional_branches.rb +22 -3
- data/lib/rubocop/cop/style/if_inside_else.rb +1 -2
- data/lib/rubocop/cop/style/if_unless_modifier.rb +3 -3
- data/lib/rubocop/cop/style/if_with_boolean_literal_branches.rb +2 -3
- data/lib/rubocop/cop/style/if_with_semicolon.rb +26 -11
- data/lib/rubocop/cop/style/infinite_loop.rb +1 -1
- data/lib/rubocop/cop/style/inverse_methods.rb +6 -7
- data/lib/rubocop/cop/style/it_assignment.rb +36 -0
- data/lib/rubocop/cop/style/keyword_arguments_merging.rb +67 -0
- data/lib/rubocop/cop/style/keyword_parameters_order.rb +1 -1
- data/lib/rubocop/cop/style/lambda.rb +1 -1
- data/lib/rubocop/cop/style/lambda_call.rb +3 -2
- data/lib/rubocop/cop/style/map_into_array.rb +60 -9
- 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 +32 -20
- data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +2 -0
- data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +8 -11
- 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/missing_respond_to_missing.rb +33 -3
- data/lib/rubocop/cop/style/multiline_block_chain.rb +1 -1
- data/lib/rubocop/cop/style/multiline_memoization.rb +2 -2
- data/lib/rubocop/cop/style/multiple_comparison.rb +52 -51
- data/lib/rubocop/cop/style/mutable_constant.rb +7 -8
- data/lib/rubocop/cop/style/negated_if_else_condition.rb +7 -5
- data/lib/rubocop/cop/style/nested_modifier.rb +1 -1
- data/lib/rubocop/cop/style/nested_parenthesized_calls.rb +2 -2
- data/lib/rubocop/cop/style/nested_ternary_operator.rb +5 -4
- data/lib/rubocop/cop/style/not.rb +1 -1
- data/lib/rubocop/cop/style/object_then.rb +14 -15
- data/lib/rubocop/cop/style/one_line_conditional.rb +29 -4
- data/lib/rubocop/cop/style/open_struct_use.rb +5 -5
- data/lib/rubocop/cop/style/operator_method_call.rb +25 -7
- data/lib/rubocop/cop/style/or_assignment.rb +3 -6
- data/lib/rubocop/cop/style/parallel_assignment.rb +9 -18
- 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 +7 -5
- data/lib/rubocop/cop/style/random_with_offset.rb +3 -3
- data/lib/rubocop/cop/style/redundant_argument.rb +3 -1
- data/lib/rubocop/cop/style/redundant_assignment.rb +1 -1
- data/lib/rubocop/cop/style/redundant_begin.rb +5 -1
- data/lib/rubocop/cop/style/redundant_condition.rb +39 -24
- 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 +238 -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 +56 -17
- data/lib/rubocop/cop/style/redundant_parentheses.rb +37 -25
- data/lib/rubocop/cop/style/redundant_regexp_argument.rb +4 -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_return.rb +2 -2
- data/lib/rubocop/cop/style/redundant_self.rb +8 -15
- data/lib/rubocop/cop/style/redundant_self_assignment.rb +20 -32
- data/lib/rubocop/cop/style/redundant_self_assignment_branch.rb +4 -4
- data/lib/rubocop/cop/style/redundant_sort.rb +3 -3
- data/lib/rubocop/cop/style/redundant_string_escape.rb +2 -2
- data/lib/rubocop/cop/style/require_order.rb +1 -1
- data/lib/rubocop/cop/style/rescue_modifier.rb +15 -4
- data/lib/rubocop/cop/style/return_nil.rb +1 -1
- data/lib/rubocop/cop/style/return_nil_in_predicate_method_definition.rb +54 -12
- data/lib/rubocop/cop/style/safe_navigation.rb +105 -51
- data/lib/rubocop/cop/style/safe_navigation_chain_length.rb +52 -0
- data/lib/rubocop/cop/style/select_by_regexp.rb +10 -7
- data/lib/rubocop/cop/style/self_assignment.rb +11 -17
- data/lib/rubocop/cop/style/semicolon.rb +2 -2
- data/lib/rubocop/cop/style/send_with_literal_method_name.rb +2 -1
- data/lib/rubocop/cop/style/signal_exception.rb +2 -3
- data/lib/rubocop/cop/style/single_argument_dig.rb +9 -5
- data/lib/rubocop/cop/style/single_line_block_params.rb +1 -1
- data/lib/rubocop/cop/style/single_line_do_end_block.rb +12 -3
- data/lib/rubocop/cop/style/single_line_methods.rb +3 -4
- data/lib/rubocop/cop/style/slicing_with_range.rb +40 -11
- data/lib/rubocop/cop/style/sole_nested_conditional.rb +4 -5
- data/lib/rubocop/cop/style/special_global_vars.rb +1 -1
- data/lib/rubocop/cop/style/string_concatenation.rb +14 -13
- 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/struct_inheritance.rb +1 -1
- data/lib/rubocop/cop/style/super_arguments.rb +65 -17
- data/lib/rubocop/cop/style/swap_values.rb +4 -15
- data/lib/rubocop/cop/style/ternary_parentheses.rb +26 -5
- 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_underscore_variable.rb +4 -4
- data/lib/rubocop/cop/style/trivial_accessors.rb +1 -1
- data/lib/rubocop/cop/style/variable_interpolation.rb +1 -2
- 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/team.rb +8 -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/assignment.rb +18 -3
- data/lib/rubocop/cop/variable_force/branch.rb +1 -1
- data/lib/rubocop/cop/variable_force/variable.rb +18 -2
- data/lib/rubocop/cop/variable_force/variable_table.rb +5 -5
- data/lib/rubocop/cop/variable_force.rb +4 -10
- data/lib/rubocop/cops_documentation_generator.rb +100 -51
- data/lib/rubocop/directive_comment.rb +44 -10
- data/lib/rubocop/file_finder.rb +9 -4
- data/lib/rubocop/formatter/disabled_config_formatter.rb +1 -1
- 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 +18 -48
- data/lib/rubocop/lsp/server.rb +0 -3
- data/lib/rubocop/lsp/stdin_runner.rb +83 -0
- data/lib/rubocop/magic_comment.rb +3 -3
- 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 +39 -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 +7 -2
- data/lib/rubocop/rspec/shared_contexts.rb +4 -1
- data/lib/rubocop/rspec/support.rb +1 -2
- data/lib/rubocop/runner.rb +22 -12
- data/lib/rubocop/server/cache.rb +39 -1
- data/lib/rubocop/server/cli.rb +2 -2
- data/lib/rubocop/server/core.rb +1 -0
- data/lib/rubocop/target_finder.rb +1 -0
- data/lib/rubocop/target_ruby.rb +28 -13
- data/lib/rubocop/version.rb +42 -6
- data/lib/rubocop/yaml_duplication_checker.rb +20 -27
- data/lib/rubocop.rb +29 -0
- data/lib/ruby_lsp/rubocop/addon.rb +75 -0
- data/lib/ruby_lsp/rubocop/runtime_adapter.rb +47 -0
- metadata +75 -19
- 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: 4a6ff0f849d961da13d2131ff60e0ed49dce01a4c2d32caa8484a2344344609b
|
4
|
+
data.tar.gz: 9da9fc43212c62cd6542649c90423e9365f50cb00e82b6337be1a241c6a17283
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ff34957554167b3b1e30645e3754094968fae93d0284a3882460b3e24f44fd64bcf358b23fd0e8154489206fd9c95fc6555b551f1af5ac810805fac2b6d27be
|
7
|
+
data.tar.gz: 48e989049de37523554c740ba1368e32de38bc0f879c1fc717924a758a1ba465ef4413cba80a42be59ccaaf87616b52c0ad437256702bf5fd091c4a5818f428a
|
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.72', require: false
|
56
56
|
```
|
57
57
|
|
58
58
|
See [our versioning policy](https://docs.rubocop.org/rubocop/versioning.html) for further details.
|
@@ -247,5 +247,5 @@ RuboCop's changelog is available [here](CHANGELOG.md).
|
|
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
@@ -861,6 +861,7 @@ Layout/FirstMethodArgumentLineBreak:
|
|
861
861
|
Enabled: false
|
862
862
|
VersionAdded: '0.49'
|
863
863
|
AllowMultilineFinalElement: false
|
864
|
+
AllowedMethods: []
|
864
865
|
|
865
866
|
Layout/FirstMethodParameterLineBreak:
|
866
867
|
Description: >-
|
@@ -1036,6 +1037,8 @@ Layout/LeadingCommentSpace:
|
|
1036
1037
|
VersionChanged: '0.73'
|
1037
1038
|
AllowDoxygenCommentStyle: false
|
1038
1039
|
AllowGemfileRubyComment: false
|
1040
|
+
AllowRBSInlineAnnotation: false
|
1041
|
+
AllowSteepAnnotation: false
|
1039
1042
|
|
1040
1043
|
Layout/LeadingEmptyLines:
|
1041
1044
|
Description: Check for unnecessary blank lines at the beginning of a file.
|
@@ -1083,11 +1086,11 @@ Layout/LineLength:
|
|
1083
1086
|
StyleGuide: '#max-line-length'
|
1084
1087
|
Enabled: true
|
1085
1088
|
VersionAdded: '0.25'
|
1086
|
-
VersionChanged: '1.
|
1089
|
+
VersionChanged: '1.69'
|
1087
1090
|
Max: 120
|
1091
|
+
AllowHeredoc: true
|
1088
1092
|
# To make it possible to copy or click on URIs in the code, we allow lines
|
1089
1093
|
# containing a URI to be longer than Max.
|
1090
|
-
AllowHeredoc: true
|
1091
1094
|
AllowURI: true
|
1092
1095
|
URISchemes:
|
1093
1096
|
- http
|
@@ -1099,6 +1102,8 @@ Layout/LineLength:
|
|
1099
1102
|
# elements. Strings will be converted to Regexp objects. A line that matches
|
1100
1103
|
# any regular expression listed in this option will be ignored by LineLength.
|
1101
1104
|
AllowedPatterns: []
|
1105
|
+
# If SplitStrings is true, long strings will be split using continuations
|
1106
|
+
SplitStrings: false
|
1102
1107
|
|
1103
1108
|
Layout/MultilineArrayBraceLayout:
|
1104
1109
|
Description: >-
|
@@ -1496,7 +1501,6 @@ Layout/SpaceInsideHashLiteralBraces:
|
|
1496
1501
|
- space
|
1497
1502
|
- no_space
|
1498
1503
|
|
1499
|
-
|
1500
1504
|
Layout/SpaceInsideParens:
|
1501
1505
|
Description: 'No spaces after ( or before ).'
|
1502
1506
|
StyleGuide: '#spaces-braces'
|
@@ -1612,6 +1616,12 @@ Lint/AmbiguousRegexpLiteral:
|
|
1612
1616
|
VersionAdded: '0.17'
|
1613
1617
|
VersionChanged: '0.83'
|
1614
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
|
+
|
1615
1625
|
Lint/AssignmentInCondition:
|
1616
1626
|
Description: "Don't use assignment in conditions."
|
1617
1627
|
StyleGuide: '#safe-assignment-in-condition'
|
@@ -1631,7 +1641,7 @@ Lint/BinaryOperatorWithIdenticalOperands:
|
|
1631
1641
|
Enabled: true
|
1632
1642
|
Safe: false
|
1633
1643
|
VersionAdded: '0.89'
|
1634
|
-
VersionChanged: '1.
|
1644
|
+
VersionChanged: '1.69'
|
1635
1645
|
|
1636
1646
|
Lint/BooleanSymbol:
|
1637
1647
|
Description: 'Check for `:true` and `:false` symbols.'
|
@@ -1661,6 +1671,11 @@ Lint/ConstantOverwrittenInRescue:
|
|
1661
1671
|
Enabled: pending
|
1662
1672
|
VersionAdded: '1.31'
|
1663
1673
|
|
1674
|
+
Lint/ConstantReassignment:
|
1675
|
+
Description: 'Checks for constant reassignments.'
|
1676
|
+
Enabled: pending
|
1677
|
+
VersionAdded: '1.70'
|
1678
|
+
|
1664
1679
|
Lint/ConstantResolution:
|
1665
1680
|
Description: 'Check that constants are fully qualified with `::`.'
|
1666
1681
|
Enabled: false
|
@@ -1670,6 +1685,11 @@ Lint/ConstantResolution:
|
|
1670
1685
|
# Restrict this cop from only looking at certain names
|
1671
1686
|
Ignore: []
|
1672
1687
|
|
1688
|
+
Lint/CopDirectiveSyntax:
|
1689
|
+
Description: 'Checks that `# rubocop:` directives are strictly formatted.'
|
1690
|
+
Enabled: pending
|
1691
|
+
VersionAdded: '1.72'
|
1692
|
+
|
1673
1693
|
Lint/Debugger:
|
1674
1694
|
Description: 'Check for debugger calls.'
|
1675
1695
|
Enabled: true
|
@@ -1783,6 +1803,7 @@ Lint/DuplicateBranch:
|
|
1783
1803
|
VersionChanged: '1.7'
|
1784
1804
|
IgnoreLiteralBranches: false
|
1785
1805
|
IgnoreConstantBranches: false
|
1806
|
+
IgnoreDuplicateElseBranch: false
|
1786
1807
|
|
1787
1808
|
Lint/DuplicateCaseCondition:
|
1788
1809
|
Description: 'Do not repeat values in case conditionals.'
|
@@ -1832,6 +1853,11 @@ Lint/DuplicateRescueException:
|
|
1832
1853
|
Enabled: true
|
1833
1854
|
VersionAdded: '0.89'
|
1834
1855
|
|
1856
|
+
Lint/DuplicateSetElement:
|
1857
|
+
Description: 'Checks for duplicate elements in Set.'
|
1858
|
+
Enabled: pending
|
1859
|
+
VersionAdded: '1.67'
|
1860
|
+
|
1835
1861
|
Lint/EachWithObjectArgument:
|
1836
1862
|
Description: 'Check for immutable argument given to each_with_object.'
|
1837
1863
|
Enabled: true
|
@@ -1947,6 +1973,11 @@ Lint/HashCompareByIdentity:
|
|
1947
1973
|
Safe: false
|
1948
1974
|
VersionAdded: '0.93'
|
1949
1975
|
|
1976
|
+
Lint/HashNewWithKeywordArgumentsAsDefault:
|
1977
|
+
Description: 'Checks for the deprecated use of keyword arguments for hash default in `Hash.new`.'
|
1978
|
+
Enabled: pending
|
1979
|
+
VersionAdded: '1.69'
|
1980
|
+
|
1950
1981
|
Lint/HeredocMethodCallPosition:
|
1951
1982
|
Description: >-
|
1952
1983
|
Checks for the ordering of a method call where
|
@@ -2137,6 +2168,11 @@ Lint/NumberedParameterAssignment:
|
|
2137
2168
|
Enabled: pending
|
2138
2169
|
VersionAdded: '1.9'
|
2139
2170
|
|
2171
|
+
Lint/NumericOperationWithConstantResult:
|
2172
|
+
Description: 'Checks for numeric operations with constant results.'
|
2173
|
+
Enabled: pending
|
2174
|
+
VersionAdded: '1.69'
|
2175
|
+
|
2140
2176
|
Lint/OrAssignmentToConstant:
|
2141
2177
|
Description: 'Checks unintended or-assignment to constant.'
|
2142
2178
|
Enabled: pending
|
@@ -2254,6 +2290,11 @@ Lint/RedundantStringCoercion:
|
|
2254
2290
|
VersionAdded: '0.19'
|
2255
2291
|
VersionChanged: '0.77'
|
2256
2292
|
|
2293
|
+
Lint/RedundantTypeConversion:
|
2294
|
+
Description: 'Checks for redundantly converting a literal to the same type.'
|
2295
|
+
Enabled: pending
|
2296
|
+
VersionAdded: '1.72'
|
2297
|
+
|
2257
2298
|
Lint/RedundantWithIndex:
|
2258
2299
|
Description: 'Checks for redundant `with_index`.'
|
2259
2300
|
Enabled: true
|
@@ -2327,9 +2368,9 @@ Lint/SafeNavigationChain:
|
|
2327
2368
|
|
2328
2369
|
Lint/SafeNavigationConsistency:
|
2329
2370
|
Description: >-
|
2330
|
-
Check to make sure that if safe navigation is used
|
2331
|
-
|
2332
|
-
for all method calls on
|
2371
|
+
Check to make sure that if safe navigation is used in an `&&` or `||` condition,
|
2372
|
+
consistent and appropriate safe navigation, without excess or deficiency,
|
2373
|
+
is used for all method calls on the same object.
|
2333
2374
|
Enabled: true
|
2334
2375
|
VersionAdded: '0.55'
|
2335
2376
|
VersionChanged: '0.77'
|
@@ -2368,7 +2409,6 @@ Lint/ShadowedArgument:
|
|
2368
2409
|
VersionAdded: '0.52'
|
2369
2410
|
IgnoreImplicitReferences: false
|
2370
2411
|
|
2371
|
-
|
2372
2412
|
Lint/ShadowedException:
|
2373
2413
|
Description: >-
|
2374
2414
|
Avoid rescuing a higher level exception
|
@@ -2383,6 +2423,12 @@ Lint/ShadowingOuterLocalVariable:
|
|
2383
2423
|
Enabled: true
|
2384
2424
|
VersionAdded: '0.9'
|
2385
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
|
+
|
2386
2432
|
Lint/StructNewOverride:
|
2387
2433
|
Description: 'Disallow overriding the `Struct` built-in methods via `Struct.new`.'
|
2388
2434
|
Enabled: true
|
@@ -2397,6 +2443,12 @@ Lint/SuppressedException:
|
|
2397
2443
|
VersionAdded: '0.9'
|
2398
2444
|
VersionChanged: '1.12'
|
2399
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
|
+
|
2400
2452
|
Lint/SymbolConversion:
|
2401
2453
|
Description: 'Checks for unnecessary symbol conversions.'
|
2402
2454
|
Enabled: pending
|
@@ -2448,6 +2500,11 @@ Lint/UnderscorePrefixedVariableName:
|
|
2448
2500
|
VersionAdded: '0.21'
|
2449
2501
|
AllowKeywordBlockArguments: false
|
2450
2502
|
|
2503
|
+
Lint/UnescapedBracketInRegexp:
|
2504
|
+
Description: 'Checks for unescaped literal `]` in Regexp.'
|
2505
|
+
Enabled: pending
|
2506
|
+
VersionAdded: '1.68'
|
2507
|
+
|
2451
2508
|
Lint/UnexpectedBlockArity:
|
2452
2509
|
Description: 'Looks for blocks that have fewer arguments that the calling method expects.'
|
2453
2510
|
Enabled: pending
|
@@ -2507,10 +2564,12 @@ Lint/UnusedMethodArgument:
|
|
2507
2564
|
Enabled: true
|
2508
2565
|
AutoCorrect: contextual
|
2509
2566
|
VersionAdded: '0.21'
|
2510
|
-
VersionChanged: '1.
|
2567
|
+
VersionChanged: '1.69'
|
2511
2568
|
AllowUnusedKeywordArguments: false
|
2512
2569
|
IgnoreEmptyMethods: true
|
2513
2570
|
IgnoreNotImplementedMethods: true
|
2571
|
+
NotImplementedExceptions:
|
2572
|
+
- NotImplementedError
|
2514
2573
|
|
2515
2574
|
Lint/UriEscapeUnescape:
|
2516
2575
|
Description: >-
|
@@ -2545,6 +2604,16 @@ Lint/UselessAssignment:
|
|
2545
2604
|
VersionAdded: '0.11'
|
2546
2605
|
VersionChanged: '1.66'
|
2547
2606
|
|
2607
|
+
Lint/UselessConstantScoping:
|
2608
|
+
Description: 'Checks for useless constant scoping.'
|
2609
|
+
Enabled: pending
|
2610
|
+
VersionAdded: '1.72'
|
2611
|
+
|
2612
|
+
Lint/UselessDefined:
|
2613
|
+
Description: 'Checks for calls to `defined?` with strings and symbols. The result of such a call will always be truthy.'
|
2614
|
+
Enabled: pending
|
2615
|
+
VersionAdded: '1.69'
|
2616
|
+
|
2548
2617
|
Lint/UselessElseWithoutRescue:
|
2549
2618
|
Description: 'Checks for useless `else` in `begin..end` without `rescue`.'
|
2550
2619
|
Enabled: true
|
@@ -2993,6 +3062,8 @@ Naming/PredicateName:
|
|
2993
3062
|
MethodDefinitionMacros:
|
2994
3063
|
- define_method
|
2995
3064
|
- define_singleton_method
|
3065
|
+
# Use Sorbet's T::Boolean return type to detect predicate methods.
|
3066
|
+
UseSorbetSigs: false
|
2996
3067
|
# Exclude Rspec specs because there is a strong convention to write spec
|
2997
3068
|
# helpers in the form of `have_something` or `be_something`.
|
2998
3069
|
Exclude:
|
@@ -3105,13 +3176,14 @@ Style/AccessModifierDeclarations:
|
|
3105
3176
|
Description: 'Checks style of how access modifiers are used.'
|
3106
3177
|
Enabled: true
|
3107
3178
|
VersionAdded: '0.57'
|
3108
|
-
VersionChanged: '
|
3179
|
+
VersionChanged: '1.70'
|
3109
3180
|
EnforcedStyle: group
|
3110
3181
|
SupportedStyles:
|
3111
3182
|
- inline
|
3112
3183
|
- group
|
3113
3184
|
AllowModifiersOnSymbols: true
|
3114
3185
|
AllowModifiersOnAttrs: true
|
3186
|
+
AllowModifiersOnAliasMethod: true
|
3115
3187
|
SafeAutoCorrect: false
|
3116
3188
|
|
3117
3189
|
Style/AccessorGrouping:
|
@@ -3136,6 +3208,12 @@ Style/Alias:
|
|
3136
3208
|
- prefer_alias
|
3137
3209
|
- prefer_alias_method
|
3138
3210
|
|
3211
|
+
Style/AmbiguousEndlessMethodDefinition:
|
3212
|
+
Description: 'Checks for endless methods inside operators of lower precedence.'
|
3213
|
+
StyleGuide: '#ambiguous-endless-method-defintions'
|
3214
|
+
Enabled: pending
|
3215
|
+
VersionAdded: '1.68'
|
3216
|
+
|
3139
3217
|
Style/AndOr:
|
3140
3218
|
Description: 'Use &&/|| instead of and/or.'
|
3141
3219
|
StyleGuide: '#no-and-or-or'
|
@@ -3243,6 +3321,13 @@ Style/BisectedAttrAccessor:
|
|
3243
3321
|
Enabled: true
|
3244
3322
|
VersionAdded: '0.87'
|
3245
3323
|
|
3324
|
+
Style/BitwisePredicate:
|
3325
|
+
Description: 'Prefer bitwise predicate methods over direct comparison operations.'
|
3326
|
+
StyleGuide: '#bitwise-predicate-methods'
|
3327
|
+
Enabled: pending
|
3328
|
+
Safe: false
|
3329
|
+
VersionAdded: '1.68'
|
3330
|
+
|
3246
3331
|
Style/BlockComments:
|
3247
3332
|
Description: 'Do not use block comments.'
|
3248
3333
|
StyleGuide: '#no-block-comments'
|
@@ -3526,6 +3611,11 @@ Style/ColonMethodDefinition:
|
|
3526
3611
|
Enabled: true
|
3527
3612
|
VersionAdded: '0.52'
|
3528
3613
|
|
3614
|
+
Style/CombinableDefined:
|
3615
|
+
Description: 'Checks successive `defined?` calls that can be combined into a single call.'
|
3616
|
+
Enabled: pending
|
3617
|
+
VersionAdded: '1.68'
|
3618
|
+
|
3529
3619
|
Style/CombinableLoops:
|
3530
3620
|
Description: >-
|
3531
3621
|
Checks for places where multiple consecutive loops over the same data
|
@@ -3666,6 +3756,12 @@ Style/DefWithParentheses:
|
|
3666
3756
|
VersionAdded: '0.9'
|
3667
3757
|
VersionChanged: '0.12'
|
3668
3758
|
|
3759
|
+
Style/DigChain:
|
3760
|
+
Description: 'Use `dig` with multiple parameters instead of chaining multiple calls.'
|
3761
|
+
Enabled: pending
|
3762
|
+
Safe: false
|
3763
|
+
VersionAdded: '1.69'
|
3764
|
+
|
3669
3765
|
Style/Dir:
|
3670
3766
|
Description: >-
|
3671
3767
|
Use the `__dir__` method to retrieve the canonicalized
|
@@ -3892,12 +3988,24 @@ Style/FileEmpty:
|
|
3892
3988
|
Safe: false
|
3893
3989
|
VersionAdded: '1.48'
|
3894
3990
|
|
3991
|
+
Style/FileNull:
|
3992
|
+
Description: 'Use `File::NULL` instead of hardcoding "dev/null".'
|
3993
|
+
Enabled: pending
|
3994
|
+
SafeAutoCorrect: false
|
3995
|
+
VersionAdded: '1.69'
|
3996
|
+
|
3895
3997
|
Style/FileRead:
|
3896
3998
|
Description: 'Favor `File.(bin)read` convenience methods.'
|
3897
3999
|
StyleGuide: '#file-read'
|
3898
4000
|
Enabled: pending
|
3899
4001
|
VersionAdded: '1.24'
|
3900
4002
|
|
4003
|
+
Style/FileTouch:
|
4004
|
+
Description: 'Favor `FileUtils.touch` for touching files.'
|
4005
|
+
Enabled: pending
|
4006
|
+
VersionAdded: '1.69'
|
4007
|
+
SafeAutoCorrect: false
|
4008
|
+
|
3901
4009
|
Style/FileWrite:
|
3902
4010
|
Description: 'Favor `File.(bin)write` convenience methods.'
|
3903
4011
|
StyleGuide: '#file-write'
|
@@ -3984,6 +4092,9 @@ Style/FrozenStringLiteralComment:
|
|
3984
4092
|
# exist in a file.
|
3985
4093
|
- never
|
3986
4094
|
SafeAutoCorrect: false
|
4095
|
+
Exclude:
|
4096
|
+
# Prevent the Ruby warning: `'frozen_string_literal' is ignored after any tokens` when using Active Admin.
|
4097
|
+
- '**/*.arb'
|
3987
4098
|
|
3988
4099
|
Style/GlobalStdStream:
|
3989
4100
|
Description: 'Enforces the use of `$stdout/$stderr/$stdin` instead of `STDOUT/STDERR/STDIN`.'
|
@@ -4062,6 +4173,14 @@ Style/HashLikeCase:
|
|
4062
4173
|
# to trigger this cop
|
4063
4174
|
MinBranchesCount: 3
|
4064
4175
|
|
4176
|
+
Style/HashSlice:
|
4177
|
+
Description: >-
|
4178
|
+
Checks for usages of `Hash#reject`, `Hash#select`, and `Hash#filter` methods
|
4179
|
+
that can be replaced with `Hash#slice` method.
|
4180
|
+
Enabled: pending
|
4181
|
+
Safe: false
|
4182
|
+
VersionAdded: '1.71'
|
4183
|
+
|
4065
4184
|
Style/HashSyntax:
|
4066
4185
|
Description: >-
|
4067
4186
|
Prefer Ruby 1.9 hash syntax { a: 1, b: 2 } over 1.8 syntax
|
@@ -4069,7 +4188,7 @@ Style/HashSyntax:
|
|
4069
4188
|
StyleGuide: '#hash-literals'
|
4070
4189
|
Enabled: true
|
4071
4190
|
VersionAdded: '0.9'
|
4072
|
-
VersionChanged: '1.
|
4191
|
+
VersionChanged: '1.67'
|
4073
4192
|
EnforcedStyle: ruby19
|
4074
4193
|
SupportedStyles:
|
4075
4194
|
# checks for 1.9 syntax (e.g. {a: 1}) for all symbol keys
|
@@ -4081,7 +4200,7 @@ Style/HashSyntax:
|
|
4081
4200
|
# enforces both ruby19 and no_mixed_keys styles
|
4082
4201
|
- ruby19_no_mixed_keys
|
4083
4202
|
# Force hashes that have a hash value omission
|
4084
|
-
EnforcedShorthandSyntax:
|
4203
|
+
EnforcedShorthandSyntax: either
|
4085
4204
|
SupportedShorthandSyntax:
|
4086
4205
|
# forces use of the 3.1 syntax (e.g. {foo:}) when the hash key and value are the same.
|
4087
4206
|
- always
|
@@ -4249,6 +4368,19 @@ Style/IpAddresses:
|
|
4249
4368
|
- '**/gems.rb'
|
4250
4369
|
- '**/*.gemspec'
|
4251
4370
|
|
4371
|
+
Style/ItAssignment:
|
4372
|
+
Description: 'Checks for assignment to `it` inside a block.'
|
4373
|
+
Enabled: pending
|
4374
|
+
VersionAdded: '1.70'
|
4375
|
+
|
4376
|
+
Style/KeywordArgumentsMerging:
|
4377
|
+
Description: >-
|
4378
|
+
When passing an existing hash as keyword arguments, provide additional arguments
|
4379
|
+
directly rather than using `merge`.
|
4380
|
+
StyleGuide: '#merging-keyword-arguments'
|
4381
|
+
Enabled: pending
|
4382
|
+
VersionAdded: '1.68'
|
4383
|
+
|
4252
4384
|
Style/KeywordParametersOrder:
|
4253
4385
|
Description: 'Enforces that optional keyword parameters are placed at the end of the parameters list.'
|
4254
4386
|
StyleGuide: '#keyword-parameters-order'
|
@@ -4318,6 +4450,7 @@ Style/MapIntoArray:
|
|
4318
4450
|
StyleGuide: '#functional-code'
|
4319
4451
|
Enabled: pending
|
4320
4452
|
VersionAdded: '1.63'
|
4453
|
+
VersionChanged: '1.67'
|
4321
4454
|
Safe: false
|
4322
4455
|
|
4323
4456
|
Style/MapToHash:
|
@@ -4983,7 +5116,7 @@ Style/RedundantConstantBase:
|
|
4983
5116
|
VersionAdded: '1.40'
|
4984
5117
|
|
4985
5118
|
Style/RedundantCurrentDirectoryInPath:
|
4986
|
-
Description: 'Checks for
|
5119
|
+
Description: 'Checks for a redundant current directory in a path given to `require_relative`.'
|
4987
5120
|
Enabled: pending
|
4988
5121
|
VersionAdded: '1.53'
|
4989
5122
|
|
@@ -5035,6 +5168,13 @@ Style/RedundantFilterChain:
|
|
5035
5168
|
VersionAdded: '1.52'
|
5036
5169
|
VersionChanged: '1.57'
|
5037
5170
|
|
5171
|
+
Style/RedundantFormat:
|
5172
|
+
Description: 'Checks for usages of `Kernel#format` or `Kernel#sprintf` with only a single argument.'
|
5173
|
+
Enabled: pending
|
5174
|
+
SafeAutoCorrect: false
|
5175
|
+
VersionAdded: '1.72'
|
5176
|
+
VersionChanged: '1.72'
|
5177
|
+
|
5038
5178
|
Style/RedundantFreeze:
|
5039
5179
|
Description: "Checks usages of Object#freeze on immutable objects."
|
5040
5180
|
Enabled: true
|
@@ -5208,6 +5348,7 @@ Style/ReturnNilInPredicateMethodDefinition:
|
|
5208
5348
|
AllowedMethods: []
|
5209
5349
|
AllowedPatterns: []
|
5210
5350
|
VersionAdded: '1.53'
|
5351
|
+
VersionChanged: '1.67'
|
5211
5352
|
|
5212
5353
|
Style/SafeNavigation:
|
5213
5354
|
Description: >-
|
@@ -5218,7 +5359,7 @@ Style/SafeNavigation:
|
|
5218
5359
|
be `nil` or truthy, but never `false`.
|
5219
5360
|
Enabled: true
|
5220
5361
|
VersionAdded: '0.43'
|
5221
|
-
VersionChanged: '1.
|
5362
|
+
VersionChanged: '1.67'
|
5222
5363
|
# Safe navigation may cause a statement to start returning `nil` in addition
|
5223
5364
|
# to whatever it used to return.
|
5224
5365
|
ConvertCodeThatCanStartToReturnNil: false
|
@@ -5232,6 +5373,13 @@ Style/SafeNavigation:
|
|
5232
5373
|
# Maximum length of method chains for register an offense.
|
5233
5374
|
MaxChainLength: 2
|
5234
5375
|
|
5376
|
+
Style/SafeNavigationChainLength:
|
5377
|
+
Description: 'Enforces safe navigation chains length to not exceed the configured maximum.'
|
5378
|
+
StyleGuide: '#safe-navigation'
|
5379
|
+
Enabled: pending
|
5380
|
+
VersionAdded: '1.68'
|
5381
|
+
Max: 2
|
5382
|
+
|
5235
5383
|
Style/Sample:
|
5236
5384
|
Description: >-
|
5237
5385
|
Use `sample` instead of `shuffle.first`,
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# Configuration for InternalAffairs cops. This file will be
|
2
|
+
# automatically loaded when `rubocop/cop/internal_affairs` is required.
|
3
|
+
# Only do this when developing custom cops or a RuboCop extension.
|
4
|
+
|
5
|
+
InternalAffairs/CopDescription:
|
6
|
+
Include:
|
7
|
+
- 'lib/rubocop/cop/**/*.rb'
|
8
|
+
|
9
|
+
InternalAffairs/UselessMessageAssertion:
|
10
|
+
Include:
|
11
|
+
- '**/*_spec.rb'
|
data/lib/rubocop/cached_data.rb
CHANGED
@@ -45,15 +45,13 @@ module RuboCop
|
|
45
45
|
|
46
46
|
# Restore an offense object loaded from a JSON file.
|
47
47
|
def deserialize_offenses(offenses)
|
48
|
-
source_buffer = Parser::Source::Buffer.new(@filename)
|
49
|
-
source_buffer.source = File.read(@filename, encoding: Encoding::UTF_8)
|
50
48
|
offenses.map! do |o|
|
51
|
-
location = location_from_source_buffer(o
|
49
|
+
location = location_from_source_buffer(o)
|
52
50
|
Cop::Offense.new(o['severity'], location, o['message'], o['cop_name'], o['status'].to_sym)
|
53
51
|
end
|
54
52
|
end
|
55
53
|
|
56
|
-
def location_from_source_buffer(offense
|
54
|
+
def location_from_source_buffer(offense)
|
57
55
|
begin_pos = offense['location']['begin_pos']
|
58
56
|
end_pos = offense['location']['end_pos']
|
59
57
|
if begin_pos.zero? && end_pos.zero?
|
@@ -62,5 +60,15 @@ module RuboCop
|
|
62
60
|
Parser::Source::Range.new(source_buffer, begin_pos, end_pos)
|
63
61
|
end
|
64
62
|
end
|
63
|
+
|
64
|
+
# Delay creation until needed. Some type of offenses will have no buffer associated with them
|
65
|
+
# and be global only. For these, trying to create the buffer will likely fail, for example
|
66
|
+
# because of unknown encoding comments.
|
67
|
+
def source_buffer
|
68
|
+
@source_buffer ||= begin
|
69
|
+
source = File.read(@filename, encoding: Encoding::UTF_8)
|
70
|
+
Parser::Source::Buffer.new(@filename, source: source)
|
71
|
+
end
|
72
|
+
end
|
65
73
|
end
|
66
74
|
end
|
@@ -151,16 +151,15 @@ module RuboCop
|
|
151
151
|
end
|
152
152
|
|
153
153
|
def relative_path_to_todo_from_options_config
|
154
|
-
return AUTO_GENERATED_FILE
|
154
|
+
return AUTO_GENERATED_FILE unless @options[:config]
|
155
155
|
|
156
|
-
base = Pathname.new(
|
157
|
-
config_dir = Pathname.new(
|
156
|
+
base = Pathname.new(Dir.pwd)
|
157
|
+
config_dir = Pathname.new(@options[:config]).realpath.dirname
|
158
158
|
|
159
|
-
|
160
|
-
|
159
|
+
# Don't have the path start with `/`
|
160
|
+
return AUTO_GENERATED_FILE if config_dir == base
|
161
161
|
|
162
|
-
|
163
|
-
File.dirname(@options[:config]) == '.'
|
162
|
+
"#{base.relative_path_from(config_dir)}/#{AUTO_GENERATED_FILE}"
|
164
163
|
end
|
165
164
|
end
|
166
165
|
end
|
@@ -71,14 +71,14 @@ 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
|
-
#{RuboCop::Version.
|
81
|
+
#{RuboCop::Version.verbose}
|
82
82
|
WARNING
|
83
83
|
end
|
84
84
|
|
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative '../../lsp/server'
|
4
|
-
|
5
3
|
module RuboCop
|
6
4
|
class CLI
|
7
5
|
module Command
|
@@ -11,6 +9,8 @@ module RuboCop
|
|
11
9
|
self.command_name = :lsp
|
12
10
|
|
13
11
|
def run
|
12
|
+
# Load on demand, `languge-server-protocol` is heavy to require.
|
13
|
+
require_relative '../../lsp/server'
|
14
14
|
RuboCop::LSP::Server.new(@config_store).start
|
15
15
|
end
|
16
16
|
end
|
@@ -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
|
@@ -9,8 +9,8 @@ module RuboCop
|
|
9
9
|
self.command_name = :version
|
10
10
|
|
11
11
|
def run
|
12
|
-
puts RuboCop::Version
|
13
|
-
puts RuboCop::Version.
|
12
|
+
puts RuboCop::Version::STRING if @options[:version]
|
13
|
+
puts RuboCop::Version.verbose(env: env) if @options[:verbose_version]
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|