rubocop 1.67.0 → 1.73.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +4 -4
- data/config/default.yml +168 -19
- data/config/internal_affairs.yml +16 -0
- data/lib/rubocop/cached_data.rb +12 -4
- data/lib/rubocop/cli/command/execute_runner.rb +4 -4
- 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 +35 -10
- data/lib/rubocop/config_validator.rb +19 -9
- data/lib/rubocop/cop/autocorrect_logic.rb +36 -19
- data/lib/rubocop/cop/base.rb +7 -1
- 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/insecure_protocol_source.rb +0 -1
- 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/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_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_source_range.rb +3 -1
- 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.rb +6 -16
- data/lib/rubocop/cop/layout/access_modifier_indentation.rb +1 -1
- 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/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 +29 -4
- 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_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 +7 -7
- data/lib/rubocop/cop/layout/leading_comment_space.rb +44 -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/array_literal_in_regexp.rb +119 -0
- data/lib/rubocop/cop/lint/assignment_in_condition.rb +1 -3
- data/lib/rubocop/cop/lint/binary_operator_with_identical_operands.rb +10 -12
- 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_methods.rb +0 -14
- data/lib/rubocop/cop/lint/duplicate_regexp_character_class_element.rb +1 -1
- data/lib/rubocop/cop/lint/duplicate_set_element.rb +20 -7
- data/lib/rubocop/cop/lint/empty_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 -1
- data/lib/rubocop/cop/lint/float_comparison.rb +20 -14
- 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 +1 -1
- data/lib/rubocop/cop/lint/interpolation_check.rb +9 -0
- data/lib/rubocop/cop/lint/it_without_arguments_in_block.rb +3 -0
- data/lib/rubocop/cop/lint/literal_as_condition.rb +105 -7
- data/lib/rubocop/cop/lint/literal_assignment_in_condition.rb +1 -1
- data/lib/rubocop/cop/lint/literal_in_interpolation.rb +24 -6
- data/lib/rubocop/cop/lint/missing_super.rb +2 -2
- data/lib/rubocop/cop/lint/mixed_case_range.rb +4 -7
- 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 +1 -5
- 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_require_statement.rb +0 -21
- data/lib/rubocop/cop/lint/redundant_safe_navigation.rb +12 -7
- 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 +252 -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 +5 -1
- 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 +1 -1
- 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/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 +14 -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 +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 +1 -1
- data/lib/rubocop/cop/mixin/multiline_expression_indentation.rb +5 -9
- 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 +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 +17 -1
- data/lib/rubocop/cop/mixin/trailing_comma.rb +15 -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/memoized_instance_variable_name.rb +11 -12
- data/lib/rubocop/cop/naming/predicate_name.rb +44 -0
- data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +6 -14
- data/lib/rubocop/cop/naming/variable_name.rb +63 -6
- data/lib/rubocop/cop/naming/variable_number.rb +2 -3
- data/lib/rubocop/cop/offense.rb +2 -3
- 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 +86 -28
- data/lib/rubocop/cop/style/accessor_grouping.rb +19 -5
- 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 +39 -23
- 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 +41 -24
- 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_methods.rb +1 -1
- data/lib/rubocop/cop/style/combinable_defined.rb +115 -0
- data/lib/rubocop/cop/style/combinable_loops.rb +2 -2
- data/lib/rubocop/cop/style/commented_keyword.rb +11 -1
- data/lib/rubocop/cop/style/concat_array_literals.rb +1 -1
- data/lib/rubocop/cop/style/conditional_assignment.rb +25 -25
- data/lib/rubocop/cop/style/constant_visibility.rb +3 -12
- 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 +150 -18
- data/lib/rubocop/cop/style/eval_with_location.rb +1 -1
- 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 +15 -2
- data/lib/rubocop/cop/style/hash_conversion.rb +1 -2
- data/lib/rubocop/cop/style/hash_each_methods.rb +3 -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 +6 -3
- data/lib/rubocop/cop/style/identical_conditional_branches.rb +22 -3
- data/lib/rubocop/cop/style/if_inside_else.rb +0 -1
- 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 +20 -9
- 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_call.rb +3 -2
- data/lib/rubocop/cop/style/line_end_concatenation.rb +10 -4
- data/lib/rubocop/cop/style/map_into_array.rb +7 -2
- 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 +20 -13
- 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 +1 -1
- 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_parenthesized_calls.rb +1 -1
- 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 +25 -4
- data/lib/rubocop/cop/style/open_struct_use.rb +5 -5
- data/lib/rubocop/cop/style/operator_method_call.rb +5 -6
- 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 +1 -1
- data/lib/rubocop/cop/style/redundant_condition.rb +72 -23
- data/lib/rubocop/cop/style/redundant_current_directory_in_path.rb +2 -1
- data/lib/rubocop/cop/style/redundant_double_splat_hash_braces.rb +6 -10
- data/lib/rubocop/cop/style/redundant_each.rb +1 -1
- data/lib/rubocop/cop/style/redundant_exception.rb +2 -2
- data/lib/rubocop/cop/style/redundant_format.rb +250 -0
- data/lib/rubocop/cop/style/redundant_freeze.rb +2 -2
- data/lib/rubocop/cop/style/redundant_initialize.rb +12 -3
- data/lib/rubocop/cop/style/redundant_line_continuation.rb +54 -15
- data/lib/rubocop/cop/style/redundant_parentheses.rb +36 -24
- 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/rescue_modifier.rb +2 -3
- data/lib/rubocop/cop/style/return_nil.rb +1 -1
- data/lib/rubocop/cop/style/safe_navigation.rb +14 -2
- data/lib/rubocop/cop/style/safe_navigation_chain_length.rb +52 -0
- data/lib/rubocop/cop/style/select_by_regexp.rb +1 -1
- data/lib/rubocop/cop/style/self_assignment.rb +11 -17
- 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/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 +6 -7
- 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 +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/super_arguments.rb +65 -17
- data/lib/rubocop/cop/style/swap_values.rb +4 -15
- data/lib/rubocop/cop/style/ternary_parentheses.rb +25 -4
- data/lib/rubocop/cop/style/top_level_method_definition.rb +1 -1
- data/lib/rubocop/cop/style/trailing_comma_in_arguments.rb +4 -1
- data/lib/rubocop/cop/style/trailing_comma_in_array_literal.rb +47 -6
- data/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb +48 -6
- data/lib/rubocop/cop/style/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/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 +44 -23
- data/lib/rubocop/directive_comment.rb +44 -10
- 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 +17 -49
- data/lib/rubocop/lsp/server.rb +0 -2
- 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 +46 -0
- data/lib/rubocop/rake_task.rb +4 -1
- data/lib/rubocop/result_cache.rb +13 -13
- data/lib/rubocop/rspec/cop_helper.rb +9 -0
- data/lib/rubocop/rspec/expect_offense.rb +6 -2
- data/lib/rubocop/rspec/shared_contexts.rb +19 -1
- data/lib/rubocop/rspec/support.rb +2 -2
- data/lib/rubocop/runner.rb +21 -14
- data/lib/rubocop/server/cache.rb +35 -2
- data/lib/rubocop/server/cli.rb +2 -2
- data/lib/rubocop/target_finder.rb +1 -0
- data/lib/rubocop/target_ruby.rb +16 -1
- data/lib/rubocop/version.rb +41 -7
- data/lib/rubocop.rb +27 -1
- data/lib/ruby_lsp/rubocop/addon.rb +75 -0
- data/lib/ruby_lsp/rubocop/runtime_adapter.rb +47 -0
- metadata +73 -20
- data/lib/rubocop/cop/utils/regexp_ranges.rb +0 -113
- data/lib/rubocop/rspec/host_environment_simulation_helper.rb +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3d6b4b7f7dd2a3128259ff94614da64550ae7c4148106a681987a9ee739b905
|
4
|
+
data.tar.gz: 023ed07c7e4445c1dc44b3062cf0199321e3cc7fc6d4abf55287d281519bdb11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cfc82c25468c882682017c7ab8f750970896dcacae270fc00fc6482e4a7d12a20c97f7f56509811fec8c811981be457fc450c977c058d72700490ae72a4aff0a
|
7
|
+
data.tar.gz: 04cfd985c5527d40ba6fd11e33e64278f37b8fcd78a63cfcdf5fef317bef248bfc8771febfa39a05a474372c1ad56190766dc7a188ea9e17bc72031f16d672da
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -52,7 +52,7 @@ To prevent an unwanted RuboCop update you might want to use a conservative versi
|
|
52
52
|
in your `Gemfile`:
|
53
53
|
|
54
54
|
```rb
|
55
|
-
gem 'rubocop', '~> 1.
|
55
|
+
gem 'rubocop', '~> 1.73', require: false
|
56
56
|
```
|
57
57
|
|
58
58
|
See [our versioning policy](https://docs.rubocop.org/rubocop/versioning.html) for further details.
|
@@ -241,11 +241,11 @@ Become a sponsor and get your logo on our README on GitHub with a link to your s
|
|
241
241
|
<a href="https://opencollective.com/rubocop/organization/28/website" target="_blank"><img src="https://opencollective.com/rubocop/organization/28/avatar.svg"></a>
|
242
242
|
<a href="https://opencollective.com/rubocop/organization/29/website" target="_blank"><img src="https://opencollective.com/rubocop/organization/29/avatar.svg"></a>
|
243
243
|
|
244
|
-
##
|
244
|
+
## Release Notes
|
245
245
|
|
246
|
-
RuboCop's
|
246
|
+
RuboCop's release notes are available [here](https://github.com/rubocop/rubocop/releases).
|
247
247
|
|
248
248
|
## Copyright
|
249
249
|
|
250
|
-
Copyright (c) 2012-
|
250
|
+
Copyright (c) 2012-2025 Bozhidar Batsov. See [LICENSE.txt](LICENSE.txt) for
|
251
251
|
further details.
|
data/config/default.yml
CHANGED
@@ -1038,6 +1038,7 @@ Layout/LeadingCommentSpace:
|
|
1038
1038
|
AllowDoxygenCommentStyle: false
|
1039
1039
|
AllowGemfileRubyComment: false
|
1040
1040
|
AllowRBSInlineAnnotation: false
|
1041
|
+
AllowSteepAnnotation: false
|
1041
1042
|
|
1042
1043
|
Layout/LeadingEmptyLines:
|
1043
1044
|
Description: Check for unnecessary blank lines at the beginning of a file.
|
@@ -1085,11 +1086,11 @@ Layout/LineLength:
|
|
1085
1086
|
StyleGuide: '#max-line-length'
|
1086
1087
|
Enabled: true
|
1087
1088
|
VersionAdded: '0.25'
|
1088
|
-
VersionChanged: '1.
|
1089
|
+
VersionChanged: '1.69'
|
1089
1090
|
Max: 120
|
1091
|
+
AllowHeredoc: true
|
1090
1092
|
# To make it possible to copy or click on URIs in the code, we allow lines
|
1091
1093
|
# containing a URI to be longer than Max.
|
1092
|
-
AllowHeredoc: true
|
1093
1094
|
AllowURI: true
|
1094
1095
|
URISchemes:
|
1095
1096
|
- http
|
@@ -1101,6 +1102,8 @@ Layout/LineLength:
|
|
1101
1102
|
# elements. Strings will be converted to Regexp objects. A line that matches
|
1102
1103
|
# any regular expression listed in this option will be ignored by LineLength.
|
1103
1104
|
AllowedPatterns: []
|
1105
|
+
# If SplitStrings is true, long strings will be split using continuations
|
1106
|
+
SplitStrings: false
|
1104
1107
|
|
1105
1108
|
Layout/MultilineArrayBraceLayout:
|
1106
1109
|
Description: >-
|
@@ -1498,7 +1501,6 @@ Layout/SpaceInsideHashLiteralBraces:
|
|
1498
1501
|
- space
|
1499
1502
|
- no_space
|
1500
1503
|
|
1501
|
-
|
1502
1504
|
Layout/SpaceInsideParens:
|
1503
1505
|
Description: 'No spaces after ( or before ).'
|
1504
1506
|
StyleGuide: '#spaces-braces'
|
@@ -1614,6 +1616,12 @@ Lint/AmbiguousRegexpLiteral:
|
|
1614
1616
|
VersionAdded: '0.17'
|
1615
1617
|
VersionChanged: '0.83'
|
1616
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
|
+
|
1617
1625
|
Lint/AssignmentInCondition:
|
1618
1626
|
Description: "Don't use assignment in conditions."
|
1619
1627
|
StyleGuide: '#safe-assignment-in-condition'
|
@@ -1633,7 +1641,7 @@ Lint/BinaryOperatorWithIdenticalOperands:
|
|
1633
1641
|
Enabled: true
|
1634
1642
|
Safe: false
|
1635
1643
|
VersionAdded: '0.89'
|
1636
|
-
VersionChanged: '1.
|
1644
|
+
VersionChanged: '1.69'
|
1637
1645
|
|
1638
1646
|
Lint/BooleanSymbol:
|
1639
1647
|
Description: 'Check for `:true` and `:false` symbols.'
|
@@ -1663,6 +1671,11 @@ Lint/ConstantOverwrittenInRescue:
|
|
1663
1671
|
Enabled: pending
|
1664
1672
|
VersionAdded: '1.31'
|
1665
1673
|
|
1674
|
+
Lint/ConstantReassignment:
|
1675
|
+
Description: 'Checks for constant reassignments.'
|
1676
|
+
Enabled: pending
|
1677
|
+
VersionAdded: '1.70'
|
1678
|
+
|
1666
1679
|
Lint/ConstantResolution:
|
1667
1680
|
Description: 'Check that constants are fully qualified with `::`.'
|
1668
1681
|
Enabled: false
|
@@ -1672,6 +1685,11 @@ Lint/ConstantResolution:
|
|
1672
1685
|
# Restrict this cop from only looking at certain names
|
1673
1686
|
Ignore: []
|
1674
1687
|
|
1688
|
+
Lint/CopDirectiveSyntax:
|
1689
|
+
Description: 'Checks that `# rubocop:` directives are strictly formatted.'
|
1690
|
+
Enabled: pending
|
1691
|
+
VersionAdded: '1.72'
|
1692
|
+
|
1675
1693
|
Lint/Debugger:
|
1676
1694
|
Description: 'Check for debugger calls.'
|
1677
1695
|
Enabled: true
|
@@ -1785,6 +1803,7 @@ Lint/DuplicateBranch:
|
|
1785
1803
|
VersionChanged: '1.7'
|
1786
1804
|
IgnoreLiteralBranches: false
|
1787
1805
|
IgnoreConstantBranches: false
|
1806
|
+
IgnoreDuplicateElseBranch: false
|
1788
1807
|
|
1789
1808
|
Lint/DuplicateCaseCondition:
|
1790
1809
|
Description: 'Do not repeat values in case conditionals.'
|
@@ -1954,6 +1973,11 @@ Lint/HashCompareByIdentity:
|
|
1954
1973
|
Safe: false
|
1955
1974
|
VersionAdded: '0.93'
|
1956
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
|
+
|
1957
1981
|
Lint/HeredocMethodCallPosition:
|
1958
1982
|
Description: >-
|
1959
1983
|
Checks for the ordering of a method call where
|
@@ -2022,6 +2046,7 @@ Lint/LambdaWithoutLiteralBlock:
|
|
2022
2046
|
Lint/LiteralAsCondition:
|
2023
2047
|
Description: 'Checks of literals used in conditions.'
|
2024
2048
|
Enabled: true
|
2049
|
+
AutoCorrect: contextual
|
2025
2050
|
VersionAdded: '0.51'
|
2026
2051
|
|
2027
2052
|
Lint/LiteralAssignmentInCondition:
|
@@ -2144,6 +2169,11 @@ Lint/NumberedParameterAssignment:
|
|
2144
2169
|
Enabled: pending
|
2145
2170
|
VersionAdded: '1.9'
|
2146
2171
|
|
2172
|
+
Lint/NumericOperationWithConstantResult:
|
2173
|
+
Description: 'Checks for numeric operations with constant results.'
|
2174
|
+
Enabled: pending
|
2175
|
+
VersionAdded: '1.69'
|
2176
|
+
|
2147
2177
|
Lint/OrAssignmentToConstant:
|
2148
2178
|
Description: 'Checks unintended or-assignment to constant.'
|
2149
2179
|
Enabled: pending
|
@@ -2230,9 +2260,8 @@ Lint/RedundantRegexpQuantifiers:
|
|
2230
2260
|
Lint/RedundantRequireStatement:
|
2231
2261
|
Description: 'Checks for unnecessary `require` statement.'
|
2232
2262
|
Enabled: true
|
2233
|
-
SafeAutoCorrect: false
|
2234
2263
|
VersionAdded: '0.76'
|
2235
|
-
VersionChanged: '1.
|
2264
|
+
VersionChanged: '1.73'
|
2236
2265
|
|
2237
2266
|
Lint/RedundantSafeNavigation:
|
2238
2267
|
Description: 'Checks for redundant safe navigation calls.'
|
@@ -2261,6 +2290,11 @@ Lint/RedundantStringCoercion:
|
|
2261
2290
|
VersionAdded: '0.19'
|
2262
2291
|
VersionChanged: '0.77'
|
2263
2292
|
|
2293
|
+
Lint/RedundantTypeConversion:
|
2294
|
+
Description: 'Checks for redundantly converting a literal to the same type.'
|
2295
|
+
Enabled: pending
|
2296
|
+
VersionAdded: '1.72'
|
2297
|
+
|
2264
2298
|
Lint/RedundantWithIndex:
|
2265
2299
|
Description: 'Checks for redundant `with_index`.'
|
2266
2300
|
Enabled: true
|
@@ -2375,7 +2409,6 @@ Lint/ShadowedArgument:
|
|
2375
2409
|
VersionAdded: '0.52'
|
2376
2410
|
IgnoreImplicitReferences: false
|
2377
2411
|
|
2378
|
-
|
2379
2412
|
Lint/ShadowedException:
|
2380
2413
|
Description: >-
|
2381
2414
|
Avoid rescuing a higher level exception
|
@@ -2390,6 +2423,12 @@ Lint/ShadowingOuterLocalVariable:
|
|
2390
2423
|
Enabled: true
|
2391
2424
|
VersionAdded: '0.9'
|
2392
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
|
+
|
2393
2432
|
Lint/StructNewOverride:
|
2394
2433
|
Description: 'Disallow overriding the `Struct` built-in methods via `Struct.new`.'
|
2395
2434
|
Enabled: true
|
@@ -2404,6 +2443,12 @@ Lint/SuppressedException:
|
|
2404
2443
|
VersionAdded: '0.9'
|
2405
2444
|
VersionChanged: '1.12'
|
2406
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
|
+
|
2407
2452
|
Lint/SymbolConversion:
|
2408
2453
|
Description: 'Checks for unnecessary symbol conversions.'
|
2409
2454
|
Enabled: pending
|
@@ -2455,6 +2500,11 @@ Lint/UnderscorePrefixedVariableName:
|
|
2455
2500
|
VersionAdded: '0.21'
|
2456
2501
|
AllowKeywordBlockArguments: false
|
2457
2502
|
|
2503
|
+
Lint/UnescapedBracketInRegexp:
|
2504
|
+
Description: 'Checks for unescaped literal `]` in Regexp.'
|
2505
|
+
Enabled: pending
|
2506
|
+
VersionAdded: '1.68'
|
2507
|
+
|
2458
2508
|
Lint/UnexpectedBlockArity:
|
2459
2509
|
Description: 'Looks for blocks that have fewer arguments that the calling method expects.'
|
2460
2510
|
Enabled: pending
|
@@ -2514,10 +2564,12 @@ Lint/UnusedMethodArgument:
|
|
2514
2564
|
Enabled: true
|
2515
2565
|
AutoCorrect: contextual
|
2516
2566
|
VersionAdded: '0.21'
|
2517
|
-
VersionChanged: '1.
|
2567
|
+
VersionChanged: '1.69'
|
2518
2568
|
AllowUnusedKeywordArguments: false
|
2519
2569
|
IgnoreEmptyMethods: true
|
2520
2570
|
IgnoreNotImplementedMethods: true
|
2571
|
+
NotImplementedExceptions:
|
2572
|
+
- NotImplementedError
|
2521
2573
|
|
2522
2574
|
Lint/UriEscapeUnescape:
|
2523
2575
|
Description: >-
|
@@ -2552,6 +2604,16 @@ Lint/UselessAssignment:
|
|
2552
2604
|
VersionAdded: '0.11'
|
2553
2605
|
VersionChanged: '1.66'
|
2554
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
|
+
|
2555
2617
|
Lint/UselessElseWithoutRescue:
|
2556
2618
|
Description: 'Checks for useless `else` in `begin..end` without `rescue`.'
|
2557
2619
|
Enabled: true
|
@@ -3000,6 +3062,8 @@ Naming/PredicateName:
|
|
3000
3062
|
MethodDefinitionMacros:
|
3001
3063
|
- define_method
|
3002
3064
|
- define_singleton_method
|
3065
|
+
# Use Sorbet's T::Boolean return type to detect predicate methods.
|
3066
|
+
UseSorbetSigs: false
|
3003
3067
|
# Exclude Rspec specs because there is a strong convention to write spec
|
3004
3068
|
# helpers in the form of `have_something` or `be_something`.
|
3005
3069
|
Exclude:
|
@@ -3017,13 +3081,15 @@ Naming/VariableName:
|
|
3017
3081
|
StyleGuide: '#snake-case-symbols-methods-vars'
|
3018
3082
|
Enabled: true
|
3019
3083
|
VersionAdded: '0.50'
|
3020
|
-
VersionChanged: '1.
|
3084
|
+
VersionChanged: '1.73'
|
3021
3085
|
EnforcedStyle: snake_case
|
3022
3086
|
SupportedStyles:
|
3023
3087
|
- snake_case
|
3024
3088
|
- camelCase
|
3025
3089
|
AllowedIdentifiers: []
|
3026
3090
|
AllowedPatterns: []
|
3091
|
+
ForbiddenIdentifiers: []
|
3092
|
+
ForbiddenPatterns: []
|
3027
3093
|
|
3028
3094
|
Naming/VariableNumber:
|
3029
3095
|
Description: 'Use the configured style when numbering symbols, methods and variables.'
|
@@ -3112,13 +3178,14 @@ Style/AccessModifierDeclarations:
|
|
3112
3178
|
Description: 'Checks style of how access modifiers are used.'
|
3113
3179
|
Enabled: true
|
3114
3180
|
VersionAdded: '0.57'
|
3115
|
-
VersionChanged: '
|
3181
|
+
VersionChanged: '1.70'
|
3116
3182
|
EnforcedStyle: group
|
3117
3183
|
SupportedStyles:
|
3118
3184
|
- inline
|
3119
3185
|
- group
|
3120
3186
|
AllowModifiersOnSymbols: true
|
3121
3187
|
AllowModifiersOnAttrs: true
|
3188
|
+
AllowModifiersOnAliasMethod: true
|
3122
3189
|
SafeAutoCorrect: false
|
3123
3190
|
|
3124
3191
|
Style/AccessorGrouping:
|
@@ -3143,6 +3210,12 @@ Style/Alias:
|
|
3143
3210
|
- prefer_alias
|
3144
3211
|
- prefer_alias_method
|
3145
3212
|
|
3213
|
+
Style/AmbiguousEndlessMethodDefinition:
|
3214
|
+
Description: 'Checks for endless methods inside operators of lower precedence.'
|
3215
|
+
StyleGuide: '#ambiguous-endless-method-defintions'
|
3216
|
+
Enabled: pending
|
3217
|
+
VersionAdded: '1.68'
|
3218
|
+
|
3146
3219
|
Style/AndOr:
|
3147
3220
|
Description: 'Use &&/|| instead of and/or.'
|
3148
3221
|
StyleGuide: '#no-and-or-or'
|
@@ -3250,6 +3323,13 @@ Style/BisectedAttrAccessor:
|
|
3250
3323
|
Enabled: true
|
3251
3324
|
VersionAdded: '0.87'
|
3252
3325
|
|
3326
|
+
Style/BitwisePredicate:
|
3327
|
+
Description: 'Prefer bitwise predicate methods over direct comparison operations.'
|
3328
|
+
StyleGuide: '#bitwise-predicate-methods'
|
3329
|
+
Enabled: pending
|
3330
|
+
Safe: false
|
3331
|
+
VersionAdded: '1.68'
|
3332
|
+
|
3253
3333
|
Style/BlockComments:
|
3254
3334
|
Description: 'Do not use block comments.'
|
3255
3335
|
StyleGuide: '#no-block-comments'
|
@@ -3533,6 +3613,11 @@ Style/ColonMethodDefinition:
|
|
3533
3613
|
Enabled: true
|
3534
3614
|
VersionAdded: '0.52'
|
3535
3615
|
|
3616
|
+
Style/CombinableDefined:
|
3617
|
+
Description: 'Checks successive `defined?` calls that can be combined into a single call.'
|
3618
|
+
Enabled: pending
|
3619
|
+
VersionAdded: '1.68'
|
3620
|
+
|
3536
3621
|
Style/CombinableLoops:
|
3537
3622
|
Description: >-
|
3538
3623
|
Checks for places where multiple consecutive loops over the same data
|
@@ -3673,6 +3758,12 @@ Style/DefWithParentheses:
|
|
3673
3758
|
VersionAdded: '0.9'
|
3674
3759
|
VersionChanged: '0.12'
|
3675
3760
|
|
3761
|
+
Style/DigChain:
|
3762
|
+
Description: 'Use `dig` with multiple parameters instead of chaining multiple calls.'
|
3763
|
+
Enabled: pending
|
3764
|
+
Safe: false
|
3765
|
+
VersionAdded: '1.69'
|
3766
|
+
|
3676
3767
|
Style/Dir:
|
3677
3768
|
Description: >-
|
3678
3769
|
Use the `__dir__` method to retrieve the canonicalized
|
@@ -3833,6 +3924,8 @@ Style/EndlessMethod:
|
|
3833
3924
|
- allow_single_line
|
3834
3925
|
- allow_always
|
3835
3926
|
- disallow
|
3927
|
+
- require_single_line
|
3928
|
+
- require_always
|
3836
3929
|
|
3837
3930
|
Style/EnvHome:
|
3838
3931
|
Description: "Checks for consistent usage of `ENV['HOME']`."
|
@@ -3899,12 +3992,24 @@ Style/FileEmpty:
|
|
3899
3992
|
Safe: false
|
3900
3993
|
VersionAdded: '1.48'
|
3901
3994
|
|
3995
|
+
Style/FileNull:
|
3996
|
+
Description: 'Use `File::NULL` instead of hardcoding "dev/null".'
|
3997
|
+
Enabled: pending
|
3998
|
+
SafeAutoCorrect: false
|
3999
|
+
VersionAdded: '1.69'
|
4000
|
+
|
3902
4001
|
Style/FileRead:
|
3903
4002
|
Description: 'Favor `File.(bin)read` convenience methods.'
|
3904
4003
|
StyleGuide: '#file-read'
|
3905
4004
|
Enabled: pending
|
3906
4005
|
VersionAdded: '1.24'
|
3907
4006
|
|
4007
|
+
Style/FileTouch:
|
4008
|
+
Description: 'Favor `FileUtils.touch` for touching files.'
|
4009
|
+
Enabled: pending
|
4010
|
+
VersionAdded: '1.69'
|
4011
|
+
SafeAutoCorrect: false
|
4012
|
+
|
3908
4013
|
Style/FileWrite:
|
3909
4014
|
Description: 'Favor `File.(bin)write` convenience methods.'
|
3910
4015
|
StyleGuide: '#file-write'
|
@@ -3991,6 +4096,9 @@ Style/FrozenStringLiteralComment:
|
|
3991
4096
|
# exist in a file.
|
3992
4097
|
- never
|
3993
4098
|
SafeAutoCorrect: false
|
4099
|
+
Exclude:
|
4100
|
+
# Prevent the Ruby warning: `'frozen_string_literal' is ignored after any tokens` when using Active Admin.
|
4101
|
+
- '**/*.arb'
|
3994
4102
|
|
3995
4103
|
Style/GlobalStdStream:
|
3996
4104
|
Description: 'Enforces the use of `$stdout/$stderr/$stdin` instead of `STDOUT/STDERR/STDIN`.'
|
@@ -4069,6 +4177,14 @@ Style/HashLikeCase:
|
|
4069
4177
|
# to trigger this cop
|
4070
4178
|
MinBranchesCount: 3
|
4071
4179
|
|
4180
|
+
Style/HashSlice:
|
4181
|
+
Description: >-
|
4182
|
+
Checks for usages of `Hash#reject`, `Hash#select`, and `Hash#filter` methods
|
4183
|
+
that can be replaced with `Hash#slice` method.
|
4184
|
+
Enabled: pending
|
4185
|
+
Safe: false
|
4186
|
+
VersionAdded: '1.71'
|
4187
|
+
|
4072
4188
|
Style/HashSyntax:
|
4073
4189
|
Description: >-
|
4074
4190
|
Prefer Ruby 1.9 hash syntax { a: 1, b: 2 } over 1.8 syntax
|
@@ -4256,6 +4372,19 @@ Style/IpAddresses:
|
|
4256
4372
|
- '**/gems.rb'
|
4257
4373
|
- '**/*.gemspec'
|
4258
4374
|
|
4375
|
+
Style/ItAssignment:
|
4376
|
+
Description: 'Checks for assignment to `it` inside a block.'
|
4377
|
+
Enabled: pending
|
4378
|
+
VersionAdded: '1.70'
|
4379
|
+
|
4380
|
+
Style/KeywordArgumentsMerging:
|
4381
|
+
Description: >-
|
4382
|
+
When passing an existing hash as keyword arguments, provide additional arguments
|
4383
|
+
directly rather than using `merge`.
|
4384
|
+
StyleGuide: '#merging-keyword-arguments'
|
4385
|
+
Enabled: pending
|
4386
|
+
VersionAdded: '1.68'
|
4387
|
+
|
4259
4388
|
Style/KeywordParametersOrder:
|
4260
4389
|
Description: 'Enforces that optional keyword parameters are placed at the end of the parameters list.'
|
4261
4390
|
StyleGuide: '#keyword-parameters-order'
|
@@ -4991,7 +5120,7 @@ Style/RedundantConstantBase:
|
|
4991
5120
|
VersionAdded: '1.40'
|
4992
5121
|
|
4993
5122
|
Style/RedundantCurrentDirectoryInPath:
|
4994
|
-
Description: 'Checks for
|
5123
|
+
Description: 'Checks for a redundant current directory in a path given to `require_relative`.'
|
4995
5124
|
Enabled: pending
|
4996
5125
|
VersionAdded: '1.53'
|
4997
5126
|
|
@@ -5043,6 +5172,13 @@ Style/RedundantFilterChain:
|
|
5043
5172
|
VersionAdded: '1.52'
|
5044
5173
|
VersionChanged: '1.57'
|
5045
5174
|
|
5175
|
+
Style/RedundantFormat:
|
5176
|
+
Description: 'Checks for usages of `Kernel#format` or `Kernel#sprintf` with only a single argument.'
|
5177
|
+
Enabled: pending
|
5178
|
+
SafeAutoCorrect: false
|
5179
|
+
VersionAdded: '1.72'
|
5180
|
+
VersionChanged: '1.72'
|
5181
|
+
|
5046
5182
|
Style/RedundantFreeze:
|
5047
5183
|
Description: "Checks usages of Object#freeze on immutable objects."
|
5048
5184
|
Enabled: true
|
@@ -5241,6 +5377,13 @@ Style/SafeNavigation:
|
|
5241
5377
|
# Maximum length of method chains for register an offense.
|
5242
5378
|
MaxChainLength: 2
|
5243
5379
|
|
5380
|
+
Style/SafeNavigationChainLength:
|
5381
|
+
Description: 'Enforces safe navigation chains length to not exceed the configured maximum.'
|
5382
|
+
StyleGuide: '#safe-navigation'
|
5383
|
+
Enabled: pending
|
5384
|
+
VersionAdded: '1.68'
|
5385
|
+
Max: 2
|
5386
|
+
|
5244
5387
|
Style/Sample:
|
5245
5388
|
Description: >-
|
5246
5389
|
Use `sample` instead of `shuffle.first`,
|
@@ -5562,14 +5705,17 @@ Style/TrailingCommaInArrayLiteral:
|
|
5562
5705
|
StyleGuide: '#no-trailing-array-commas'
|
5563
5706
|
Enabled: true
|
5564
5707
|
VersionAdded: '0.53'
|
5565
|
-
# If `comma`, the cop requires a comma after the last item in an array,
|
5566
|
-
#
|
5567
|
-
# If `consistent_comma`, the cop requires a comma after the last item of all
|
5568
|
-
#
|
5708
|
+
# If `comma`, the cop requires a comma after the last item in an array, but only when each item is
|
5709
|
+
# on its own line.
|
5710
|
+
# If `consistent_comma`, the cop requires a comma after the last item of all non-empty, multiline
|
5711
|
+
# array literals.
|
5712
|
+
# If `diff_comma`, the cop requires a comma after the last item of all non-empty, multiline array
|
5713
|
+
# literals, but only when that last item immediately precedes a newline.
|
5569
5714
|
EnforcedStyleForMultiline: no_comma
|
5570
5715
|
SupportedStylesForMultiline:
|
5571
5716
|
- comma
|
5572
5717
|
- consistent_comma
|
5718
|
+
- diff_comma
|
5573
5719
|
- no_comma
|
5574
5720
|
|
5575
5721
|
Style/TrailingCommaInBlockArgs:
|
@@ -5581,14 +5727,17 @@ Style/TrailingCommaInBlockArgs:
|
|
5581
5727
|
Style/TrailingCommaInHashLiteral:
|
5582
5728
|
Description: 'Checks for trailing comma in hash literals.'
|
5583
5729
|
Enabled: true
|
5584
|
-
# If `comma`, the cop requires a comma after the last item in a hash,
|
5585
|
-
#
|
5586
|
-
# If `consistent_comma`, the cop requires a comma after the last item of all
|
5587
|
-
#
|
5730
|
+
# If `comma`, the cop requires a comma after the last item in a hash, but only when each item is
|
5731
|
+
# on its own line.
|
5732
|
+
# If `consistent_comma`, the cop requires a comma after the last item of all non-empty, multiline
|
5733
|
+
# hash literals.
|
5734
|
+
# If `diff_comma`, the cop requires a comma after the last item of all non-empty, multiline hash
|
5735
|
+
# literals, but only when that last item immediately precedes a newline.
|
5588
5736
|
EnforcedStyleForMultiline: no_comma
|
5589
5737
|
SupportedStylesForMultiline:
|
5590
5738
|
- comma
|
5591
5739
|
- consistent_comma
|
5740
|
+
- diff_comma
|
5592
5741
|
- no_comma
|
5593
5742
|
VersionAdded: '0.53'
|
5594
5743
|
|
data/config/internal_affairs.yml
CHANGED
@@ -6,6 +6,22 @@ InternalAffairs/CopDescription:
|
|
6
6
|
Include:
|
7
7
|
- 'lib/rubocop/cop/**/*.rb'
|
8
8
|
|
9
|
+
InternalAffairs/ExampleHeredocDelimiter:
|
10
|
+
Include:
|
11
|
+
- 'spec/rubocop/cop/**/*.rb'
|
12
|
+
|
13
|
+
InternalAffairs/ExampleDescription:
|
14
|
+
Include:
|
15
|
+
- 'spec/rubocop/cop/**/*.rb'
|
16
|
+
|
17
|
+
InternalAffairs/OnSendWithoutOnCSend:
|
18
|
+
Include:
|
19
|
+
- 'lib/rubocop/cop/**/*.rb'
|
20
|
+
|
21
|
+
InternalAffairs/UndefinedConfig:
|
22
|
+
Include:
|
23
|
+
- 'lib/rubocop/cop/**/*.rb'
|
24
|
+
|
9
25
|
InternalAffairs/UselessMessageAssertion:
|
10
26
|
Include:
|
11
27
|
- '**/*_spec.rb'
|
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
|
@@ -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
|
|
@@ -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
|
@@ -87,7 +87,7 @@ module RuboCop
|
|
87
87
|
next unless directive.enabled?
|
88
88
|
next if directive.all_cops?
|
89
89
|
|
90
|
-
cops.merge(directive.
|
90
|
+
cops.merge(directive.raw_cop_names)
|
91
91
|
end
|
92
92
|
cops
|
93
93
|
end
|
@@ -205,7 +205,7 @@ module RuboCop
|
|
205
205
|
directive.cop_names.each do |name|
|
206
206
|
if directive.disabled?
|
207
207
|
names[name] += 1
|
208
|
-
elsif
|
208
|
+
elsif names[name].positive?
|
209
209
|
names[name] -= 1
|
210
210
|
else
|
211
211
|
extras[directive.comment] << name
|