rubocop 1.50.2 → 1.68.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 +73 -72
 - data/assets/output.css.erb +159 -0
 - data/assets/output.html.erb +1 -160
 - data/config/default.yml +316 -38
 - data/config/internal_affairs.yml +11 -0
 - data/config/obsoletion.yml +5 -0
 - data/exe/rubocop +4 -3
 - data/lib/rubocop/cached_data.rb +21 -5
 - data/lib/rubocop/cli/command/auto_generate_config.rb +28 -15
 - data/lib/rubocop/cli/command/execute_runner.rb +1 -1
 - data/lib/rubocop/cli/command/lsp.rb +19 -0
 - data/lib/rubocop/cli/command/show_docs_url.rb +2 -2
 - data/lib/rubocop/cli/command/version.rb +2 -2
 - data/lib/rubocop/cli.rb +14 -2
 - data/lib/rubocop/comment_config.rb +1 -1
 - data/lib/rubocop/config.rb +45 -13
 - data/lib/rubocop/config_finder.rb +14 -4
 - data/lib/rubocop/config_loader.rb +15 -10
 - data/lib/rubocop/config_loader_resolver.rb +17 -11
 - data/lib/rubocop/config_obsoletion/parameter_rule.rb +9 -1
 - data/lib/rubocop/config_obsoletion.rb +13 -10
 - data/lib/rubocop/config_validator.rb +17 -9
 - data/lib/rubocop/cop/autocorrect_logic.rb +30 -3
 - data/lib/rubocop/cop/base.rb +78 -19
 - data/lib/rubocop/cop/bundler/duplicated_gem.rb +1 -0
 - data/lib/rubocop/cop/bundler/duplicated_group.rb +127 -0
 - data/lib/rubocop/cop/bundler/gem_comment.rb +3 -3
 - data/lib/rubocop/cop/bundler/gem_version.rb +6 -7
 - data/lib/rubocop/cop/bundler/ordered_gems.rb +9 -1
 - data/lib/rubocop/cop/cop.rb +30 -4
 - data/lib/rubocop/cop/correctors/alignment_corrector.rb +2 -13
 - data/lib/rubocop/cop/correctors/each_to_for_corrector.rb +4 -8
 - data/lib/rubocop/cop/correctors/for_to_each_corrector.rb +5 -13
 - data/lib/rubocop/cop/correctors/lambda_literal_to_method_corrector.rb +7 -4
 - data/lib/rubocop/cop/correctors/line_break_corrector.rb +2 -0
 - data/lib/rubocop/cop/correctors/parentheses_corrector.rb +1 -1
 - data/lib/rubocop/cop/correctors/percent_literal_corrector.rb +10 -0
 - data/lib/rubocop/cop/documentation.rb +32 -5
 - data/lib/rubocop/cop/exclude_limit.rb +1 -1
 - data/lib/rubocop/cop/force.rb +12 -0
 - data/lib/rubocop/cop/gemspec/add_runtime_dependency.rb +38 -0
 - data/lib/rubocop/cop/gemspec/dependency_version.rb +5 -7
 - data/lib/rubocop/cop/gemspec/deprecated_attribute_assignment.rb +2 -2
 - data/lib/rubocop/cop/gemspec/development_dependencies.rb +1 -1
 - data/lib/rubocop/cop/gemspec/duplicated_assignment.rb +2 -2
 - data/lib/rubocop/cop/gemspec/ordered_dependencies.rb +9 -1
 - data/lib/rubocop/cop/gemspec/required_ruby_version.rb +5 -1
 - data/lib/rubocop/cop/gemspec/ruby_version_globals_usage.rb +3 -3
 - data/lib/rubocop/cop/generator/require_file_injector.rb +1 -1
 - data/lib/rubocop/cop/internal_affairs/cop_description.rb +32 -12
 - data/lib/rubocop/cop/internal_affairs/empty_line_between_expect_offense_and_correction.rb +2 -1
 - data/lib/rubocop/cop/internal_affairs/example_description.rb +46 -24
 - data/lib/rubocop/cop/internal_affairs/location_line_equality_comparison.rb +3 -1
 - data/lib/rubocop/cop/internal_affairs/method_name_end_with.rb +8 -6
 - data/lib/rubocop/cop/internal_affairs/method_name_equal.rb +19 -20
 - data/lib/rubocop/cop/internal_affairs/node_first_or_last_argument.rb +53 -0
 - data/lib/rubocop/cop/internal_affairs/node_matcher_directive.rb +128 -34
 - data/lib/rubocop/cop/internal_affairs/redundant_expect_offense_arguments.rb +34 -0
 - data/lib/rubocop/cop/internal_affairs/redundant_message_argument.rb +6 -21
 - data/lib/rubocop/cop/internal_affairs/redundant_method_dispatch_node.rb +11 -2
 - data/lib/rubocop/cop/internal_affairs/redundant_source_range.rb +8 -1
 - data/lib/rubocop/cop/internal_affairs/undefined_config.rb +11 -1
 - data/lib/rubocop/cop/internal_affairs/useless_message_assertion.rb +2 -5
 - data/lib/rubocop/cop/internal_affairs.rb +18 -0
 - data/lib/rubocop/cop/layout/access_modifier_indentation.rb +5 -1
 - data/lib/rubocop/cop/layout/argument_alignment.rb +1 -1
 - data/lib/rubocop/cop/layout/assignment_indentation.rb +3 -2
 - data/lib/rubocop/cop/layout/block_alignment.rb +30 -12
 - data/lib/rubocop/cop/layout/case_indentation.rb +1 -1
 - data/lib/rubocop/cop/layout/class_structure.rb +7 -0
 - data/lib/rubocop/cop/layout/closing_heredoc_indentation.rb +1 -2
 - data/lib/rubocop/cop/layout/comment_indentation.rb +1 -1
 - data/lib/rubocop/cop/layout/condition_position.rb +0 -4
 - data/lib/rubocop/cop/layout/def_end_alignment.rb +1 -1
 - data/lib/rubocop/cop/layout/dot_position.rb +1 -5
 - data/lib/rubocop/cop/layout/empty_comment.rb +3 -1
 - data/lib/rubocop/cop/layout/empty_line_after_guard_clause.rb +43 -10
 - data/lib/rubocop/cop/layout/empty_line_after_magic_comment.rb +14 -7
 - data/lib/rubocop/cop/layout/empty_line_after_multiline_condition.rb +1 -1
 - data/lib/rubocop/cop/layout/empty_line_between_defs.rb +29 -5
 - data/lib/rubocop/cop/layout/empty_lines_around_exception_handling_keywords.rb +10 -3
 - data/lib/rubocop/cop/layout/end_alignment.rb +15 -3
 - data/lib/rubocop/cop/layout/extra_spacing.rb +4 -10
 - data/lib/rubocop/cop/layout/first_argument_indentation.rb +2 -2
 - data/lib/rubocop/cop/layout/first_array_element_indentation.rb +24 -10
 - data/lib/rubocop/cop/layout/first_method_argument_line_break.rb +8 -0
 - data/lib/rubocop/cop/layout/first_parameter_indentation.rb +1 -1
 - data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +4 -4
 - data/lib/rubocop/cop/layout/heredoc_indentation.rb +5 -2
 - data/lib/rubocop/cop/layout/indentation_style.rb +1 -1
 - data/lib/rubocop/cop/layout/indentation_width.rb +8 -9
 - data/lib/rubocop/cop/layout/leading_comment_space.rb +57 -2
 - data/lib/rubocop/cop/layout/line_continuation_leading_space.rb +17 -9
 - data/lib/rubocop/cop/layout/line_continuation_spacing.rb +1 -1
 - data/lib/rubocop/cop/layout/line_end_string_concatenation_indentation.rb +2 -0
 - data/lib/rubocop/cop/layout/line_length.rb +20 -20
 - data/lib/rubocop/cop/layout/multiline_method_call_indentation.rb +18 -3
 - data/lib/rubocop/cop/layout/redundant_line_break.rb +30 -7
 - data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +4 -4
 - data/lib/rubocop/cop/layout/single_line_block_chain.rb +5 -0
 - data/lib/rubocop/cop/layout/space_after_comma.rb +9 -1
 - data/lib/rubocop/cop/layout/space_after_not.rb +1 -1
 - data/lib/rubocop/cop/layout/space_around_method_call_operator.rb +2 -2
 - data/lib/rubocop/cop/layout/space_around_operators.rb +56 -21
 - data/lib/rubocop/cop/layout/space_before_block_braces.rb +19 -10
 - data/lib/rubocop/cop/layout/space_before_brackets.rb +5 -5
 - data/lib/rubocop/cop/layout/space_inside_block_braces.rb +6 -0
 - data/lib/rubocop/cop/layout/space_inside_hash_literal_braces.rb +1 -1
 - data/lib/rubocop/cop/layout/space_inside_parens.rb +1 -1
 - data/lib/rubocop/cop/layout/space_inside_range_literal.rb +1 -1
 - data/lib/rubocop/cop/layout/space_inside_string_interpolation.rb +3 -4
 - data/lib/rubocop/cop/layout/trailing_empty_lines.rb +5 -0
 - data/lib/rubocop/cop/legacy/corrector.rb +12 -2
 - data/lib/rubocop/cop/lint/ambiguous_block_association.rb +13 -3
 - data/lib/rubocop/cop/lint/ambiguous_operator.rb +0 -2
 - data/lib/rubocop/cop/lint/ambiguous_range.rb +4 -1
 - data/lib/rubocop/cop/lint/ambiguous_regexp_literal.rb +0 -2
 - data/lib/rubocop/cop/lint/assignment_in_condition.rb +6 -6
 - data/lib/rubocop/cop/lint/big_decimal_new.rb +4 -7
 - data/lib/rubocop/cop/lint/binary_operator_with_identical_operands.rb +2 -2
 - data/lib/rubocop/cop/lint/boolean_symbol.rb +1 -3
 - data/lib/rubocop/cop/lint/circular_argument_reference.rb +0 -13
 - data/lib/rubocop/cop/lint/constant_overwritten_in_rescue.rb +1 -1
 - data/lib/rubocop/cop/lint/debugger.rb +45 -10
 - data/lib/rubocop/cop/lint/deprecated_class_methods.rb +1 -1
 - data/lib/rubocop/cop/lint/deprecated_open_ssl_constant.rb +0 -10
 - data/lib/rubocop/cop/lint/duplicate_branch.rb +39 -4
 - data/lib/rubocop/cop/lint/duplicate_case_condition.rb +1 -5
 - data/lib/rubocop/cop/lint/duplicate_hash_key.rb +2 -5
 - data/lib/rubocop/cop/lint/duplicate_methods.rb +1 -11
 - data/lib/rubocop/cop/lint/duplicate_regexp_character_class_element.rb +46 -19
 - data/lib/rubocop/cop/lint/duplicate_set_element.rb +74 -0
 - data/lib/rubocop/cop/lint/each_with_object_argument.rb +0 -4
 - data/lib/rubocop/cop/lint/else_layout.rb +0 -2
 - data/lib/rubocop/cop/lint/empty_block.rb +1 -1
 - data/lib/rubocop/cop/lint/empty_conditional_body.rb +29 -8
 - data/lib/rubocop/cop/lint/empty_ensure.rb +1 -11
 - data/lib/rubocop/cop/lint/empty_interpolation.rb +0 -4
 - data/lib/rubocop/cop/lint/empty_when.rb +1 -3
 - data/lib/rubocop/cop/lint/ensure_return.rb +1 -9
 - data/lib/rubocop/cop/lint/erb_new_arguments.rb +27 -21
 - data/lib/rubocop/cop/lint/float_comparison.rb +10 -0
 - data/lib/rubocop/cop/lint/float_out_of_range.rb +0 -4
 - data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +0 -10
 - data/lib/rubocop/cop/lint/hash_compare_by_identity.rb +2 -1
 - data/lib/rubocop/cop/lint/heredoc_method_call_position.rb +1 -1
 - data/lib/rubocop/cop/lint/identity_comparison.rb +0 -1
 - data/lib/rubocop/cop/lint/implicit_string_concatenation.rb +23 -12
 - data/lib/rubocop/cop/lint/incompatible_io_select_with_fiber_scheduler.rb +5 -3
 - data/lib/rubocop/cop/lint/ineffective_access_modifier.rb +0 -7
 - data/lib/rubocop/cop/lint/inherit_exception.rb +9 -0
 - data/lib/rubocop/cop/lint/interpolation_check.rb +0 -4
 - data/lib/rubocop/cop/lint/it_without_arguments_in_block.rb +47 -0
 - data/lib/rubocop/cop/lint/lambda_without_literal_block.rb +1 -1
 - data/lib/rubocop/cop/lint/literal_as_condition.rb +1 -1
 - data/lib/rubocop/cop/lint/literal_assignment_in_condition.rb +85 -0
 - data/lib/rubocop/cop/lint/literal_in_interpolation.rb +26 -7
 - data/lib/rubocop/cop/lint/loop.rb +6 -12
 - data/lib/rubocop/cop/lint/missing_super.rb +34 -5
 - data/lib/rubocop/cop/lint/mixed_case_range.rb +116 -0
 - data/lib/rubocop/cop/lint/nested_method_definition.rb +1 -7
 - data/lib/rubocop/cop/lint/next_without_accumulator.rb +6 -25
 - data/lib/rubocop/cop/lint/no_return_in_begin_end_blocks.rb +0 -5
 - data/lib/rubocop/cop/lint/non_atomic_file_operation.rb +17 -7
 - data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +3 -5
 - data/lib/rubocop/cop/lint/number_conversion.rb +14 -4
 - data/lib/rubocop/cop/lint/numbered_parameter_assignment.rb +2 -2
 - data/lib/rubocop/cop/lint/ordered_magic_comments.rb +0 -1
 - data/lib/rubocop/cop/lint/out_of_range_regexp_ref.rb +2 -2
 - data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +5 -6
 - data/lib/rubocop/cop/lint/percent_string_array.rb +0 -4
 - data/lib/rubocop/cop/lint/percent_symbol_array.rb +0 -4
 - data/lib/rubocop/cop/lint/rand_one.rb +0 -4
 - data/lib/rubocop/cop/lint/redundant_cop_enable_directive.rb +3 -1
 - data/lib/rubocop/cop/lint/redundant_regexp_quantifiers.rb +130 -0
 - data/lib/rubocop/cop/lint/redundant_require_statement.rb +12 -3
 - data/lib/rubocop/cop/lint/redundant_safe_navigation.rb +72 -8
 - data/lib/rubocop/cop/lint/redundant_splat_expansion.rb +1 -1
 - data/lib/rubocop/cop/lint/redundant_string_coercion.rb +1 -5
 - data/lib/rubocop/cop/lint/redundant_with_index.rb +6 -2
 - data/lib/rubocop/cop/lint/redundant_with_object.rb +2 -2
 - data/lib/rubocop/cop/lint/require_parentheses.rb +0 -4
 - data/lib/rubocop/cop/lint/rescue_exception.rb +0 -4
 - data/lib/rubocop/cop/lint/rescue_type.rb +1 -3
 - data/lib/rubocop/cop/lint/return_in_void_context.rb +0 -2
 - data/lib/rubocop/cop/lint/safe_navigation_chain.rb +23 -12
 - data/lib/rubocop/cop/lint/safe_navigation_consistency.rb +107 -41
 - data/lib/rubocop/cop/lint/script_permission.rb +3 -3
 - data/lib/rubocop/cop/lint/self_assignment.rb +38 -0
 - data/lib/rubocop/cop/lint/send_with_mixin_argument.rb +1 -2
 - data/lib/rubocop/cop/lint/shadowed_argument.rb +1 -0
 - data/lib/rubocop/cop/lint/shadowed_exception.rb +5 -11
 - data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +13 -11
 - data/lib/rubocop/cop/lint/struct_new_override.rb +12 -12
 - data/lib/rubocop/cop/lint/suppressed_exception.rb +2 -2
 - data/lib/rubocop/cop/lint/symbol_conversion.rb +9 -4
 - data/lib/rubocop/cop/lint/syntax.rb +6 -3
 - data/lib/rubocop/cop/lint/to_enum_arguments.rb +6 -6
 - data/lib/rubocop/cop/lint/top_level_return_with_argument.rb +23 -9
 - data/lib/rubocop/cop/lint/trailing_comma_in_attribute_declaration.rb +1 -1
 - data/lib/rubocop/cop/lint/unescaped_bracket_in_regexp.rb +88 -0
 - data/lib/rubocop/cop/lint/unified_integer.rb +0 -4
 - data/lib/rubocop/cop/lint/unmodified_reduce_accumulator.rb +3 -2
 - data/lib/rubocop/cop/lint/unreachable_code.rb +4 -7
 - data/lib/rubocop/cop/lint/unreachable_loop.rb +8 -2
 - data/lib/rubocop/cop/lint/uri_regexp.rb +25 -7
 - data/lib/rubocop/cop/lint/useless_access_modifier.rb +2 -2
 - data/lib/rubocop/cop/lint/useless_assignment.rb +102 -15
 - data/lib/rubocop/cop/lint/useless_else_without_rescue.rb +0 -4
 - data/lib/rubocop/cop/lint/useless_numeric_operation.rb +77 -0
 - data/lib/rubocop/cop/lint/useless_setter_call.rb +0 -4
 - data/lib/rubocop/cop/lint/useless_times.rb +2 -2
 - data/lib/rubocop/cop/lint/void.rb +128 -15
 - data/lib/rubocop/cop/metrics/abc_size.rb +3 -3
 - data/lib/rubocop/cop/metrics/block_length.rb +7 -6
 - data/lib/rubocop/cop/metrics/block_nesting.rb +19 -7
 - data/lib/rubocop/cop/metrics/class_length.rb +14 -8
 - data/lib/rubocop/cop/metrics/cyclomatic_complexity.rb +4 -1
 - data/lib/rubocop/cop/metrics/method_length.rb +7 -6
 - data/lib/rubocop/cop/metrics/module_length.rb +6 -5
 - data/lib/rubocop/cop/metrics/utils/abc_size_calculator.rb +1 -2
 - data/lib/rubocop/cop/metrics/utils/code_length_calculator.rb +37 -9
 - data/lib/rubocop/cop/migration/department_name.rb +2 -2
 - data/lib/rubocop/cop/mixin/alignment.rb +5 -1
 - data/lib/rubocop/cop/mixin/allowed_methods.rb +7 -1
 - data/lib/rubocop/cop/mixin/allowed_pattern.rb +15 -3
 - data/lib/rubocop/cop/mixin/allowed_receivers.rb +34 -0
 - data/lib/rubocop/cop/mixin/annotation_comment.rb +0 -2
 - data/lib/rubocop/cop/mixin/check_line_breakable.rb +11 -1
 - data/lib/rubocop/cop/mixin/code_length.rb +12 -1
 - data/lib/rubocop/cop/mixin/comments_help.rb +19 -11
 - data/lib/rubocop/cop/mixin/configurable_formatting.rb +1 -0
 - data/lib/rubocop/cop/mixin/configurable_max.rb +5 -1
 - data/lib/rubocop/cop/mixin/def_node.rb +1 -1
 - data/lib/rubocop/cop/mixin/end_keyword_alignment.rb +1 -1
 - data/lib/rubocop/cop/mixin/endless_method_rewriter.rb +24 -0
 - data/lib/rubocop/cop/mixin/frozen_string_literal.rb +22 -10
 - data/lib/rubocop/cop/mixin/hash_shorthand_syntax.rb +23 -13
 - data/lib/rubocop/cop/mixin/heredoc.rb +6 -2
 - data/lib/rubocop/cop/mixin/line_length_help.rb +7 -2
 - data/lib/rubocop/cop/mixin/method_complexity.rb +15 -6
 - data/lib/rubocop/cop/mixin/multiline_expression_indentation.rb +4 -3
 - data/lib/rubocop/cop/mixin/percent_array.rb +1 -1
 - data/lib/rubocop/cop/mixin/percent_literal.rb +1 -1
 - data/lib/rubocop/cop/mixin/preceding_following_alignment.rb +6 -8
 - data/lib/rubocop/cop/mixin/rescue_node.rb +4 -0
 - data/lib/rubocop/cop/mixin/safe_assignment.rb +1 -1
 - data/lib/rubocop/cop/mixin/space_after_punctuation.rb +1 -1
 - data/lib/rubocop/cop/mixin/space_before_punctuation.rb +1 -1
 - data/lib/rubocop/cop/mixin/statement_modifier.rb +3 -2
 - data/lib/rubocop/cop/mixin/string_help.rb +4 -2
 - data/lib/rubocop/cop/mixin/string_literals_help.rb +12 -0
 - data/lib/rubocop/cop/mixin/trailing_comma.rb +1 -1
 - data/lib/rubocop/cop/naming/accessor_method_name.rb +5 -0
 - data/lib/rubocop/cop/naming/block_forwarding.rb +35 -8
 - data/lib/rubocop/cop/naming/constant_name.rb +2 -3
 - data/lib/rubocop/cop/naming/file_name.rb +3 -3
 - data/lib/rubocop/cop/naming/heredoc_delimiter_naming.rb +3 -1
 - data/lib/rubocop/cop/naming/inclusive_language.rb +13 -5
 - data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +26 -11
 - data/lib/rubocop/cop/naming/predicate_name.rb +55 -29
 - data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +21 -4
 - data/lib/rubocop/cop/naming/variable_name.rb +6 -1
 - data/lib/rubocop/cop/offense.rb +4 -5
 - data/lib/rubocop/cop/registry.rb +1 -1
 - data/lib/rubocop/cop/security/compound_hash.rb +2 -2
 - data/lib/rubocop/cop/security/open.rb +2 -2
 - data/lib/rubocop/cop/style/access_modifier_declarations.rb +63 -3
 - data/lib/rubocop/cop/style/accessor_grouping.rb +14 -2
 - data/lib/rubocop/cop/style/alias.rb +11 -9
 - data/lib/rubocop/cop/style/ambiguous_endless_method_definition.rb +79 -0
 - data/lib/rubocop/cop/style/arguments_forwarding.rb +459 -63
 - data/lib/rubocop/cop/style/array_first_last.rb +64 -0
 - data/lib/rubocop/cop/style/array_intersect.rb +13 -5
 - data/lib/rubocop/cop/style/attr.rb +11 -1
 - data/lib/rubocop/cop/style/auto_resource_cleanup.rb +21 -14
 - data/lib/rubocop/cop/style/begin_block.rb +1 -2
 - data/lib/rubocop/cop/style/bisected_attr_accessor.rb +2 -2
 - data/lib/rubocop/cop/style/bitwise_predicate.rb +100 -0
 - data/lib/rubocop/cop/style/block_comments.rb +1 -1
 - data/lib/rubocop/cop/style/block_delimiters.rb +36 -7
 - data/lib/rubocop/cop/style/case_like_if.rb +5 -5
 - data/lib/rubocop/cop/style/class_and_module_children.rb +1 -1
 - data/lib/rubocop/cop/style/class_check.rb +1 -0
 - data/lib/rubocop/cop/style/class_equality_comparison.rb +24 -39
 - data/lib/rubocop/cop/style/class_vars.rb +3 -3
 - data/lib/rubocop/cop/style/collection_compact.rb +31 -11
 - data/lib/rubocop/cop/style/collection_methods.rb +2 -0
 - data/lib/rubocop/cop/style/colon_method_call.rb +2 -2
 - data/lib/rubocop/cop/style/combinable_defined.rb +115 -0
 - data/lib/rubocop/cop/style/combinable_loops.rb +43 -8
 - data/lib/rubocop/cop/style/commented_keyword.rb +12 -3
 - data/lib/rubocop/cop/style/concat_array_literals.rb +2 -1
 - data/lib/rubocop/cop/style/conditional_assignment.rb +13 -12
 - data/lib/rubocop/cop/style/copyright.rb +36 -23
 - data/lib/rubocop/cop/style/data_inheritance.rb +1 -1
 - data/lib/rubocop/cop/style/date_time.rb +5 -4
 - data/lib/rubocop/cop/style/def_with_parentheses.rb +0 -2
 - data/lib/rubocop/cop/style/dir.rb +1 -1
 - data/lib/rubocop/cop/style/dir_empty.rb +8 -14
 - data/lib/rubocop/cop/style/document_dynamic_eval_definition.rb +1 -1
 - data/lib/rubocop/cop/style/documentation.rb +25 -25
 - data/lib/rubocop/cop/style/documentation_method.rb +20 -0
 - data/lib/rubocop/cop/style/each_for_simple_loop.rb +7 -8
 - data/lib/rubocop/cop/style/each_with_object.rb +2 -2
 - data/lib/rubocop/cop/style/empty_case_condition.rb +6 -1
 - data/lib/rubocop/cop/style/empty_else.rb +6 -5
 - data/lib/rubocop/cop/style/empty_heredoc.rb +1 -14
 - data/lib/rubocop/cop/style/empty_literal.rb +32 -23
 - data/lib/rubocop/cop/style/endless_method.rb +1 -14
 - data/lib/rubocop/cop/style/eval_with_location.rb +24 -32
 - data/lib/rubocop/cop/style/exact_regexp_match.rb +70 -0
 - data/lib/rubocop/cop/style/explicit_block_argument.rb +2 -2
 - data/lib/rubocop/cop/style/file_read.rb +4 -7
 - data/lib/rubocop/cop/style/file_write.rb +2 -5
 - data/lib/rubocop/cop/style/for.rb +3 -1
 - data/lib/rubocop/cop/style/format_string.rb +33 -12
 - data/lib/rubocop/cop/style/format_string_token.rb +2 -2
 - data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +3 -1
 - data/lib/rubocop/cop/style/global_std_stream.rb +7 -1
 - data/lib/rubocop/cop/style/guard_clause.rb +45 -2
 - data/lib/rubocop/cop/style/hash_conversion.rb +10 -0
 - data/lib/rubocop/cop/style/hash_each_methods.rb +112 -33
 - data/lib/rubocop/cop/style/hash_except.rb +29 -14
 - data/lib/rubocop/cop/style/hash_syntax.rb +26 -4
 - 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 +34 -5
 - data/lib/rubocop/cop/style/if_inside_else.rb +7 -1
 - data/lib/rubocop/cop/style/if_unless_modifier.rb +3 -0
 - data/lib/rubocop/cop/style/if_with_boolean_literal_branches.rb +5 -4
 - data/lib/rubocop/cop/style/if_with_semicolon.rb +51 -8
 - data/lib/rubocop/cop/style/in_pattern_then.rb +6 -2
 - data/lib/rubocop/cop/style/inverse_methods.rb +14 -13
 - data/lib/rubocop/cop/style/invertible_unless_condition.rb +56 -10
 - data/lib/rubocop/cop/style/keyword_arguments_merging.rb +67 -0
 - data/lib/rubocop/cop/style/lambda.rb +4 -4
 - data/lib/rubocop/cop/style/lambda_call.rb +5 -0
 - data/lib/rubocop/cop/style/magic_comment_format.rb +1 -1
 - data/lib/rubocop/cop/style/map_compact_with_conditional_block.rb +82 -50
 - data/lib/rubocop/cop/style/map_into_array.rb +233 -0
 - data/lib/rubocop/cop/style/map_to_hash.rb +18 -8
 - data/lib/rubocop/cop/style/map_to_set.rb +1 -1
 - data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +40 -15
 - data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +3 -5
 - data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +22 -2
 - data/lib/rubocop/cop/style/method_def_parentheses.rb +1 -1
 - data/lib/rubocop/cop/style/missing_else.rb +0 -4
 - data/lib/rubocop/cop/style/missing_respond_to_missing.rb +2 -2
 - data/lib/rubocop/cop/style/mixin_grouping.rb +1 -1
 - 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/multiline_method_signature.rb +10 -1
 - data/lib/rubocop/cop/style/multiline_ternary_operator.rb +6 -4
 - data/lib/rubocop/cop/style/multiline_when_then.rb +0 -4
 - data/lib/rubocop/cop/style/multiple_comparison.rb +41 -46
 - data/lib/rubocop/cop/style/nested_modifier.rb +1 -1
 - data/lib/rubocop/cop/style/nested_parenthesized_calls.rb +1 -1
 - data/lib/rubocop/cop/style/nested_ternary_operator.rb +3 -11
 - data/lib/rubocop/cop/style/next.rb +1 -1
 - data/lib/rubocop/cop/style/nil_comparison.rb +2 -0
 - data/lib/rubocop/cop/style/numeric_literal_prefix.rb +1 -1
 - data/lib/rubocop/cop/style/numeric_literals.rb +1 -1
 - data/lib/rubocop/cop/style/numeric_predicate.rb +12 -4
 - data/lib/rubocop/cop/style/object_then.rb +5 -3
 - data/lib/rubocop/cop/style/one_line_conditional.rb +6 -2
 - data/lib/rubocop/cop/style/open_struct_use.rb +1 -1
 - data/lib/rubocop/cop/style/operator_method_call.rb +32 -7
 - data/lib/rubocop/cop/style/parallel_assignment.rb +8 -9
 - data/lib/rubocop/cop/style/parentheses_around_condition.rb +8 -0
 - data/lib/rubocop/cop/style/percent_literal_delimiters.rb +1 -1
 - data/lib/rubocop/cop/style/preferred_hash_methods.rb +1 -1
 - data/lib/rubocop/cop/style/quoted_symbols.rb +1 -3
 - data/lib/rubocop/cop/style/raise_args.rb +4 -1
 - data/lib/rubocop/cop/style/redundant_argument.rb +33 -4
 - data/lib/rubocop/cop/style/redundant_array_constructor.rb +77 -0
 - data/lib/rubocop/cop/style/redundant_assignment.rb +10 -2
 - data/lib/rubocop/cop/style/redundant_begin.rb +15 -3
 - data/lib/rubocop/cop/style/redundant_condition.rb +4 -4
 - data/lib/rubocop/cop/style/redundant_conditional.rb +2 -10
 - data/lib/rubocop/cop/style/redundant_current_directory_in_path.rb +39 -0
 - data/lib/rubocop/cop/style/redundant_double_splat_hash_braces.rb +93 -5
 - data/lib/rubocop/cop/style/redundant_each.rb +7 -4
 - data/lib/rubocop/cop/style/redundant_exception.rb +32 -12
 - data/lib/rubocop/cop/style/redundant_fetch_block.rb +3 -3
 - data/lib/rubocop/cop/style/redundant_file_extension_in_require.rb +1 -1
 - data/lib/rubocop/cop/style/redundant_filter_chain.rb +118 -0
 - data/lib/rubocop/cop/style/redundant_interpolation_unfreeze.rb +46 -0
 - data/lib/rubocop/cop/style/redundant_line_continuation.rb +48 -9
 - data/lib/rubocop/cop/style/redundant_parentheses.rb +80 -33
 - data/lib/rubocop/cop/style/redundant_percent_q.rb +1 -1
 - data/lib/rubocop/cop/style/redundant_regexp_argument.rb +103 -0
 - data/lib/rubocop/cop/style/redundant_regexp_constructor.rb +46 -0
 - data/lib/rubocop/cop/style/redundant_regexp_escape.rb +9 -24
 - data/lib/rubocop/cop/style/redundant_return.rb +14 -3
 - data/lib/rubocop/cop/style/redundant_self.rb +17 -2
 - data/lib/rubocop/cop/style/redundant_self_assignment_branch.rb +8 -1
 - data/lib/rubocop/cop/style/redundant_sort.rb +10 -9
 - data/lib/rubocop/cop/style/redundant_sort_by.rb +2 -2
 - data/lib/rubocop/cop/style/redundant_string_escape.rb +3 -1
 - data/lib/rubocop/cop/style/regexp_literal.rb +11 -2
 - data/lib/rubocop/cop/style/require_order.rb +13 -7
 - data/lib/rubocop/cop/style/rescue_modifier.rb +14 -4
 - data/lib/rubocop/cop/style/return_nil.rb +6 -2
 - data/lib/rubocop/cop/style/return_nil_in_predicate_method_definition.rb +137 -0
 - data/lib/rubocop/cop/style/safe_navigation.rb +106 -52
 - data/lib/rubocop/cop/style/safe_navigation_chain_length.rb +52 -0
 - data/lib/rubocop/cop/style/sample.rb +3 -4
 - data/lib/rubocop/cop/style/select_by_regexp.rb +29 -15
 - data/lib/rubocop/cop/style/self_assignment.rb +1 -1
 - data/lib/rubocop/cop/style/semicolon.rb +21 -5
 - data/lib/rubocop/cop/style/send.rb +4 -4
 - data/lib/rubocop/cop/style/send_with_literal_method_name.rb +104 -0
 - data/lib/rubocop/cop/style/signal_exception.rb +1 -1
 - data/lib/rubocop/cop/style/single_argument_dig.rb +7 -3
 - data/lib/rubocop/cop/style/single_line_do_end_block.rb +67 -0
 - data/lib/rubocop/cop/style/single_line_methods.rb +1 -1
 - data/lib/rubocop/cop/style/slicing_with_range.rb +76 -10
 - data/lib/rubocop/cop/style/sole_nested_conditional.rb +27 -4
 - data/lib/rubocop/cop/style/special_global_vars.rb +4 -6
 - data/lib/rubocop/cop/style/string_chars.rb +1 -0
 - data/lib/rubocop/cop/style/string_literals_in_interpolation.rb +30 -5
 - data/lib/rubocop/cop/style/strip.rb +7 -4
 - data/lib/rubocop/cop/style/struct_inheritance.rb +1 -1
 - data/lib/rubocop/cop/style/super_arguments.rb +174 -0
 - data/lib/rubocop/cop/style/super_with_args_parentheses.rb +35 -0
 - data/lib/rubocop/cop/style/symbol_array.rb +35 -15
 - data/lib/rubocop/cop/style/symbol_proc.rb +75 -5
 - data/lib/rubocop/cop/style/ternary_parentheses.rb +26 -5
 - data/lib/rubocop/cop/style/top_level_method_definition.rb +1 -1
 - data/lib/rubocop/cop/style/trivial_accessors.rb +1 -1
 - data/lib/rubocop/cop/style/unpack_first.rb +11 -14
 - data/lib/rubocop/cop/style/while_until_do.rb +0 -2
 - data/lib/rubocop/cop/style/while_until_modifier.rb +0 -1
 - data/lib/rubocop/cop/style/yaml_file_read.rb +66 -0
 - data/lib/rubocop/cop/style/yoda_condition.rb +4 -2
 - data/lib/rubocop/cop/style/yoda_expression.rb +8 -7
 - data/lib/rubocop/cop/style/zero_length_predicate.rb +32 -24
 - data/lib/rubocop/cop/team.rb +27 -3
 - data/lib/rubocop/cop/util.rb +9 -3
 - data/lib/rubocop/cop/utils/regexp_ranges.rb +113 -0
 - data/lib/rubocop/cop/variable_force/assignment.rb +62 -6
 - data/lib/rubocop/cop/variable_force/branch.rb +1 -1
 - data/lib/rubocop/cop/variable_force/variable.rb +5 -1
 - data/lib/rubocop/cop/variable_force/variable_table.rb +4 -4
 - data/lib/rubocop/cop/variable_force.rb +14 -1
 - data/lib/rubocop/cops_documentation_generator.rb +97 -44
 - data/lib/rubocop/core_ext/string.rb +2 -6
 - data/lib/rubocop/directive_comment.rb +10 -8
 - data/lib/rubocop/ext/regexp_node.rb +18 -35
 - data/lib/rubocop/ext/regexp_parser.rb +7 -21
 - data/lib/rubocop/file_finder.rb +11 -9
 - data/lib/rubocop/formatter/clang_style_formatter.rb +3 -7
 - data/lib/rubocop/formatter/disabled_config_formatter.rb +24 -9
 - data/lib/rubocop/formatter/formatter_set.rb +7 -1
 - data/lib/rubocop/formatter/html_formatter.rb +37 -14
 - data/lib/rubocop/formatter/json_formatter.rb +0 -1
 - data/lib/rubocop/formatter/junit_formatter.rb +71 -24
 - data/lib/rubocop/formatter/offense_count_formatter.rb +12 -2
 - data/lib/rubocop/formatter/tap_formatter.rb +3 -7
 - data/lib/rubocop/formatter.rb +1 -1
 - data/lib/rubocop/lockfile.rb +58 -7
 - data/lib/rubocop/lsp/logger.rb +22 -0
 - data/lib/rubocop/lsp/routes.rb +243 -0
 - data/lib/rubocop/lsp/runtime.rb +101 -0
 - data/lib/rubocop/lsp/server.rb +72 -0
 - data/lib/rubocop/lsp/severity.rb +27 -0
 - data/lib/rubocop/lsp.rb +36 -0
 - data/lib/rubocop/magic_comment.rb +13 -11
 - data/lib/rubocop/options.rb +28 -13
 - data/lib/rubocop/path_util.rb +6 -2
 - data/lib/rubocop/rake_task.rb +1 -1
 - data/lib/rubocop/remote_config.rb +5 -1
 - data/lib/rubocop/result_cache.rb +7 -10
 - data/lib/rubocop/rspec/cop_helper.rb +8 -2
 - data/lib/rubocop/rspec/expect_offense.rb +17 -8
 - data/lib/rubocop/rspec/shared_contexts.rb +77 -21
 - data/lib/rubocop/rspec/support.rb +3 -0
 - data/lib/rubocop/runner.rb +36 -12
 - data/lib/rubocop/server/cache.rb +16 -1
 - data/lib/rubocop/server/client_command/exec.rb +5 -5
 - data/lib/rubocop/server/client_command/start.rb +1 -1
 - data/lib/rubocop/server/core.rb +5 -0
 - data/lib/rubocop/server/server_command/exec.rb +0 -1
 - data/lib/rubocop/string_interpreter.rb +3 -3
 - data/lib/rubocop/target_finder.rb +91 -81
 - data/lib/rubocop/target_ruby.rb +90 -79
 - data/lib/rubocop/version.rb +53 -13
 - data/lib/rubocop/yaml_duplication_checker.rb +20 -26
 - data/lib/rubocop.rb +40 -1
 - metadata +73 -36
 - /data/lib/rubocop/formatter/{git_hub_actions_formatter.rb → github_actions_formatter.rb} +0 -0
 
