whitequark/parser

View on GitHub
lib/parser/builders/default.rb

Summary

Maintainability
F
2 wks
Test Coverage

File default.rb has 1648 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Parser

  ##
  # Default AST builder. Uses {AST::Node}s.
  #
Severity: Major
Found in lib/parser/builders/default.rb - About 4 days to fix

    Class Default has 198 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Builders::Default
        class << self
          ##
          # AST compatibility attribute; since `-> {}` is not semantically
          # equivalent to `lambda {}`, all new code should set this attribute
    Severity: Major
    Found in lib/parser/builders/default.rb - About 3 days to fix

      Method accessible has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          def accessible(node)
            case node.type
            when :__FILE__
              if @emit_file_line_as_literals
                n(:str, [ node.loc.expression.source_buffer.name ],
      Severity: Minor
      Found in lib/parser/builders/default.rb - About 3 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method check_condition has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          def check_condition(cond)
            case cond.type
            when :masgn
              if @parser.version <= 23
                diagnostic :error, :masgn_as_condition, nil, cond.loc.expression
      Severity: Minor
      Found in lib/parser/builders/default.rb - About 3 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method accessible has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def accessible(node)
            case node.type
            when :__FILE__
              if @emit_file_line_as_literals
                n(:str, [ node.loc.expression.source_buffer.name ],
      Severity: Minor
      Found in lib/parser/builders/default.rb - About 1 hr to fix

        Method associate has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            def associate(begin_t, pairs, end_t)
              key_set = Set.new
        
              pairs.each do |pair|
                next unless pair.type.eql?(:pair)
        Severity: Minor
        Found in lib/parser/builders/default.rb - About 1 hr to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Method dedent_string has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            def dedent_string(node, dedent_level)
              if !dedent_level.nil?
                dedenter = Lexer::Dedenter.new(dedent_level)
        
                case node.type
        Severity: Minor
        Found in lib/parser/builders/default.rb - About 1 hr to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Method check_condition has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def check_condition(cond)
              case cond.type
              when :masgn
                if @parser.version <= 23
                  diagnostic :error, :masgn_as_condition, nil, cond.loc.expression
        Severity: Minor
        Found in lib/parser/builders/default.rb - About 1 hr to fix

          Method begin_body has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def begin_body(compound_stmt, rescue_bodies=[],
                             else_t=nil,    else_=nil,
                             ensure_t=nil,  ensure_=nil)
                if rescue_bodies.any?
                  if else_t
          Severity: Minor
          Found in lib/parser/builders/default.rb - About 1 hr to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Method begin_body has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def begin_body(compound_stmt, rescue_bodies=[],
                             else_t=nil,    else_=nil,
                             ensure_t=nil,  ensure_=nil)
                if rescue_bodies.any?
                  if else_t
          Severity: Minor
          Found in lib/parser/builders/default.rb - About 1 hr to fix

            Method assignable has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def assignable(node)
                  case node.type
                  when :cvar
                    node.updated(:cvasgn)
            
            
            Severity: Minor
            Found in lib/parser/builders/default.rb - About 1 hr to fix

              Method eh_keyword_map has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  def eh_keyword_map(compstmt_e, keyword_t, body_es,
                                     else_t, else_e)
                    if compstmt_e.nil?
                      if keyword_t.nil?
                        begin_l = body_es.first.loc.expression
              Severity: Minor
              Found in lib/parser/builders/default.rb - About 1 hr to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Method condition has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def condition(cond_t, cond, then_t,
                                if_true, else_t, if_false, end_t)
              Severity: Major
              Found in lib/parser/builders/default.rb - About 50 mins to fix

                Method for has 7 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def for(for_t, iterator, in_t, iteratee,
                            do_t, body, end_t)
                Severity: Major
                Found in lib/parser/builders/default.rb - About 50 mins to fix

                  Method def_endless_singleton has 7 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def def_endless_singleton(def_t, definee, dot_t,
                                                name_t, args,
                                                assignment_t, body)
                  Severity: Major
                  Found in lib/parser/builders/default.rb - About 50 mins to fix

                    Method condition_map has 7 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def condition_map(keyword_t, cond_e, begin_t, body_e, else_t, else_e, end_t)
                    Severity: Major
                    Found in lib/parser/builders/default.rb - About 50 mins to fix

                      Method def_singleton has 7 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          def def_singleton(def_t, definee, dot_t,
                                            name_t, args,
                                            body, end_t)
                      Severity: Major
                      Found in lib/parser/builders/default.rb - About 50 mins to fix

                        Method rescue_body has 6 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            def rescue_body(rescue_t,
                                            exc_list, assoc_t, exc_var,
                                            then_t, compound_stmt)
                        Severity: Minor
                        Found in lib/parser/builders/default.rb - About 45 mins to fix

                          Method rescue_body_map has 6 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              def rescue_body_map(keyword_t, exc_list_e, assoc_t,
                                                  exc_var_e, then_t,
                                                  compstmt_e)
                          Severity: Minor
                          Found in lib/parser/builders/default.rb - About 45 mins to fix

                            Method check_duplicate_args has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def check_duplicate_args(args, map={})
                                  args.each do |this_arg|
                                    case this_arg.type
                                    when :arg, :optarg, :restarg, :blockarg,
                                         :kwarg, :kwoptarg, :kwrestarg,
                            Severity: Minor
                            Found in lib/parser/builders/default.rb - About 45 mins to fix

                            Cognitive Complexity

                            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                            A method's cognitive complexity is based on a few simple rules:

                            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                            • Code is considered more complex for each "break in the linear flow of the code"
                            • Code is considered more complex when "flow breaking structures are nested"

                            Further reading

                            Method case has 6 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                def case(case_t, expr, when_bodies, else_t, else_body, end_t)
                            Severity: Minor
                            Found in lib/parser/builders/default.rb - About 45 mins to fix

                              Method loop has 6 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                  def loop(type, keyword_t, cond, do_t, body, end_t)
                              Severity: Minor
                              Found in lib/parser/builders/default.rb - About 45 mins to fix

                                Method case_match has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                    def case_match(case_t, expr, in_bodies, else_t, else_body, end_t)
                                Severity: Minor
                                Found in lib/parser/builders/default.rb - About 45 mins to fix

                                  Method begin_body has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                      def begin_body(compound_stmt, rescue_bodies=[],
                                                     else_t=nil,    else_=nil,
                                                     ensure_t=nil,  ensure_=nil)
                                  Severity: Minor
                                  Found in lib/parser/builders/default.rb - About 45 mins to fix

                                    Method call_method has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                    Open

                                        def call_method(receiver, dot_t, selector_t,
                                                        lparen_t=nil, args=[], rparen_t=nil)
                                    Severity: Minor
                                    Found in lib/parser/builders/default.rb - About 45 mins to fix

                                      Method send_map has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                      Open

                                          def send_map(receiver_e, dot_t, selector_t, begin_t=nil, args=[], end_t=nil)
                                      Severity: Minor
                                      Found in lib/parser/builders/default.rb - About 45 mins to fix

                                        Method def_class has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                        Open

                                            def def_class(class_t, name,
                                                          lt_t, superclass,
                                                          body, end_t)
                                        Severity: Minor
                                        Found in lib/parser/builders/default.rb - About 45 mins to fix

                                          Method block has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                          Open

                                              def block(method_call, begin_t, args, body, end_t)
                                                _receiver, _selector, *call_args = *method_call
                                          
                                                if method_call.type == :yield
                                                  diagnostic :error, :block_given_to_yield, nil, method_call.loc.keyword, [loc(begin_t)]
                                          Severity: Minor
                                          Found in lib/parser/builders/default.rb - About 45 mins to fix

                                          Cognitive Complexity

                                          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                          A method's cognitive complexity is based on a few simple rules:

                                          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                          • Code is considered more complex for each "break in the linear flow of the code"
                                          • Code is considered more complex when "flow breaking structures are nested"

                                          Further reading

                                          Method def_sclass has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                          Open

                                              def def_sclass(class_t, lshft_t, expr,
                                                             body, end_t)
                                          Severity: Minor
                                          Found in lib/parser/builders/default.rb - About 35 mins to fix

                                            Method in_pattern has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                            Open

                                                def in_pattern(in_t, pattern, guard, then_t, body)
                                            Severity: Minor
                                            Found in lib/parser/builders/default.rb - About 35 mins to fix

                                              Method def_method has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                              Open

                                                  def def_method(def_t, name_t, args,
                                                                 body, end_t)
                                              Severity: Minor
                                              Found in lib/parser/builders/default.rb - About 35 mins to fix

                                                Method keyword_cmd has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                Open

                                                    def keyword_cmd(type, keyword_t, lparen_t=nil, args=[], rparen_t=nil)
                                                Severity: Minor
                                                Found in lib/parser/builders/default.rb - About 35 mins to fix

                                                  Method ternary_map has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                  Open

                                                      def ternary_map(begin_e, question_t, mid_e, colon_t, end_e)
                                                  Severity: Minor
                                                  Found in lib/parser/builders/default.rb - About 35 mins to fix

                                                    Method endless_definition_map has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                    Open

                                                        def endless_definition_map(keyword_t, operator_t, name_t, assignment_t, body_e)
                                                    Severity: Minor
                                                    Found in lib/parser/builders/default.rb - About 35 mins to fix

                                                      Method diagnostic has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                      Open

                                                          def diagnostic(type, reason, arguments, location, highlights=[])
                                                      Severity: Minor
                                                      Found in lib/parser/builders/default.rb - About 35 mins to fix

                                                        Method ternary has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                        Open

                                                            def ternary(cond, question_t, if_true, colon_t, if_false)
                                                        Severity: Minor
                                                        Found in lib/parser/builders/default.rb - About 35 mins to fix

                                                          Method block has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                          Open

                                                              def block(method_call, begin_t, args, body, end_t)
                                                          Severity: Minor
                                                          Found in lib/parser/builders/default.rb - About 35 mins to fix

                                                            Method eh_keyword_map has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                            Open

                                                                def eh_keyword_map(compstmt_e, keyword_t, body_es,
                                                                                   else_t, else_e)
                                                            Severity: Minor
                                                            Found in lib/parser/builders/default.rb - About 35 mins to fix

                                                              Method def_endless_method has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                              Open

                                                                  def def_endless_method(def_t, name_t, args,
                                                                                         assignment_t, body)
                                                              Severity: Minor
                                                              Found in lib/parser/builders/default.rb - About 35 mins to fix

                                                                Method match_hash_var_from_str has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                                Open

                                                                    def match_hash_var_from_str(begin_t, strings, end_t)
                                                                      if strings.length > 1
                                                                        diagnostic :error, :pm_interp_in_var_name, nil, loc(begin_t).join(loc(end_t))
                                                                      end
                                                                
                                                                
                                                                Severity: Minor
                                                                Found in lib/parser/builders/default.rb - About 35 mins to fix

                                                                Cognitive Complexity

                                                                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                                A method's cognitive complexity is based on a few simple rules:

                                                                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                                • Code is considered more complex for each "break in the linear flow of the code"
                                                                • Code is considered more complex when "flow breaking structures are nested"

                                                                Further reading

                                                                Method condition_map has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                                Open

                                                                    def condition_map(keyword_t, cond_e, begin_t, body_e, else_t, else_e, end_t)
                                                                      if end_t
                                                                        end_l = loc(end_t)
                                                                      elsif else_e && else_e.loc.expression
                                                                        end_l = else_e.loc.expression
                                                                Severity: Minor
                                                                Found in lib/parser/builders/default.rb - About 35 mins to fix

                                                                Cognitive Complexity

                                                                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                                A method's cognitive complexity is based on a few simple rules:

                                                                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                                • Code is considered more complex for each "break in the linear flow of the code"
                                                                • Code is considered more complex when "flow breaking structures are nested"

                                                                Further reading

                                                                Method collection_map has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                                Open

                                                                    def collection_map(begin_t, parts, end_t)
                                                                      if begin_t.nil? || end_t.nil?
                                                                        if parts.any?
                                                                          expr_l = join_exprs(parts.first, parts.last)
                                                                        elsif !begin_t.nil?
                                                                Severity: Minor
                                                                Found in lib/parser/builders/default.rb - About 35 mins to fix

                                                                Cognitive Complexity

                                                                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                                A method's cognitive complexity is based on a few simple rules:

                                                                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                                • Code is considered more complex for each "break in the linear flow of the code"
                                                                • Code is considered more complex when "flow breaking structures are nested"

                                                                Further reading

                                                                Method static_string has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                                Open

                                                                    def static_string(nodes)
                                                                      nodes.map do |node|
                                                                        case node.type
                                                                        when :str
                                                                          node.children[0]
                                                                Severity: Minor
                                                                Found in lib/parser/builders/default.rb - About 35 mins to fix

                                                                Cognitive Complexity

                                                                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                                A method's cognitive complexity is based on a few simple rules:

                                                                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                                • Code is considered more complex for each "break in the linear flow of the code"
                                                                • Code is considered more complex when "flow breaking structures are nested"

                                                                Further reading

                                                                Method procarg0 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                Open

                                                                    def procarg0(arg)
                                                                      if self.class.emit_procarg0
                                                                        if arg.type == :arg && self.class.emit_arg_inside_procarg0
                                                                          n(:procarg0, [ arg ],
                                                                            Source::Map::Collection.new(nil, nil, arg.location.expression))
                                                                Severity: Minor
                                                                Found in lib/parser/builders/default.rb - About 25 mins to fix

                                                                Cognitive Complexity

                                                                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                                A method's cognitive complexity is based on a few simple rules:

                                                                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                                • Code is considered more complex for each "break in the linear flow of the code"
                                                                • Code is considered more complex when "flow breaking structures are nested"

                                                                Further reading

                                                                Method binary_op has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                Open

                                                                    def binary_op(receiver, operator_t, arg)
                                                                      source_map = send_binary_op_map(receiver, operator_t, arg)
                                                                
                                                                      if @parser.version == 18
                                                                        operator = value(operator_t)
                                                                Severity: Minor
                                                                Found in lib/parser/builders/default.rb - About 25 mins to fix

                                                                Cognitive Complexity

                                                                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                                A method's cognitive complexity is based on a few simple rules:

                                                                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                                • Code is considered more complex for each "break in the linear flow of the code"
                                                                • Code is considered more complex when "flow breaking structures are nested"

                                                                Further reading

                                                                Method array_pattern has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                Open

                                                                    def array_pattern(lbrack_t, elements, rbrack_t)
                                                                      return n(:array_pattern, nil, collection_map(lbrack_t, [], rbrack_t)) if elements.nil?
                                                                
                                                                      trailing_comma = false
                                                                
                                                                
                                                                Severity: Minor
                                                                Found in lib/parser/builders/default.rb - About 25 mins to fix

                                                                Cognitive Complexity

                                                                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                                A method's cognitive complexity is based on a few simple rules:

                                                                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                                • Code is considered more complex for each "break in the linear flow of the code"
                                                                • Code is considered more complex when "flow breaking structures are nested"

                                                                Further reading

                                                                Method string_compose has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                Open

                                                                    def string_compose(begin_t, parts, end_t)
                                                                      if collapse_string_parts?(parts)
                                                                        if begin_t.nil? && end_t.nil?
                                                                          parts.first
                                                                        else
                                                                Severity: Minor
                                                                Found in lib/parser/builders/default.rb - About 25 mins to fix

                                                                Cognitive Complexity

                                                                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                                A method's cognitive complexity is based on a few simple rules:

                                                                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                                • Code is considered more complex for each "break in the linear flow of the code"
                                                                • Code is considered more complex when "flow breaking structures are nested"

                                                                Further reading

                                                                Method string_map has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                Open

                                                                    def string_map(begin_t, parts, end_t)
                                                                      if begin_t && value(begin_t).start_with?('<<')
                                                                        if parts.any?
                                                                          expr_l = join_exprs(parts.first, parts.last)
                                                                        else
                                                                Severity: Minor
                                                                Found in lib/parser/builders/default.rb - About 25 mins to fix

                                                                Cognitive Complexity

                                                                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                                A method's cognitive complexity is based on a few simple rules:

                                                                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                                • Code is considered more complex for each "break in the linear flow of the code"
                                                                • Code is considered more complex when "flow breaking structures are nested"

                                                                Further reading

                                                                Method rescue_body_map has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                Open

                                                                    def rescue_body_map(keyword_t, exc_list_e, assoc_t,
                                                                                        exc_var_e, then_t,
                                                                                        compstmt_e)
                                                                      end_l = compstmt_e.loc.expression if compstmt_e
                                                                      end_l = loc(then_t)               if end_l.nil? && then_t
                                                                Severity: Minor
                                                                Found in lib/parser/builders/default.rb - About 25 mins to fix

                                                                Cognitive Complexity

                                                                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                                A method's cognitive complexity is based on a few simple rules:

                                                                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                                • Code is considered more complex for each "break in the linear flow of the code"
                                                                • Code is considered more complex when "flow breaking structures are nested"

                                                                Further reading

                                                                Method keyword_map has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                Open

                                                                    def keyword_map(keyword_t, begin_t, args, end_t)
                                                                      args ||= []
                                                                
                                                                      if end_t
                                                                        end_l = loc(end_t)
                                                                Severity: Minor
                                                                Found in lib/parser/builders/default.rb - About 25 mins to fix

                                                                Cognitive Complexity

                                                                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                                A method's cognitive complexity is based on a few simple rules:

                                                                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                                • Code is considered more complex for each "break in the linear flow of the code"
                                                                • Code is considered more complex when "flow breaking structures are nested"

                                                                Further reading

                                                                Similar blocks of code found in 2 locations. Consider refactoring.
                                                                Open

                                                                    def restarg(star_t, name_t=nil)
                                                                      if name_t
                                                                        check_reserved_for_numparam(value(name_t), loc(name_t))
                                                                        n(:restarg, [ value(name_t).to_sym ],
                                                                          arg_prefix_map(star_t, name_t))
                                                                Severity: Minor
                                                                Found in lib/parser/builders/default.rb and 1 other location - About 15 mins to fix
                                                                lib/parser/builders/default.rb on lines 958..966

                                                                Duplicated Code

                                                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                Tuning

                                                                This issue has a mass of 25.

                                                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                Refactorings

                                                                Further Reading

                                                                Similar blocks of code found in 2 locations. Consider refactoring.
                                                                Open

                                                                      if self.class.emit_index
                                                                        n(:index, [ receiver, *indexes ],
                                                                          index_map(receiver, lbrack_t, rbrack_t))
                                                                      else
                                                                        n(:send, [ receiver, :[], *indexes ],
                                                                Severity: Minor
                                                                Found in lib/parser/builders/default.rb and 1 other location - About 15 mins to fix
                                                                lib/parser/builders/default.rb on lines 1195..1201

                                                                Duplicated Code

                                                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                Tuning

                                                                This issue has a mass of 25.

                                                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                Refactorings

                                                                Further Reading

                                                                Similar blocks of code found in 2 locations. Consider refactoring.
                                                                Open

                                                                    def kwrestarg(dstar_t, name_t=nil)
                                                                      if name_t
                                                                        check_reserved_for_numparam(value(name_t), loc(name_t))
                                                                
                                                                        n(:kwrestarg, [ value(name_t).to_sym ],
                                                                Severity: Minor
                                                                Found in lib/parser/builders/default.rb and 1 other location - About 15 mins to fix
                                                                lib/parser/builders/default.rb on lines 933..940

                                                                Duplicated Code

                                                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                Tuning

                                                                This issue has a mass of 25.

                                                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                Refactorings

                                                                Further Reading

                                                                Similar blocks of code found in 2 locations. Consider refactoring.
                                                                Open

                                                                      if self.class.emit_index
                                                                        n(:indexasgn, [ receiver, *indexes ],
                                                                          index_map(receiver, lbrack_t, rbrack_t))
                                                                      else
                                                                        # Incomplete method call.
                                                                Severity: Minor
                                                                Found in lib/parser/builders/default.rb and 1 other location - About 15 mins to fix
                                                                lib/parser/builders/default.rb on lines 1185..1190

                                                                Duplicated Code

                                                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                Tuning

                                                                This issue has a mass of 25.

                                                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                Refactorings

                                                                Further Reading

                                                                There are no issues that match your filters.

                                                                Category
                                                                Status