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
 
| 
         @@ -16,7 +16,7 @@ module RuboCop 
     | 
|
| 
       16 
16 
     | 
    
         
             
                  # start of the line where the expression started.
         
     | 
| 
       17 
17 
     | 
    
         
             
                  #
         
     | 
| 
       18 
18 
     | 
    
         
             
                  # `either` (which is the default) : the `end` is allowed to be in either
         
     | 
| 
       19 
     | 
    
         
            -
                  # location. The  
     | 
| 
      
 19 
     | 
    
         
            +
                  # location. The autocorrect will default to `start_of_line`.
         
     | 
| 
       20 
20 
     | 
    
         
             
                  #
         
     | 
| 
       21 
21 
     | 
    
         
             
                  # @example EnforcedStyleAlignWith: either (default)
         
     | 
| 
       22 
22 
     | 
    
         
             
                  #   # bad
         
     | 
| 
         @@ -92,16 +92,6 @@ module RuboCop 
     | 
|
| 
       92 
92 
     | 
    
         | 
| 
       93 
93 
     | 
    
         
             
                    private
         
     | 
| 
       94 
94 
     | 
    
         | 
| 
       95 
     | 
    
         
            -
                    def start_for_block_node(block_node)
         
     | 
| 
       96 
     | 
    
         
            -
                      # Which node should we align the 'end' with?
         
     | 
| 
       97 
     | 
    
         
            -
                      result = block_end_align_target(block_node)
         
     | 
| 
       98 
     | 
    
         
            -
             
     | 
| 
       99 
     | 
    
         
            -
                      # In offense message, we want to show the assignment LHS rather than
         
     | 
| 
       100 
     | 
    
         
            -
                      # the entire assignment
         
     | 
| 
       101 
     | 
    
         
            -
                      result, = *result while result.op_asgn_type? || result.masgn_type?
         
     | 
| 
       102 
     | 
    
         
            -
                      result
         
     | 
| 
       103 
     | 
    
         
            -
                    end
         
     | 
| 
       104 
     | 
    
         
            -
             
     | 
| 
       105 
95 
     | 
    
         
             
                    def block_end_align_target(node)
         
     | 
| 
       106 
96 
     | 
    
         
             
                      lineage = [node, *node.ancestors]
         
     | 
| 
       107 
97 
     | 
    
         | 
| 
         @@ -153,7 +143,11 @@ module RuboCop 
     | 
|
| 
       153 
143 
     | 
    
         
             
                    end
         
     | 
| 
       154 
144 
     | 
    
         | 
| 
       155 
145 
     | 
    
         
             
                    def autocorrect(corrector, node)
         
     | 
| 
       156 
     | 
    
         
            -
                      ancestor_node =  
     | 
| 
      
 146 
     | 
    
         
            +
                      ancestor_node = if style == :start_of_block
         
     | 
| 
      
 147 
     | 
    
         
            +
                                        start_for_block_node(node)
         
     | 
| 
      
 148 
     | 
    
         
            +
                                      else
         
     | 
| 
      
 149 
     | 
    
         
            +
                                        start_for_line_node(node)
         
     | 
| 
      
 150 
     | 
    
         
            +
                                      end
         
     | 
| 
       157 
151 
     | 
    
         
             
                      start_col = compute_start_col(ancestor_node, node)
         
     | 
| 
       158 
152 
     | 
    
         
             
                      loc_end = node.loc.end
         
     | 
| 
       159 
153 
     | 
    
         
             
                      delta = start_col - loc_end.column
         
     | 
| 
         @@ -175,6 +169,30 @@ module RuboCop 
     | 
|
| 
       175 
169 
     | 
    
         
             
                      )
         
     | 
| 
       176 
170 
     | 
    
         
             
                    end
         
     | 
| 
       177 
171 
     | 
    
         | 
| 
      
 172 
     | 
    
         
            +
                    def start_for_block_node(block_node)
         
     | 
| 
      
 173 
     | 
    
         
            +
                      # Which node should we align the 'end' with?
         
     | 
| 
      
 174 
     | 
    
         
            +
                      start_node = block_end_align_target(block_node)
         
     | 
| 
      
 175 
     | 
    
         
            +
             
     | 
| 
      
 176 
     | 
    
         
            +
                      find_lhs_node(start_node)
         
     | 
| 
      
 177 
     | 
    
         
            +
                    end
         
     | 
| 
      
 178 
     | 
    
         
            +
             
     | 
| 
      
 179 
     | 
    
         
            +
                    def start_for_line_node(block_node)
         
     | 
| 
      
 180 
     | 
    
         
            +
                      start_node = start_for_block_node(block_node)
         
     | 
| 
      
 181 
     | 
    
         
            +
             
     | 
| 
      
 182 
     | 
    
         
            +
                      start_node = start_node.each_ancestor.to_a.reverse.find do |node|
         
     | 
| 
      
 183 
     | 
    
         
            +
                        same_line?(start_node, node)
         
     | 
| 
      
 184 
     | 
    
         
            +
                      end || start_node
         
     | 
| 
      
 185 
     | 
    
         
            +
             
     | 
| 
      
 186 
     | 
    
         
            +
                      find_lhs_node(start_node)
         
     | 
| 
      
 187 
     | 
    
         
            +
                    end
         
     | 
| 
      
 188 
     | 
    
         
            +
             
     | 
| 
      
 189 
     | 
    
         
            +
                    # In offense message, we want to show the assignment LHS rather than
         
     | 
| 
      
 190 
     | 
    
         
            +
                    # the entire assignment.
         
     | 
| 
      
 191 
     | 
    
         
            +
                    def find_lhs_node(node)
         
     | 
| 
      
 192 
     | 
    
         
            +
                      node, = *node while node.op_asgn_type? || node.masgn_type?
         
     | 
| 
      
 193 
     | 
    
         
            +
                      node
         
     | 
| 
      
 194 
     | 
    
         
            +
                    end
         
     | 
| 
      
 195 
     | 
    
         
            +
             
     | 
| 
       178 
196 
     | 
    
         
             
                    def compute_do_source_line_column(node, end_loc)
         
     | 
| 
       179 
197 
     | 
    
         
             
                      do_loc = node.loc.begin # Actually it's either do or {.
         
     | 
| 
       180 
198 
     | 
    
         | 
| 
         @@ -121,7 +121,7 @@ module RuboCop 
     | 
|
| 
       121 
121 
     | 
    
         
             
                      return if case_node.single_line?
         
     | 
| 
       122 
122 
     | 
    
         
             
                      return if enforced_style_end? && end_and_last_conditional_same_line?(case_node)
         
     | 
| 
       123 
123 
     | 
    
         | 
| 
       124 
     | 
    
         
            -
                      case_node. 
     | 
| 
      
 124 
     | 
    
         
            +
                      case_node.when_branches.each { |when_node| check_when(when_node, 'when') }
         
     | 
| 
       125 
125 
     | 
    
         
             
                    end
         
     | 
| 
       126 
126 
     | 
    
         | 
| 
       127 
127 
     | 
    
         
             
                    def on_case_match(case_match_node)
         
     | 