| 
         @@ -14,8 +14,6 @@ module RuboCop 
     | 
|
| 
       14 
14 
     | 
    
         
             
                  #   when baz
         
     | 
| 
       15 
15 
     | 
    
         
             
                  #   end
         
     | 
| 
       16 
16 
     | 
    
         
             
                  #
         
     | 
| 
       17 
     | 
    
         
            -
                  # @example
         
     | 
| 
       18 
     | 
    
         
            -
                  #
         
     | 
| 
       19 
17 
     | 
    
         
             
                  #   # good
         
     | 
| 
       20 
18 
     | 
    
         
             
                  #   case condition
         
     | 
| 
       21 
19 
     | 
    
         
             
                  #   when foo
         
     | 
| 
         @@ -50,7 +48,7 @@ module RuboCop 
     | 
|
| 
       50 
48 
     | 
    
         
             
                    MSG = 'Avoid `when` branches without a body.'
         
     | 
| 
       51 
49 
     | 
    
         | 
| 
       52 
50 
     | 
    
         
             
                    def on_case(node)
         
     | 
| 
       53 
     | 
    
         
            -
                      node. 
     | 
| 
      
 51 
     | 
    
         
            +
                      node.when_branches.each do |when_node|
         
     | 
| 
       54 
52 
     | 
    
         
             
                        next if when_node.body
         
     | 
