rubocop 0.49.1 → 0.50.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/README.md +5 -3
- data/bin/rubocop +1 -1
- data/config/default.yml +160 -99
- data/config/disabled.yml +4 -5
- data/config/enabled.yml +149 -47
- data/lib/rubocop.rb +41 -14
- data/lib/rubocop/ast/builder.rb +4 -1
- data/lib/rubocop/ast/node.rb +36 -42
- data/lib/rubocop/ast/node/args_node.rb +1 -13
- data/lib/rubocop/ast/node/array_node.rb +9 -0
- data/lib/rubocop/ast/node/block_node.rb +9 -0
- data/lib/rubocop/ast/node/def_node.rb +71 -0
- data/lib/rubocop/ast/node/for_node.rb +8 -0
- data/lib/rubocop/ast/node/if_node.rb +10 -2
- data/lib/rubocop/ast/node/mixin/collection_node.rb +15 -0
- data/lib/rubocop/ast/node/mixin/method_dispatch_node.rb +174 -0
- data/lib/rubocop/ast/node/mixin/method_identifier_predicates.rb +89 -0
- data/lib/rubocop/ast/node/mixin/parameterized_node.rb +18 -31
- data/lib/rubocop/ast/node/regexp_node.rb +35 -0
- data/lib/rubocop/ast/node/send_node.rb +1 -154
- data/lib/rubocop/ast/node/super_node.rb +3 -24
- data/lib/rubocop/ast/node/yield_node.rb +21 -0
- data/lib/rubocop/ast/traversal.rb +6 -6
- data/lib/rubocop/cli.rb +7 -3
- data/lib/rubocop/config.rb +45 -8
- data/lib/rubocop/config_loader.rb +7 -5
- data/lib/rubocop/cop/bundler/duplicated_gem.rb +3 -3
- data/lib/rubocop/cop/bundler/insecure_protocol_source.rb +64 -0
- data/lib/rubocop/cop/bundler/ordered_gems.rb +12 -12
- data/lib/rubocop/cop/commissioner.rb +8 -2
- data/lib/rubocop/cop/cop.rb +3 -1
- data/lib/rubocop/cop/generator.rb +94 -21
- data/lib/rubocop/cop/internal_affairs.rb +3 -0
- data/lib/rubocop/cop/internal_affairs/node_type_predicate.rb +14 -3
- data/lib/rubocop/cop/internal_affairs/offense_location_keyword.rb +43 -0
- data/lib/rubocop/cop/internal_affairs/redundant_location_argument.rb +46 -0
- data/lib/rubocop/cop/internal_affairs/redundant_message_argument.rb +49 -0
- data/lib/rubocop/cop/internal_affairs/useless_message_assertion.rb +1 -1
- data/lib/rubocop/cop/layout/access_modifier_indentation.rb +2 -3
- data/lib/rubocop/cop/layout/align_array.rb +2 -2
- data/lib/rubocop/cop/layout/align_hash.rb +2 -2
- data/lib/rubocop/cop/layout/align_parameters.rb +5 -11
- data/lib/rubocop/cop/layout/closing_parenthesis_indentation.rb +5 -5
- data/lib/rubocop/cop/layout/comment_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/dot_position.rb +9 -0
- data/lib/rubocop/cop/layout/else_alignment.rb +30 -13
- data/lib/rubocop/cop/layout/empty_line_between_defs.rb +4 -0
- data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +20 -4
- data/lib/rubocop/cop/layout/empty_lines_around_exception_handling_keywords.rb +3 -3
- data/lib/rubocop/cop/layout/empty_lines_around_method_body.rb +3 -3
- data/lib/rubocop/cop/layout/first_method_parameter_line_break.rb +3 -3
- data/lib/rubocop/cop/layout/first_parameter_indentation.rb +5 -2
- data/lib/rubocop/cop/layout/indent_heredoc.rb +19 -24
- data/lib/rubocop/cop/layout/indentation_consistency.rb +1 -2
- data/lib/rubocop/cop/layout/indentation_width.rb +12 -8
- data/lib/rubocop/cop/layout/leading_comment_space.rb +33 -18
- data/lib/rubocop/cop/layout/multiline_method_call_indentation.rb +20 -17
- data/lib/rubocop/cop/layout/multiline_method_definition_brace_layout.rb +3 -3
- data/lib/rubocop/cop/layout/multiline_operation_indentation.rb +6 -0
- data/lib/rubocop/cop/layout/space_after_colon.rb +7 -0
- data/lib/rubocop/cop/layout/space_after_comma.rb +10 -0
- data/lib/rubocop/cop/layout/space_after_method_name.rb +5 -3
- data/lib/rubocop/cop/layout/space_after_not.rb +1 -1
- data/lib/rubocop/cop/layout/space_around_block_parameters.rb +13 -4
- data/lib/rubocop/cop/layout/space_around_keyword.rb +9 -5
- data/lib/rubocop/cop/layout/space_before_block_braces.rb +54 -5
- data/lib/rubocop/cop/layout/space_before_comment.rb +7 -0
- data/lib/rubocop/cop/layout/space_before_semicolon.rb +7 -0
- data/lib/rubocop/cop/layout/space_inside_array_percent_literal.rb +1 -1
- data/lib/rubocop/cop/layout/space_inside_percent_literal_delimiters.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 +8 -4
- data/lib/rubocop/cop/layout/tab.rb +1 -1
- data/lib/rubocop/cop/lint/ambiguous_block_association.rb +4 -2
- data/lib/rubocop/cop/lint/assignment_in_condition.rb +15 -1
- data/lib/rubocop/cop/lint/block_alignment.rb +15 -6
- data/lib/rubocop/cop/lint/boolean_symbol.rb +38 -0
- data/lib/rubocop/cop/lint/condition_position.rb +5 -1
- data/lib/rubocop/cop/lint/debugger.rb +16 -9
- data/lib/rubocop/cop/lint/def_end_alignment.rb +4 -4
- data/lib/rubocop/cop/lint/duplicate_case_condition.rb +3 -3
- data/lib/rubocop/cop/lint/duplicate_methods.rb +73 -5
- data/lib/rubocop/cop/lint/duplicated_key.rb +1 -1
- data/lib/rubocop/cop/lint/each_with_object_argument.rb +1 -1
- data/lib/rubocop/cop/lint/else_layout.rb +1 -1
- data/lib/rubocop/cop/lint/empty_expression.rb +1 -1
- data/lib/rubocop/cop/lint/empty_interpolation.rb +1 -1
- data/lib/rubocop/cop/lint/empty_when.rb +1 -1
- data/lib/rubocop/cop/lint/ensure_return.rb +1 -1
- data/lib/rubocop/cop/lint/float_out_of_range.rb +5 -5
- data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +35 -40
- data/lib/rubocop/cop/lint/handle_exceptions.rb +1 -1
- data/lib/rubocop/cop/lint/ineffective_access_modifier.rb +18 -13
- data/lib/rubocop/cop/lint/inherit_exception.rb +8 -7
- data/lib/rubocop/cop/lint/interpolation_check.rb +36 -0
- data/lib/rubocop/cop/lint/literal_in_condition.rb +3 -3
- data/lib/rubocop/cop/lint/literal_in_interpolation.rb +1 -1
- data/lib/rubocop/cop/lint/multiple_compare.rb +1 -1
- data/lib/rubocop/cop/lint/nested_method_definition.rb +5 -7
- data/lib/rubocop/cop/lint/next_without_accumulator.rb +1 -1
- data/lib/rubocop/cop/lint/percent_string_array.rb +3 -12
- data/lib/rubocop/cop/lint/percent_symbol_array.rb +1 -1
- data/lib/rubocop/cop/lint/rand_one.rb +7 -1
- data/lib/rubocop/cop/lint/redundant_with_index.rb +77 -0
- data/lib/rubocop/cop/lint/require_parentheses.rb +1 -1
- data/lib/rubocop/cop/lint/rescue_exception.rb +1 -1
- data/lib/rubocop/cop/lint/rescue_type.rb +13 -6
- data/lib/rubocop/cop/lint/rescue_without_error_class.rb +38 -0
- data/lib/rubocop/cop/lint/return_in_void_context.rb +63 -0
- data/lib/rubocop/cop/lint/script_permission.rb +6 -0
- data/lib/rubocop/cop/lint/syntax.rb +17 -20
- data/lib/rubocop/cop/lint/unified_integer.rb +3 -2
- data/lib/rubocop/cop/lint/unneeded_disable.rb +1 -1
- data/lib/rubocop/cop/lint/unneeded_splat_expansion.rb +1 -1
- data/lib/rubocop/cop/lint/unreachable_code.rb +53 -8
- data/lib/rubocop/cop/lint/uri_escape_unescape.rb +74 -0
- data/lib/rubocop/cop/lint/uri_regexp.rb +73 -0
- data/lib/rubocop/cop/lint/useless_access_modifier.rb +4 -8
- data/lib/rubocop/cop/lint/useless_setter_call.rb +10 -11
- data/lib/rubocop/cop/lint/void.rb +29 -23
- data/lib/rubocop/cop/metrics/line_length.rb +2 -2
- data/lib/rubocop/cop/metrics/method_length.rb +8 -3
- data/lib/rubocop/cop/metrics/parameter_lists.rb +5 -2
- data/lib/rubocop/cop/mixin/autocorrect_alignment.rb +1 -1
- data/lib/rubocop/cop/mixin/enforce_superclass.rb +2 -2
- data/lib/rubocop/cop/mixin/first_element_line_break.rb +12 -3
- data/lib/rubocop/cop/mixin/heredoc.rb +28 -0
- data/lib/rubocop/cop/mixin/method_complexity.rb +9 -6
- data/lib/rubocop/cop/mixin/multiline_expression_indentation.rb +68 -31
- data/lib/rubocop/cop/mixin/multiline_literal_brace_layout.rb +18 -0
- data/lib/rubocop/cop/mixin/negative_conditional.rb +1 -1
- data/lib/rubocop/cop/mixin/percent_array.rb +52 -0
- data/lib/rubocop/cop/mixin/string_help.rb +1 -1
- data/lib/rubocop/cop/{style → naming}/accessor_method_name.rb +11 -12
- data/lib/rubocop/cop/{style → naming}/ascii_identifiers.rb +1 -1
- data/lib/rubocop/cop/{style/op_method.rb → naming/binary_operator_parameter_name.rb} +2 -2
- data/lib/rubocop/cop/{style → naming}/class_and_module_camel_case.rb +1 -1
- data/lib/rubocop/cop/{style → naming}/constant_name.rb +1 -1
- data/lib/rubocop/cop/{style → naming}/file_name.rb +8 -4
- data/lib/rubocop/cop/naming/heredoc_delimiter_case.rb +68 -0
- data/lib/rubocop/cop/naming/heredoc_delimiter_naming.rb +58 -0
- data/lib/rubocop/cop/{style → naming}/method_name.rb +1 -1
- data/lib/rubocop/cop/{style → naming}/predicate_name.rb +6 -7
- data/lib/rubocop/cop/{style → naming}/variable_name.rb +11 -15
- data/lib/rubocop/cop/{style → naming}/variable_number.rb +1 -1
- data/lib/rubocop/cop/performance/caller.rb +39 -11
- data/lib/rubocop/cop/performance/casecmp.rb +4 -4
- data/lib/rubocop/cop/performance/compare_with_block.rb +4 -4
- data/lib/rubocop/cop/performance/double_start_end_with.rb +4 -4
- data/lib/rubocop/cop/performance/end_with.rb +3 -3
- data/lib/rubocop/cop/performance/fixed_size.rb +1 -1
- data/lib/rubocop/cop/performance/hash_each_methods.rb +66 -25
- data/lib/rubocop/cop/performance/lstrip_rstrip.rb +2 -2
- data/lib/rubocop/cop/performance/range_include.rb +2 -2
- data/lib/rubocop/cop/performance/redundant_block_call.rb +6 -6
- data/lib/rubocop/cop/performance/redundant_match.rb +5 -5
- data/lib/rubocop/cop/performance/redundant_merge.rb +39 -23
- data/lib/rubocop/cop/performance/redundant_sort_by.rb +2 -2
- data/lib/rubocop/cop/performance/regexp_match.rb +13 -5
- data/lib/rubocop/cop/performance/size.rb +1 -1
- data/lib/rubocop/cop/performance/start_with.rb +3 -3
- data/lib/rubocop/cop/performance/times_map.rb +23 -12
- data/lib/rubocop/cop/performance/unfreeze_string.rb +50 -0
- data/lib/rubocop/cop/performance/uri_default_parser.rb +47 -0
- data/lib/rubocop/cop/rails/active_support_aliases.rb +1 -1
- data/lib/rubocop/cop/rails/delegate.rb +36 -7
- data/lib/rubocop/cop/rails/delegate_allow_blank.rb +1 -1
- data/lib/rubocop/cop/rails/enum_uniqueness.rb +2 -2
- data/lib/rubocop/cop/rails/file_path.rb +3 -4
- data/lib/rubocop/cop/rails/find_each.rb +1 -1
- data/lib/rubocop/cop/rails/has_many_or_has_one_dependent.rb +48 -0
- data/lib/rubocop/cop/rails/http_positional_arguments.rb +5 -5
- data/lib/rubocop/cop/rails/not_null_column.rb +1 -1
- data/lib/rubocop/cop/rails/pluralization_grammar.rb +2 -2
- data/lib/rubocop/cop/rails/relative_date_constant.rb +1 -1
- data/lib/rubocop/cop/rails/request_referer.rb +2 -2
- data/lib/rubocop/cop/rails/reversible_migration.rb +12 -12
- data/lib/rubocop/cop/rails/save_bang.rb +8 -6
- data/lib/rubocop/cop/rails/scope_args.rb +1 -1
- data/lib/rubocop/cop/security/eval.rb +2 -2
- data/lib/rubocop/cop/security/json_load.rb +2 -2
- data/lib/rubocop/cop/security/marshal_load.rb +2 -2
- data/lib/rubocop/cop/security/yaml_load.rb +2 -2
- data/lib/rubocop/cop/style/alias.rb +44 -20
- data/lib/rubocop/cop/style/and_or.rb +48 -34
- data/lib/rubocop/cop/style/auto_resource_cleanup.rb +1 -1
- data/lib/rubocop/cop/style/block_comments.rb +3 -1
- data/lib/rubocop/cop/style/block_delimiters.rb +2 -1
- data/lib/rubocop/cop/style/command_literal.rb +20 -9
- data/lib/rubocop/cop/style/conditional_assignment.rb +30 -28
- data/lib/rubocop/cop/style/copyright.rb +10 -10
- data/lib/rubocop/cop/style/def_with_parentheses.rb +6 -5
- data/lib/rubocop/cop/style/dir.rb +52 -0
- data/lib/rubocop/cop/style/documentation_method.rb +2 -6
- data/lib/rubocop/cop/style/empty_case_condition.rb +1 -1
- data/lib/rubocop/cop/style/empty_else.rb +3 -2
- data/lib/rubocop/cop/style/empty_literal.rb +1 -2
- data/lib/rubocop/cop/style/empty_method.rb +27 -17
- data/lib/rubocop/cop/style/flip_flop.rb +2 -2
- data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +1 -1
- data/lib/rubocop/cop/style/guard_clause.rb +4 -2
- data/lib/rubocop/cop/style/hash_syntax.rb +10 -10
- data/lib/rubocop/cop/style/identical_conditional_branches.rb +5 -1
- data/lib/rubocop/cop/style/if_with_semicolon.rb +1 -1
- data/lib/rubocop/cop/style/implicit_runtime_error.rb +4 -3
- data/lib/rubocop/cop/style/inline_comment.rb +1 -1
- data/lib/rubocop/cop/style/inverse_methods.rb +20 -8
- data/lib/rubocop/cop/style/lambda.rb +19 -9
- data/lib/rubocop/cop/style/lambda_call.rb +22 -1
- data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +4 -20
- data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +6 -4
- data/lib/rubocop/cop/style/method_def_parentheses.rb +18 -26
- data/lib/rubocop/cop/style/method_missing.rb +5 -18
- data/lib/rubocop/cop/style/min_max.rb +67 -0
- data/lib/rubocop/cop/style/missing_else.rb +16 -3
- data/lib/rubocop/cop/style/mixin_grouping.rb +2 -2
- data/lib/rubocop/cop/style/module_function.rb +8 -4
- data/lib/rubocop/cop/style/multiline_if_modifier.rb +5 -1
- data/lib/rubocop/cop/style/multiline_memoization.rb +25 -3
- data/lib/rubocop/cop/style/multiline_ternary_operator.rb +1 -1
- data/lib/rubocop/cop/style/multiple_comparison.rb +1 -1
- data/lib/rubocop/cop/style/mutable_constant.rb +2 -6
- data/lib/rubocop/cop/style/negated_if.rb +8 -4
- data/lib/rubocop/cop/style/nested_parenthesized_calls.rb +8 -8
- data/lib/rubocop/cop/style/nested_ternary_operator.rb +1 -1
- data/lib/rubocop/cop/style/non_nil_check.rb +14 -14
- data/lib/rubocop/cop/style/numeric_literal_prefix.rb +6 -2
- data/lib/rubocop/cop/style/numeric_literals.rb +2 -2
- data/lib/rubocop/cop/style/numeric_predicate.rb +8 -4
- data/lib/rubocop/cop/style/one_line_conditional.rb +8 -3
- data/lib/rubocop/cop/style/option_hash.rb +1 -1
- data/lib/rubocop/cop/style/optional_arguments.rb +1 -2
- data/lib/rubocop/cop/style/or_assignment.rb +88 -0
- data/lib/rubocop/cop/style/parallel_assignment.rb +2 -2
- data/lib/rubocop/cop/style/parentheses_around_condition.rb +12 -11
- data/lib/rubocop/cop/style/percent_literal_delimiters.rb +1 -1
- data/lib/rubocop/cop/style/percent_q_literals.rb +2 -2
- data/lib/rubocop/cop/style/perl_backrefs.rb +1 -1
- data/lib/rubocop/cop/style/proc.rb +1 -1
- data/lib/rubocop/cop/style/raise_args.rb +16 -17
- data/lib/rubocop/cop/style/redundant_begin.rb +6 -5
- data/lib/rubocop/cop/style/redundant_conditional.rb +95 -0
- data/lib/rubocop/cop/style/redundant_freeze.rb +1 -1
- data/lib/rubocop/cop/style/redundant_parentheses.rb +13 -11
- data/lib/rubocop/cop/style/redundant_return.rb +23 -11
- data/lib/rubocop/cop/style/redundant_self.rb +18 -9
- data/lib/rubocop/cop/style/regexp_literal.rb +12 -4
- data/lib/rubocop/cop/style/rescue_modifier.rb +1 -1
- data/lib/rubocop/cop/style/return_nil.rb +98 -0
- data/lib/rubocop/cop/style/safe_navigation.rb +80 -43
- data/lib/rubocop/cop/style/single_line_block_params.rb +14 -13
- data/lib/rubocop/cop/style/single_line_methods.rb +9 -13
- data/lib/rubocop/cop/style/special_global_vars.rb +3 -3
- data/lib/rubocop/cop/style/stabby_lambda_parentheses.rb +17 -39
- data/lib/rubocop/cop/style/string_literals_in_interpolation.rb +22 -1
- data/lib/rubocop/cop/style/struct_inheritance.rb +1 -1
- data/lib/rubocop/cop/style/symbol_array.rb +5 -25
- data/lib/rubocop/cop/style/symbol_literal.rb +1 -1
- data/lib/rubocop/cop/style/symbol_proc.rb +3 -18
- data/lib/rubocop/cop/style/ternary_parentheses.rb +14 -10
- data/lib/rubocop/cop/style/trailing_underscore_variable.rb +28 -9
- data/lib/rubocop/cop/style/trivial_accessors.rb +39 -56
- data/lib/rubocop/cop/style/unless_else.rb +1 -1
- data/lib/rubocop/cop/style/unneeded_capital_w.rb +1 -1
- data/lib/rubocop/cop/style/unneeded_interpolation.rb +1 -1
- data/lib/rubocop/cop/style/unneeded_percent_q.rb +1 -1
- data/lib/rubocop/cop/style/variable_interpolation.rb +8 -3
- data/lib/rubocop/cop/style/word_array.rb +7 -24
- data/lib/rubocop/cop/style/yoda_condition.rb +49 -14
- data/lib/rubocop/cop/style/zero_length_predicate.rb +25 -18
- data/lib/rubocop/cop/team.rb +16 -8
- data/lib/rubocop/cop/util.rb +11 -0
- data/lib/rubocop/formatter/disabled_config_formatter.rb +1 -1
- data/lib/rubocop/formatter/formatter_set.rb +2 -1
- data/lib/rubocop/formatter/offense_count_formatter.rb +2 -0
- data/lib/rubocop/formatter/simple_text_formatter.rb +1 -1
- data/lib/rubocop/formatter/tap_formatter.rb +71 -0
- data/lib/rubocop/formatter/worst_offenders_formatter.rb +2 -0
- data/lib/rubocop/node_pattern.rb +44 -26
- data/lib/rubocop/options.rb +1 -0
- data/lib/rubocop/processed_source.rb +3 -1
- data/lib/rubocop/remote_config.rb +5 -1
- data/lib/rubocop/result_cache.rb +1 -0
- data/lib/rubocop/rspec/cop_helper.rb +10 -10
- data/lib/rubocop/rspec/expect_offense.rb +6 -8
- data/lib/rubocop/rspec/shared_examples.rb +8 -8
- data/lib/rubocop/string_util.rb +2 -0
- data/lib/rubocop/version.rb +1 -1
- metadata +51 -18
- data/lib/rubocop/cop/mixin/access_modifier_node.rb +0 -41
- data/lib/rubocop/cop/mixin/on_method_def.rb +0 -44
| @@ -15,7 +15,6 @@ module RuboCop | |
| 15 15 | 
             
                  #   end
         | 