| 
         @@ -68,6 +68,13 @@ module RuboCop 
     | 
|
| 
       68 
68 
     | 
    
         
             
                  #        - extend
         
     | 
| 
       69 
69 
     | 
    
         
             
                  # ----
         
     | 
| 
       70 
70 
     | 
    
         
             
                  #
         
     | 
| 
      
 71 
     | 
    
         
            +
                  # @safety
         
     | 
| 
      
 72 
     | 
    
         
            +
                  #   Autocorrection is unsafe because class methods and module inclusion
         
     | 
| 
      
 73 
     | 
    
         
            +
                  #   can behave differently, based on which methods or constants have
         
     | 
| 
      
 74 
     | 
    
         
            +
                  #   already been defined.
         
     | 
| 
      
 75 
     | 
    
         
            +
                  #
         
     | 
| 
      
 76 
     | 
    
         
            +
                  #   Constants will only be moved when they are assigned with literals.
         
     | 
| 
      
 77 
     | 
    
         
            +
                  #
         
     | 
| 
       71 
78 
     | 
    
         
             
                  # @example
         
     | 
| 
       72 
79 
     | 
    
         
             
                  #   # bad
         
     | 
| 
       73 
80 
     | 
    
         
             
                  #   # Expect extend be before constant
         
     | 
| 
         @@ -3,7 +3,6 @@ 
     | 
|
| 
       3 
3 
     | 
    
         
             
            module RuboCop
         
     | 
| 
       4 
4 
     | 
    
         
             
              module Cop
         
     | 
| 
       5 
5 
     | 
    
         
             
                module Layout
         
     | 
| 
       6 
     | 
    
         
            -
                  #
         
     | 
| 
       7 
6 
     | 
    
         
             
                  # Checks the indentation of here document closings.
         
     | 
| 
       8 
7 
     | 
    
         
             
                  #
         
     | 
| 
       9 
8 
     | 
    
         
             
                  # @example
         
     | 
| 
         @@ -73,7 +72,7 @@ module RuboCop 
     | 
|
| 
       73 
72 
     | 
    
         
             
                    end
         
     | 
| 
       74 
73 
     | 
    
         | 
| 
       75 
74 
     | 
    
         
             
                    def argument_indentation_correct?(node)
         
     | 
| 
       76 
     | 
    
         
            -
                      return unless node.argument? || node.chained?
         
     | 
| 
      
 75 
     | 
    
         
            +
                      return false unless node.argument? || node.chained?
         
     | 
| 
       77 
76 
     | 
    
         | 
| 
       78 