| 
       55 
53 
     | 
    
         
             
                        next if cop_config['AllowComments'] && contains_comments?(when_node)
         
     | 
| 
       56 
54 
     | 
    
         | 
| 
         @@ -13,7 +13,6 @@ module RuboCop 
     | 
|
| 
       13 
13 
     | 
    
         
             
                  # @example
         
     | 
| 
       14 
14 
     | 
    
         
             
                  #
         
     | 
| 
       15 
15 
     | 
    
         
             
                  #   # bad
         
     | 
| 
       16 
     | 
    
         
            -
                  #
         
     | 
| 
       17 
16 
     | 
    
         
             
                  #   def foo
         
     | 
| 
       18 
17 
     | 
    
         
             
                  #     do_something
         
     | 
| 
       19 
18 
     | 
    
         
             
                  #   ensure
         
     | 
| 
         @@ -21,10 +20,7 @@ module RuboCop 
     | 
|
| 
       21 
20 
     | 
    
         
             
                  #     return self
         
     | 
| 
       22 
21 
     | 
    
         
             
                  #   end
         
     | 
| 
       23 
22 
     | 
    
         
             
                  #
         
     | 
| 
       24 
     | 
    
         
            -
                  # @example
         
     | 
| 
       25 
     | 
    
         
            -
                  #
         
     | 