| 16 16 | 
             
                  class IndentationConsistency < Cop
         | 
| 17 17 | 
             
                    include AutocorrectAlignment
         | 
| 18 | 
            -
                    include AccessModifierNode
         | 
| 19 18 | 
             
                    include ConfigurableEnforcedStyle
         | 
| 20 19 |  | 
| 21 20 | 
             
                    MSG = 'Inconsistent indentation detected.'.freeze
         | 
| @@ -37,7 +36,7 @@ module RuboCop | |
| 37 36 | 
             
                        # the AccessModifierIndentation cop. This cop uses them as dividers
         | 
| 38 37 | 
             
                        # in rails mode. Then consistency is checked only within each
         | 
| 39 38 | 
             
                        # section delimited by a modifier node.
         | 
| 40 | 
            -
                        if  | 
| 39 | 
            +
                        if child.send_type? && child.access_modifier?
         | 
| 41 40 | 
             
                          children_to_check << [] if style == :rails
         | 
| 42 41 | 
             
                        else
         | 
| 43 42 | 
             
                          children_to_check.last << child
         | 
| @@ -48,9 +48,7 @@ module RuboCop | |
| 48 48 | 
             
                  class IndentationWidth < Cop
         | 
| 49 49 | 
             
                    include EndKeywordAlignment
         | 
