rubocop 1.69.0 → 1.76.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +22 -16
- data/config/default.yml +234 -47
- data/config/internal_affairs.yml +20 -0
- data/config/obsoletion.yml +8 -3
- data/lib/rubocop/cli/command/execute_runner.rb +3 -3
- data/lib/rubocop/cli/command/show_cops.rb +24 -2
- data/lib/rubocop/cli/command/suggest_extensions.rb +7 -1
- data/lib/rubocop/cli.rb +1 -1
- data/lib/rubocop/comment_config.rb +2 -2
- data/lib/rubocop/config.rb +52 -10
- data/lib/rubocop/config_loader.rb +52 -9
- data/lib/rubocop/config_loader_resolver.rb +36 -10
- data/lib/rubocop/config_obsoletion/extracted_cop.rb +4 -3
- data/lib/rubocop/config_obsoletion/renamed_cop.rb +18 -3
- data/lib/rubocop/config_obsoletion.rb +46 -2
- data/lib/rubocop/config_validator.rb +25 -14
- data/lib/rubocop/cop/autocorrect_logic.rb +44 -39
- data/lib/rubocop/cop/base.rb +6 -0
- 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/ordered_gems.rb +1 -1
- data/lib/rubocop/cop/gemspec/duplicated_assignment.rb +50 -6
- data/lib/rubocop/cop/gemspec/ordered_dependencies.rb +1 -1
- data/lib/rubocop/cop/generator.rb +6 -0
- data/lib/rubocop/cop/internal_affairs/cop_enabled.rb +85 -0
- data/lib/rubocop/cop/internal_affairs/example_description.rb +8 -4
- 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 +1 -0
- 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 +231 -0
- data/lib/rubocop/cop/internal_affairs/node_type_group.rb +91 -0
- data/lib/rubocop/cop/internal_affairs/node_type_multiple_predicates.rb +126 -0
- data/lib/rubocop/cop/internal_affairs/node_type_predicate.rb +4 -3
- data/lib/rubocop/cop/internal_affairs/on_send_without_on_csend.rb +90 -0
- data/lib/rubocop/cop/internal_affairs/operator_keyword.rb +4 -2
- data/lib/rubocop/cop/internal_affairs/plugin.rb +33 -0
- data/lib/rubocop/cop/internal_affairs/redundant_described_class_as_subject.rb +6 -5
- data/lib/rubocop/cop/internal_affairs/redundant_source_range.rb +3 -1
- data/lib/rubocop/cop/internal_affairs/single_line_comparison.rb +5 -4
- data/lib/rubocop/cop/internal_affairs/undefined_config.rb +13 -2
- data/lib/rubocop/cop/internal_affairs.rb +6 -16
- data/lib/rubocop/cop/layout/access_modifier_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/argument_alignment.rb +2 -8
- data/lib/rubocop/cop/layout/block_alignment.rb +3 -1
- data/lib/rubocop/cop/layout/block_end_newline.rb +1 -0
- data/lib/rubocop/cop/layout/class_structure.rb +44 -9
- data/lib/rubocop/cop/layout/closing_parenthesis_indentation.rb +4 -4
- 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 +2 -2
- data/lib/rubocop/cop/layout/empty_line_between_defs.rb +7 -11
- data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +34 -3
- data/lib/rubocop/cop/layout/empty_lines_around_begin_body.rb +5 -6
- data/lib/rubocop/cop/layout/empty_lines_around_block_body.rb +1 -0
- data/lib/rubocop/cop/layout/empty_lines_around_exception_handling_keywords.rb +1 -1
- data/lib/rubocop/cop/layout/empty_lines_around_method_body.rb +22 -2
- data/lib/rubocop/cop/layout/end_alignment.rb +1 -1
- data/lib/rubocop/cop/layout/extra_spacing.rb +1 -1
- data/lib/rubocop/cop/layout/first_argument_indentation.rb +4 -9
- data/lib/rubocop/cop/layout/first_array_element_indentation.rb +2 -7
- data/lib/rubocop/cop/layout/first_hash_element_indentation.rb +2 -7
- data/lib/rubocop/cop/layout/first_hash_element_line_break.rb +1 -1
- data/lib/rubocop/cop/layout/first_parameter_indentation.rb +2 -2
- data/lib/rubocop/cop/layout/hash_alignment.rb +8 -6
- data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +2 -1
- data/lib/rubocop/cop/layout/indentation_width.rb +1 -0
- data/lib/rubocop/cop/layout/leading_comment_space.rb +13 -1
- data/lib/rubocop/cop/layout/line_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 +9 -4
- data/lib/rubocop/cop/layout/multiline_block_layout.rb +1 -0
- data/lib/rubocop/cop/layout/multiline_hash_key_line_breaks.rb +1 -1
- data/lib/rubocop/cop/layout/multiline_method_argument_line_breaks.rb +25 -0
- data/lib/rubocop/cop/layout/multiline_method_call_brace_layout.rb +1 -0
- data/lib/rubocop/cop/layout/multiline_method_call_indentation.rb +4 -4
- data/lib/rubocop/cop/layout/multiline_method_parameter_line_breaks.rb +1 -0
- data/lib/rubocop/cop/layout/multiline_operation_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/redundant_line_break.rb +16 -11
- data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +3 -5
- 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 +11 -1
- data/lib/rubocop/cop/layout/space_around_keyword.rb +1 -0
- data/lib/rubocop/cop/layout/space_around_method_call_operator.rb +1 -1
- data/lib/rubocop/cop/layout/space_around_operators.rb +7 -4
- data/lib/rubocop/cop/layout/space_before_block_braces.rb +1 -0
- data/lib/rubocop/cop/layout/space_before_brackets.rb +6 -32
- 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 +5 -1
- data/lib/rubocop/cop/layout/space_inside_block_braces.rb +1 -0
- data/lib/rubocop/cop/layout/space_inside_hash_literal_braces.rb +3 -0
- data/lib/rubocop/cop/layout/trailing_whitespace.rb +5 -3
- data/lib/rubocop/cop/lint/ambiguous_block_association.rb +1 -1
- data/lib/rubocop/cop/lint/array_literal_in_regexp.rb +118 -0
- data/lib/rubocop/cop/lint/assignment_in_condition.rb +1 -3
- data/lib/rubocop/cop/lint/binary_operator_with_identical_operands.rb +2 -3
- data/lib/rubocop/cop/lint/boolean_symbol.rb +1 -1
- data/lib/rubocop/cop/lint/circular_argument_reference.rb +4 -3
- 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 +3 -3
- data/lib/rubocop/cop/lint/deprecated_class_methods.rb +1 -1
- data/lib/rubocop/cop/lint/deprecated_open_ssl_constant.rb +2 -1
- data/lib/rubocop/cop/lint/duplicate_match_pattern.rb +1 -1
- data/lib/rubocop/cop/lint/duplicate_methods.rb +86 -19
- data/lib/rubocop/cop/lint/duplicate_regexp_character_class_element.rb +1 -1
- data/lib/rubocop/cop/lint/duplicate_set_element.rb +20 -7
- data/lib/rubocop/cop/lint/empty_conditional_body.rb +14 -64
- data/lib/rubocop/cop/lint/empty_expression.rb +0 -2
- data/lib/rubocop/cop/lint/empty_interpolation.rb +3 -1
- data/lib/rubocop/cop/lint/erb_new_arguments.rb +0 -6
- data/lib/rubocop/cop/lint/float_comparison.rb +33 -8
- data/lib/rubocop/cop/lint/float_out_of_range.rb +1 -1
- data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +2 -2
- data/lib/rubocop/cop/lint/identity_comparison.rb +19 -15
- data/lib/rubocop/cop/lint/implicit_string_concatenation.rb +1 -1
- data/lib/rubocop/cop/lint/literal_as_condition.rb +110 -9
- data/lib/rubocop/cop/lint/literal_in_interpolation.rb +24 -6
- data/lib/rubocop/cop/lint/missing_cop_enable_directive.rb +1 -1
- data/lib/rubocop/cop/lint/missing_super.rb +2 -2
- data/lib/rubocop/cop/lint/mixed_case_range.rb +3 -3
- data/lib/rubocop/cop/lint/mixed_regexp_capture_types.rb +1 -1
- data/lib/rubocop/cop/lint/nested_method_definition.rb +9 -5
- data/lib/rubocop/cop/lint/next_without_accumulator.rb +1 -1
- data/lib/rubocop/cop/lint/non_atomic_file_operation.rb +4 -2
- data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +3 -3
- data/lib/rubocop/cop/lint/non_local_exit_from_iterator.rb +3 -3
- data/lib/rubocop/cop/lint/numeric_operation_with_constant_result.rb +18 -31
- data/lib/rubocop/cop/lint/or_assignment_to_constant.rb +1 -1
- data/lib/rubocop/cop/lint/out_of_range_regexp_ref.rb +2 -1
- data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +1 -5
- data/lib/rubocop/cop/lint/raise_exception.rb +29 -10
- data/lib/rubocop/cop/lint/redundant_regexp_quantifiers.rb +1 -1
- data/lib/rubocop/cop/lint/redundant_require_statement.rb +0 -21
- data/lib/rubocop/cop/lint/redundant_string_coercion.rb +2 -2
- data/lib/rubocop/cop/lint/redundant_type_conversion.rb +261 -0
- data/lib/rubocop/cop/lint/redundant_with_index.rb +3 -0
- data/lib/rubocop/cop/lint/redundant_with_object.rb +3 -0
- data/lib/rubocop/cop/lint/refinement_import_methods.rb +1 -1
- data/lib/rubocop/cop/lint/rescue_exception.rb +1 -1
- data/lib/rubocop/cop/lint/return_in_void_context.rb +9 -11
- data/lib/rubocop/cop/lint/safe_navigation_chain.rb +8 -1
- data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +13 -1
- data/lib/rubocop/cop/lint/shared_mutable_default.rb +76 -0
- data/lib/rubocop/cop/lint/suppressed_exception.rb +1 -1
- data/lib/rubocop/cop/lint/suppressed_exception_in_number_conversion.rb +111 -0
- data/lib/rubocop/cop/lint/symbol_conversion.rb +1 -1
- data/lib/rubocop/cop/lint/syntax.rb +4 -1
- data/lib/rubocop/cop/lint/to_enum_arguments.rb +1 -1
- data/lib/rubocop/cop/lint/top_level_return_with_argument.rb +1 -1
- data/lib/rubocop/cop/lint/unescaped_bracket_in_regexp.rb +1 -1
- data/lib/rubocop/cop/lint/unexpected_block_arity.rb +3 -1
- data/lib/rubocop/cop/lint/unmodified_reduce_accumulator.rb +1 -1
- data/lib/rubocop/cop/lint/unreachable_code.rb +52 -2
- data/lib/rubocop/cop/lint/unreachable_loop.rb +6 -6
- data/lib/rubocop/cop/lint/useless_access_modifier.rb +5 -4
- data/lib/rubocop/cop/lint/useless_assignment.rb +3 -1
- data/lib/rubocop/cop/lint/useless_constant_scoping.rb +71 -0
- data/lib/rubocop/cop/lint/useless_default_value_argument.rb +87 -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_or.rb +98 -0
- 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/void.rb +14 -11
- data/lib/rubocop/cop/message_annotator.rb +7 -3
- data/lib/rubocop/cop/metrics/abc_size.rb +1 -1
- data/lib/rubocop/cop/metrics/block_length.rb +1 -0
- data/lib/rubocop/cop/metrics/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 +1 -1
- data/lib/rubocop/cop/metrics/method_length.rb +9 -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/code_length_calculator.rb +2 -2
- data/lib/rubocop/cop/metrics/utils/repeated_attribute_discount.rb +7 -7
- data/lib/rubocop/cop/mixin/alignment.rb +2 -2
- data/lib/rubocop/cop/mixin/allowed_pattern.rb +4 -4
- data/lib/rubocop/cop/mixin/check_line_breakable.rb +13 -13
- data/lib/rubocop/cop/mixin/check_single_line_suitability.rb +2 -2
- data/lib/rubocop/cop/mixin/comments_help.rb +8 -3
- data/lib/rubocop/cop/mixin/def_node.rb +1 -1
- data/lib/rubocop/cop/mixin/dig_help.rb +1 -1
- data/lib/rubocop/cop/mixin/empty_lines_around_body.rb +1 -1
- data/lib/rubocop/cop/mixin/forbidden_identifiers.rb +20 -0
- data/lib/rubocop/cop/mixin/forbidden_pattern.rb +16 -0
- data/lib/rubocop/cop/mixin/frozen_string_literal.rb +0 -1
- data/lib/rubocop/cop/mixin/hash_alignment_styles.rb +15 -14
- data/lib/rubocop/cop/mixin/hash_shorthand_syntax.rb +22 -22
- data/lib/rubocop/cop/mixin/hash_subset.rb +203 -0
- data/lib/rubocop/cop/mixin/hash_transform_method.rb +74 -74
- data/lib/rubocop/cop/mixin/line_length_help.rb +5 -4
- data/lib/rubocop/cop/mixin/method_complexity.rb +2 -1
- data/lib/rubocop/cop/mixin/multiline_expression_indentation.rb +2 -0
- data/lib/rubocop/cop/mixin/ordered_gem_node.rb +1 -1
- data/lib/rubocop/cop/mixin/percent_literal.rb +1 -1
- data/lib/rubocop/cop/mixin/preceding_following_alignment.rb +68 -30
- data/lib/rubocop/cop/mixin/range_help.rb +15 -3
- data/lib/rubocop/cop/mixin/space_before_punctuation.rb +1 -1
- data/lib/rubocop/cop/mixin/statement_modifier.rb +8 -3
- data/lib/rubocop/cop/mixin/string_help.rb +2 -2
- data/lib/rubocop/cop/mixin/string_literals_help.rb +1 -1
- data/lib/rubocop/cop/mixin/target_ruby_version.rb +1 -1
- data/lib/rubocop/cop/mixin/trailing_comma.rb +21 -5
- data/lib/rubocop/cop/naming/accessor_method_name.rb +6 -6
- data/lib/rubocop/cop/naming/block_forwarding.rb +19 -15
- data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +1 -1
- data/lib/rubocop/cop/naming/method_name.rb +64 -8
- data/lib/rubocop/cop/naming/predicate_method.rb +216 -0
- data/lib/rubocop/cop/naming/{predicate_name.rb → predicate_prefix.rb} +46 -2
- data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +4 -4
- data/lib/rubocop/cop/naming/variable_name.rb +51 -6
- data/lib/rubocop/cop/registry.rb +9 -6
- data/lib/rubocop/cop/security/compound_hash.rb +2 -0
- data/lib/rubocop/cop/security/yaml_load.rb +3 -2
- data/lib/rubocop/cop/style/access_modifier_declarations.rb +66 -15
- data/lib/rubocop/cop/style/accessor_grouping.rb +19 -5
- data/lib/rubocop/cop/style/and_or.rb +1 -1
- data/lib/rubocop/cop/style/arguments_forwarding.rb +47 -28
- data/lib/rubocop/cop/style/array_first_last.rb +18 -2
- data/lib/rubocop/cop/style/array_intersect.rb +39 -28
- data/lib/rubocop/cop/style/block_delimiters.rb +26 -23
- data/lib/rubocop/cop/style/class_and_module_children.rb +52 -11
- data/lib/rubocop/cop/style/class_equality_comparison.rb +1 -1
- data/lib/rubocop/cop/style/collection_methods.rb +2 -1
- data/lib/rubocop/cop/style/combinable_defined.rb +1 -1
- data/lib/rubocop/cop/style/combinable_loops.rb +3 -2
- data/lib/rubocop/cop/style/command_literal.rb +1 -1
- data/lib/rubocop/cop/style/commented_keyword.rb +12 -5
- data/lib/rubocop/cop/style/comparable_between.rb +78 -0
- data/lib/rubocop/cop/style/concat_array_literals.rb +1 -1
- data/lib/rubocop/cop/style/conditional_assignment.rb +20 -6
- data/lib/rubocop/cop/style/data_inheritance.rb +7 -0
- data/lib/rubocop/cop/style/def_with_parentheses.rb +18 -5
- data/lib/rubocop/cop/style/dig_chain.rb +5 -6
- data/lib/rubocop/cop/style/documentation.rb +1 -1
- data/lib/rubocop/cop/style/double_negation.rb +4 -4
- 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 +5 -1
- data/lib/rubocop/cop/style/empty_method.rb +1 -1
- data/lib/rubocop/cop/style/empty_string_inside_interpolation.rb +100 -0
- data/lib/rubocop/cop/style/endless_method.rb +163 -18
- data/lib/rubocop/cop/style/eval_with_location.rb +4 -4
- data/lib/rubocop/cop/style/exact_regexp_match.rb +2 -3
- data/lib/rubocop/cop/style/expand_path_arguments.rb +2 -7
- data/lib/rubocop/cop/style/explicit_block_argument.rb +16 -3
- data/lib/rubocop/cop/style/exponential_notation.rb +3 -3
- data/lib/rubocop/cop/style/fetch_env_var.rb +2 -1
- data/lib/rubocop/cop/style/file_null.rb +20 -4
- data/lib/rubocop/cop/style/float_division.rb +8 -4
- data/lib/rubocop/cop/style/for.rb +1 -0
- data/lib/rubocop/cop/style/format_string_token.rb +38 -11
- data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +3 -2
- data/lib/rubocop/cop/style/global_std_stream.rb +3 -0
- data/lib/rubocop/cop/style/guard_clause.rb +2 -1
- data/lib/rubocop/cop/style/hash_each_methods.rb +6 -8
- data/lib/rubocop/cop/style/hash_except.rb +35 -147
- data/lib/rubocop/cop/style/hash_fetch_chain.rb +104 -0
- data/lib/rubocop/cop/style/hash_slice.rb +80 -0
- data/lib/rubocop/cop/style/hash_syntax.rb +9 -3
- data/lib/rubocop/cop/style/hash_transform_keys.rb +2 -2
- data/lib/rubocop/cop/style/hash_transform_values.rb +2 -2
- data/lib/rubocop/cop/style/identical_conditional_branches.rb +25 -6
- data/lib/rubocop/cop/style/if_inside_else.rb +10 -13
- data/lib/rubocop/cop/style/if_unless_modifier.rb +25 -7
- data/lib/rubocop/cop/style/if_unless_modifier_of_if_unless.rb +4 -7
- data/lib/rubocop/cop/style/if_with_boolean_literal_branches.rb +2 -2
- 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/inverse_methods.rb +15 -11
- data/lib/rubocop/cop/style/invertible_unless_condition.rb +2 -2
- data/lib/rubocop/cop/style/ip_addresses.rb +2 -2
- data/lib/rubocop/cop/style/it_assignment.rb +36 -0
- data/lib/rubocop/cop/style/it_block_parameter.rb +119 -0
- data/lib/rubocop/cop/style/keyword_parameters_order.rb +14 -8
- data/lib/rubocop/cop/style/lambda.rb +1 -0
- data/lib/rubocop/cop/style/lambda_call.rb +10 -3
- data/lib/rubocop/cop/style/line_end_concatenation.rb +10 -4
- data/lib/rubocop/cop/style/map_into_array.rb +5 -2
- data/lib/rubocop/cop/style/map_to_hash.rb +12 -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 +26 -16
- data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +2 -0
- data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +3 -2
- data/lib/rubocop/cop/style/method_called_on_do_end_block.rb +3 -4
- data/lib/rubocop/cop/style/method_def_parentheses.rb +1 -1
- data/lib/rubocop/cop/style/missing_else.rb +2 -0
- data/lib/rubocop/cop/style/multiline_block_chain.rb +3 -2
- data/lib/rubocop/cop/style/multiline_if_modifier.rb +2 -0
- data/lib/rubocop/cop/style/multiline_method_signature.rb +1 -9
- data/lib/rubocop/cop/style/multiple_comparison.rb +34 -22
- data/lib/rubocop/cop/style/mutable_constant.rb +3 -3
- data/lib/rubocop/cop/style/negated_if_else_condition.rb +1 -1
- data/lib/rubocop/cop/style/nested_parenthesized_calls.rb +1 -1
- data/lib/rubocop/cop/style/next.rb +44 -0
- data/lib/rubocop/cop/style/object_then.rb +15 -15
- data/lib/rubocop/cop/style/open_struct_use.rb +5 -5
- data/lib/rubocop/cop/style/parallel_assignment.rb +1 -5
- data/lib/rubocop/cop/style/parentheses_around_condition.rb +2 -2
- data/lib/rubocop/cop/style/percent_literal_delimiters.rb +1 -1
- data/lib/rubocop/cop/style/percent_q_literals.rb +1 -1
- data/lib/rubocop/cop/style/proc.rb +2 -2
- data/lib/rubocop/cop/style/quoted_symbols.rb +1 -1
- data/lib/rubocop/cop/style/raise_args.rb +14 -12
- 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_array_flatten.rb +50 -0
- data/lib/rubocop/cop/style/redundant_begin.rb +2 -1
- data/lib/rubocop/cop/style/redundant_condition.rb +59 -2
- data/lib/rubocop/cop/style/redundant_current_directory_in_path.rb +16 -5
- 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 +262 -0
- data/lib/rubocop/cop/style/redundant_freeze.rb +3 -3
- data/lib/rubocop/cop/style/redundant_initialize.rb +12 -3
- data/lib/rubocop/cop/style/redundant_line_continuation.rb +38 -21
- data/lib/rubocop/cop/style/redundant_parentheses.rb +61 -17
- data/lib/rubocop/cop/style/redundant_regexp_argument.rb +3 -0
- data/lib/rubocop/cop/style/redundant_regexp_character_class.rb +1 -1
- data/lib/rubocop/cop/style/redundant_regexp_escape.rb +1 -1
- data/lib/rubocop/cop/style/redundant_self.rb +2 -1
- data/lib/rubocop/cop/style/redundant_self_assignment.rb +14 -28
- data/lib/rubocop/cop/style/redundant_sort.rb +2 -2
- data/lib/rubocop/cop/style/redundant_sort_by.rb +17 -1
- data/lib/rubocop/cop/style/redundant_string_escape.rb +2 -2
- data/lib/rubocop/cop/style/regexp_literal.rb +1 -1
- data/lib/rubocop/cop/style/rescue_modifier.rb +3 -0
- data/lib/rubocop/cop/style/return_nil.rb +2 -2
- data/lib/rubocop/cop/style/safe_navigation.rb +44 -16
- data/lib/rubocop/cop/style/select_by_regexp.rb +4 -1
- data/lib/rubocop/cop/style/semicolon.rb +1 -1
- data/lib/rubocop/cop/style/send_with_literal_method_name.rb +2 -1
- data/lib/rubocop/cop/style/single_line_block_params.rb +1 -1
- data/lib/rubocop/cop/style/single_line_do_end_block.rb +4 -3
- data/lib/rubocop/cop/style/single_line_methods.rb +6 -7
- data/lib/rubocop/cop/style/slicing_with_range.rb +40 -11
- data/lib/rubocop/cop/style/sole_nested_conditional.rb +42 -105
- data/lib/rubocop/cop/style/string_concatenation.rb +15 -14
- 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 +8 -1
- data/lib/rubocop/cop/style/super_arguments.rb +66 -19
- data/lib/rubocop/cop/style/symbol_proc.rb +2 -0
- data/lib/rubocop/cop/style/ternary_parentheses.rb +1 -1
- data/lib/rubocop/cop/style/top_level_method_definition.rb +2 -1
- data/lib/rubocop/cop/style/trailing_comma_in_arguments.rb +11 -2
- data/lib/rubocop/cop/style/trailing_comma_in_array_literal.rb +47 -6
- data/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb +48 -6
- data/lib/rubocop/cop/style/trivial_accessors.rb +1 -1
- data/lib/rubocop/cop/style/while_until_modifier.rb +0 -1
- data/lib/rubocop/cop/style/yoda_condition.rb +8 -4
- data/lib/rubocop/cop/style/yoda_expression.rb +2 -1
- data/lib/rubocop/cop/team.rb +1 -1
- data/lib/rubocop/cop/util.rb +12 -5
- data/lib/rubocop/cop/utils/format_string.rb +10 -5
- data/lib/rubocop/cop/variable_force/assignment.rb +7 -3
- data/lib/rubocop/cop/variable_force/scope.rb +1 -1
- data/lib/rubocop/cop/variable_force/variable.rb +10 -3
- data/lib/rubocop/cop/variable_force/variable_table.rb +3 -3
- data/lib/rubocop/cop/variable_force.rb +1 -1
- data/lib/rubocop/cops_documentation_generator.rb +31 -16
- data/lib/rubocop/directive_comment.rb +45 -11
- data/lib/rubocop/ext/regexp_node.rb +0 -1
- data/lib/rubocop/formatter/disabled_config_formatter.rb +2 -1
- data/lib/rubocop/formatter/formatter_set.rb +1 -1
- data/lib/rubocop/formatter/html_formatter.rb +1 -1
- data/lib/rubocop/formatter/pacman_formatter.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 -50
- data/lib/rubocop/lsp/server.rb +0 -2
- data/lib/rubocop/lsp/stdin_runner.rb +85 -0
- data/lib/rubocop/magic_comment.rb +11 -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 +46 -0
- data/lib/rubocop/rake_task.rb +4 -1
- data/lib/rubocop/result_cache.rb +13 -13
- data/lib/rubocop/rspec/cop_helper.rb +13 -1
- data/lib/rubocop/rspec/expect_offense.rb +15 -5
- data/lib/rubocop/rspec/shared_contexts.rb +38 -1
- data/lib/rubocop/rspec/support.rb +4 -2
- data/lib/rubocop/runner.rb +10 -7
- data/lib/rubocop/server/cache.rb +47 -11
- data/lib/rubocop/server/cli.rb +2 -2
- data/lib/rubocop/target_finder.rb +7 -2
- data/lib/rubocop/target_ruby.rb +16 -1
- data/lib/rubocop/version.rb +30 -8
- data/lib/rubocop.rb +22 -2
- data/lib/ruby_lsp/rubocop/addon.rb +75 -0
- data/lib/ruby_lsp/rubocop/runtime_adapter.rb +65 -0
- metadata +67 -19
- data/lib/rubocop/cop/utils/regexp_ranges.rb +0 -113
- data/lib/rubocop/rspec/host_environment_simulation_helper.rb +0 -28
data/config/default.yml
CHANGED
@@ -146,12 +146,14 @@ AllCops:
|
|
146
146
|
# Ruby version is still unresolved, RuboCop will use the oldest officially
|
147
147
|
# supported Ruby version (currently Ruby 2.7).
|
148
148
|
TargetRubyVersion: ~
|
149
|
-
#
|
149
|
+
# RuboCop choses the parser engine automatically but you can also specify it yourself.
|
150
|
+
# These options are available:
|
151
|
+
# - `default`
|
150
152
|
# - `parser_whitequark` ... https://github.com/whitequark/parser
|
151
153
|
# - `parser_prism` ... https://github.com/ruby/prism (`Prism::Translation::Parser`)
|
152
|
-
#
|
153
|
-
#
|
154
|
-
ParserEngine:
|
154
|
+
# Not every parser engine can handle every `TargetRubyVersion`. `parser_whitequark`
|
155
|
+
# only works with versions 3.4 and below, `parser_prism` with versions 3.3 and above.
|
156
|
+
ParserEngine: default
|
155
157
|
# Determines if a notification for extension libraries should be shown when
|
156
158
|
# rubocop is run. Keys are the name of the extension, and values are an array
|
157
159
|
# of gems in the Gemfile that the extension is suggested for, if not already
|
@@ -272,7 +274,8 @@ Bundler/OrderedGems:
|
|
272
274
|
Gemspec/AddRuntimeDependency:
|
273
275
|
Description: 'Prefer `add_dependency` over `add_runtime_dependency`.'
|
274
276
|
StyleGuide: '#add_dependency_vs_add_runtime_dependency'
|
275
|
-
|
277
|
+
References:
|
278
|
+
- https://github.com/rubygems/rubygems/issues/7799#issuecomment-2192720316
|
276
279
|
Enabled: pending
|
277
280
|
VersionAdded: '1.65'
|
278
281
|
Include:
|
@@ -341,7 +344,7 @@ Gemspec/RequireMFA:
|
|
341
344
|
Severity: warning
|
342
345
|
VersionAdded: '1.23'
|
343
346
|
VersionChanged: '1.40'
|
344
|
-
|
347
|
+
References:
|
345
348
|
- https://guides.rubygems.org/mfa-requirement-opt-in/
|
346
349
|
Include:
|
347
350
|
- '**/*.gemspec'
|
@@ -602,7 +605,7 @@ Layout/EmptyLineAfterMultilineCondition:
|
|
602
605
|
# This is disabled, because this style is not very common in practice.
|
603
606
|
Enabled: false
|
604
607
|
VersionAdded: '0.90'
|
605
|
-
|
608
|
+
References:
|
606
609
|
- https://github.com/airbnb/ruby#multiline-if-newline
|
607
610
|
|
608
611
|
Layout/EmptyLineBetweenDefs:
|
@@ -637,7 +640,7 @@ Layout/EmptyLinesAroundAccessModifier:
|
|
637
640
|
SupportedStyles:
|
638
641
|
- around
|
639
642
|
- only_before
|
640
|
-
|
643
|
+
References:
|
641
644
|
# A reference to `EnforcedStyle: only_before`.
|
642
645
|
- https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#follow-the-coding-conventions
|
643
646
|
|
@@ -994,7 +997,7 @@ Layout/IndentationConsistency:
|
|
994
997
|
SupportedStyles:
|
995
998
|
- normal
|
996
999
|
- indented_internal_methods
|
997
|
-
|
1000
|
+
References:
|
998
1001
|
# A reference to `EnforcedStyle: indented_internal_methods`.
|
999
1002
|
- https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#follow-the-coding-conventions
|
1000
1003
|
|
@@ -1616,6 +1619,12 @@ Lint/AmbiguousRegexpLiteral:
|
|
1616
1619
|
VersionAdded: '0.17'
|
1617
1620
|
VersionChanged: '0.83'
|
1618
1621
|
|
1622
|
+
Lint/ArrayLiteralInRegexp:
|
1623
|
+
Description: 'Checks for an array literal interpolated inside a regexp.'
|
1624
|
+
Enabled: pending
|
1625
|
+
VersionAdded: '1.71'
|
1626
|
+
SafeAutoCorrect: false
|
1627
|
+
|
1619
1628
|
Lint/AssignmentInCondition:
|
1620
1629
|
Description: "Don't use assignment in conditions."
|
1621
1630
|
StyleGuide: '#safe-assignment-in-condition'
|
@@ -1665,6 +1674,11 @@ Lint/ConstantOverwrittenInRescue:
|
|
1665
1674
|
Enabled: pending
|
1666
1675
|
VersionAdded: '1.31'
|
1667
1676
|
|
1677
|
+
Lint/ConstantReassignment:
|
1678
|
+
Description: 'Checks for constant reassignments.'
|
1679
|
+
Enabled: pending
|
1680
|
+
VersionAdded: '1.70'
|
1681
|
+
|
1668
1682
|
Lint/ConstantResolution:
|
1669
1683
|
Description: 'Check that constants are fully qualified with `::`.'
|
1670
1684
|
Enabled: false
|
@@ -1674,6 +1688,11 @@ Lint/ConstantResolution:
|
|
1674
1688
|
# Restrict this cop from only looking at certain names
|
1675
1689
|
Ignore: []
|
1676
1690
|
|
1691
|
+
Lint/CopDirectiveSyntax:
|
1692
|
+
Description: 'Checks that `# rubocop:` directives are strictly formatted.'
|
1693
|
+
Enabled: pending
|
1694
|
+
VersionAdded: '1.72'
|
1695
|
+
|
1677
1696
|
Lint/Debugger:
|
1678
1697
|
Description: 'Check for debugger calls.'
|
1679
1698
|
Enabled: true
|
@@ -1871,10 +1890,9 @@ Lint/EmptyConditionalBody:
|
|
1871
1890
|
Description: 'Checks for the presence of `if`, `elsif` and `unless` branches without a body.'
|
1872
1891
|
Enabled: true
|
1873
1892
|
AutoCorrect: contextual
|
1874
|
-
SafeAutoCorrect: false
|
1875
1893
|
AllowComments: true
|
1876
1894
|
VersionAdded: '0.89'
|
1877
|
-
VersionChanged: '1.
|
1895
|
+
VersionChanged: '1.73'
|
1878
1896
|
|
1879
1897
|
Lint/EmptyEnsure:
|
1880
1898
|
Description: 'Checks for empty ensure block.'
|
@@ -1905,7 +1923,7 @@ Lint/EmptyInterpolation:
|
|
1905
1923
|
Enabled: true
|
1906
1924
|
AutoCorrect: contextual
|
1907
1925
|
VersionAdded: '0.20'
|
1908
|
-
VersionChanged: '1.
|
1926
|
+
VersionChanged: '1.76'
|
1909
1927
|
|
1910
1928
|
Lint/EmptyWhen:
|
1911
1929
|
Description: 'Checks for `when` branches with empty bodies.'
|
@@ -2018,7 +2036,8 @@ Lint/InterpolationCheck:
|
|
2018
2036
|
|
2019
2037
|
Lint/ItWithoutArgumentsInBlock:
|
2020
2038
|
Description: 'Checks uses of `it` calls without arguments in block.'
|
2021
|
-
|
2039
|
+
References:
|
2040
|
+
- 'https://bugs.ruby-lang.org/issues/18980'
|
2022
2041
|
Enabled: pending
|
2023
2042
|
VersionAdded: '1.59'
|
2024
2043
|
|
@@ -2030,6 +2049,7 @@ Lint/LambdaWithoutLiteralBlock:
|
|
2030
2049
|
Lint/LiteralAsCondition:
|
2031
2050
|
Description: 'Checks of literals used in conditions.'
|
2032
2051
|
Enabled: true
|
2052
|
+
AutoCorrect: contextual
|
2033
2053
|
VersionAdded: '0.51'
|
2034
2054
|
|
2035
2055
|
Lint/LiteralAssignmentInCondition:
|
@@ -2243,9 +2263,8 @@ Lint/RedundantRegexpQuantifiers:
|
|
2243
2263
|
Lint/RedundantRequireStatement:
|
2244
2264
|
Description: 'Checks for unnecessary `require` statement.'
|
2245
2265
|
Enabled: true
|
2246
|
-
SafeAutoCorrect: false
|
2247
2266
|
VersionAdded: '0.76'
|
2248
|
-
VersionChanged: '1.
|
2267
|
+
VersionChanged: '1.73'
|
2249
2268
|
|
2250
2269
|
Lint/RedundantSafeNavigation:
|
2251
2270
|
Description: 'Checks for redundant safe navigation calls.'
|
@@ -2274,6 +2293,11 @@ Lint/RedundantStringCoercion:
|
|
2274
2293
|
VersionAdded: '0.19'
|
2275
2294
|
VersionChanged: '0.77'
|
2276
2295
|
|
2296
|
+
Lint/RedundantTypeConversion:
|
2297
|
+
Description: 'Checks for redundantly converting a literal to the same type.'
|
2298
|
+
Enabled: pending
|
2299
|
+
VersionAdded: '1.72'
|
2300
|
+
|
2277
2301
|
Lint/RedundantWithIndex:
|
2278
2302
|
Description: 'Checks for redundant `with_index`.'
|
2279
2303
|
Enabled: true
|
@@ -2399,8 +2423,15 @@ Lint/ShadowingOuterLocalVariable:
|
|
2399
2423
|
Description: >-
|
2400
2424
|
Do not use the same name as outer local variable
|
2401
2425
|
for block arguments or block local variables.
|
2402
|
-
Enabled:
|
2426
|
+
Enabled: false
|
2403
2427
|
VersionAdded: '0.9'
|
2428
|
+
VersionChanged: '1.76'
|
2429
|
+
|
2430
|
+
Lint/SharedMutableDefault:
|
2431
|
+
Description: 'Checks for mutable literals used as default arguments during Hash initialization.'
|
2432
|
+
StyleGuide: '#no-mutable-defaults'
|
2433
|
+
Enabled: pending
|
2434
|
+
VersionAdded: '1.70'
|
2404
2435
|
|
2405
2436
|
Lint/StructNewOverride:
|
2406
2437
|
Description: 'Disallow overriding the `Struct` built-in methods via `Struct.new`.'
|
@@ -2416,6 +2447,12 @@ Lint/SuppressedException:
|
|
2416
2447
|
VersionAdded: '0.9'
|
2417
2448
|
VersionChanged: '1.12'
|
2418
2449
|
|
2450
|
+
Lint/SuppressedExceptionInNumberConversion:
|
2451
|
+
Description: 'Checks for cases where exceptions unrelated to the numeric constructors may be unintentionally swallowed.'
|
2452
|
+
Enabled: pending
|
2453
|
+
SafeAutoCorrect: false
|
2454
|
+
VersionAdded: '1.72'
|
2455
|
+
|
2419
2456
|
Lint/SymbolConversion:
|
2420
2457
|
Description: 'Checks for unnecessary symbol conversions.'
|
2421
2458
|
Enabled: pending
|
@@ -2571,6 +2608,18 @@ Lint/UselessAssignment:
|
|
2571
2608
|
VersionAdded: '0.11'
|
2572
2609
|
VersionChanged: '1.66'
|
2573
2610
|
|
2611
|
+
Lint/UselessConstantScoping:
|
2612
|
+
Description: 'Checks for useless constant scoping.'
|
2613
|
+
Enabled: pending
|
2614
|
+
VersionAdded: '1.72'
|
2615
|
+
|
2616
|
+
Lint/UselessDefaultValueArgument:
|
2617
|
+
Description: 'Checks for usage of `fetch` or `Array.new` with default value argument and block.'
|
2618
|
+
Enabled: pending
|
2619
|
+
VersionAdded: '1.76'
|
2620
|
+
Safe: false
|
2621
|
+
AllowedReceivers: []
|
2622
|
+
|
2574
2623
|
Lint/UselessDefined:
|
2575
2624
|
Description: 'Checks for calls to `defined?` with strings and symbols. The result of such a call will always be truthy.'
|
2576
2625
|
Enabled: pending
|
@@ -2595,6 +2644,11 @@ Lint/UselessNumericOperation:
|
|
2595
2644
|
Enabled: pending
|
2596
2645
|
VersionAdded: '1.66'
|
2597
2646
|
|
2647
|
+
Lint/UselessOr:
|
2648
|
+
Description: 'Checks for useless OR expressions.'
|
2649
|
+
Enabled: pending
|
2650
|
+
VersionAdded: '1.76'
|
2651
|
+
|
2598
2652
|
Lint/UselessRescue:
|
2599
2653
|
Description: 'Checks for useless `rescue`s.'
|
2600
2654
|
Enabled: pending
|
@@ -2634,8 +2688,8 @@ Metrics/AbcSize:
|
|
2634
2688
|
Description: >-
|
2635
2689
|
A calculated magnitude based on number of assignments,
|
2636
2690
|
branches, and conditions.
|
2637
|
-
|
2638
|
-
-
|
2691
|
+
References:
|
2692
|
+
- https://wiki.c2.com/?AbcMetric
|
2639
2693
|
- https://en.wikipedia.org/wiki/ABC_Software_Metric
|
2640
2694
|
Enabled: true
|
2641
2695
|
VersionAdded: '0.27'
|
@@ -2958,6 +3012,7 @@ Naming/MethodName:
|
|
2958
3012
|
StyleGuide: '#snake-case-symbols-methods-vars'
|
2959
3013
|
Enabled: true
|
2960
3014
|
VersionAdded: '0.50'
|
3015
|
+
VersionChanged: '1.75'
|
2961
3016
|
EnforcedStyle: snake_case
|
2962
3017
|
SupportedStyles:
|
2963
3018
|
- snake_case
|
@@ -2969,6 +3024,10 @@ Naming/MethodName:
|
|
2969
3024
|
# - '\A\s*onSelectionCleared\s*'
|
2970
3025
|
#
|
2971
3026
|
AllowedPatterns: []
|
3027
|
+
ForbiddenIdentifiers:
|
3028
|
+
- __id__
|
3029
|
+
- __send__
|
3030
|
+
ForbiddenPatterns: []
|
2972
3031
|
|
2973
3032
|
Naming/MethodParameterName:
|
2974
3033
|
Description: >-
|
@@ -3000,22 +3059,36 @@ Naming/MethodParameterName:
|
|
3000
3059
|
# Forbidden names that will register an offense
|
3001
3060
|
ForbiddenNames: []
|
3002
3061
|
|
3003
|
-
Naming/
|
3004
|
-
Description: '
|
3062
|
+
Naming/PredicateMethod:
|
3063
|
+
Description: 'Checks that predicate methods end with `?` and non-predicate methods do not.'
|
3064
|
+
Enabled: pending
|
3065
|
+
VersionAdded: '1.76'
|
3066
|
+
# In `aggressive` mode, the cop will register an offense for predicate methods that
|
3067
|
+
# may return a non-boolean value.
|
3068
|
+
# In `conservative` mode, the cop will *not* register an offense for predicate methods
|
3069
|
+
# that may return a non-boolean value.
|
3070
|
+
Mode: conservative
|
3071
|
+
AllowedMethods:
|
3072
|
+
- call
|
3073
|
+
|
3074
|
+
Naming/PredicatePrefix:
|
3075
|
+
Description: 'Predicate method names should not be prefixed and end with a `?`.'
|
3005
3076
|
StyleGuide: '#bool-methods-qmark'
|
3006
3077
|
Enabled: true
|
3007
3078
|
VersionAdded: '0.50'
|
3008
|
-
VersionChanged: '
|
3079
|
+
VersionChanged: '1.75'
|
3009
3080
|
# Predicate name prefixes.
|
3010
3081
|
NamePrefix:
|
3011
3082
|
- is_
|
3012
3083
|
- has_
|
3013
3084
|
- have_
|
3085
|
+
- does_
|
3014
3086
|
# Predicate name prefixes that should be removed.
|
3015
3087
|
ForbiddenPrefixes:
|
3016
3088
|
- is_
|
3017
3089
|
- has_
|
3018
3090
|
- have_
|
3091
|
+
- does_
|
3019
3092
|
# Predicate names which, despite having a forbidden prefix, or no `?`,
|
3020
3093
|
# should still be accepted
|
3021
3094
|
AllowedMethods:
|
@@ -3024,6 +3097,8 @@ Naming/PredicateName:
|
|
3024
3097
|
MethodDefinitionMacros:
|
3025
3098
|
- define_method
|
3026
3099
|
- define_singleton_method
|
3100
|
+
# Use Sorbet's T::Boolean return type to detect predicate methods.
|
3101
|
+
UseSorbetSigs: false
|
3027
3102
|
# Exclude Rspec specs because there is a strong convention to write spec
|
3028
3103
|
# helpers in the form of `have_something` or `be_something`.
|
3029
3104
|
Exclude:
|
@@ -3041,13 +3116,15 @@ Naming/VariableName:
|
|
3041
3116
|
StyleGuide: '#snake-case-symbols-methods-vars'
|
3042
3117
|
Enabled: true
|
3043
3118
|
VersionAdded: '0.50'
|
3044
|
-
VersionChanged: '1.
|
3119
|
+
VersionChanged: '1.73'
|
3045
3120
|
EnforcedStyle: snake_case
|
3046
3121
|
SupportedStyles:
|
3047
3122
|
- snake_case
|
3048
3123
|
- camelCase
|
3049
3124
|
AllowedIdentifiers: []
|
3050
3125
|
AllowedPatterns: []
|
3126
|
+
ForbiddenIdentifiers: []
|
3127
|
+
ForbiddenPatterns: []
|
3051
3128
|
|
3052
3129
|
Naming/VariableNumber:
|
3053
3130
|
Description: 'Use the configured style when numbering symbols, methods and variables.'
|
@@ -3063,6 +3140,8 @@ Naming/VariableNumber:
|
|
3063
3140
|
CheckMethodNames: true
|
3064
3141
|
CheckSymbols: true
|
3065
3142
|
AllowedIdentifiers:
|
3143
|
+
- TLS1_1 # OpenSSL::SSL::TLS1_1_VERSION
|
3144
|
+
- TLS1_2 # OpenSSL::SSL::TLS1_2_VERSION
|
3066
3145
|
- capture3 # Open3.capture3
|
3067
3146
|
- iso8601 # Time#iso8601
|
3068
3147
|
- rfc1123_date # CGI.rfc1123_date
|
@@ -3098,7 +3177,8 @@ Security/JSONLoad:
|
|
3098
3177
|
Description: >-
|
3099
3178
|
Prefer usage of `JSON.parse` over `JSON.load` due to potential
|
3100
3179
|
security issues. See reference for more information.
|
3101
|
-
|
3180
|
+
References:
|
3181
|
+
- 'https://ruby-doc.org/stdlib-2.7.0/libdoc/json/rdoc/JSON.html#method-i-load'
|
3102
3182
|
Enabled: true
|
3103
3183
|
VersionAdded: '0.43'
|
3104
3184
|
VersionChanged: '1.22'
|
@@ -3110,7 +3190,8 @@ Security/MarshalLoad:
|
|
3110
3190
|
Description: >-
|
3111
3191
|
Avoid using of `Marshal.load` or `Marshal.restore` due to potential
|
3112
3192
|
security issues. See reference for more information.
|
3113
|
-
|
3193
|
+
References:
|
3194
|
+
- 'https://ruby-doc.org/core-2.7.0/Marshal.html#module-Marshal-label-Security+considerations'
|
3114
3195
|
Enabled: true
|
3115
3196
|
VersionAdded: '0.47'
|
3116
3197
|
|
@@ -3125,7 +3206,8 @@ Security/YAMLLoad:
|
|
3125
3206
|
Description: >-
|
3126
3207
|
Prefer usage of `YAML.safe_load` over `YAML.load` due to potential
|
3127
3208
|
security issues. See reference for more information.
|
3128
|
-
|
3209
|
+
References:
|
3210
|
+
- 'https://ruby-doc.org/stdlib-2.7.0/libdoc/yaml/rdoc/YAML.html#module-YAML-label-Security'
|
3129
3211
|
Enabled: true
|
3130
3212
|
VersionAdded: '0.47'
|
3131
3213
|
SafeAutoCorrect: false
|
@@ -3136,13 +3218,14 @@ Style/AccessModifierDeclarations:
|
|
3136
3218
|
Description: 'Checks style of how access modifiers are used.'
|
3137
3219
|
Enabled: true
|
3138
3220
|
VersionAdded: '0.57'
|
3139
|
-
VersionChanged: '
|
3221
|
+
VersionChanged: '1.70'
|
3140
3222
|
EnforcedStyle: group
|
3141
3223
|
SupportedStyles:
|
3142
3224
|
- inline
|
3143
3225
|
- group
|
3144
3226
|
AllowModifiersOnSymbols: true
|
3145
3227
|
AllowModifiersOnAttrs: true
|
3228
|
+
AllowModifiersOnAliasMethod: true
|
3146
3229
|
SafeAutoCorrect: false
|
3147
3230
|
|
3148
3231
|
Style/AccessorGrouping:
|
@@ -3218,7 +3301,8 @@ Style/ArrayCoercion:
|
|
3218
3301
|
|
3219
3302
|
Style/ArrayFirstLast:
|
3220
3303
|
Description: 'Use `arr.first` and `arr.last` instead of `arr[0]` and `arr[-1]`.'
|
3221
|
-
|
3304
|
+
References:
|
3305
|
+
- '#first-and-last'
|
3222
3306
|
Enabled: false
|
3223
3307
|
VersionAdded: '1.58'
|
3224
3308
|
Safe: false
|
@@ -3457,6 +3541,7 @@ Style/ClassAndModuleChildren:
|
|
3457
3541
|
SafeAutoCorrect: false
|
3458
3542
|
Enabled: true
|
3459
3543
|
VersionAdded: '0.19'
|
3544
|
+
VersionChanged: '1.74'
|
3460
3545
|
#
|
3461
3546
|
# Basically there are two different styles:
|
3462
3547
|
#
|
@@ -3472,7 +3557,21 @@ Style/ClassAndModuleChildren:
|
|
3472
3557
|
#
|
3473
3558
|
# The compact style is only forced, for classes or modules with one child.
|
3474
3559
|
EnforcedStyle: nested
|
3475
|
-
SupportedStyles:
|
3560
|
+
SupportedStyles: &supported_styles
|
3561
|
+
- nested
|
3562
|
+
- compact
|
3563
|
+
# Configure classes separately, if desired. If not set, or set to `nil`,
|
3564
|
+
# the `EnforcedStyle` value will be used.
|
3565
|
+
EnforcedStyleForClasses: ~
|
3566
|
+
SupportedStylesForClasses:
|
3567
|
+
- ~
|
3568
|
+
- nested
|
3569
|
+
- compact
|
3570
|
+
# Configure modules separately, if desired. If not set, or set to `nil`,
|
3571
|
+
# the `EnforcedStyle` value will be used.
|
3572
|
+
EnforcedStyleForModules: ~
|
3573
|
+
SupportedStylesForModules:
|
3574
|
+
- ~
|
3476
3575
|
- nested
|
3477
3576
|
- compact
|
3478
3577
|
|
@@ -3625,6 +3724,14 @@ Style/CommentedKeyword:
|
|
3625
3724
|
VersionAdded: '0.51'
|
3626
3725
|
VersionChanged: '1.19'
|
3627
3726
|
|
3727
|
+
Style/ComparableBetween:
|
3728
|
+
Description: 'Enforces the use of `Comparable#between?` instead of logical comparison.'
|
3729
|
+
Enabled: pending
|
3730
|
+
Safe: false
|
3731
|
+
VersionAdded: '1.74'
|
3732
|
+
VersionChanged: '1.75'
|
3733
|
+
StyleGuide: '#ranges-or-between'
|
3734
|
+
|
3628
3735
|
Style/ComparableClamp:
|
3629
3736
|
Description: 'Enforces the use of `Comparable#clamp` instead of comparison by minimum and maximum.'
|
3630
3737
|
Enabled: pending
|
@@ -3857,6 +3964,16 @@ Style/EmptyMethod:
|
|
3857
3964
|
- compact
|
3858
3965
|
- expanded
|
3859
3966
|
|
3967
|
+
Style/EmptyStringInsideInterpolation:
|
3968
|
+
Description: 'Checks for empty strings being assigned inside string interpolation.'
|
3969
|
+
StyleGuide: '#empty-strings-in-interpolation'
|
3970
|
+
Enabled: pending
|
3971
|
+
EnforcedStyle: trailing_conditional
|
3972
|
+
SupportedStyles:
|
3973
|
+
- trailing_conditional
|
3974
|
+
- ternary
|
3975
|
+
VersionAdded: '1.76'
|
3976
|
+
|
3860
3977
|
Style/Encoding:
|
3861
3978
|
Description: 'Use UTF-8 as the source file encoding.'
|
3862
3979
|
StyleGuide: '#utf-8'
|
@@ -3881,6 +3998,8 @@ Style/EndlessMethod:
|
|
3881
3998
|
- allow_single_line
|
3882
3999
|
- allow_always
|
3883
4000
|
- disallow
|
4001
|
+
- require_single_line
|
4002
|
+
- require_always
|
3884
4003
|
|
3885
4004
|
Style/EnvHome:
|
3886
4005
|
Description: "Checks for consistent usage of `ENV['HOME']`."
|
@@ -3933,7 +4052,7 @@ Style/ExponentialNotation:
|
|
3933
4052
|
Style/FetchEnvVar:
|
3934
4053
|
Description: >-
|
3935
4054
|
Suggests `ENV.fetch` for the replacement of `ENV[]`.
|
3936
|
-
|
4055
|
+
References:
|
3937
4056
|
- https://rubystyle.guide/#hash-fetch-defaults
|
3938
4057
|
Enabled: pending
|
3939
4058
|
VersionAdded: '1.28'
|
@@ -3974,7 +4093,8 @@ Style/FileWrite:
|
|
3974
4093
|
Style/FloatDivision:
|
3975
4094
|
Description: 'For performing float division, coerce one side only.'
|
3976
4095
|
StyleGuide: '#float-division'
|
3977
|
-
|
4096
|
+
References:
|
4097
|
+
- 'https://blog.rubystyle.guide/ruby/2019/06/21/float-division.html'
|
3978
4098
|
Enabled: true
|
3979
4099
|
VersionAdded: '0.72'
|
3980
4100
|
VersionChanged: '1.9'
|
@@ -4025,8 +4145,14 @@ Style/FormatStringToken:
|
|
4025
4145
|
# style token in a format string to be allowed when enforced style is not
|
4026
4146
|
# `unannotated`.
|
4027
4147
|
MaxUnannotatedPlaceholdersAllowed: 1
|
4148
|
+
# The mode the cop operates in. Two values are allowed:
|
4149
|
+
# * aggressive (default): all strings are considered
|
4150
|
+
# * conservative:
|
4151
|
+
# only register offenses for strings given to `printf`, `sprintf`,
|
4152
|
+
# format` and `%` methods. Other strings are not considered.
|
4153
|
+
Mode: aggressive
|
4028
4154
|
VersionAdded: '0.49'
|
4029
|
-
VersionChanged: '1.
|
4155
|
+
VersionChanged: '1.74'
|
4030
4156
|
AllowedMethods: []
|
4031
4157
|
AllowedPatterns: []
|
4032
4158
|
|
@@ -4051,6 +4177,9 @@ Style/FrozenStringLiteralComment:
|
|
4051
4177
|
# exist in a file.
|
4052
4178
|
- never
|
4053
4179
|
SafeAutoCorrect: false
|
4180
|
+
Exclude:
|
4181
|
+
# Prevent the Ruby warning: `'frozen_string_literal' is ignored after any tokens` when using Active Admin.
|
4182
|
+
- '**/*.arb'
|
4054
4183
|
|
4055
4184
|
Style/GlobalStdStream:
|
4056
4185
|
Description: 'Enforces the use of `$stdout/$stderr/$stdin` instead of `STDOUT/STDERR/STDIN`.'
|
@@ -4062,7 +4191,8 @@ Style/GlobalStdStream:
|
|
4062
4191
|
Style/GlobalVars:
|
4063
4192
|
Description: 'Do not introduce global variables.'
|
4064
4193
|
StyleGuide: '#instance-vars'
|
4065
|
-
|
4194
|
+
References:
|
4195
|
+
- 'https://www.zenspider.com/ruby/quickref.html'
|
4066
4196
|
Enabled: true
|
4067
4197
|
VersionAdded: '0.13'
|
4068
4198
|
# Built-in global variables are allowed by default.
|
@@ -4119,6 +4249,12 @@ Style/HashExcept:
|
|
4119
4249
|
VersionAdded: '1.7'
|
4120
4250
|
VersionChanged: '1.39'
|
4121
4251
|
|
4252
|
+
Style/HashFetchChain:
|
4253
|
+
Description: 'Use `Hash#dig` instead of chained `fetch` calls.'
|
4254
|
+
Enabled: pending
|
4255
|
+
Safe: false
|
4256
|
+
VersionAdded: '1.75'
|
4257
|
+
|
4122
4258
|
Style/HashLikeCase:
|
4123
4259
|
Description: >-
|
4124
4260
|
Checks for places where `case-when` represents a simple 1:1
|
@@ -4129,6 +4265,14 @@ Style/HashLikeCase:
|
|
4129
4265
|
# to trigger this cop
|
4130
4266
|
MinBranchesCount: 3
|
4131
4267
|
|
4268
|
+
Style/HashSlice:
|
4269
|
+
Description: >-
|
4270
|
+
Checks for usages of `Hash#reject`, `Hash#select`, and `Hash#filter` methods
|
4271
|
+
that can be replaced with `Hash#slice` method.
|
4272
|
+
Enabled: pending
|
4273
|
+
Safe: false
|
4274
|
+
VersionAdded: '1.71'
|
4275
|
+
|
4132
4276
|
Style/HashSyntax:
|
4133
4277
|
Description: >-
|
4134
4278
|
Prefer Ruby 1.9 hash syntax { a: 1, b: 2 } over 1.8 syntax
|
@@ -4316,6 +4460,23 @@ Style/IpAddresses:
|
|
4316
4460
|
- '**/gems.rb'
|
4317
4461
|
- '**/*.gemspec'
|
4318
4462
|
|
4463
|
+
Style/ItAssignment:
|
4464
|
+
Description: 'Checks for assignment to `it` inside a block.'
|
4465
|
+
Enabled: pending
|
4466
|
+
VersionAdded: '1.70'
|
4467
|
+
|
4468
|
+
Style/ItBlockParameter:
|
4469
|
+
Description: 'Checks for blocks with one argument where `it` block parameter can be used.'
|
4470
|
+
Enabled: pending
|
4471
|
+
EnforcedStyle: allow_single_line
|
4472
|
+
SupportedStyles:
|
4473
|
+
- allow_single_line
|
4474
|
+
- only_numbered_parameters
|
4475
|
+
- always
|
4476
|
+
- disallow
|
4477
|
+
VersionAdded: '1.75'
|
4478
|
+
VersionChanged: '1.76'
|
4479
|
+
|
4319
4480
|
Style/KeywordArgumentsMerging:
|
4320
4481
|
Description: >-
|
4321
4482
|
When passing an existing hash as keyword arguments, provide additional arguments
|
@@ -4704,7 +4865,7 @@ Style/Next:
|
|
4704
4865
|
StyleGuide: '#no-nested-conditionals'
|
4705
4866
|
Enabled: true
|
4706
4867
|
VersionAdded: '0.22'
|
4707
|
-
VersionChanged: '
|
4868
|
+
VersionChanged: '1.75'
|
4708
4869
|
# With `always` all conditions at the end of an iteration needs to be
|
4709
4870
|
# replaced by next - with `skip_modifier_ifs` the modifier if like this one
|
4710
4871
|
# are ignored: [1, 2].each { |a| return 'yes' if a == 1 }
|
@@ -4712,6 +4873,7 @@ Style/Next:
|
|
4712
4873
|
# `MinBodyLength` defines the number of lines of the a body of an `if` or `unless`
|
4713
4874
|
# needs to have to trigger this cop
|
4714
4875
|
MinBodyLength: 3
|
4876
|
+
AllowConsecutiveConditionals: false
|
4715
4877
|
SupportedStyles:
|
4716
4878
|
- skip_modifier_ifs
|
4717
4879
|
- always
|
@@ -4843,8 +5005,8 @@ Style/OpenStructUse:
|
|
4843
5005
|
Description: >-
|
4844
5006
|
Avoid using OpenStruct. As of Ruby 3.0, use is officially discouraged due to performance,
|
4845
5007
|
version compatibility, and potential security issues.
|
4846
|
-
|
4847
|
-
- https://docs.ruby-lang.org/en/3.0
|
5008
|
+
References:
|
5009
|
+
- https://docs.ruby-lang.org/en/3.0/OpenStruct.html#class-OpenStruct-label-Caveats
|
4848
5010
|
|
4849
5011
|
Enabled: pending
|
4850
5012
|
Safe: false
|
@@ -5026,6 +5188,12 @@ Style/RedundantArrayConstructor:
|
|
5026
5188
|
Enabled: pending
|
5027
5189
|
VersionAdded: '1.52'
|
5028
5190
|
|
5191
|
+
Style/RedundantArrayFlatten:
|
5192
|
+
Description: 'Checks for redundant calls of `Array#flatten`.'
|
5193
|
+
Enabled: pending
|
5194
|
+
Safe: false
|
5195
|
+
VersionAdded: '1.76'
|
5196
|
+
|
5029
5197
|
Style/RedundantAssignment:
|
5030
5198
|
Description: 'Checks for redundant assignment before returning.'
|
5031
5199
|
Enabled: true
|
@@ -5047,6 +5215,9 @@ Style/RedundantCondition:
|
|
5047
5215
|
Description: 'Checks for unnecessary conditional expressions.'
|
5048
5216
|
Enabled: true
|
5049
5217
|
VersionAdded: '0.76'
|
5218
|
+
VersionChanged: '1.73'
|
5219
|
+
AllowedMethods:
|
5220
|
+
- nonzero?
|
5050
5221
|
|
5051
5222
|
Style/RedundantConditional:
|
5052
5223
|
Description: "Don't return true/false from a conditional."
|
@@ -5059,7 +5230,7 @@ Style/RedundantConstantBase:
|
|
5059
5230
|
VersionAdded: '1.40'
|
5060
5231
|
|
5061
5232
|
Style/RedundantCurrentDirectoryInPath:
|
5062
|
-
Description: 'Checks for
|
5233
|
+
Description: 'Checks for a redundant current directory in a path given to `require_relative`.'
|
5063
5234
|
Enabled: pending
|
5064
5235
|
VersionAdded: '1.53'
|
5065
5236
|
|
@@ -5085,7 +5256,8 @@ Style/RedundantFetchBlock:
|
|
5085
5256
|
Description: >-
|
5086
5257
|
Use `fetch(key, value)` instead of `fetch(key) { value }`
|
5087
5258
|
when value has Numeric, Rational, Complex, Symbol or String type, `false`, `true`, `nil` or is a constant.
|
5088
|
-
|
5259
|
+
References:
|
5260
|
+
- 'https://github.com/fastruby/fast-ruby#hashfetch-with-argument-vs-hashfetch--block-code'
|
5089
5261
|
Enabled: true
|
5090
5262
|
Safe: false
|
5091
5263
|
# If enabled, this cop will autocorrect usages of
|
@@ -5111,6 +5283,13 @@ Style/RedundantFilterChain:
|
|
5111
5283
|
VersionAdded: '1.52'
|
5112
5284
|
VersionChanged: '1.57'
|
5113
5285
|
|
5286
|
+
Style/RedundantFormat:
|
5287
|
+
Description: 'Checks for usages of `Kernel#format` or `Kernel#sprintf` with only a single argument.'
|
5288
|
+
Enabled: pending
|
5289
|
+
SafeAutoCorrect: false
|
5290
|
+
VersionAdded: '1.72'
|
5291
|
+
VersionChanged: '1.72'
|
5292
|
+
|
5114
5293
|
Style/RedundantFreeze:
|
5115
5294
|
Description: "Checks usages of Object#freeze on immutable objects."
|
5116
5295
|
Enabled: true
|
@@ -5320,7 +5499,8 @@ Style/Sample:
|
|
5320
5499
|
Description: >-
|
5321
5500
|
Use `sample` instead of `shuffle.first`,
|
5322
5501
|
`shuffle.last`, and `shuffle[Integer]`.
|
5323
|
-
|
5502
|
+
References:
|
5503
|
+
- 'https://github.com/fastruby/fast-ruby#arrayshufflefirst-vs-arraysample-code'
|
5324
5504
|
Enabled: true
|
5325
5505
|
VersionAdded: '0.30'
|
5326
5506
|
|
@@ -5637,14 +5817,17 @@ Style/TrailingCommaInArrayLiteral:
|
|
5637
5817
|
StyleGuide: '#no-trailing-array-commas'
|
5638
5818
|
Enabled: true
|
5639
5819
|
VersionAdded: '0.53'
|
5640
|
-
# If `comma`, the cop requires a comma after the last item in an array,
|
5641
|
-
#
|
5642
|
-
# If `consistent_comma`, the cop requires a comma after the last item of all
|
5643
|
-
#
|
5820
|
+
# If `comma`, the cop requires a comma after the last item in an array, but only when each item is
|
5821
|
+
# on its own line.
|
5822
|
+
# If `consistent_comma`, the cop requires a comma after the last item of all non-empty, multiline
|
5823
|
+
# array literals.
|
5824
|
+
# If `diff_comma`, the cop requires a comma after the last item of all non-empty, multiline array
|
5825
|
+
# literals, but only when that last item immediately precedes a newline.
|
5644
5826
|
EnforcedStyleForMultiline: no_comma
|
5645
5827
|
SupportedStylesForMultiline:
|
5646
5828
|
- comma
|
5647
5829
|
- consistent_comma
|
5830
|
+
- diff_comma
|
5648
5831
|
- no_comma
|
5649
5832
|
|
5650
5833
|
Style/TrailingCommaInBlockArgs:
|
@@ -5656,14 +5839,17 @@ Style/TrailingCommaInBlockArgs:
|
|
5656
5839
|
Style/TrailingCommaInHashLiteral:
|
5657
5840
|
Description: 'Checks for trailing comma in hash literals.'
|
5658
5841
|
Enabled: true
|
5659
|
-
# If `comma`, the cop requires a comma after the last item in a hash,
|
5660
|
-
#
|
5661
|
-
# If `consistent_comma`, the cop requires a comma after the last item of all
|
5662
|
-
#
|
5842
|
+
# If `comma`, the cop requires a comma after the last item in a hash, but only when each item is
|
5843
|
+
# on its own line.
|
5844
|
+
# If `consistent_comma`, the cop requires a comma after the last item of all non-empty, multiline
|
5845
|
+
# hash literals.
|
5846
|
+
# If `diff_comma`, the cop requires a comma after the last item of all non-empty, multiline hash
|
5847
|
+
# literals, but only when that last item immediately precedes a newline.
|
5663
5848
|
EnforcedStyleForMultiline: no_comma
|
5664
5849
|
SupportedStylesForMultiline:
|
5665
5850
|
- comma
|
5666
5851
|
- consistent_comma
|
5852
|
+
- diff_comma
|
5667
5853
|
- no_comma
|
5668
5854
|
VersionAdded: '0.53'
|
5669
5855
|
|
@@ -5809,7 +5995,8 @@ Style/YAMLFileRead:
|
|
5809
5995
|
|
5810
5996
|
Style/YodaCondition:
|
5811
5997
|
Description: 'Forbid or enforce yoda conditions.'
|
5812
|
-
|
5998
|
+
References:
|
5999
|
+
- 'https://en.wikipedia.org/wiki/Yoda_conditions'
|
5813
6000
|
Enabled: true
|
5814
6001
|
EnforcedStyle: forbid_for_all_comparison_operators
|
5815
6002
|
SupportedStyles:
|