| 
       26 
23 
     | 
    
         
             
                  #   # good
         
     | 
| 
       27 
     | 
    
         
            -
                  #
         
     | 
| 
       28 
24 
     | 
    
         
             
                  #   def foo
         
     | 
| 
       29 
25 
     | 
    
         
             
                  #     do_something
         
     | 
| 
       30 
26 
     | 
    
         
             
                  #     self
         
     | 
| 
         @@ -32,8 +28,7 @@ module RuboCop 
     | 
|
| 
       32 
28 
     | 
    
         
             
                  #     cleanup
         
     | 
| 
       33 
29 
     | 
    
         
             
                  #   end
         
     | 
| 
       34 
30 
     | 
    
         
             
                  #
         
     | 
| 
       35 
     | 
    
         
            -
                  #   #  
     | 
| 
       36 
     | 
    
         
            -
                  #
         
     | 
| 
      
 31 
     | 
    
         
            +
                  #   # good
         
     | 
| 
       37 
32 
     | 
    
         
             
                  #   def foo
         
     | 
| 
       38 
33 
     | 
    
         
             
                  #     begin
         
     | 
| 
       39 
34 
     | 
    
         
             
                  #       do_something
         
     | 
| 
         @@ -45,9 +40,6 @@ module RuboCop 
     | 
|
| 
       45 
40 
     | 
    
         
             
                  #     cleanup
         
     | 
| 
       46 
41 
     | 
    
         
             
                  #   end
         
     | 
| 
       47 
42 
     | 
    
         
             
                  class EnsureReturn < Base
         
     | 
| 
       48 
     | 
    
         
            -
                    extend AutoCorrector
         
     | 
| 
       49 
     | 
    
         
            -
                    include RangeHelp
         
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
43 
     | 
    
         
             
                    MSG = 'Do not return from an `ensure` block.'
         
     | 
| 
       52 
44 
     | 
    
         | 
| 
       53 
45 
     | 
    
         
             
                    def on_ensure(node)
         
     | 
| 
         @@ -3,14 +3,13 @@ 
     | 
|
| 
       3 
3 
     | 
    
         
             
            module RuboCop
         
     | 
| 
       4 
4 
     | 
    
         
             
              module Cop
         
     | 
| 
       5 
5 
     | 
    
         
             
                module Lint
         
     | 
| 
       6 
     | 
    
         
            -
                  #
         
     | 
| 
       7 
     | 
    
         
            -
                  # This cop emulates the following Ruby warnings in Ruby 2.6.
         
     | 
| 
      
 6 
     | 
    
         
            +
                  # Emulates the following Ruby warnings in Ruby 2.6.
         
     | 
| 
       8 
7 
     | 
    
         
             
                  #
         
     | 
| 
       9 
8 
     | 
    
         
             
                  # [source,console]
         
     | 
| 
       10 
9 
     | 
    
         
             
                  # ----
         
     | 
| 
       11 
     | 
    
         
            -
                  #  
     | 
| 
      
 10 
     | 
    
         
            +
                  # $ cat example.rb
         
     | 
| 
       12 
11 
     | 
    
         
             
                  # ERB.new('hi', nil, '-', '@output_buffer')
         
     | 
| 
       13 
     | 
    
         
            -
                  #  
     | 
| 
      
 12 
     | 
    
         
            +
                  # $ ruby -rerb example.rb
         
     | 
| 
       14 
13 
     | 
    
         
             
                  # example.rb:1: warning: Passing safe_level with the 2nd argument of ERB.new is
         
     | 
| 
       15 
14 
     | 
    
         
             
                  # deprecated. Do not use it, and specify other arguments as keyword arguments.
         
     | 
| 
       16 
15 
     | 
    
         
             
                  # example.rb:1: warning: Passing trim_mode with the 3rd argument of ERB.new is
         
     | 
| 
         @@ -66,17 +65,15 @@ module RuboCop 
     | 
|
| 
       66 
65 
     | 
    
         | 
| 
       67 
66 
     | 
    
         
             
                    minimum_target_ruby_version 2.6
         
     | 
| 
       68 
67 
     | 
    
         | 
| 
       69 
     | 
    
         
            -
                     
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
       74 
     | 
    
         
            -
             
     | 
| 
       75 
     | 
    
         
            -
             
     | 
| 
       76 
     | 
    
         
            -
             
     | 
| 
       77 
     | 
    
         
            -
             
     | 
| 
       78 
     | 
    
         
            -
                      '`ERB.new(str, eoutvar: %<arg_value>s)` instead.'
         
     | 
| 
       79 
     | 
    
         
            -
                    ].freeze
         
     | 