| 50 50 | 
             
                    include AutocorrectAlignment
         | 
| 51 | 
            -
                    include OnMethodDef
         | 
| 52 51 | 
             
                    include CheckAssignment
         | 
| 53 | 
            -
                    include AccessModifierNode
         | 
| 54 52 | 
             
                    include IgnoredPattern
         | 
| 55 53 |  | 
| 56 54 | 
             
                    SPECIAL_MODIFIERS = %w[private protected].freeze
         | 
| @@ -98,7 +96,7 @@ module RuboCop | |
| 98 96 |  | 
| 99 97 | 
             
                    def on_send(node)
         | 
| 100 98 | 
             
                      super
         | 
| 101 | 
            -
                      return unless  | 
| 99 | 
            +
                      return unless node.adjacent_def_modifier?
         | 
| 102 100 |  | 
| 103 101 | 
             
                      *_, body = *node.first_argument
         | 
| 104 102 |  | 
| @@ -110,9 +108,12 @@ module RuboCop | |
| 110 108 | 
             
                      ignore_node(node.first_argument)
         | 
| 111 109 | 
             
                    end
         | 
| 112 110 |  | 
| 113 | 
            -
                    def  | 
| 114 | 
            -
                       | 
| 111 | 
            +
                    def on_def(node)
         | 