77 
     | 
    
         
             
                      opening_indentation(
         
     | 
| 
       79 
78 
     | 
    
         
             
                        find_node_used_heredoc_argument(node.parent)
         
     | 
| 
         @@ -61,7 +61,7 @@ module RuboCop 
     | 
|
| 
       61 
61 
     | 
    
         
             
                    private
         
     | 
| 
       62 
62 
     | 
    
         | 
| 
       63 
63 
     | 
    
         
             
                    def autocorrect(corrector, node)
         
     | 
| 
       64 
     | 
    
         
            -
                      if style == :start_of_line && node.parent 
     | 
| 
      
 64 
     | 
    
         
            +
                      if style == :start_of_line && node.parent&.send_type?
         
     | 
| 
       65 
65 
     | 
    
         
             
                        AlignmentCorrector.align_end(corrector, processed_source, node, node.parent)
         
     | 
| 
       66 
66 
     | 
    
         
             
                      else
         
     | 
| 
       67 
67 
     | 
    
         
             
                        AlignmentCorrector.align_end(corrector, processed_source, node, node)
         
     | 
| 
         @@ -32,7 +32,7 @@ module RuboCop 
     | 
|
| 
       32 
32 
     | 
    
         
             
                    end
         
     | 
| 
       33 
33 
     | 
    
         | 
| 
       34 
34 
     | 
    
         
             
                    def on_send(node)
         
     | 
| 
       35 
     | 
    
         
            -
                      return unless node.dot? ||  
     | 
| 
      
 35 
     | 
    
         
            +
                      return unless node.dot? || node.safe_navigation?
         
     | 
| 
       36 
36 
     | 
    
         | 
| 
       37 
37 
     | 
    
         
             
                      return correct_style_detected if proper_dot_position?(node)
         
     | 
| 
       38 
38 
     | 
    
         | 
| 
         @@ -133,10 +133,6 @@ module RuboCop 
     | 
|
| 
       133 
133 
     | 
    
         
             
                      # l.(1) has no selector, so we use the opening parenthesis instead
         
     | 
| 
       134 
134 
     | 
    
         
             
                      node.loc.selector || node.loc.begin
         
     | 
| 
       135 
135 
     | 
    
         
             
                    end
         
     | 
| 
       136 
     | 
    
         
            -
             
     | 
| 
       137 
     | 
    
         
            -
                    def ampersand_dot?(node)
         
     | 
| 
       138 
     | 
    
         
            -
                      node.loc.respond_to?(:dot) && node.loc.dot && node.loc.dot.is?('&.')
         
     | 
| 
       139 
     | 
    
         
            -
                    end
         
     | 
| 
       140 
136 
     | 
    
         
             
                  end
         
     | 
| 
       141 
137 
     | 
    
         
             
                end
         
     | 
| 
       142 
138 
     | 
    
         
             
              end
         
     | 
| 
         @@ -106,7 +106,9 @@ module RuboCop 
     | 
|
| 
       106 
106 
     | 
    
         
             
                    end
         
     | 
| 
       107 
107 
     | 
    
         | 
| 
       108 
108 
     | 
    
         
             
                    def concat_consecutive_comments(comments)
         
     | 
| 
       109 
     | 
    
         
            -
                      consecutive_comments = comments.chunk_while  
     | 
| 
      
 109 
     | 
    
         
            +
                      consecutive_comments = comments.chunk_while do |i, j|
         
     | 
| 
      
 110 
     | 
    
         
            +
                        i.loc.line.succ == j.loc.line && i.loc.column == j.loc.column
         
     | 
| 
      
 111 
     | 
    
         
            +
                      end
         
     | 
| 
       110 
112 
     | 
    
         | 
| 
       111 
113 
     | 
    
         
             
                      consecutive_comments.map do |chunk|
         
     | 
| 
       112 
114 
     | 
    
         
             
                        joined_text = chunk.map { |c| comment_text(c) }.join
         
     | 
| 
         @@ -3,7 +3,23 @@ 
     | 
|
| 
       3 
3 
     | 
    
         
             
            module RuboCop
         
     | 
| 
       4 
4 
     | 
    
         
             
              module Cop
         
     | 
| 
       5 
5 
     | 
    
         
             
                module Layout
         
     | 
| 
       6 
     | 
    
         
            -
                  # Enforces empty line after guard clause
         
     | 
| 
      
 6 
     | 
    
         
            +
                  # Enforces empty line after guard clause.
         
     | 
| 
      
 7 
     | 
    
         
            +
                  #
         
     | 
| 
      
 8 
     | 
    
         
            +
                  # This cop allows `# :nocov:` directive after guard clause because
         
     | 
| 
      
 9 
     | 
    
         
            +
                  # SimpleCov excludes code from the coverage report by wrapping it in `# :nocov:`:
         
     | 
| 
      
 10 
     | 
    
         
            +
                  #
         
     | 
| 
      
 11 
     | 
    
         
            +
                  # [source,ruby]
         
     | 
| 
      
 12 
     | 
    
         
            +
                  # ----
         
     | 
| 
      
 13 
     | 
    
         
            +
                  # def foo
         
     | 
| 
      
 14 
     | 
    
         
            +
                  #   # :nocov:
         
     | 
| 
      
 15 
     | 
    
         
            +
                  #   return if condition
         
     | 
| 
      
 16 
     | 
    
         
            +
                  #   # :nocov:
         
     | 
| 
      
 17 
     | 
    
         
            +
                  #   bar
         
     | 
| 
      
 18 
     | 
    
         
            +
                  # end
         
     | 
| 
      
 19 
     | 
    
         
            +
                  # ----
         
     | 
| 
      
 20 
     | 
    
         
            +
                  #
         
     | 
| 
      
 21 
     | 
    
         
            +
                  # Refer to SimpleCov's documentation for more details:
         
     | 
| 
      
 22 
     | 
    
         
            +
                  # https://github.com/simplecov-ruby/simplecov#ignoringskipping-code
         
     | 
| 
       7 
23 
     | 
    
         
             
                  #
         
     | 
| 
       8 
24 
     | 
    
         
             
                  # @example
         
     | 
| 
       9 
25 
     | 
    
         
             
                  #
         
     | 
| 
         @@ -42,19 +58,22 @@ module RuboCop 
     | 
|
| 
       42 
58 
     | 
    
         | 
| 
       43 
59 
     | 
    
         
             
                    MSG = 'Add empty line after guard clause.'
         
     | 
| 
       44 
60 
     | 
    
         
             
                    END_OF_HEREDOC_LINE = 1
         
     | 
| 
      
 61 
     | 
    
         
            +
                    SIMPLE_DIRECTIVE_COMMENT_PATTERN = /\A# *:nocov:\z/.freeze
         
     | 
| 
       45 
62 
     | 
    
         | 
| 
       46 
63 
     | 
    
         
             
                    def on_if(node)
         
     | 
| 
       47 
64 
     | 
    
         
             
                      return if correct_style?(node)
         
     | 
| 
       48 
65 
     | 
    
         
             
                      return if multiple_statements_on_line?(node)
         
     | 
| 
       49 
66 
     | 
    
         | 
| 
       50 
67 
     | 
    
         
             
                      if node.modifier_form? && (heredoc_node = last_heredoc_argument(node))
         
     | 
| 
       51 
     | 
    
         
            -
                         
     | 
| 
      
 68 
     | 
    
         
            +
                        if next_line_empty_or_allowed_directive_comment?(heredoc_line(node, heredoc_node))
         
     | 
| 
      
 69 
     | 
    
         
            +
                          return
         
     | 
| 
      
 70 
     | 
    
         
            +
                        end
         
     | 
| 
       52 
71 
     | 
    
         | 
| 
       53 
72 
     | 
    
         
             
                        add_offense(heredoc_node.loc.heredoc_end) do |corrector|
         
     | 
| 
       54 
73 
     | 
    
         
             
                          autocorrect(corrector, heredoc_node)
         
     | 
| 
       55 
74 
     | 
    
         
             
                        end
         
     | 
| 
       56 
75 
     | 
    
         
             
                      else
         
     | 
| 
       57 
     | 
    
         
            -
                        return if  
     | 
| 
      
 76 
     | 
    
         
            +
                        return if next_line_empty_or_allowed_directive_comment?(node.last_line)
         
     | 
| 
       58 
77 
     | 
    
         | 
| 
       59 
78 
     | 
    
         
             
                        add_offense(offense_location(node)) { |corrector| autocorrect(corrector, node) }
         
     | 
| 
       60 
79 
     | 
    
         
             
                      end
         
     | 
| 
         @@ -70,7 +89,7 @@ module RuboCop 
     | 
|
| 
       70 
89 
     | 
    
         
             
                                   end
         
     | 
| 
       71 
90 
     | 
    
         | 
| 
       72 
91 
     | 
    
         
             
                      next_line = node_range.last_line + 1
         
     | 
| 
       73 
     | 
    
         
            -
                      if  
     | 
| 
      
 92 
     | 
    
         
            +
                      if next_line_allowed_directive_comment?(next_line)
         
     | 
| 
       74 
93 
     | 
    
         
             
                        node_range = processed_source.comment_at_line(next_line)
         
     | 
| 
       75 
94 
     | 
    
         
             
                      end
         
     | 
| 
       76 
95 
     | 
    
         | 
| 
         @@ -88,21 +107,21 @@ module RuboCop 
     | 
|
| 
       88 
107 
     | 
    
         
             
                      node.if_branch&.guard_clause?
         
     | 
| 
       89 
108 
     | 
    
         
             
                    end
         
     | 
| 
       90 
109 
     | 
    
         | 
| 
       91 
     | 
    
         
            -
                    def  
     | 
| 
      
 110 
     | 
    
         
            +
                    def next_line_empty_or_allowed_directive_comment?(line)
         
     | 
| 
       92 
111 
     | 
    
         
             
                      return true if next_line_empty?(line)
         
     | 
| 
       93 
112 
     | 
    
         | 
| 
       94 
113 
     | 
    
         
             
                      next_line = line + 1
         
     | 
| 
       95 
     | 
    
         
            -
                       
     | 
| 
      
 114 
     | 
    
         
            +
                      next_line_allowed_directive_comment?(next_line) && next_line_empty?(next_line)
         
     | 
| 
       96 
115 
     | 
    
         
             
                    end
         
     | 
| 
       97 
116 
     | 
    
         | 
| 
       98 
117 
     | 
    
         
             
                    def next_line_empty?(line)
         
     | 
| 
       99 
118 
     | 
    
         
             
                      processed_source[line].blank?
         
     | 
| 
       100 
119 
     | 
    
         
             
                    end
         
     | 
| 
       101 
120 
     | 
    
         | 
| 
       102 
     | 
    
         
            -
                    def  
     | 
| 
      
 121 
     | 
    
         
            +
                    def next_line_allowed_directive_comment?(line)
         
     | 
| 
       103 
122 
     | 
    
         
             
                      return false unless (comment = processed_source.comment_at_line(line))
         
     | 
| 
       104 
123 
     | 
    
         | 
| 
       105 
     | 
    
         
            -
                      DirectiveComment.new(comment).enabled?
         
     | 
| 
      
 124 
     | 
    
         
            +
                      DirectiveComment.new(comment).enabled? || simplecov_directive_comment?(comment)
         
     | 
| 
       106 
125 
     | 
    
         
             
                    end
         
     | 
| 
       107 
126 
     | 
    
         | 
| 
       108 
127 
     | 
    
         
             
                    def next_line_rescue_or_ensure?(node)
         
     | 
| 
         @@ -116,7 +135,7 @@ module RuboCop 
     | 
|
| 
       116 
135 
     | 
    
         | 
| 
       117 
136 
     | 
    
         
             
                      parent = next_sibling.parent
         
     | 
| 
       118 
137 
     | 
    
         | 
| 
       119 
     | 
    
         
            -
                      parent&.if_type? && parent 
     | 
| 
      
 138 
     | 
    
         
            +
                      parent&.if_type? && parent.else?
         
     | 
| 
       120 
139 
     | 
    
         
             
                    end
         
     | 
| 
       121 
140 
     | 
    
         | 
| 
       122 
141 
     | 
    
         
             
                    def next_sibling_empty_or_guard_clause?(node)
         
     | 
| 
         @@ -137,7 +156,7 @@ module RuboCop 
     | 
|
| 
       137 
156 
     | 
    
         
             
                        return node if node
         
     | 
| 
       138 
157 
     | 
    
         
             
                      end
         
     | 
| 
       139 
158 
     | 
    
         | 
| 
       140 
     | 
    
         
            -
                       
     | 
| 
      
 159 
     | 
    
         
            +
                      last_heredoc_argument(n.receiver) if n.respond_to?(:receiver)
         
     | 
| 
       141 
160 
     | 
    
         
             
                    end
         
     | 
| 
       142 
161 
     | 
    
         | 
| 
       143 
162 
     | 
    
         
             
                    def last_heredoc_argument_node(node)
         
     | 
| 
         @@ -145,6 +164,8 @@ module RuboCop 
     | 
|
| 
       145 
164 
     | 
    
         | 
| 
       146 
165 
     | 
    
         
             
                      if node.if_branch.and_type?
         
     | 
| 
       147 
166 
     | 
    
         
             
                        node.if_branch.children.first
         
     | 
| 
      
 167 
     | 
    
         
            +
                      elsif use_heredoc_in_condition?(node.condition)
         
     | 
| 
      
 168 
     | 
    
         
            +
                        node.condition
         
     | 
| 
       148 
169 
     | 
    
         
             
                      else
         
     | 
| 
       149 
170 
     | 
    
         
             
                        node.if_branch.children.last
         
     | 
| 
       150 
171 
     | 
    
         
             
                      end
         
     | 
| 
         @@ -161,6 +182,12 @@ module RuboCop 
     | 
|
| 
       161 
182 
     | 
    
         
             
                      node.respond_to?(:heredoc?) && node.heredoc?
         
     | 
| 
       162 
183 
     | 
    
         
             
                    end
         
     | 
| 
       163 
184 
     | 
    
         | 
| 
      
 185 
     | 
    
         
            +
                    def use_heredoc_in_condition?(condition)
         
     | 
| 
      
 186 
     | 
    
         
            +
                      condition.descendants.any? do |descendant|
         
     | 
| 
      
 187 
     | 
    
         
            +
                        descendant.respond_to?(:heredoc?) && descendant.heredoc?
         
     | 
| 
      
 188 
     | 
    
         
            +
                      end
         
     | 
| 
      
 189 
     | 
    
         
            +
                    end
         
     | 
| 
      
 190 
     | 
    
         
            +
             
     | 
| 
       164 
191 
     | 
    
         
             
                    def offense_location(node)
         
     | 
| 
       165 
192 
     | 
    
         
             
                      if node.loc.respond_to?(:end) && node.loc.end
         
     | 
| 
       166 
193 
     | 
    
         
             
                        node.loc.end
         
     | 
| 
         @@ -175,6 +202,12 @@ module RuboCop 
     | 
|
| 
       175 
202 
     | 
    
         | 
| 
       176 
203 
     | 
    
         
             
                      parent.begin_type? && parent.single_line?
         
     | 
| 
       177 
204 
     | 
    
         
             
                    end
         
     | 
| 
      
 205 
     | 
    
         
            +
             
     | 
| 
      
 206 
     | 
    
         
            +
                    # SimpleCov excludes code from the coverage report by wrapping it in `# :nocov:`:
         
     | 
| 
      
 207 
     | 
    
         
            +
                    # https://github.com/simplecov-ruby/simplecov#ignoringskipping-code
         
     | 
| 
      
 208 
     | 
    
         
            +
                    def simplecov_directive_comment?(comment)
         
     | 
| 
      
 209 
     | 
    
         
            +
                      SIMPLE_DIRECTIVE_COMMENT_PATTERN.match?(comment.text)
         
     | 
| 
      
 210 
     | 
    
         
            +
                    end
         
     | 
| 
       178 
211 
     | 
    
         
             
                  end
         
     | 
| 
       179 
212 
     | 
    
         
             
                end
         
     | 
| 
       180 
213 
     | 
    
         
             
              end
         
     | 
| 
         @@ -27,9 +27,9 @@ module RuboCop 
     | 
|
| 
       27 
27 
     | 
    
         
             
                    MSG = 'Add an empty line after magic comments.'
         
     | 
| 
       28 
28 
     | 
    
         | 
| 
       29 
29 
     | 
    
         
             
                    def on_new_investigation
         
     | 
| 
       30 
     | 
    
         
            -
                      return unless processed_source 
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
                      return if  
     | 
| 
      
 30 
     | 
    
         
            +
                      return unless (last_magic_comment = last_magic_comment(processed_source))
         
     | 
| 
      
 31 
     | 
    
         
            +
                      return unless (next_line = processed_source[last_magic_comment.loc.line])
         
     | 
| 
      
 32 
     | 
    
         
            +
                      return if next_line.strip.empty?
         
     | 
| 
       33 
33 
     | 
    
         | 
| 
       34 
34 
     | 
    
         
             
                      offending_range = offending_range(last_magic_comment)
         
     | 
| 
       35 
35 
     | 
    
         | 
| 
         @@ -46,18 +46,25 @@ module RuboCop 
     | 
|
| 
       46 
46 
     | 
    
         | 
| 
       47 
47 
     | 
    
         
             
                    # Find the last magic comment in the source file.
         
     | 
| 
       48 
48 
     | 
    
         
             
                    #
         
     | 
| 
       49 
     | 
    
         
            -
                    # Take all comments that precede the first line of code 
     | 
| 
      
 49 
     | 
    
         
            +
                    # Take all comments that precede the first line of code (or just take
         
     | 
| 
      
 50 
     | 
    
         
            +
                    # them all in the case when there is no code), select the
         
     | 
| 
       50 
51 
     | 
    
         
             
                    # magic comments, and return the last magic comment in the file.
         
     | 
| 
       51 
52 
     | 
    
         
             
                    #
         
     | 
| 
       52 
53 
     | 
    
         
             
                    # @return [Parser::Source::Comment] if magic comments exist before code
         
     | 
| 
       53 
54 
     | 
    
         
             
                    # @return [nil] otherwise
         
     | 
| 
       54 
55 
     | 
    
         
             
                    def last_magic_comment(source)
         
     | 
| 
       55 
     | 
    
         
            -
                      source
         
     | 
| 
       56 
     | 
    
         
            -
                        .comments
         
     | 
| 
       57 
     | 
    
         
            -
                        .take_while { |comment| comment.loc.line < source.ast.loc.line }
         
     | 
| 
      
 56 
     | 
    
         
            +
                      comments_before_code(source)
         
     | 
| 
       58 
57 
     | 
    
         
             
                        .reverse
         
     | 
| 
       59 
58 
     | 
    
         
             
                        .find { |comment| MagicComment.parse(comment.text).any? }
         
     | 
| 
       60 
59 
     | 
    
         
             
                    end
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
                    def comments_before_code(source)
         
     | 
| 
      
 62 
     | 
    
         
            +
                      if source.ast
         
     | 
| 
      
 63 
     | 
    
         
            +
                        source.comments.take_while { |comment| comment.loc.line < source.ast.loc.line }
         
     | 
| 
      
 64 
     | 
    
         
            +
                      else
         
     | 
| 
      
 65 
     | 
    
         
            +
                        source.comments
         
     | 
| 
      
 66 
     | 
    
         
            +
                      end
         
     | 
| 
      
 67 
     | 
    
         
            +
                    end
         
     | 
| 
       61 
68 
     | 
    
         
             
                  end
         
     | 
| 
       62 
69 
     | 
    
         
             
                end
         
     | 
| 
       63 
70 
     | 
    
         
             
              end
         
     | 
| 
         @@ -135,7 +135,8 @@ module RuboCop 
     | 
|
| 
       135 
135 
     | 
    
         
             
                      return if nodes.all?(&:single_line?) && cop_config['AllowAdjacentOneLineDefs']
         
     | 
| 
       136 
136 
     | 
    
         | 
| 
       137 
137 
     | 
    
         
             
                      correction_node = nodes.last
         
     | 
| 
       138 
     | 
    
         
            -
             
     | 
| 
      
 138 
     | 
    
         
            +
             
     | 
| 
      
 139 
     | 
    
         
            +
                      location = def_location(correction_node)
         
     | 
| 
       139 
140 
     | 
    
         
             
                      add_offense(location, message: message(correction_node, count: count)) do |corrector|
         
     | 
| 
       140 
141 
     | 
    
         
             
                        autocorrect(corrector, *nodes, count)
         
     | 
| 
       141 
142 
     | 
    
         
             
                      end
         
     | 
| 
         @@ -148,7 +149,8 @@ module RuboCop 
     | 
|
| 
       148 
149 
     | 
    
         
             
                      newline_pos = source_buffer.source.index("\n", end_pos)
         
     | 
| 
       149 
150 
     | 
    
         | 
| 
       150 
151 
     | 
    
         
             
                      # Handle the case when multiple one-liners are on the same line.
         
     | 
| 
       151 
     | 
    
         
            -
                       
     | 
| 
      
 152 
     | 
    
         
            +
                      begin_pos = node.source_range.begin_pos
         
     | 
| 
      
 153 
     | 
    
         
            +
                      newline_pos = begin_pos - 1 if newline_pos > begin_pos
         
     | 
| 
       152 
154 
     | 
    
         | 
| 
       153 
155 
     | 
    
         
             
                      if count > maximum_empty_lines
         
     | 
| 
       154 
156 
     | 
    
         
             
                        autocorrect_remove_lines(corrector, newline_pos, count)
         
     | 
| 
         @@ -159,10 +161,28 @@ module RuboCop 
     | 
|
| 
       159 
161 
     | 
    
         | 
| 
       160 
162 
     | 
    
         
             
                    private
         
     | 
| 
       161 
163 
     | 
    
         | 
| 
      
 164 
     | 
    
         
            +
                    def def_location(correction_node)
         
     | 
| 
      
 165 
     | 
    
         
            +
                      if correction_node.block_type?
         
     | 
| 
      
 166 
     | 
    
         
            +
                        correction_node.source_range.join(correction_node.children.first.source_range)
         
     | 
| 
      
 167 
     | 
    
         
            +
                      else
         
     | 
| 
      
 168 
     | 
    
         
            +
                        correction_node.loc.keyword.join(correction_node.loc.name)
         
     | 
| 
      
 169 
     | 
    
         
            +
                      end
         
     | 
| 
      
 170 
     | 
    
         
            +
                    end
         
     | 
| 
      
 171 
     | 
    
         
            +
             
     | 
| 
       162 
172 
     | 
    
         
             
                    def candidate?(node)
         
     | 
| 
       163 
     | 
    
         
            -
                      return unless node
         
     | 
| 
      
 173 
     | 
    
         
            +
                      return false unless node
         
     | 
| 
       164 
174 
     | 
    
         | 
| 
       165 
     | 
    
         
            -
                      method_candidate?(node) || class_candidate?(node) || module_candidate?(node)
         
     | 
| 
      
 175 
     | 
    
         
            +
                      method_candidate?(node) || class_candidate?(node) || module_candidate?(node) ||
         
     | 
| 
      
 176 
     | 
    
         
            +
                        macro_candidate?(node)
         
     | 
| 
      
 177 
     | 
    
         
            +
                    end
         
     | 
| 
      
 178 
     | 
    
         
            +
             
     | 
| 
      
 179 
     | 
    
         
            +
                    def empty_line_between_macros
         
     | 
| 
      
 180 
     | 
    
         
            +
                      cop_config.fetch('DefLikeMacros', []).map(&:to_sym)
         
     | 
| 
      
 181 
     | 
    
         
            +
                    end
         
     | 
| 
      
 182 
     | 
    
         
            +
             
     | 
| 
      
 183 
     | 
    
         
            +
                    def macro_candidate?(node)
         
     | 
| 
      
 184 
     | 
    
         
            +
                      node.block_type? && node.children.first.macro? &&
         
     | 
| 
      
 185 
     | 
    
         
            +
                        empty_line_between_macros.include?(node.children.first.method_name)
         
     | 
| 
       166 
186 
     | 
    
         
             
                    end
         
     | 
| 
       167 
187 
     | 
    
         | 
| 
       168 
188 
     | 
    
         
             
                    def method_candidate?(node)
         
     | 
| 
         @@ -226,7 +246,11 @@ module RuboCop 
     | 
|
| 
       226 
246 
     | 
    
         
             
                    end
         
     | 
| 
       227 
247 
     | 
    
         | 
| 
       228 
248 
     | 
    
         
             
                    def def_start(node)
         
     | 
| 
       229 
     | 
    
         
            -
                      node. 
     | 
| 
      
 249 
     | 
    
         
            +
                      if node.block_type? && node.children.first.send_type?
         
     | 
| 
      
 250 
     | 
    
         
            +
                        node.source_range.line
         
     | 
| 
      
 251 
     | 
    
         
            +
                      else
         
     | 
| 
      
 252 
     | 
    
         
            +
                        node.loc.keyword.line
         
     | 
| 
      
 253 
     | 
    
         
            +
                      end
         
     | 
| 
       230 
254 
     | 
    
         
             
                    end
         
     | 
| 
       231 
255 
     | 
    
         | 
| 
       232 
256 
     | 
    
         
             
                    def def_end(node)
         
     | 
| 
         @@ -68,6 +68,8 @@ module RuboCop 
     | 
|
| 
       68 
68 
     | 
    
         
             
                      check_body(node.body, node.loc.line)
         
     | 
| 
       69 
69 
     | 
    
         
             
                    end
         
     | 
| 
       70 
70 
     | 
    
         
             
                    alias on_defs on_def
         
     | 
| 
      
 71 
     | 
    
         
            +
                    alias on_block on_def
         
     | 
| 
      
 72 
     | 
    
         
            +
                    alias on_numblock on_def
         
     | 
| 
       71 
73 
     | 
    
         | 
| 
       72 
74 
     | 
    
         
             
                    def on_kwbegin(node)
         
     | 
| 
       73 
75 
     | 
    
         
             
                      body, = *node
         
     | 
| 
         @@ -81,7 +83,7 @@ module RuboCop 
     | 
|
| 
       81 
83 
     | 
    
         | 
| 
       82 
84 
     | 
    
         
             
                      locations.each do |loc|
         
     | 
| 
       83 
85 
     | 
    
         
             
                        line = loc.line
         
     | 
| 
       84 
     | 
    
         
            -
                        next if line == line_of_def_or_kwbegin ||  
     | 
| 
      
 86 
     | 
    
         
            +
                        next if line == line_of_def_or_kwbegin || last_body_and_end_on_same_line?(body)
         
     | 
| 
       85 
87 
     | 
    
         | 
| 
       86 
88 
     | 
    
         
             
                        keyword = loc.source
         
     | 
| 
       87 
89 
     | 
    
         
             
                        # below the keyword
         
     | 
| 
         @@ -91,8 +93,13 @@ module RuboCop 
     | 
|
| 
       91 
93 
     | 
    
         
             
                      end
         
     | 
| 
       92 
94 
     | 
    
         
             
                    end
         
     | 
| 
       93 
95 
     | 
    
         | 
| 
       94 
     | 
    
         
            -
                    def  
     | 
| 
       95 
     | 
    
         
            -
                       
     | 
| 
      
 96 
     | 
    
         
            +
                    def last_body_and_end_on_same_line?(body)
         
     | 
| 
      
 97 
     | 
    
         
            +
                      end_keyword_line = body.parent.loc.end.line
         
     | 
| 
      
 98 
     | 
    
         
            +
                      return body.loc.last_line == end_keyword_line unless body.rescue_type?
         
     | 
| 
      
 99 
     | 
    
         
            +
             
     | 
| 
      
 100 
     | 
    
         
            +
                      last_body_line = body.else? ? body.loc.else.line : body.resbody_branches.last.loc.line
         
     | 
| 
      
 101 
     | 
    
         
            +
             
     | 
| 
      
 102 
     | 
    
         
            +
                      last_body_line == end_keyword_line
         
     | 
| 
       96 
103 
     | 
    
         
             
                    end
         
     | 
| 
       97 
104 
     | 
    
         | 
| 
       98 
105 
     | 
    
         
             
                    def message(location, keyword)
         
     | 
| 
         @@ -20,7 +20,9 @@ module RuboCop 
     | 
|
| 
       20 
20 
     | 
    
         
             
                  # This `Layout/EndAlignment` cop aligns with keywords (e.g. `if`, `while`, `case`)
         
     | 
| 
       21 
21 
     | 
    
         
             
                  # by default. On the other hand, `Layout/BeginEndAlignment` cop aligns with
         
     | 
| 
       22 
22 
     | 
    
         
             
                  # `EnforcedStyleAlignWith: start_of_line` by default due to `||= begin` tends
         
     | 
| 
       23 
     | 
    
         
            -
                  # to align with the start of the line.  
     | 
| 
      
 23 
     | 
    
         
            +
                  # to align with the start of the line. `Layout/DefEndAlignment` cop also aligns with
         
     | 
| 
      
 24 
     | 
    
         
            +
                  # `EnforcedStyleAlignWith: start_of_line` by default.
         
     | 
| 
      
 25 
     | 
    
         
            +
                  # These style can be configured by each cop.
         
     | 
| 
       24 
26 
     | 
    
         
             
                  #
         
     | 
| 
       25 
27 
     | 
    
         
             
                  # @example EnforcedStyleAlignWith: keyword (default)
         
     | 
| 
       26 
28 
     | 
    
         
             
                  #   # bad
         
     | 
| 
         @@ -83,7 +85,11 @@ module RuboCop 
     | 
|
| 
       83 
85 
     | 
    
         
             
                    end
         
     | 
| 
       84 
86 
     | 
    
         | 
| 
       85 
87 
     | 
    
         
             
                    def on_sclass(node)
         
     | 
| 
       86 
     | 
    
         
            -
                       
     | 
| 
      
 88 
     | 
    
         
            +
                      if node.parent&.assignment?
         
     | 
| 
      
 89 
     | 
    
         
            +
                        check_asgn_alignment(node.parent, node)
         
     | 
| 
      
 90 
     | 
    
         
            +
                      else
         
     | 
| 
      
 91 
     | 
    
         
            +
                        check_other_alignment(node)
         
     | 
| 
      
 92 
     | 
    
         
            +
                      end
         
     | 
| 
       87 
93 
     | 
    
         
             
                    end
         
     | 
| 
       88 
94 
     | 
    
         | 
| 
       89 
95 
     | 
    
         
             
                    def on_module(node)
         
     | 
| 
         @@ -163,7 +169,13 @@ module RuboCop 
     | 
|
| 
       163 
169 
     | 
    
         
             
                      when :keyword
         
     | 
| 
       164 
170 
     | 
    
         
             
                        node
         
     | 
| 
       165 
171 
     | 
    
         
             
                      when :variable
         
     | 
| 
       166 
     | 
    
         
            -
                        alignment_node_for_variable_style(node)
         
     | 
| 
      
 172 
     | 
    
         
            +
                        align_to = alignment_node_for_variable_style(node)
         
     | 
| 
      
 173 
     | 
    
         
            +
             
     | 
| 
      
 174 
     | 
    
         
            +
                        while (parent = align_to.parent) && parent.send_type? && same_line?(align_to, parent)
         
     | 
| 
      
 175 
     | 
    
         
            +
                          align_to = parent
         
     | 
| 
      
 176 
     | 
    
         
            +
                        end
         
     | 
| 
      
 177 
     | 
    
         
            +
             
     | 
| 
      
 178 
     | 
    
         
            +
                        align_to
         
     | 
| 
       167 
179 
     | 
    
         
             
                      else
         
     | 
| 
       168 
180 
     | 
    
         
             
                        start_line_range(node)
         
     | 
| 
       169 
181 
     | 
    
         
             
                      end
         
     | 
| 
         @@ -49,19 +49,13 @@ module RuboCop 
     | 
|
| 
       49 
49 
     | 
    
         | 
| 
       50 
50 
     | 
    
         
             
                    private
         
     | 
| 
       51 
51 
     | 
    
         | 
| 
       52 
     | 
    
         
            -
                    def aligned_locations(locs) 
     | 
| 
      
 52 
     | 
    
         
            +
                    def aligned_locations(locs)
         
     | 
| 
       53 
53 
     | 
    
         
             
                      return [] if locs.empty?
         
     | 
| 
       54 
54 
     | 
    
         | 
| 
       55 
     | 
    
         
            -
                      aligned = Set 
     | 
| 
       56 
     | 
    
         
            -
                      locs.each_cons( 
     | 
| 
       57 
     | 
    
         
            -
                         
     | 
| 
       58 
     | 
    
         
            -
                        aligned << loc.line if col == before.column || col == after.column
         
     | 
| 
      
 55 
     | 
    
         
            +
                      aligned = Set.new
         
     | 
| 
      
 56 
     | 
    
         
            +
                      locs.each_cons(2) do |loc1, loc2|
         
     | 
| 
      
 57 
     | 
    
         
            +
                        aligned << loc1.line << loc2.line if loc1.column == loc2.column
         
     | 
| 
       59 
58 
     | 
    
         
             
                      end
         
     | 
| 
       60 
     | 
    
         
            -
             
     | 
| 
       61 
     | 
    
         
            -
                      # if locs.size > 2 and the size of variable `aligned`
         
     | 
| 
       62 
     | 
    
         
            -
                      # has not increased from its initial value, there are not aligned lines.
         
     | 
| 
       63 
     | 
    
         
            -
                      return [] if locs.size > 2 && aligned.size == 2
         
     | 
| 
       64 
     | 
    
         
            -
             
     | 
| 
       65 
59 
     | 
    
         
             
                      aligned
         
     | 
| 
       66 
60 
     | 
    
         
             
                    end
         
     | 
| 
       67 
61 
     | 
    
         | 
| 
         @@ -118,8 +118,8 @@ module RuboCop 
     | 
|
| 
       118 
118 
     | 
    
         
             
                  #
         
     | 
| 
       119 
119 
     | 
    
         
             
                  # @example EnforcedStyle: special_for_inner_method_call
         
     | 
| 
       120 
120 
     | 
    
         
             
                  #   # The first argument should normally be indented one step more than
         
     | 
| 
       121 
     | 
    
         
            -
                  #   # the preceding line, but if it's  
     | 
| 
       122 
     | 
    
         
            -
                  #   # is itself  
     | 
| 
      
 121 
     | 
    
         
            +
                  #   # the preceding line, but if it's an argument for a method call that
         
     | 
| 
      
 122 
     | 
    
         
            +
                  #   # is itself an argument in a method call, then the inner argument
         
     | 
| 
       123 
123 
     | 
    
         
             
                  #   # should be indented relative to the inner method.
         
     | 
| 
       124 
124 
     | 
    
         
             
                  #
         
     | 
| 
       125 
125 
     | 
    
         
             
                  #   # good
         
     | 
| 
         @@ -5,7 +5,10 @@ module RuboCop 
     | 
|
| 
       5 
5 
     | 
    
         
             
                module Layout
         
     | 
| 
       6 
6 
     | 
    
         
             
                  # Checks the indentation of the first element in an array literal
         
     | 
| 
       7 
7 
     | 
    
         
             
                  # where the opening bracket and the first element are on separate lines.
         
     | 
| 
       8 
     | 
    
         
            -
                  # The other elements' indentations are handled by  
     | 
| 
      
 8 
     | 
    
         
            +
                  # The other elements' indentations are handled by `Layout/ArrayAlignment` cop.
         
     | 
| 
      
 9 
     | 
    
         
            +
                  #
         
     | 
| 
      
 10 
     | 
    
         
            +
                  # This cop will respect `Layout/ArrayAlignment` and will not work when
         
     | 
| 
      
 11 
     | 
    
         
            +
                  # `EnforcedStyle: with_fixed_indentation` is specified for `Layout/ArrayAlignment`.
         
     | 
| 
       9 
12 
     | 
    
         
             
                  #
         
     | 
| 
       10 
13 
     | 
    
         
             
                  # By default, array literals that are arguments in a method call with
         
     | 
| 
       11 
14 
     | 
    
         
             
                  # parentheses, and where the opening square bracket of the array is on the
         
     | 
| 
         @@ -25,7 +28,7 @@ module RuboCop 
     | 
|
| 
       25 
28 
     | 
    
         
             
                  #   # element are on separate lines is indented one step (two spaces) more
         
     | 
| 
       26 
29 
     | 
    
         
             
                  #   # than the position inside the opening parenthesis.
         
     | 
| 
       27 
30 
     | 
    
         
             
                  #
         
     | 
| 
       28 
     | 
    
         
            -
                  #   #bad
         
     | 
| 
      
 31 
     | 
    
         
            +
                  #   # bad
         
     | 
| 
       29 
32 
     | 
    
         
             
                  #   array = [
         
     | 
| 
       30 
33 
     | 
    
         
             
                  #     :value
         
     | 
| 
       31 
34 
     | 
    
         
             
                  #   ]
         
     | 
| 
         @@ -33,7 +36,7 @@ module RuboCop 
     | 
|
| 
       33 
36 
     | 
    
         
             
                  #     :no_difference
         
     | 
| 
       34 
37 
     | 
    
         
             
                  #                        ])
         
     | 
| 
       35 
38 
     | 
    
         
             
                  #
         
     | 
| 
       36 
     | 
    
         
            -
                  #   #good
         
     | 
| 
      
 39 
     | 
    
         
            +
                  #   # good
         
     | 
| 
       37 
40 
     | 
    
         
             
                  #   array = [
         
     | 
| 
       38 
41 
     | 
    
         
             
                  #     :value
         
     | 
| 
       39 
42 
     | 
    
         
             
                  #   ]
         
     | 
| 
         @@ -47,8 +50,7 @@ module RuboCop 
     | 
|
| 
       47 
50 
     | 
    
         
             
                  #   # separate lines is indented the same as an array literal which is not
         
     | 
| 
       48 
51 
     | 
    
         
             
                  #   # defined inside a method call.
         
     | 
| 
       49 
52 
     | 
    
         
             
                  #
         
     | 
| 
       50 
     | 
    
         
            -
                  #   #bad
         
     | 
| 
       51 
     | 
    
         
            -
                  #   # consistent
         
     | 
| 
      
 53 
     | 
    
         
            +
                  #   # bad
         
     | 
| 
       52 
54 
     | 
    
         
             
                  #   array = [
         
     | 
| 
       53 
55 
     | 
    
         
             
                  #     :value
         
     | 
| 
       54 
56 
     | 
    
         
             
                  #   ]
         
     | 
| 
         @@ -56,7 +58,7 @@ module RuboCop 
     | 
|
| 
       56 
58 
     | 
    
         
             
                  #                          :its_like_this
         
     | 
| 
       57 
59 
     | 
    
         
             
                  #   ])
         
     | 
| 
       58 
60 
     | 
    
         
             
                  #
         
     | 
| 
       59 
     | 
    
         
            -
                  #   #good
         
     | 
| 
      
 61 
     | 
    
         
            +
                  #   # good
         
     | 
| 
       60 
62 
     | 
    
         
             
                  #   array = [
         
     | 
| 
       61 
63 
     | 
    
         
             
                  #     :value
         
     | 
| 
       62 
64 
     | 
    
         
             
                  #   ]
         
     | 
| 
         @@ -68,14 +70,12 @@ module RuboCop 
     | 
|
| 
       68 
70 
     | 
    
         
             
                  #   # The `align_brackets` style enforces that the opening and closing
         
     | 
| 
       69 
71 
     | 
    
         
             
                  #   # brackets are indented to the same position.
         
     | 
| 
       70 
72 
     | 
    
         
             
                  #
         
     | 
| 
       71 
     | 
    
         
            -
                  #   #bad
         
     | 
| 
       72 
     | 
    
         
            -
                  #   # align_brackets
         
     | 
| 
      
 73 
     | 
    
         
            +
                  #   # bad
         
     | 
| 
       73 
74 
     | 
    
         
             
                  #   and_now_for_something = [
         
     | 
| 
       74 
75 
     | 
    
         
             
                  #                             :completely_different
         
     | 
| 
       75 
76 
     | 
    
         
             
                  #   ]
         
     | 
| 
       76 
77 
     | 
    
         
             
                  #
         
     | 
| 
       77 
     | 
    
         
            -
                  #   #good
         
     | 
| 
       78 
     | 
    
         
            -
                  #   # align_brackets
         
     | 
| 
      
 78 
     | 
    
         
            +
                  #   # good
         
     | 
| 
       79 
79 
     | 
    
         
             
                  #   and_now_for_something = [
         
     | 
| 
       80 
80 
     | 
    
         
             
                  #                             :completely_different
         
     | 
| 
       81 
81 
     | 
    
         
             
                  #                           ]
         
     | 
| 
         @@ -89,10 +89,14 @@ module RuboCop 
     | 
|
| 
       89 
89 
     | 
    
         
             
                          'in an array, relative to %<base_description>s.'
         
     | 
| 
       90 
90 
     | 
    
         | 
| 
       91 
91 
     | 
    
         
             
                    def on_array(node)
         
     | 
| 
      
 92 
     | 
    
         
            +
                      return if style != :consistent && enforce_first_argument_with_fixed_indentation?
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
       92 
94 
     | 
    
         
             
                      check(node, nil) if node.loc.begin
         
     | 
| 
       93 
95 
     | 
    
         
             
                    end
         
     | 
| 
       94 
96 
     | 
    
         | 
| 
       95 
97 
     | 
    
         
             
                    def on_send(node)
         
     | 
| 
      
 98 
     | 
    
         
            +
                      return if style != :consistent && enforce_first_argument_with_fixed_indentation?
         
     | 
| 
      
 99 
     | 
    
         
            +
             
     | 
| 
       96 
100 
     | 
    
         
             
                      each_argument_node(node, :array) do |array_node, left_parenthesis|
         
     | 
| 
       97 
101 
     | 
    
         
             
                        check(array_node, left_parenthesis)
         
     | 
| 
       98 
102 
     | 
    
         
             
                      end
         
     | 
| 
         @@ -174,6 +178,16 @@ module RuboCop 
     | 
|
| 
       174 
178 
     | 
    
         
             
                        'where the left bracket is.'
         
     | 
| 
       175 
179 
     | 
    
         
             
                      end
         
     | 
| 
       176 
180 
     | 
    
         
             
                    end
         
     | 
| 
      
 181 
     | 
    
         
            +
             
     | 
| 
      
 182 
     | 
    
         
            +
                    def enforce_first_argument_with_fixed_indentation?
         
     | 
| 
      
 183 
     | 
    
         
            +
                      return false unless array_alignment_config['Enabled']
         
     | 
| 
      
 184 
     | 
    
         
            +
             
     | 
| 
      
 185 
     | 
    
         
            +
                      array_alignment_config['EnforcedStyle'] == 'with_fixed_indentation'
         
     | 
| 
      
 186 
     | 
    
         
            +
                    end
         
     | 
| 
      
 187 
     | 
    
         
            +
             
     | 
| 
      
 188 
     | 
    
         
            +
                    def array_alignment_config
         
     | 
| 
      
 189 
     | 
    
         
            +
                      config.for_cop('Layout/ArrayAlignment')
         
     | 
| 
      
 190 
     | 
    
         
            +
                    end
         
     | 
| 
       177 
191 
     | 
    
         
             
                  end
         
     | 
| 
       178 
192 
     | 
    
         
             
                end
         
     | 
| 
       179 
193 
     | 
    
         
             
              end
         
     | 
| 
         @@ -63,13 +63,21 @@ module RuboCop 
     | 
|
| 
       63 
63 
     | 
    
         
             
                  #     }
         
     | 
| 
       64 
64 
     | 
    
         
             
                  #   )
         
     | 
| 
       65 
65 
     | 
    
         
             
                  #
         
     | 
| 
      
 66 
     | 
    
         
            +
                  # @example AllowedMethods: ['some_method']
         
     | 
| 
      
 67 
     | 
    
         
            +
                  #
         
     | 
| 
      
 68 
     | 
    
         
            +
                  #   # good
         
     | 
| 
      
 69 
     | 
    
         
            +
                  #   some_method(foo, bar,
         
     | 
| 
      
 70 
     | 
    
         
            +
                  #     baz)
         
     | 
| 
       66 
71 
     | 
    
         
             
                  class FirstMethodArgumentLineBreak < Base
         
     | 
| 
       67 
72 
     | 
    
         
             
                    include FirstElementLineBreak
         
     | 
| 
      
 73 
     | 
    
         
            +
                    include AllowedMethods
         
     | 
| 
       68 
74 
     | 
    
         
             
                    extend AutoCorrector
         
     | 
| 
       69 
75 
     | 
    
         | 
| 
       70 
76 
     | 
    
         
             
                    MSG = 'Add a line break before the first argument of a multi-line method argument list.'
         
     | 
| 
       71 
77 
     | 
    
         | 
| 
       72 
78 
     | 
    
         
             
                    def on_send(node)
         
     | 
| 
      
 79 
     | 
    
         
            +
                      return if allowed_method?(node.method_name)
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
       73 
81 
     | 
    
         
             
                      args = node.arguments.dup
         
     | 
| 
       74 
82 
     | 
    
         | 
| 
       75 
83 
     | 
    
         
             
                      # If there is a trailing hash arg without explicit braces, like this:
         
     | 
| 
         @@ -72,7 +72,7 @@ module RuboCop 
     | 
|
| 
       72 
72 
     | 
    
         
             
                      return if ignored_node?(def_node)
         
     | 
| 
       73 
73 
     | 
    
         | 
| 
       74 
74 
     | 
    
         
             
                      left_parenthesis = def_node.arguments.loc.begin
         
     | 
| 
       75 
     | 
    
         
            -
                      first_elem = def_node. 
     | 
| 
      
 75 
     | 
    
         
            +
                      first_elem = def_node.first_argument
         
     | 
| 
       76 
76 
     | 
    
         
             
                      return unless first_elem
         
     | 
| 
       77 
77 
     | 
    
         
             
                      return if same_line?(first_elem, left_parenthesis)
         
     | 
| 
       78 
78 
     | 
    
         |