| 
      
 68 
     | 
    
         
            +
                    MESSAGE_SAFE_LEVEL = 'Passing safe_level with the 2nd argument of `ERB.new` is ' \
         
     | 
| 
      
 69 
     | 
    
         
            +
                                         'deprecated. Do not use it, and specify other arguments as ' \
         
     | 
| 
      
 70 
     | 
    
         
            +
                                         'keyword arguments.'
         
     | 
| 
      
 71 
     | 
    
         
            +
                    MESSAGE_TRIM_MODE =  'Passing trim_mode with the 3rd argument of `ERB.new` is ' \
         
     | 
| 
      
 72 
     | 
    
         
            +
                                         'deprecated. Use keyword argument like ' \
         
     | 
| 
      
 73 
     | 
    
         
            +
                                         '`ERB.new(str, trim_mode: %<arg_value>s)` instead.'
         
     | 
| 
      
 74 
     | 
    
         
            +
                    MESSAGE_EOUTVAR =    'Passing eoutvar with the 4th argument of `ERB.new` is ' \
         
     | 
| 
      
 75 
     | 
    
         
            +
                                         'deprecated. Use keyword argument like ' \
         
     | 
| 
      
 76 
     | 
    
         
            +
                                         '`ERB.new(str, eoutvar: %<arg_value>s)` instead.'
         
     | 
| 
       80 
77 
     | 
    
         | 
| 
       81 
78 
     | 
    
         
             
                    RESTRICT_ON_SEND = %i[new].freeze
         
     | 
| 
       82 
79 
     | 
    
         | 
| 
         @@ -93,10 +90,8 @@ module RuboCop 
     | 
|
| 
       93 
90 
     | 
    
         
             
                        arguments[1..3].each_with_index do |argument, i|
         
     | 
| 
       94 
91 
     | 
    
         
             
                          next if !argument || argument.hash_type?
         
     | 
| 
       95 
92 
     | 
    
         | 
| 
       96 
     | 
    
         
            -
                          message = format(MESSAGES[i], arg_value: argument.source)
         
     | 
| 
       97 
     | 
    
         
            -
             
     | 
| 
       98 
93 
     | 
    
         
             
                          add_offense(
         
     | 
| 
       99 
     | 
    
         
            -
                            argument 
     | 
| 
      
 94 
     | 
    
         
            +
                            argument, message: message(i, argument.source)
         
     | 
| 
       100 
95 
     | 
    
         
             
                          ) do |corrector|
         
     | 
| 
       101 
96 
     | 
    
         
             
                            autocorrect(corrector, node)
         
     | 
| 
       102 
97 
     | 
    
         
             
                          end
         
     | 
| 
         @@ -106,8 +101,19 @@ module RuboCop 
     | 
|
| 
       106 
101 
     | 
    
         | 
| 
       107 
102 
     | 
    
         
             
                    private
         
     | 
| 
       108 
103 
     | 
    
         | 
| 
      
 104 
     | 
    
         
            +
                    def message(positional_argument_index, arg_value)
         
     | 
| 
      
 105 
     | 
    
         
            +
                      case positional_argument_index
         
     | 
| 
      
 106 
     | 
    
         
            +
                      when 0
         
     | 
| 
      
 107 
     | 
    
         
            +
                        MESSAGE_SAFE_LEVEL
         
     | 
| 
      
 108 
     | 
    
         
            +
                      when 1
         
     | 
| 
      
 109 
     | 
    
         
            +
                        format(MESSAGE_TRIM_MODE, arg_value: arg_value)
         
     | 
| 
      
 110 
     | 
    
         
            +
                      when 2
         
     | 
| 
      
 111 
     | 
    
         
            +
                        format(MESSAGE_EOUTVAR, arg_value: arg_value)
         
     | 
| 
      
 112 
     | 
    
         
            +
                      end
         
     | 
| 
      
 113 
     | 
    
         
            +
                    end
         
     | 
| 
      
 114 
     | 
    
         
            +
             
     | 
| 
       109 
115 
     | 
    
         
             
                    def autocorrect(corrector, node)
         
     | 
| 
       110 
     | 
    
         
            -
                      str_arg = node. 
     | 
| 
      
 116 
     | 
    
         
            +
                      str_arg = node.first_argument.source
         
     | 
| 
       111 
117 
     | 
    
         | 
| 
       112 
118 
     | 
    
         
             
                      kwargs = build_kwargs(node)
         
     | 
| 
       113 
119 
     | 
    
         
             
                      overridden_kwargs = override_by_legacy_args(kwargs, node)
         
     | 
| 
         @@ -122,11 +128,11 @@ module RuboCop 
     | 
|
| 
       122 
128 
     | 
    
         
             
                    end
         
     | 
| 
       123 
129 
     | 
    
         | 
| 
       124 
130 
     | 
    
         
             
                    def build_kwargs(node)
         
     | 
| 
       125 
     | 
    
         
            -
                      return [nil, nil] unless node. 
     | 
| 
      
 131 
     | 
    
         
            +
                      return [nil, nil] unless node.last_argument.hash_type?
         
     | 
| 
       126 
132 
     | 
    
         | 
| 
       127 
133 
     | 
    
         
             
                      trim_mode_arg, eoutvar_arg = nil
         
     | 
| 
       128 
134 
     | 
    
         | 
| 
       129 
     | 
    
         
            -
                      node. 
     | 
| 
      
 135 
     | 
    
         
            +
                      node.last_argument.pairs.each do |pair|
         
     | 
| 
       130 
136 
     | 
    
         
             
                        case pair.key.source
         
     | 
| 
       131 
137 
     | 
    
         
             
                        when 'trim_mode'
         
     | 
| 
       132 
138 
     | 
    
         
             
                          trim_mode_arg = "trim_mode: #{pair.value.source}"
         
     | 
| 
         @@ -18,6 +18,10 @@ module RuboCop 
     | 
|
| 
       18 
18 
     | 
    
         
             
                  #   # good - using BigDecimal
         
     | 
| 
       19 
19 
     | 
    
         
             
                  #   x.to_d == 0.1.to_d
         
     | 
| 
       20 
20 
     | 
    
         
             
                  #
         
     | 
| 
      
 21 
     | 
    
         
            +
                  #   # good - comparing against zero
         
     | 
| 
      
 22 
     | 
    
         
            +
                  #   x == 0.0
         
     | 
| 
      
 23 
     | 
    
         
            +
                  #   x != 0.0
         
     | 
| 
      
 24 
     | 
    
         
            +
                  #
         
     | 
| 
       21 
25 
     | 
    
         
             
                  #   # good
         
     | 
| 
       22 
26 
     | 
    
         
             
                  #   (x - 0.1).abs < Float::EPSILON
         
     | 
| 
       23 
27 
     | 
    
         
             
                  #
         
     | 
| 
         @@ -39,6 +43,8 @@ module RuboCop 
     | 
|
| 
       39 
43 
     | 
    
         | 
| 
       40 
44 
     | 
    
         
             
                    def on_send(node)
         
     | 
| 
       41 
45 
     | 
    
         
             
                      lhs, _method, rhs = *node
         
     | 
| 
      
 46 
     | 
    
         
            +
                      return if literal_zero?(lhs) || literal_zero?(rhs)
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
       42 
48 
     | 
    
         
             
                      add_offense(node) if float?(lhs) || float?(rhs)
         
     | 
| 
       43 
49 
     | 
    
         
             
                    end
         
     | 
| 
       44 
50 
     | 
    
         | 
| 
         @@ -59,6 +65,10 @@ module RuboCop 
     | 
|
| 
       59 
65 
     | 
    
         
             
                      end
         
     | 
| 
       60 
66 
     | 
    
         
             
                    end
         
     | 
| 
       61 
67 
     | 
    
         | 
| 
      
 68 
     | 
    
         
            +
                    def literal_zero?(node)
         
     | 
| 
      
 69 
     | 
    
         
            +
                      node&.numeric_type? && node.value.zero?
         
     | 
| 
      
 70 
     | 
    
         
            +
                    end
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
       62 
72 
     | 
    
         
             
                    # rubocop:disable Metrics/PerceivedComplexity
         
     | 
| 
       63 
73 
     | 
    
         
             
                    def check_send(node)
         
     | 
| 
       64 
74 
     | 
    
         
             
                      if node.arithmetic_operation?
         
     | 
| 
         @@ -14,25 +14,15 @@ module RuboCop 
     | 
|
| 
       14 
14 
     | 
    
         
             
                  # @example
         
     | 
| 
       15 
15 
     | 
    
         
             
                  #
         
     | 
| 
       16 
16 
     | 
    
         
             
                  #   # bad
         
     | 
| 
       17 
     | 
    
         
            -
                  #
         
     | 
| 
       18 
17 
     | 
    
         
             
                  #   format('A value: %s and another: %i', a_value)
         
     | 
| 
       19 
18 
     | 
    
         
             
                  #
         
     | 
| 
       20 
     | 
    
         
            -
                  # @example
         
     | 
| 
       21 
     | 
    
         
            -
                  #
         
     | 
| 
       22 
19 
     | 
    
         
             
                  #   # good
         
     | 
| 
       23 
     | 
    
         
            -
                  #
         
     | 
| 
       24 
20 
     | 
    
         
             
                  #   format('A value: %s and another: %i', a_value, another)
         
     | 
| 
       25 
21 
     | 
    
         
             
                  #
         
     | 
| 
       26 
     | 
    
         
            -
                  # @example
         
     | 
| 
       27 
     | 
    
         
            -
                  #
         
     | 
| 
       28 
22 
     | 
    
         
             
                  #   # bad
         
     | 
| 
       29 
     | 
    
         
            -
                  #
         
     | 
| 
       30 
23 
     | 
    
         
             
                  #   format('Unnumbered format: %s and numbered: %2$s', a_value, another)
         
     | 
| 
       31 
24 
     | 
    
         
             
                  #
         
     | 
| 
       32 
     | 
    
         
            -
                  # @example
         
     | 
| 
       33 
     | 
    
         
            -
                  #
         
     | 
| 
       34 
25 
     | 
    
         
             
                  #   # good
         
     | 
| 
       35 
     | 
    
         
            -
                  #
         
     | 
| 
       36 
26 
     | 
    
         
             
                  #   format('Numbered format: %1$s and numbered %2$s', a_value, another)
         
     | 
| 
       37 
27 
     | 
    
         
             
                  class FormatParameterMismatch < Base
         
     | 
| 
       38 
28 
     | 
    
         
             
                    # http://rubular.com/r/CvpbxkcTzy
         
     | 
| 
         @@ -35,12 +35,13 @@ module RuboCop 
     | 
|
| 
       35 
35 
     | 
    
         | 
| 
       36 
36 
     | 
    
         
             
                    # @!method id_as_hash_key?(node)
         
     | 
| 
       37 
37 
     | 
    
         
             
                    def_node_matcher :id_as_hash_key?, <<~PATTERN
         
     | 