| 112 | 
            +
                      return if ignored_node?(node)
         | 
| 113 | 
            +
             | 
| 114 | 
            +
                      check_indentation(node.loc.keyword, node.body)
         | 
| 115 115 | 
             
                    end
         | 
| 116 | 
            +
                    alias on_defs on_def
         | 
| 116 117 |  | 
| 117 118 | 
             
                    def on_while(node, base = node)
         | 
| 118 119 | 
             
                      return if ignored_node?(node)
         | 
| @@ -157,7 +158,7 @@ module RuboCop | |
| 157 158 | 
             
                    def each_member(members)
         | 
| 158 159 | 
             
                      previous_modifier = nil
         | 
| 159 160 | 
             
                      members.first.children.each do |member|
         | 
| 160 | 
            -
                        if special_modifier?(member)
         | 
| 161 | 
            +
                        if member.send_type? && special_modifier?(member)
         | 
| 161 162 | 
             
                          previous_modifier = member
         | 
| 162 163 | 
             
                        elsif previous_modifier
         | 
| 163 164 | 
             
                          yield member, previous_modifier.source_range
         | 
| @@ -167,7 +168,7 @@ module RuboCop | |
| 167 168 | 
             
                    end
         | 
| 168 169 |  | 
| 169 170 | 
             
                    def special_modifier?(node)
         | 
