whitequark/parser

View on GitHub

Showing 90 of 94 total issues

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 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 100 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 4 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 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

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

              class Lexer::Literal
                DELIMITERS = { '(' => ')', '[' => ']', '{' => '}', '<' => '>' }
                SPACE = ' '.ord
                TAB = "\t".ord
            
            
            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 StaticEnvironment has 22 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                    class StaticEnvironment
                      FORWARD_ARGS = :FORWARD_ARGS
                  
                      ANONYMOUS_RESTARG_IN_CURRENT_SCOPE = :ANONYMOUS_RESTARG_IN_CURRENT_SCOPE
                      ANONYMOUS_RESTARG_INHERITED = :ANONYMOUS_RESTARG_INHERITED
                  Severity: Minor
                  Found in lib/parser/static_environment.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 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 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

                          Severity
                          Category
                          Status
                          Source
                          Language