parser/scanner.go

Summary

Maintainability
D
2 days
Test Coverage

Method Scanner.Scan has a Cognitive Complexity of 47 (exceeds 20 allowed). Consider refactoring.
Open

func (s *Scanner) Scan() (
    tok token.Token,
    literal string,
    pos Pos,
) {
Severity: Minor
Found in parser/scanner.go - 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 Scanner.Scan has 143 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (s *Scanner) Scan() (
    tok token.Token,
    literal string,
    pos Pos,
) {
Severity: Major
Found in parser/scanner.go - About 4 hrs to fix

    File scanner.go has 590 lines of code (exceeds 500 allowed). Consider refactoring.
    Open

    // A modified version Go and Tengo parsers.
    
    // Copyright (c) 2020-2023 Ozan Hacıbekiroğlu.
    // Use of this source code is governed by a MIT License
    // that can be found in the LICENSE file.
    Severity: Minor
    Found in parser/scanner.go - About 4 hrs to fix

      Method Scanner.scanNumber has a Cognitive Complexity of 39 (exceeds 20 allowed). Consider refactoring.
      Open

      func (s *Scanner) scanNumber(seenDecimalPoint bool) (tok token.Token, lit string) {
          // digitVal(s.ch) < 10
          offs := s.offset
          tok = token.Int
      
      
      Severity: Minor
      Found in parser/scanner.go - 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 Scanner.scanNumber has 65 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (s *Scanner) scanNumber(seenDecimalPoint bool) (tok token.Token, lit string) {
          // digitVal(s.ch) < 10
          offs := s.offset
          tok = token.Int
      
      
      Severity: Minor
      Found in parser/scanner.go - About 1 hr to fix

        Consider simplifying this complex logical expression.
        Open

                if ch != '\r' || comment && i > len("/*") && c[i-1] == '*' &&
                    j+1 < len(b) && b[j+1] == '/' {
        Severity: Major
        Found in parser/scanner.go - About 40 mins to fix

          Method Scanner.scanEscape has 5 return statements (exceeds 4 allowed).
          Open

          func (s *Scanner) scanEscape(quote rune) bool {
              offs := s.offset
          
              var n int
              var base, max uint32
          Severity: Major
          Found in parser/scanner.go - About 35 mins to fix

            Method Scanner.Scan has 5 return statements (exceeds 4 allowed).
            Open

            func (s *Scanner) Scan() (
                tok token.Token,
                literal string,
                pos Pos,
            ) {
            Severity: Major
            Found in parser/scanner.go - About 35 mins to fix

              Method Scanner.findLineEnd has 5 return statements (exceeds 4 allowed).
              Open

              func (s *Scanner) findLineEnd() bool {
                  // initial '/' already consumed
              
                  defer func(offs int) {
                      // reset scanner state to where it was upon calling findLineEnd
              Severity: Major
              Found in parser/scanner.go - About 35 mins to fix

                Method Scanner.scanComment has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
                Open

                func (s *Scanner) scanComment() string {
                    // initial '/' already consumed; s.ch == '/' || s.ch == '*'
                    offs := s.offset - 1 // position of initial '/'
                    var numCR int
                
                
                Severity: Minor
                Found in parser/scanner.go - 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

                There are no issues that match your filters.

                Category
                Status