| 170 | 
            -
                       | 
| 171 | 
            +
                      node.access_modifier? && SPECIAL_MODIFIERS.include?(node.source)
         | 
| 171 172 | 
             
                    end
         | 
| 172 173 |  | 
| 173 174 | 
             
                    def indentation_consistency_style
         | 
| @@ -289,7 +290,10 @@ module RuboCop | |
| 289 290 | 
             
                    end
         | 
| 290 291 |  | 
| 291 292 | 
             
                    def starts_with_access_modifier?(body_node)
         | 
| 292 | 
            -
                      body_node.begin_type? | 
| 293 | 
            +
                      return unless body_node.begin_type?
         | 
| 294 | 
            +
             | 
| 295 | 
            +
                      starting_node = body_node.children.first
         | 
| 296 | 
            +
                      starting_node.send_type? && starting_node.access_modifier?
         | 
| 293 297 | 
             
                    end
         | 
| 294 298 |  | 
| 295 299 | 
             
                    def configured_indentation_width
         | 
| @@ -3,39 +3,54 @@ | |
| 3 3 | 
             
            module RuboCop
         | 
| 4 4 | 
             
              module Cop
         | 
| 5 5 | 
             
                module Layout
         | 
| 6 | 
            -
                  # This cop checks whether comments have a leading space
         | 
| 7 | 
            -
                  #  | 
| 8 | 
            -
                  #  | 
| 9 | 
            -
                  #  | 
| 10 | 
            -
                  #  | 
| 6 | 
            +
                  # This cop checks whether comments have a leading space after the
         | 
| 7 | 
            +
                  # `#` denoting the start of the comment. The leading space is not
         | 
| 8 | 
            +
                  # required for some RDoc special syntax, like `#++`, `#--`,
         | 
| 9 | 
            +
                  # `#:nodoc`, `=begin`- and `=end` comments, "shebang" directives,
         | 
| 10 | 
            +
                  # or rackup options.
         | 
| 11 | 
            +
                  #
         | 
| 12 | 
            +
                  # @example
         | 
| 13 | 
            +
                  #
         | 
| 14 | 
            +
                  #   # bad
         | 
| 15 | 
            +
                  #   #Some comment
         | 
| 16 | 
            +
                  #
         | 
| 17 | 
            +
                  #   # good
         | 
| 18 | 
            +
                  #   # Some comment
         | 
| 11 19 | 
             
                  class LeadingCommentSpace < Cop
         | 
| 12 | 
            -
                    MSG = 'Missing space after  | 
| 20 | 
            +
                    MSG = 'Missing space after `#`.'.freeze
         | 
| 13 21 |  | 
| 14 22 | 
             
                    def investigate(processed_source)
         | 
| 15 23 | 
             
                      processed_source.comments.each do |comment|
         | 
| 16 24 | 
             
                        next unless comment.text =~ /\A#+[^#\s=:+-]/
         | 
| 17 | 
            -
                        next if comment. | 
| 25 | 
            +
                        next if comment.loc.line == 1 && allowed_on_first_line?(comment)
         | 
| 18 26 |  | 
| 19 | 
            -
                         | 
| 20 | 
            -
                        # as options (e.g. `#\ -p 8765` sets the request port to 8765)
         | 
| 21 | 
            -
                        next if comment.text.start_with?('#\\') && comment.loc.line == 1 &&
         | 
| 22 | 
            -
                                config_ru?(processed_source.buffer.name)
         | 
| 23 | 
            -
             | 
| 24 | 
            -
                        add_offense(comment, :expression)
         | 
| 27 | 
            +
                        add_offense(comment)
         | 
| 25 28 | 
             
                      end
         | 
| 26 29 | 
             
                    end
         | 
| 27 30 |  | 
| 31 | 
            +
                    private
         | 
| 32 | 
            +
             | 
| 28 33 | 
             
                    def autocorrect(comment)
         | 
| 29 34 | 
             
                      expr = comment.loc.expression
         | 
| 30 | 
            -
                       | 
| 31 | 
            -
             | 
| 35 | 
            +
                      hash_mark = range_between(expr.begin_pos, expr.begin_pos + 1)
         | 
| 36 | 
            +
             | 
| 32 37 | 
             
                      ->(corrector) { corrector.insert_after(hash_mark, ' ') }
         | 
| 33 38 | 
             
                    end
         | 
| 34 39 |  | 
| 35 | 
            -
                     | 
| 40 | 
            +
                    def allowed_on_first_line?(comment)
         | 
| 41 | 
            +
                      shebang?(comment) || rackup_config_file? && rackup_options?(comment)
         | 
| 42 | 
            +
                    end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                    def shebang?(comment)
         | 
| 45 | 
            +
                      comment.text.start_with?('#!')
         | 
| 46 | 
            +
                    end
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                    def rackup_options?(comment)
         | 
| 49 | 
            +
                      comment.text.start_with?('#\\')
         | 
| 50 | 
            +
                    end
         | 
| 36 51 |  | 
| 37 | 
            -
                    def  | 
