whitequark/parser

View on GitHub

Showing 92 of 92 total issues

File default.rb has 1627 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 196 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 process has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
      Open

            def process(node)
              if node
                p node
      
                source_line_no = nil
      Severity: Minor
      Found in lib/parser/runner/ruby_parse.rb - About 7 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

      Class Rewriter has 33 methods (exceeds 20 allowed). Consider refactoring.
      Open

          class Rewriter
            attr_reader :source_buffer
            attr_reader :diagnostics
      
            ##
      Severity: Minor
      Found in lib/parser/source/rewriter.rb - About 4 hrs to fix

        Method append has a Cognitive Complexity of 28 (exceeds 5 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 4 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 setup_option_parsing has 92 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def setup_option_parsing(opts)
              opts.banner = "Usage: #{runner_name} [options] FILE|DIRECTORY..."
        
              opts.on_tail '-h', '--help', 'Display this help message and exit' do
                puts opts.help
        Severity: Major
        Found in lib/parser/runner.rb - About 3 hrs to fix

          Class Range has 29 methods (exceeds 20 allowed). Consider refactoring.
          Open

              class Range
                include Comparable
          
                attr_reader :source_buffer
                attr_reader :begin_pos, :end_pos
          Severity: Minor
          Found in lib/parser/source/range.rb - About 3 hrs to fix

            Method accessible has a Cognitive Complexity of 20 (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 2 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

            Class Literal has 24 methods (exceeds 20 allowed). Consider refactoring.
            Open

              class Lexer::Literal
                DELIMITERS = { '(' => ')', '[' => ']', '{' => '}', '<' => '>' }
            
                TYPES = {
                # type       start token     interpolate?
            Severity: Minor
            Found in lib/parser/lexer/literal.rb - About 2 hrs to fix

              Class TreeRewriter has 24 methods (exceeds 20 allowed). Consider refactoring.
              Open

                  class TreeRewriter
                    attr_reader :source_buffer
                    attr_reader :diagnostics
              
                    ##
              Severity: Minor
              Found in lib/parser/source/tree_rewriter.rb - About 2 hrs to fix

                Method process has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      def process(node)
                        if node
                          p node
                
                          source_line_no = nil
                Severity: Major
                Found in lib/parser/runner/ruby_parse.rb - About 2 hrs to fix

                  Class Buffer has 22 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                      class Buffer
                        attr_reader :name, :first_line
                  
                        ##
                        # @api private
                  Severity: Minor
                  Found in lib/parser/source/buffer.rb - About 2 hrs to fix

                    File rewriter.rb has 263 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    module Parser
                      module Source
                    
                        ##
                        # {Rewriter} is deprecated. Use {TreeRewriter} instead.
                    Severity: Minor
                    Found in lib/parser/source/rewriter.rb - About 2 hrs to fix

                      Method dedent has a Cognitive Complexity of 17 (exceeds 5 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 2 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 16 (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 2 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 associate has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def associate(begin_t, pairs, end_t)
                            0.upto(pairs.length - 1) do |i|
                              (i + 1).upto(pairs.length - 1) do |j|
                                key1, = *pairs[i]
                                key2, = *pairs[j]
                      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 nest_and_try_closing has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def nest_and_try_closing(delimiter, ts, te, lookahead=nil)
                            delimiter = coerce_encoding(delimiter)
                      
                            if @start_delim && @start_delim == delimiter
                              @nesting += 1
                      Severity: Minor
                      Found in lib/parser/lexer/literal.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 accessible has 43 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 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
                          Severity
                          Category
                          Status
                          Source
                          Language