whitequark/parser

View on GitHub

Showing 90 of 94 total issues

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 append has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def append(action)
            range = action.range
    
            # Is this an insertion?
            if range.empty?
    Severity: Minor
    Found in lib/parser/source/rewriter.rb - About 1 hr to fix

      Method analyse_hierarchy has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

            def analyse_hierarchy(action)
              r = action.range
              # left_index is the index of the first child that isn't completely to the left of action
              left_index = bsearch_child_index { |child| child.range.end_pos > r.begin_pos }
              # right_index is the index of the first child that is completely on the right of action
      Severity: Minor
      Found in lib/parser/source/tree_rewriter/action.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 process has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def process(initial_buffer)
            buffer = initial_buffer
            original_name = buffer.name
      
            @rewriters.each do |rewriter_class|
      Severity: Minor
      Found in lib/parser/runner/ruby_rewrite.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 dedent has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def dedent(string)
                original_encoding = string.encoding
                # Prevent the following error when processing binary encoded source.
                # "\xC0".split # => ArgumentError (invalid byte sequence in UTF-8)
                lines = string.force_encoding(Encoding::BINARY).split("\\\n")
          Severity: Minor
          Found in lib/parser/lexer/dedenter.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 recognize_encoding has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                    def self.recognize_encoding(string)
                      return if string.empty?
              
                      # extract the first two lines in an efficient way
                      string =~ /\A(.*)\n?(.*\n)?/
              Severity: Minor
              Found in lib/parser/source/buffer.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 parse_options has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  def parse_options(options)
                    @option_parser.parse!(options)
              
                    # Slop has just removed recognized options from `options`.
                    @fragments << $stdin.read if options.delete('-')
              Severity: Minor
              Found in lib/parser/runner.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 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 try has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def try(parser, ruby, file, show_ok: false)
                  try_ruby = lambda do |e|
                    Process.spawn(%{#{ruby} -c #{Shellwords.escape file}},
                                  :err => '/dev/null', :out => '/dev/null')
                    _, status = Process.wait2
              Severity: Minor
              Found in lib/gauntlet_parser.rb - About 1 hr to fix

                Method analyse_hierarchy has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      def analyse_hierarchy(action)
                        r = action.range
                        # left_index is the index of the first child that isn't completely to the left of action
                        left_index = bsearch_child_index { |child| child.range.end_pos > r.begin_pos }
                        # right_index is the index of the first child that is completely on the right of action
                Severity: Minor
                Found in lib/parser/source/tree_rewriter/action.rb - About 1 hr to fix

                  Method process has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def process(buffer)
                        ast = @parser.parse(buffer)
                  
                        if @locate
                          LocationProcessor.new.process(ast)
                  Severity: Minor
                  Found in lib/parser/runner/ruby_parse.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 initialize has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def initialize(lexer, str_type, delimiter, str_s, heredoc_e = nil,
                                     indent = false, dedent_body = false, label_allowed = false)
                        @lexer       = lexer
                        @nesting     = 1
                  
                  
                  Severity: Minor
                  Found in lib/parser/lexer/literal.rb - About 1 hr to fix

                    Method initialize has 8 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def initialize(lexer, str_type, delimiter, str_s, heredoc_e = nil,
                                       indent = false, dedent_body = false, label_allowed = false)
                    Severity: Major
                    Found in lib/parser/lexer/literal.rb - About 1 hr 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 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 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
                              Severity
                              Category
                              Status
                              Source
                              Language