| 38 | 
            -
                      File.basename( | 
| 52 | 
            +
                    def rackup_config_file?
         | 
| 53 | 
            +
                      File.basename(processed_source.buffer.name).eql?('config.ru')
         | 
| 39 54 | 
             
                    end
         | 
| 40 55 | 
             
                  end
         | 
| 41 56 | 
             
                end
         | 
| @@ -144,25 +144,21 @@ module RuboCop | |
| 144 144 | 
             
                    def syntactic_alignment_base(lhs, rhs)
         | 
| 145 145 | 
             
                      # a if b
         | 
| 146 146 | 
             
                      #      .c
         | 
| 147 | 
            -
                       | 
| 148 | 
            -
             | 
| 149 | 
            -
                        case n.type
         | 
| 150 | 
            -
                        when :for            then _, expression, = *n
         | 
| 151 | 
            -
                        when :return         then expression, = *n
         | 
| 152 | 
            -
                        when *MODIFIER_NODES then expression, = *n
         | 
| 153 | 
            -
                        end
         | 
| 154 | 
            -
                        return expression.source_range
         | 
| 147 | 
            +
                      kw_node_with_special_indentation(lhs) do |base|
         | 
| 148 | 
            +
                        return indented_keyword_expression(base).source_range
         | 
| 155 149 | 
             
                      end
         | 
| 156 150 |  | 
| 157 151 | 
             
                      # a = b
         | 
| 158 152 | 
             
                      #     .c
         | 
| 159 | 
            -
                       | 
| 160 | 
            -
             | 
| 153 | 
            +
                      part_of_assignment_rhs(lhs, rhs) do |base|
         | 
| 154 | 
            +
                        return assignment_rhs(base).source_range
         | 
| 155 | 
            +
                      end
         | 
| 161 156 |  | 
| 162 157 | 
             
                      # a + b
         | 
| 163 158 | 
             
                      #     .c
         | 
| 164 | 
            -
                       | 
| 165 | 
            -
             | 
| 159 | 
            +
                      operation_rhs(lhs) do |base|
         | 
| 160 | 
            +
                        return base.source_range
         | 
| 161 | 
            +
                      end
         | 
| 166 162 | 
             
                    end
         | 
| 167 163 |  | 
| 168 164 | 
             
                    # a.b
         | 
| @@ -202,12 +198,19 @@ module RuboCop | |
| 202 198 |  | 
| 203 199 | 
             
                    def operation_rhs(node)
         | 
| 204 200 | 
             
                      receiver, = *node
         | 
| 205 | 
            -
             | 
| 206 | 
            -
             | 
| 207 | 
            -
                         | 
| 208 | 
            -
                                       within_node?(receiver, args)
         | 
| 201 | 
            +
             | 
| 202 | 
            +
                      operation_rhs = receiver.each_ancestor(:send).find do |rhs|
         | 
| 203 | 
            +
                        operator_rhs?(rhs, receiver)
         | 
| 209 204 | 
             
                      end
         | 
| 210 | 
            -
             | 
| 205 | 
            +
             | 
| 206 | 
            +
                      return unless operation_rhs
         | 
| 207 | 
            +
             | 
| 208 | 
            +
                      yield operation_rhs.first_argument
         | 
| 209 | 
            +
                    end
         | 
| 210 | 
            +
             | 
| 211 | 
            +
                    def operator_rhs?(node, receiver)
         | 
| 212 | 
            +
                      node.operator_method? && node.arguments? &&
         | 
| 213 | 
            +
                        within_node?(receiver, node.first_argument)
         | 
| 211 214 | 
             
                    end
         | 
| 212 215 | 
             
                  end
         | 
| 213 216 | 
             
                end
         | 
| @@ -56,7 +56,6 @@ module RuboCop | |
| 56 56 | 
             
                  #       b
         | 
| 57 57 | 
             
                  #     )
         | 
| 58 58 | 
             
                  class MultilineMethodDefinitionBraceLayout < Cop
         | 
| 59 | 
            -
                    include OnMethodDef
         | 
| 60 59 | 
             
                    include MultilineLiteralBraceLayout
         | 
| 61 60 |  | 
| 62 61 | 
             
                    SAME_LINE_MESSAGE = 'Closing method definition brace must be on the ' \
         | 
| @@ -73,9 +72,10 @@ module RuboCop | |
| 73 72 | 
             
                    ALWAYS_SAME_LINE_MESSAGE = 'Closing method definition brace must be ' \
         | 
| 74 73 | 
             
                      'on the same line as the last parameter.'.freeze
         | 
| 75 74 |  | 
| 76 | 
            -
                    def  | 
| 77 | 
            -
                      check_brace_layout( | 
| 75 | 
            +
                    def on_def(node)
         | 
| 76 | 
            +
                      check_brace_layout(node.arguments)
         | 
| 78 77 | 
             
                    end
         | 
| 78 | 
            +
                    alias on_defs on_def
         | 
| 79 79 | 
             
                  end
         | 
| 80 80 | 
             
                end
         | 
| 81 81 | 
             
              end
         | 
| @@ -6,6 +6,13 @@ module RuboCop | |
| 6 6 | 
             
                  # Checks for colon (:) not followed by some kind of space.
         | 
| 7 7 | 
             
                  # N.B. this cop does not handle spaces after a ternary operator, which are
         | 
| 8 8 | 
             
                  # instead handled by Layout/SpaceAroundOperators.
         | 
| 9 | 
            +
                  #
         | 
| 10 | 
            +
                  # @example
         | 
| 11 | 
            +
                  #   # bad
         | 
| 12 | 
            +
                  #   def f(a:, b:2); {a:3}; end
         | 
| 13 | 
            +
                  #
         | 
| 14 | 
            +
                  #   # good
         | 
| 15 | 
            +
                  #   def f(a:, b: 2); {a: 3}; end
         | 
| 9 16 | 
             
                  class SpaceAfterColon < Cop
         | 
| 10 17 | 
             
                    MSG = 'Space missing after colon.'.freeze
         | 
| 11 18 |  | 
| @@ -4,6 +4,16 @@ module RuboCop | |
| 4 4 | 
             
              module Cop
         | 
| 5 5 | 
             
                module Layout
         | 
| 6 6 | 
             
                  # Checks for comma (,) not followed by some kind of space.
         | 
| 7 | 
            +
                  #
         | 
| 8 | 
            +
                  # @example
         | 
| 9 | 
            +
                  #
         | 
| 10 | 
            +
                  #   # bad
         | 
| 11 | 
            +
                  #   1,2
         | 
| 12 | 
            +
                  #   { foo:bar,}
         | 
| 13 | 
            +
                  #
         | 
| 14 | 
            +
                  #   # good
         | 
| 15 | 
            +
                  #   1, 2
         | 
| 16 | 
            +
                  #   { foo:bar, }
         | 
| 7 17 | 
             
                  class SpaceAfterComma < Cop
         | 
| 8 18 | 
             
                    include SpaceAfterPunctuation
         | 
| 9 19 |  | 
| @@ -13,12 +13,11 @@ module RuboCop | |
| 13 13 | 
             
                  #   # good
         | 
| 14 14 | 
             
                  #   def func(x) ... end
         | 
| 15 15 | 
             
                  class SpaceAfterMethodName < Cop
         | 
| 16 | 
            -
                    include OnMethodDef
         | 
| 17 | 
            -
             | 
| 18 16 | 
             
                    MSG = 'Do not put a space between a method name and the opening ' \
         | 
| 19 17 | 
             
                          'parenthesis.'.freeze
         | 
| 20 18 |  | 
| 21 | 
            -
                    def  | 
| 19 | 
            +
                    def on_def(node)
         | 
| 20 | 
            +
                      args = node.arguments
         | 
| 22 21 | 
             
                      return unless args.loc.begin && args.loc.begin.is?('(')
         | 
| 23 22 | 
             
                      expr = args.source_range
         | 
| 24 23 | 
             
                      pos_before_left_paren = range_between(expr.begin_pos - 1,
         | 
| @@ -27,6 +26,9 @@ module RuboCop | |
| 27 26 |  | 
| 28 27 | 
             
                      add_offense(pos_before_left_paren, pos_before_left_paren)
         | 
| 29 28 | 
             
                    end
         | 
| 29 | 
            +
                    alias on_defs on_def
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                    private
         | 
| 30 32 |  | 
| 31 33 | 
             
                    def autocorrect(pos_before_left_paren)
         | 
| 32 34 | 
             
                      ->(corrector) { corrector.remove(pos_before_left_paren) }
         | 
| @@ -75,16 +75,25 @@ module RuboCop | |
| 75 75 | 
             
                    end
         | 
| 76 76 |  | 
| 77 77 | 
             
                    def check_space_style_inside_pipes(args, opening_pipe, closing_pipe)
         | 
| 78 | 
            +
                      check_opening_pipe_space(args, opening_pipe)
         | 
| 79 | 
            +
                      check_closing_pipe_space(args, closing_pipe)
         | 
| 80 | 
            +
                    end
         | 
| 81 | 
            +
             | 
| 82 | 
            +
                    def check_opening_pipe_space(args, opening_pipe)
         | 
| 78 83 | 
             
                      first = args.first.source_range
         | 
| 79 | 
            -
                      last = args.last.source_range
         | 
| 80 | 
            -
                      last_end_pos = last_end_pos_inside_pipes(last.end_pos)
         | 
| 81 84 |  | 
| 82 85 | 
             
                      check_space(opening_pipe.end_pos, first.begin_pos, first,
         | 
| 83 86 | 
             
                                  'before first block parameter')
         | 
| 84 | 
            -
                      check_space(last_end_pos, closing_pipe.begin_pos, last,
         | 
| 85 | 
            -
                                  'after last block parameter')
         | 
| 86 87 | 
             
                      check_no_space(opening_pipe.end_pos, first.begin_pos - 1,
         | 
| 87 88 | 
             
                                     'Extra space before first')
         | 
| 89 | 
            +
                    end
         | 
| 90 | 
            +
             | 
| 91 | 
            +
                    def check_closing_pipe_space(args, closing_pipe)
         | 
| 92 | 
            +
                      last         = args.last.source_range
         | 
| 93 | 
            +
                      last_end_pos = last_end_pos_inside_pipes(last.end_pos)
         | 
| 94 | 
            +
             | 
| 95 | 
            +
                      check_space(last_end_pos, closing_pipe.begin_pos, last,
         | 
| 96 | 
            +
                                  'after last block parameter')
         | 
| 88 97 | 
             
                      check_no_space(last_end_pos + 1, closing_pipe.begin_pos,
         | 
| 89 98 | 
             
                                     'Extra space after last')
         | 
| 90 99 | 
             
                    end
         | 
| @@ -178,16 +178,20 @@ module RuboCop | |
| 178 178 | 
             
                    def space_after_missing?(range)
         | 
| 179 179 | 
             
                      pos = range.end_pos
         | 
| 180 180 | 
             
                      char = range.source_buffer.source[pos]
         | 
| 181 | 
            -
             | 
| 182 | 
            -
                      return false if  | 
| 183 | 
            -
                                      char == '('.freeze
         | 
| 184 | 
            -
                      return false if accept_left_square_bracket?(range) &&
         | 
| 185 | 
            -
                                      char == '['.freeze
         | 
| 181 | 
            +
             | 
| 182 | 
            +
                      return false if accepted_opening_delimiter?(range, char)
         | 
| 186 183 | 
             
                      return false if safe_navigation_call?(range, pos)
         | 
| 187 184 |  | 
| 188 185 | 
             
                      char !~ /[\s;,#\\\)\}\]\.]/
         | 
| 189 186 | 
             
                    end
         | 
| 190 187 |  | 
| 188 | 
            +
                    def accepted_opening_delimiter?(range, char)
         | 
| 189 | 
            +
                      return true unless char
         | 
| 190 | 
            +
             | 
| 191 | 
            +
                      accept_left_square_bracket?(range) && char == '[' ||
         | 
| 192 | 
            +
                        accept_left_parenthesis?(range) && char == '('
         | 
| 193 | 
            +
                    end
         | 
| 194 | 
            +
             | 
| 191 195 | 
             
                    def accept_left_parenthesis?(range)
         | 
| 192 196 | 
             
                      ACCEPT_LEFT_PAREN.include?(range.source)
         | 
| 193 197 | 
             
                    end
         | 
| @@ -5,9 +5,23 @@ module RuboCop | |
| 5 5 | 
             
                module Layout
         | 
| 6 6 | 
             
                  # Checks that block braces have or don't have a space before the opening
         | 
| 7 7 | 
             
                  # brace depending on configuration.
         | 
| 8 | 
            +
                  #
         | 
| 9 | 
            +
                  # @example
         | 
| 10 | 
            +
                  #   # bad
         | 
| 11 | 
            +
                  #   foo.map{ |a|
         | 
| 12 | 
            +
                  #     a.bar.to_s
         | 
| 13 | 
            +
                  #   }
         | 
| 14 | 
            +
                  #
         | 
| 15 | 
            +
                  #   # good
         | 
| 16 | 
            +
                  #   foo.map { |a|
         | 
| 17 | 
            +
                  #     a.bar.to_s
         | 
| 18 | 
            +
                  #   }
         | 
| 8 19 | 
             
                  class SpaceBeforeBlockBraces < Cop
         | 
| 9 20 | 
             
                    include ConfigurableEnforcedStyle
         | 
| 10 21 |  | 
| 22 | 
            +
                    MISSING_MSG = 'Space missing to the left of {.'.freeze
         | 
| 23 | 
            +
                    DETECTED_MSG = 'Space detected to the left of {.'.freeze
         | 
| 24 | 
            +
             | 
| 11 25 | 
             
                    def self.autocorrect_incompatible_with
         | 
| 12 26 | 
             
                      [Style::SymbolProc]
         | 
| 13 27 | 
             
                    end
         | 
| @@ -20,6 +34,31 @@ module RuboCop | |
| 20 34 | 
             
                      used_style =
         | 
| 21 35 | 
             
                        space_plus_brace.source.start_with?('{') ? :no_space : :space
         | 
| 22 36 |  | 
| 37 | 
            +
                      if empty_braces?(node.loc)
         | 
| 38 | 
            +
                        check_empty(left_brace, space_plus_brace, used_style)
         | 
| 39 | 
            +
                      else
         | 
| 40 | 
            +
                        check_non_empty(left_brace, space_plus_brace, used_style)
         | 
| 41 | 
            +
                      end
         | 
| 42 | 
            +
                    end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                    private
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                    def check_empty(left_brace, space_plus_brace, used_style)
         | 
| 47 | 
            +
                      return if style_for_empty_braces == used_style
         | 
| 48 | 
            +
             | 
| 49 | 
            +
                      config_to_allow_offenses['EnforcedStyleForEmptyBraces'] =
         | 
| 50 | 
            +
                        used_style.to_s
         | 
| 51 | 
            +
             | 
| 52 | 
            +
                      if style_for_empty_braces == :space
         | 
| 53 | 
            +
                        add_offense(left_brace, left_brace, MISSING_MSG)
         | 
| 54 | 
            +
                      else
         | 
| 55 | 
            +
                        space = range_between(space_plus_brace.begin_pos,
         | 
| 56 | 
            +
                                              left_brace.begin_pos)
         | 
| 57 | 
            +
                        add_offense(space, space, DETECTED_MSG)
         | 
| 58 | 
            +
                      end
         | 
| 59 | 
            +
                    end
         | 
| 60 | 
            +
             | 
| 61 | 
            +
                    def check_non_empty(left_brace, space_plus_brace, used_style)
         | 
| 23 62 | 
             
                      case used_style
         | 
| 24 63 | 
             
                      when style  then correct_style_detected
         | 
| 25 64 | 
             
                      when :space then space_detected(left_brace, space_plus_brace)
         | 
| @@ -27,11 +66,8 @@ module RuboCop | |
| 27 66 | 
             
                      end
         | 
| 28 67 | 
             
                    end
         | 
| 29 68 |  | 
| 30 | 
            -
                    private
         | 
| 31 | 
            -
             | 
| 32 69 | 
             
                    def space_missing(left_brace)
         | 
| 33 | 
            -
                      add_offense(left_brace, left_brace,
         | 
| 34 | 
            -
                                  'Space missing to the left of {.') do
         | 
| 70 | 
            +
                      add_offense(left_brace, left_brace, MISSING_MSG) do
         | 
| 35 71 | 
             
                        opposite_style_detected
         | 
| 36 72 | 
             
                      end
         | 
| 37 73 | 
             
                    end
         | 
| @@ -39,11 +75,20 @@ module RuboCop | |
| 39 75 | 
             
                    def space_detected(left_brace, space_plus_brace)
         | 
| 40 76 | 
             
                      space = range_between(space_plus_brace.begin_pos,
         | 
| 41 77 | 
             
                                            left_brace.begin_pos)
         | 
| 42 | 
            -
                      add_offense(space, space,  | 
| 78 | 
            +
                      add_offense(space, space, DETECTED_MSG) do
         | 
| 43 79 | 
             
                        opposite_style_detected
         | 
| 44 80 | 
             
                      end
         | 
| 45 81 | 
             
                    end
         | 
| 46 82 |  | 
| 83 | 
            +
                    def style_for_empty_braces
         | 
| 84 | 
            +
                      case cop_config['EnforcedStyleForEmptyBraces']
         | 
| 85 | 
            +
                      when 'space'    then :space
         | 
| 86 | 
            +
                      when 'no_space' then :no_space
         | 
| 87 | 
            +
                      when nil then style
         | 
| 88 | 
            +
                      else raise 'Unknown EnforcedStyleForEmptyBraces selected!'
         | 
| 89 | 
            +
                      end
         | 
| 90 | 
            +
                    end
         | 
| 91 | 
            +
             | 
| 47 92 | 
             
                    def autocorrect(range)
         | 
| 48 93 | 
             
                      lambda do |corrector|
         | 
| 49 94 | 
             
                        case range.source
         | 
| @@ -52,6 +97,10 @@ module RuboCop | |
| 52 97 | 
             
                        end
         | 
| 53 98 | 
             
                      end
         | 
| 54 99 | 
             
                    end
         | 
| 100 | 
            +
             | 
| 101 | 
            +
                    def empty_braces?(loc)
         | 
| 102 | 
            +
                      loc.begin.end_pos == loc.end.begin_pos
         | 
| 103 | 
            +
                    end
         | 
| 55 104 | 
             
                  end
         | 
| 56 105 | 
             
                end
         | 
| 57 106 | 
             
              end
         |