| 
       38 
     | 
    
         
            -
                      ( 
     | 
| 
      
 38 
     | 
    
         
            +
                      (call _ {:key? :has_key? :fetch :[] :[]=} (send _ :object_id) ...)
         
     | 
| 
       39 
39 
     | 
    
         
             
                    PATTERN
         
     | 
| 
       40 
40 
     | 
    
         | 
| 
       41 
41 
     | 
    
         
             
                    def on_send(node)
         
     | 
| 
       42 
42 
     | 
    
         
             
                      add_offense(node) if id_as_hash_key?(node)
         
     | 
| 
       43 
43 
     | 
    
         
             
                    end
         
     | 
| 
      
 44 
     | 
    
         
            +
                    alias on_csend on_send
         
     | 
| 
       44 
45 
     | 
    
         
             
                  end
         
     | 
| 
       45 
46 
     | 
    
         
             
                end
         
     | 
| 
       46 
47 
     | 
    
         
             
              end
         
     | 
| 
         @@ -9,13 +9,9 @@ module RuboCop 
     | 
|
| 
       9 
9 
     | 
    
         
             
                  # @example
         
     | 
| 
       10 
10 
     | 
    
         
             
                  #
         
     | 
| 
       11 
11 
     | 
    
         
             
                  #   # bad
         
     | 
| 
       12 
     | 
    
         
            -
                  #
         
     | 
| 
       13 
12 
     | 
    
         
             
                  #   array = ['Item 1' 'Item 2']
         
     | 
| 
       14 
13 
     | 
    
         
             
                  #
         
     | 
| 
       15 
     | 
    
         
            -
                  # @example
         
     | 
| 
       16 
     | 
    
         
            -
                  #
         
     | 
| 
       17 
14 
     | 
    
         
             
                  #   # good
         
     | 
| 
       18 
     | 
    
         
            -
                  #
         
     | 
| 
       19 
15 
     | 
    
         
             
                  #   array = ['Item 1Item 2']
         
     | 
| 
       20 
16 
     | 
    
         
             
                  #   array = ['Item 1' + 'Item 2']
         
     | 
| 
       21 
17 
     | 
    
         
             
                  #   array = [
         
     | 
| 
         @@ -23,27 +19,40 @@ module RuboCop 
     | 
|
| 
       23 
19 
     | 
    
         
             
                  #     'Item 2'
         
     | 
| 
       24 
20 
     | 
    
         
             
                  #   ]
         
     | 
| 
       25 
21 
     | 
    
         
             
                  class ImplicitStringConcatenation < Base
         
     | 
| 
       26 
     | 
    
         
            -
                     
     | 
| 
      
 22 
     | 
    
         
            +
                    extend AutoCorrector
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                    MSG = 'Combine %<lhs>s and %<rhs>s into a single string ' \
         
     | 
| 
       27 
25 
     | 
    
         
             
                          'literal, rather than using implicit string concatenation.'
         
     | 
| 
       28 
26 
     | 
    
         
             
                    FOR_ARRAY = ' Or, if they were intended to be separate array ' \
         
     | 
| 
       29 
27 
     | 
    
         
             
                                'elements, separate them with a comma.'
         
     | 
| 
       30 
28 
     | 
    
         
             
                    FOR_METHOD = ' Or, if they were intended to be separate method ' \
         
     | 
| 
       31 
29 
     | 
    
         
             
                                 'arguments, separate them with a comma.'
         
     | 
| 
       32 
30 
     | 
    
         | 
| 
      
 31 
     | 
    
         
            +
                    # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/PerceivedComplexity
         
     | 
| 
       33 
32 
     | 
    
         
             
                    def on_dstr(node)
         
     | 
| 
       34 
     | 
    
         
            -
                      each_bad_cons(node) do | 
     | 
| 
       35 
     | 
    
         
            -
                        range 
     | 
| 
       36 
     | 
    
         
            -
                        message = format(MSG,
         
     | 
| 
       37 
     | 
    
         
            -
                                         string1: display_str(child_node1),
         
     | 
| 
       38 
     | 
    
         
            -
                                         string2: display_str(child_node2))
         
     | 
| 
      
 33 
     | 
    
         
            +
                      each_bad_cons(node) do |lhs_node, rhs_node|
         
     | 
| 
      
 34 
     | 
    
         
            +
                        range = lhs_node.source_range.join(rhs_node.source_range)
         
     | 
| 
      
 35 
     | 
    
         
            +
                        message = format(MSG, lhs: display_str(lhs_node), rhs: display_str(rhs_node))
         
     | 
| 
       39 
36 
     | 
    
         
             
                        if node.parent&.array_type?
         
     | 
| 
       40 
37 
     | 
    
         
             
                          message << FOR_ARRAY
         
     | 
| 
       41 
38 
     | 
    
         
             
                        elsif node.parent&.send_type?
         
     | 
| 
       42 
39 
     | 
    
         
             
                          message << FOR_METHOD
         
     | 
| 
       43 
40 
     | 
    
         
             
                        end
         
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                        add_offense(range, message: message) do |corrector|
         
     | 
| 
      
 43 
     | 
    
         
            +
                          if lhs_node.value == ''
         
     | 
| 
      
 44 
     | 
    
         
            +
                            corrector.remove(lhs_node)
         
     | 
| 
      
 45 
     | 
    
         
            +
                          elsif rhs_node.value == ''
         
     | 
| 
      
 46 
     | 
    
         
            +
                            corrector.remove(rhs_node)
         
     | 
| 
      
 47 
     | 
    
         
            +
                          else
         
     | 
| 
      
 48 
     | 
    
         
            +
                            range = lhs_node.source_range.end.join(rhs_node.source_range.begin)
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
                            corrector.replace(range, ' + ')
         
     | 
| 
      
 51 
     | 
    
         
            +
                          end
         
     | 
| 
      
 52 
     | 
    
         
            +
                        end
         
     | 
| 
       45 
53 
     | 
    
         
             
                      end
         
     | 
| 
       46 
54 
     | 
    
         
             
                    end
         
     | 
| 
      
 55 
     | 
    
         
            +
                    # rubocop:enable Metrics/AbcSize, Metrics/MethodLength, Metrics/PerceivedComplexity
         
     | 
| 
       47 
56 
     | 
    
         | 
| 
       48 
57 
     | 
    
         
             
                    private
         
     | 
| 
       49 
58 
     | 
    
         | 
| 
         @@ -73,7 +82,7 @@ module RuboCop 
     | 
|
| 
       73 
82 
     | 
    
         
             
                    end
         
     | 
| 
       74 
83 
     | 
    
         | 
| 
       75 
84 
     | 
    
         
             
                    def string_literal?(node)
         
     | 
| 
       76 
     | 
    
         
            -
                      node.str_type? ||  
     | 
| 
      
 85 
     | 
    
         
            +
                      node.str_type? || node.dstr_type?
         
     | 
| 
       77 
86 
     | 
    
         
             
                    end
         
     | 
| 
       78 
87 
     | 
    
         | 
| 
       79 
88 
     | 
    
         
             
                    def string_literals?(node1, node2)
         
     | 
| 
         @@ -89,6 +98,8 @@ module RuboCop 
     | 
|
| 
       89 
98 
     | 
    
         
             
                    end
         
     | 
| 
       90 
99 
     | 
    
         | 
| 
       91 
100 
     | 
    
         
             
                    def str_content(node)
         
     | 
| 
      
 101 
     | 
    
         
            +
                      return unless node.respond_to?(:str_type?)
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
       92 
103 
     | 
    
         
             
                      if node.str_type?
         
     | 
| 
       93 
104 
     | 
    
         
             
                        node.children[0]
         
     | 
| 
       94 
105 
     | 
    
         
             
                      else
         
     | 
| 
         @@ -3,8 +3,10 @@ 
     | 
|
| 
       3 
3 
     | 
    
         
             
            module RuboCop
         
     | 
| 
       4 
4 
     | 
    
         
             
              module Cop
         
     | 
| 
       5 
5 
     | 
    
         
             
                module Lint
         
     | 
| 
      
 6 
     | 
    
         
            +
                  # Checks for `IO.select` that is incompatible with Fiber Scheduler since Ruby 3.0.
         
     | 
| 
       6 
7 
     | 
    
         
             
                  #
         
     | 
| 
       7 
     | 
    
         
            -
                  #  
     | 
| 
      
 8 
     | 
    
         
            +
                  # When an array of IO objects waiting for an exception (the third argument of `IO.select`)
         
     | 
| 
      
 9 
     | 
    
         
            +
                  # is used as an argument, there is no alternative API, so offenses are not registered.
         
     | 
| 
       8 
10 
     | 
    
         
             
                  #
         
     | 
| 
       9 
11 
     | 
    
         
             
                  # NOTE: When the method is successful the return value of `IO.select` is `[[IO]]`,
         
     | 
| 
       10 
12 
     | 
    
         
             
                  # and the return value of `io.wait_readable` and `io.wait_writable` are `self`.
         
     | 
| 
         @@ -42,8 +44,8 @@ module RuboCop 
     | 
|
| 
       42 
44 
     | 
    
         
             
                    PATTERN
         
     | 
| 
       43 
45 
     | 
    
         | 
| 
       44 
46 
     | 
    
         
             
                    def on_send(node)
         
     | 
| 
       45 
     | 
    
         
            -
                      read, write,  
     | 
| 
       46 
     | 
    
         
            -
                      return  
     | 
| 
      
 47 
     | 
    
         
            +
                      read, write, excepts, timeout = *io_select(node)
         
     | 
| 
      
 48 
     | 
    
         
            +
                      return if excepts && !excepts.children.empty?
         
     | 
| 
       47 
49 
     | 
    
         
             
                      return unless scheduler_compatible?(read, write) || scheduler_compatible?(write, read)
         
     | 
| 
       48 
50 
     | 
    
         | 
| 
       49 
51 
     | 
    
         
             
                      preferred = preferred_method(read, write, timeout)
         
     | 
| 
         @@ -11,7 +11,6 @@ module RuboCop 
     | 
|
| 
       11 
11 
     | 
    
         
             
                  # @example
         
     | 
| 
       12 
12 
     | 
    
         
             
                  #
         
     | 
| 
       13 
13 
     | 
    
         
             
                  #   # bad
         
     | 
| 
       14 
     | 
    
         
            -
                  #
         
     | 
| 
       15 
14 
     | 
    
         
             
                  #   class C
         
     | 
| 
       16 
15 
     | 
    
         
             
                  #     private
         
     | 
| 
       17 
16 
     | 
    
         
             
                  #
         
     | 
| 
         @@ -20,10 +19,7 @@ module RuboCop 
     | 
|
| 
       20 
19 
     | 
    
         
             
                  #     end
         
     | 
| 
       21 
20 
     | 
    
         
             
                  #   end
         
     | 
| 
       22 
21 
     | 
    
         
             
                  #
         
     | 
| 
       23 
     | 
    
         
            -
                  # @example
         
     | 
| 
       24 
     | 
    
         
            -
                  #
         
     | 
| 
       25 
22 
     | 
    
         
             
                  #   # good
         
     | 
| 
       26 
     | 
    
         
            -
                  #
         
     | 
| 
       27 
23 
     | 
    
         
             
                  #   class C
         
     | 
| 
       28 
24 
     | 
    
         
             
                  #     def self.method
         
     | 
| 
       29 
25 
     | 
    
         
             
                  #       puts 'hi'
         
     | 
| 
         @@ -32,10 +28,7 @@ module RuboCop 
     | 
|
| 
       32 
28 
     | 
    
         
             
                  #     private_class_method :method
         
     | 
| 
       33 
29 
     | 
    
         
             
                  #   end
         
     | 
| 
       34 
30 
     | 
    
         
             
                  #
         
     | 
| 
       35 
     | 
    
         
            -
                  # @example
         
     | 
| 
       36 
     | 
    
         
            -
                  #
         
     | 
| 
       37 
31 
     | 
    
         
             
                  #   # good
         
     | 
| 
       38 
     | 
    
         
            -
                  #
         
     | 
| 
       39 
32 
     | 
    
         
             
                  #   class C
         
     | 
| 
       40 
33 
     | 
    
         
             
                  #     class << self
         
     | 
| 
       41 
34 
     | 
    
         
             
                  #       private
         
     | 
| 
         @@ -58,6 +58,7 @@ module RuboCop 
     | 
|
| 
       58 
58 
     | 
    
         | 
| 
       59 
59 
     | 
    
         
             
                    def on_class(node)
         
     | 
| 
       60 
60 
     | 
    
         
             
                      return unless node.parent_class && exception_class?(node.parent_class)
         
     | 
| 
      
 61 
     | 
    
         
            +
                      return if inherit_exception_class_with_omitted_namespace?(node)
         
     | 
| 
       61 
62 
     | 
    
         | 
| 
       62 
63 
     | 
    
         
             
                      message = message(node.parent_class)
         
     | 
| 
       63 
64 
     | 
    
         | 
| 
         @@ -87,6 +88,14 @@ module RuboCop 
     | 
|
| 
       87 
88 
     | 
    
         
             
                      class_node.const_name == 'Exception'
         
     | 
| 
       88 
89 
     | 
    
         
             
                    end
         
     | 
| 
       89 
90 
     | 
    
         | 
| 
      
 91 
     | 
    
         
            +
                    def inherit_exception_class_with_omitted_namespace?(class_node)
         
     | 
| 
      
 92 
     | 
    
         
            +
                      return false if class_node.parent_class.namespace&.cbase_type?
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
      
 94 
     | 
    
         
            +
                      class_node.left_siblings.any? do |sibling|
         
     | 
| 
      
 95 
     | 
    
         
            +
                        sibling.respond_to?(:identifier) && exception_class?(sibling.identifier)
         
     | 
| 
      
 96 
     | 
    
         
            +
                      end
         
     | 
| 
      
 97 
     | 
    
         
            +
                    end
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
       90 
99 
     | 
    
         
             
                    def preferred_base_class
         
     | 
| 
       91 
100 
     | 
    
         
             
                      PREFERRED_BASE_CLASS[style]
         
     | 
| 
       92 
101 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -14,13 +14,9 @@ module RuboCop 
     | 
|
| 
       14 
14 
     | 
    
         
             
                  # @example
         
     | 
| 
       15 
15 
     | 
    
         
             
                  #
         
     | 
| 
       16 
16 
     | 
    
         
             
                  #   # bad
         
     | 
| 
       17 
     | 
    
         
            -
                  #
         
     | 
| 
       18 
17 
     | 
    
         
             
                  #   foo = 'something with #{interpolation} inside'
         
     | 
| 
       19 
18 
     | 
    
         
             
                  #
         
     | 
| 
       20 
     | 
    
         
            -
                  # @example
         
     | 
| 
       21 
     | 
    
         
            -
                  #
         
     | 
| 
       22 
19 
     | 
    
         
             
                  #   # good
         
     | 
| 
       23 
     | 
    
         
            -
                  #
         
     | 
| 
       24 
20 
     | 
    
         
             
                  #   foo = "something with #{interpolation} inside"
         
     | 
| 
       25 
21 
     | 
    
         
             
                  class InterpolationCheck < Base
         
     | 
| 
       26 
22 
     | 
    
         
             
                    extend AutoCorrector
         
     | 
| 
         @@ -0,0 +1,47 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module RuboCop
         
     | 
| 
      
 4 
     | 
    
         
            +
              module Cop
         
     | 
| 
      
 5 
     | 
    
         
            +
                module Lint
         
     | 
| 
      
 6 
     | 
    
         
            +
                  # Emulates the following Ruby warning in Ruby 3.3.
         
     | 
| 
      
 7 
     | 
    
         
            +
                  #
         
     | 
| 
      
 8 
     | 
    
         
            +
                  # [source,ruby]
         
     | 
| 
      
 9 
     | 
    
         
            +
                  # ----
         
     | 
| 
      
 10 
     | 
    
         
            +
                  # $ ruby -e '0.times { it }'
         
     | 
| 
      
 11 
     | 
    
         
            +
                  # -e:1: warning: `it` calls without arguments will refer to the first block param in Ruby 3.4;
         
     | 
| 
      
 12 
     | 
    
         
            +
                  # use it() or self.it
         
     | 
| 
      
 13 
     | 
    
         
            +
                  # ----
         
     | 
| 
      
 14 
     | 
    
         
            +
                  #
         
     | 
| 
      
 15 
     | 
    
         
            +
                  # `it` calls without arguments will refer to the first block param in Ruby 3.4.
         
     | 
| 
      
 16 
     | 
    
         
            +
                  # So use `it()` or `self.it` to ensure compatibility.
         
     | 
| 
      
 17 
     | 
    
         
            +
                  #
         
     | 
| 
      
 18 
     | 
    
         
            +
                  # @example
         
     | 
| 
      
 19 
     | 
    
         
            +
                  #
         
     | 
| 
      
 20 
     | 
    
         
            +
                  #   # bad
         
     | 
| 
      
 21 
     | 
    
         
            +
                  #   do_something { it }
         
     | 
| 
      
 22 
     | 
    
         
            +
                  #
         
     | 
| 
      
 23 
     | 
    
         
            +
                  #   # good
         
     | 
| 
      
 24 
     | 
    
         
            +
                  #   do_something { it() }
         
     | 
| 
      
 25 
     | 
    
         
            +
                  #   do_something { self.it }
         
     | 
| 
      
 26 
     | 
    
         
            +
                  #
         
     | 
| 
      
 27 
     | 
    
         
            +
                  class ItWithoutArgumentsInBlock < Base
         
     | 
| 
      
 28 
     | 
    
         
            +
                    include NodePattern::Macros
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                    MSG = '`it` calls without arguments will refer to the first block param in Ruby 3.4; ' \
         
     | 
| 
      
 31 
     | 
    
         
            +
                          'use `it()` or `self.it`.'
         
     | 
| 
      
 32 
     | 
    
         
            +
                    RESTRICT_ON_SEND = %i[it].freeze
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                    def on_send(node)
         
     | 
| 
      
 35 
     | 
    
         
            +
                      return unless (block_node = node.each_ancestor(:block).first)
         
     | 
| 
      
 36 
     | 
    
         
            +
                      return unless block_node.arguments.empty_and_without_delimiters?
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
                      add_offense(node) if deprecated_it_method?(node)
         
     | 
| 
      
 39 
     | 
    
         
            +
                    end
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
                    def deprecated_it_method?(node)
         
     | 
| 
      
 42 
     | 
    
         
            +
                      !node.receiver && node.arguments.empty? && !node.parenthesized? && !node.block_literal?
         
     | 
| 
      
 43 
     | 
    
         
            +
                    end
         
     | 
| 
      
 44 
     | 
    
         
            +
                  end
         
     | 
| 
      
 45 
     | 
    
         
            +
                end
         
     | 
| 
      
 46 
     | 
    
         
            +
              end
         
     | 
| 
      
 47 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -6,7 +6,7 @@ module RuboCop 
     | 
|
| 
       6 
6 
     | 
    
         
             
                  # Checks uses of lambda without a literal block.
         
     | 
| 
       7 
7 
     | 
    
         
             
                  # It emulates the following warning in Ruby 3.0:
         
     | 
| 
       8 
8 
     | 
    
         
             
                  #
         
     | 
| 
       9 
     | 
    
         
            -
                  #    
     | 
| 
      
 9 
     | 
    
         
            +
                  #   $ ruby -vwe 'lambda(&proc {})'
         
     | 
| 
       10 
10 
     | 
    
         
             
                  #   ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19]
         
     | 
| 
       11 
11 
     | 
    
         
             
                  #   -e:1: warning: lambda without a literal block is deprecated; use the proc without
         
     | 
| 
       12 
12 
     | 
    
         
             
                  #   lambda instead
         
     | 
| 
         @@ -0,0 +1,85 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module RuboCop
         
     | 
| 
      
 4 
     | 
    
         
            +
              module Cop
         
     | 
| 
      
 5 
     | 
    
         
            +
                module Lint
         
     | 
| 
      
 6 
     | 
    
         
            +
                  # Checks for literal assignments in the conditions of `if`, `while`, and `until`.
         
     | 
| 
      
 7 
     | 
    
         
            +
                  # It emulates the following Ruby warning:
         
     | 
| 
      
 8 
     | 
    
         
            +
                  #
         
     | 
| 
      
 9 
     | 
    
         
            +
                  # [source,console]
         
     | 
| 
      
 10 
     | 
    
         
            +
                  # ----
         
     | 
| 
      
 11 
     | 
    
         
            +
                  # $ ruby -we 'if x = true; end'
         
     | 
| 
      
 12 
     | 
    
         
            +
                  # -e:1: warning: found `= literal' in conditional, should be ==
         
     | 
| 
      
 13 
     | 
    
         
            +
                  # ----
         
     | 
| 
      
 14 
     | 
    
         
            +
                  #
         
     | 
| 
      
 15 
     | 
    
         
            +
                  # As a lint cop, it cannot be determined if `==` is appropriate as intended,
         
     | 
| 
      
 16 
     | 
    
         
            +
                  # therefore this cop does not provide autocorrection.
         
     | 
| 
      
 17 
     | 
    
         
            +
                  #
         
     | 
| 
      
 18 
     | 
    
         
            +
                  # @example
         
     | 
| 
      
 19 
     | 
    
         
            +
                  #
         
     | 
| 
      
 20 
     | 
    
         
            +
                  #   # bad
         
     | 
| 
      
 21 
     | 
    
         
            +
                  #   if x = 42
         
     | 
| 
      
 22 
     | 
    
         
            +
                  #     do_something
         
     | 
| 
      
 23 
     | 
    
         
            +
                  #   end
         
     | 
| 
      
 24 
     | 
    
         
            +
                  #
         
     | 
| 
      
 25 
     | 
    
         
            +
                  #   # good
         
     | 
| 
      
 26 
     | 
    
         
            +
                  #   if x == 42
         
     | 
| 
      
 27 
     | 
    
         
            +
                  #     do_something
         
     | 
| 
      
 28 
     | 
    
         
            +
                  #   end
         
     | 
| 
      
 29 
     | 
    
         
            +
                  #
         
     | 
| 
      
 30 
     | 
    
         
            +
                  #   # good
         
     | 
| 
      
 31 
     | 
    
         
            +
                  #   if x = y
         
     | 
| 
      
 32 
     | 
    
         
            +
                  #     do_something
         
     | 
| 
      
 33 
     | 
    
         
            +
                  #   end
         
     | 
| 
      
 34 
     | 
    
         
            +
                  #
         
     | 
| 
      
 35 
     | 
    
         
            +
                  class LiteralAssignmentInCondition < Base
         
     | 
| 
      
 36 
     | 
    
         
            +
                    MSG = "Don't use literal assignment `= %<literal>s` in conditional, " \
         
     | 
| 
      
 37 
     | 
    
         
            +
                          'should be `==` or non-literal operand.'
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                    def on_if(node)
         
     | 
| 
      
 40 
     | 
    
         
            +
                      traverse_node(node.condition) do |asgn_node|
         
     | 
| 
      
 41 
     | 
    
         
            +
                        next unless asgn_node.loc.operator
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                        rhs = asgn_node.to_a.last
         
     | 
| 
      
 44 
     | 
    
         
            +
                        next if !all_literals?(rhs) || parallel_assignment_with_splat_operator?(rhs)
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                        range = offense_range(asgn_node, rhs)
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                        add_offense(range, message: format(MSG, literal: rhs.source))
         
     | 
| 
      
 49 
     | 
    
         
            +
                      end
         
     | 
| 
      
 50 
     | 
    
         
            +
                    end
         
     | 
| 
      
 51 
     | 
    
         
            +
                    alias on_while on_if
         
     | 
| 
      
 52 
     | 
    
         
            +
                    alias on_until on_if
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
                    private
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
                    def traverse_node(node, &block)
         
     | 
| 
      
 57 
     | 
    
         
            +
                      yield node if node.equals_asgn?
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
                      node.each_child_node { |child| traverse_node(child, &block) }
         
     | 
| 
      
 60 
     | 
    
         
            +
                    end
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
                    def all_literals?(node)
         
     | 
| 
      
 63 
     | 
    
         
            +
                      case node.type
         
     | 
| 
      
 64 
     | 
    
         
            +
                      when :dstr, :xstr
         
     | 
| 
      
 65 
     | 
    
         
            +
                        false
         
     | 
| 
      
 66 
     | 
    
         
            +
                      when :array
         
     | 
| 
      
 67 
     | 
    
         
            +
                        node.values.all? { |value| all_literals?(value) }
         
     | 
| 
      
 68 
     | 
    
         
            +
                      when :hash
         
     | 
| 
      
 69 
     | 
    
         
            +
                        (node.values + node.keys).all? { |item| all_literals?(item) }
         
     | 
| 
      
 70 
     | 
    
         
            +
                      else
         
     | 
| 
      
 71 
     | 
    
         
            +
                        node.respond_to?(:literal?) && node.literal?
         
     | 
| 
      
 72 
     | 
    
         
            +
                      end
         
     | 
| 
      
 73 
     | 
    
         
            +
                    end
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
                    def parallel_assignment_with_splat_operator?(node)
         
     | 
| 
      
 76 
     | 
    
         
            +
                      node.array_type? && node.values.first&.splat_type?
         
     | 
| 
      
 77 
     | 
    
         
            +
                    end
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
                    def offense_range(asgn_node, rhs)
         
     | 
| 
      
 80 
     | 
    
         
            +
                      asgn_node.loc.operator.join(rhs.source_range.end)
         
     | 
| 
      
 81 
     | 
    
         
            +
                    end
         
     | 
| 
      
 82 
     | 
    
         
            +
                  end
         
     | 
| 
      
 83 
     | 
    
         
            +
                end
         
     | 
| 
      
 84 
     | 
    
         
            +
              end
         
     | 
| 
      
 85 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -8,13 +8,9 @@ module RuboCop 
     | 
|
| 
       8 
8 
     | 
    
         
             
                  # @example
         
     | 
| 
       9 
9 
     | 
    
         
             
                  #
         
     | 
| 
       10 
10 
     | 
    
         
             
                  #   # bad
         
     | 
| 
       11 
     | 
    
         
            -
                  #
         
     | 
| 
       12 
11 
     | 
    
         
             
                  #   "result is #{10}"
         
     | 
| 
       13 
12 
     | 
    
         
             
                  #
         
     | 
| 
       14 
     | 
    
         
            -
                  # @example
         
     | 
| 
       15 
     | 
    
         
            -
                  #
         
     | 
| 
       16 
13 
     | 
    
         
             
                  #   # good
         
     | 
| 
       17 
     | 
    
         
            -
                  #
         
     | 
| 
       18 
14 
     | 
    
         
             
                  #   "result is 10"
         
     | 
| 
       19 
15 
     | 
    
         
             
                  class LiteralInInterpolation < Base
         
     | 
| 
       20 
16 
     | 
    
         
             
                    include Interpolation
         
     | 
| 
         @@ -34,7 +30,9 @@ module RuboCop 
     | 
|
| 
       34 
30 
     | 
    
         
             
                      # interpolation should not be removed if the expanded value
         
     | 
| 
       35 
31 
     | 
    
         
             
                      # contains a space character.
         
     | 
| 
       36 
32 
     | 
    
         
             
                      expanded_value = autocorrected_value(final_node)
         
     | 
| 
       37 
     | 
    
         
            -
                       
     | 
| 
      
 33 
     | 
    
         
            +
                      expanded_value = handle_special_regexp_chars(begin_node, expanded_value)
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                      return if in_array_percent_literal?(begin_node) && /\s|\A\z/.match?(expanded_value)
         
     | 
| 
       38 
36 
     | 
    
         | 
| 
       39 
37 
     | 
    
         
             
                      add_offense(final_node) do |corrector|
         
     | 
| 
       40 
38 
     | 
    
         
             
                        return if final_node.dstr_type? # nested, fixed in next iteration
         
     | 
| 
         @@ -81,6 +79,27 @@ module RuboCop 
     | 
|
| 
       81 
79 
     | 
    
         
             
                    end
         
     | 
| 
       82 
80 
     | 
    
         
             
                    # rubocop:enable Metrics/MethodLength, Metrics/CyclomaticComplexity
         
     | 
| 
       83 
81 
     | 
    
         | 
| 
      
 82 
     | 
    
         
            +
                    def handle_special_regexp_chars(begin_node, value)
         
     | 
| 
      
 83 
     | 
    
         
            +
                      parent_node = begin_node.parent
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
                      return value unless parent_node.regexp_type? && parent_node.slash_literal? && value['/']
         
     | 
| 
      
 86 
     | 
    
         
            +
             
     | 
| 
      
 87 
     | 
    
         
            +
                      # When a literal string containing a forward slash preceded by backslashes
         
     | 
| 
      
 88 
     | 
    
         
            +
                      # is interpolated inside a regexp, the number of resultant backslashes in the
         
     | 
| 
      
 89 
     | 
    
         
            +
                      # compiled Regexp is `(2(n+1) / 4)+1`, where `n` is the number of backslashes
         
     | 
| 
      
 90 
     | 
    
         
            +
                      # inside the interpolation.
         
     | 
| 
      
 91 
     | 
    
         
            +
                      # ie. 0-2 backslashes is compiled to 1, 3-6 is compiled to 3, etc.
         
     | 
| 
      
 92 
     | 
    
         
            +
                      # This maintains that same behavior in order to ensure the Regexp behavior
         
     | 
| 
      
 93 
     | 
    
         
            +
                      # does not change upon removing the interpolation.
         
     | 
| 
      
 94 
     | 
    
         
            +
                      value.gsub(%r{(\\*)/}) do
         
     | 
| 
      
 95 
     | 
    
         
            +
                        backslashes = Regexp.last_match[1]
         
     | 
| 
      
 96 
     | 
    
         
            +
                        backslash_count = backslashes.length
         
     | 
| 
      
 97 
     | 
    
         
            +
                        needed_backslashes = (2 * ((backslash_count + 1) / 4)) + 1
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
                        "#{'\\' * needed_backslashes}/"
         
     | 
| 
      
 100 
     | 
    
         
            +
                      end
         
     | 
| 
      
 101 
     | 
    
         
            +
                    end
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
       84 
103 
     | 
    
         
             
                    def autocorrected_value_for_string(node)
         
     | 
| 
       85 
104 
     | 
    
         
             
                      if node.source.start_with?("'", '%q')
         
     | 
| 
       86 
105 
     | 
    
         
             
                        node.children.last.inspect[1..-2]
         
     | 
| 
         @@ -154,7 +173,7 @@ module RuboCop 
     | 
|
| 
       154 
173 
     | 
    
         | 
| 
       155 
174 
     | 
    
         
             
                    def ends_heredoc_line?(node)
         
     | 
| 
       156 
175 
     | 
    
         
             
                      grandparent = node.parent.parent
         
     | 
| 
       157 
     | 
    
         
            -
                      return false unless grandparent&.dstr_type? && grandparent 
     | 
| 
      
 176 
     | 
    
         
            +
                      return false unless grandparent&.dstr_type? && grandparent.heredoc?
         
     | 
| 
       158 
177 
     | 
    
         | 
| 
       159 
178 
     | 
    
         
             
                      line = processed_source.lines[node.last_line - 1]
         
     | 
| 
       160 
179 
     | 
    
         
             
                      line.size == node.loc.last_column + 1
         
     | 
| 
         @@ -165,7 +184,7 @@ module RuboCop 
     | 
|
| 
       165 
184 
     | 
    
         
             
                      return false unless parent.dstr_type? || parent.dsym_type?
         
     | 
| 
       166 
185 
     | 
    
         | 
| 
       167 
186 
     | 
    
         
             
                      grandparent = parent.parent
         
     | 
| 
       168 
     | 
    
         
            -
                      grandparent&.array_type? && grandparent 
     | 
| 
      
 187 
     | 
    
         
            +
                      grandparent&.array_type? && grandparent.percent_literal?
         
     | 
| 
       169 
188 
     | 
    
         
             
                    end
         
     | 
| 
       170 
189 
     | 
    
         
             
                  end
         
     | 
| 
       171 
190 
     | 
    
         
             
                end
         
     | 
| 
         @@ -19,17 +19,6 @@ module RuboCop 
     | 
|
| 
       19 
19 
     | 
    
         
             
                  #     do_something
         
     | 
| 
       20 
20 
     | 
    
         
             
                  #   end while some_condition
         
     | 
| 
       21 
21 
     | 
    
         
             
                  #
         
     | 
| 
       22 
     | 
    
         
            -
                  # @example
         
     | 
| 
       23 
     | 
    
         
            -
                  #
         
     | 
| 
       24 
     | 
    
         
            -
                  #   # bad
         
     | 
| 
       25 
     | 
    
         
            -
                  #
         
     | 
| 
       26 
     | 
    
         
            -
                  #   # using until
         
     | 
| 
       27 
     | 
    
         
            -
                  #   begin
         
     | 
| 
       28 
     | 
    
         
            -
                  #     do_something
         
     | 
| 
       29 
     | 
    
         
            -
                  #   end until some_condition
         
     | 
| 
       30 
     | 
    
         
            -
                  #
         
     | 
| 
       31 
     | 
    
         
            -
                  # @example
         
     | 
| 
       32 
     | 
    
         
            -
                  #
         
     | 
| 
       33 
22 
     | 
    
         
             
                  #   # good
         
     | 
| 
       34 
23 
     | 
    
         
             
                  #
         
     | 
| 
       35 
24 
     | 
    
         
             
                  #   # while replacement
         
     | 
| 
         @@ -38,7 +27,12 @@ module RuboCop 
     | 
|
| 
       38 
27 
     | 
    
         
             
                  #     break unless some_condition
         
     | 
| 
       39 
28 
     | 
    
         
             
                  #   end
         
     | 
| 
       40 
29 
     | 
    
         
             
                  #
         
     | 
| 
       41 
     | 
    
         
            -
                  #  
     | 
| 
      
 30 
     | 
    
         
            +
                  #   # bad
         
     | 
| 
      
 31 
     | 
    
         
            +
                  #
         
     | 
| 
      
 32 
     | 
    
         
            +
                  #   # using until
         
     | 
| 
      
 33 
     | 
    
         
            +
                  #   begin
         
     | 
| 
      
 34 
     | 
    
         
            +
                  #     do_something
         
     | 
| 
      
 35 
     | 
    
         
            +
                  #   end until some_condition
         
     | 
| 
       42 
36 
     | 
    
         
             
                  #
         
     | 
| 
       43 
37 
     | 
    
         
             
                  #   # good
         
     | 
| 
       44 
38 
     | 
    
         
             
                  #
         
     |