Konstantin8105/f4go

View on GitHub
fortran/parser.go

Summary

Maintainability
F
1 wk
Test Coverage

File parser.go has 2252 lines of code (exceeds 1000 allowed). Consider refactoring.
Confirmed

package fortran

import (
    "bytes"
    "fmt"
Severity: Major
Found in fortran/parser.go - About 4 days to fix

    Method parser.parseData has a Cognitive Complexity of 129 (exceeds 20 allowed). Consider refactoring.
    Open

    func (p *parser) parseData() (stmts []goast.Stmt) {
        p.expect(ftData)
        p.ident++
    
        // parse names and values
    Severity: Minor
    Found in fortran/parser.go - About 2 days 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 parser.parseStmt has a Cognitive Complexity of 103 (exceeds 20 allowed). Consider refactoring.
    Open

    func (p *parser) parseStmt() (stmts []goast.Stmt) {
        onlyForRecover := p.ident
    
        pos := p.ns[p.ident].pos
    
    
    Severity: Minor
    Found in fortran/parser.go - About 1 day 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

    parser has 34 methods (exceeds 20 allowed). Consider refactoring.
    Confirmed

    func (p parser) getSize(name string, col int) (size int, ok bool) {
        v, ok := p.initVars.get(name)
        if !ok {
            panic("Cannot find variable : " + name)
        }
    Severity: Minor
    Found in fortran/parser.go - About 4 hrs to fix

      Method parser.initializeVars has a Cognitive Complexity of 42 (exceeds 20 allowed). Consider refactoring.
      Open

      func (p *parser) initializeVars() (vars []goast.Stmt) {
          defer func() {
              if r := recover(); r != nil {
                  err := fmt.Sprintf("Recover initializeVars : %v", r)
                  Debugf("%s", err)
      Severity: Minor
      Found in fortran/parser.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 parser.parseCommon has a Cognitive Complexity of 42 (exceeds 20 allowed). Consider refactoring.
      Open

      func (p *parser) parseCommon() (stmts []goast.Stmt) {
          p.expect(ftCommon)
          p.ident++
      
          var blockName string = "ALL"
      Severity: Minor
      Found in fortran/parser.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 parser.parseNodes has a Cognitive Complexity of 36 (exceeds 20 allowed). Consider refactoring.
      Open

      func (p *parser) parseNodes() (decls []goast.Decl) {
          Debugf("Parse nodes")
      
          if p.ident < 0 || p.ident >= len(p.ns) {
              p.errs = append(p.errs,
      Severity: Minor
      Found in fortran/parser.go - 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

      Function explodeFor has a Cognitive Complexity of 36 (exceeds 20 allowed). Consider refactoring.
      Open

      func explodeFor(name []node) (out [][]node, ok bool) {
          // have loop
          if len(name) == 0 {
              return
          }
      Severity: Minor
      Found in fortran/parser.go - 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 parser.parseSubroutine has a Cognitive Complexity of 35 (exceeds 20 allowed). Consider refactoring.
      Open

      func (p *parser) parseSubroutine() (decl goast.Decl) {
          Debugf("Parse subroutine")
      
          defer func() {
              p.init()
      Severity: Minor
      Found in fortran/parser.go - 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 parser.parseStmt has 287 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      func (p *parser) parseStmt() (stmts []goast.Stmt) {
          onlyForRecover := p.ident
      
          pos := p.ns[p.ident].pos
      
      
      Severity: Major
      Found in fortran/parser.go - About 2 hrs to fix

        Method parser.parseParameter has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring.
        Open

        func (p *parser) parseParameter() (stmts []goast.Stmt) {
            start := p.ident
            p.expect(ftParameter)
            p.ident++
            p.expect(token.LPAREN)
        Severity: Minor
        Found in fortran/parser.go - 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 parser.parseData has 266 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        func (p *parser) parseData() (stmts []goast.Stmt) {
            p.expect(ftData)
            p.ident++
        
            // parse names and values
        Severity: Major
        Found in fortran/parser.go - About 1 hr to fix

          Function Parse has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
          Open

          func Parse(b []byte, packageName string) (_ goast.File, errs []error) {
          
              if packageName == "" {
                  packageName = "main"
              }
          Severity: Minor
          Found in fortran/parser.go - 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 parser.parseCall has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
          Open

          func (p *parser) parseCall() goast.Stmt {
              {
                  begin := p.ident
                  p.expect(ftCall)
                  p.ident++
          Severity: Minor
          Found in fortran/parser.go - 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 parser.parseDo has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring.
          Open

          func (p *parser) parseDo() (sDo goast.ForStmt) {
              p.expect(ftDo)
              p.ident++
              if p.ns[p.ident].tok == ftWhile {
                  p.ident--
          Severity: Minor
          Found in fortran/parser.go - 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 parser.parseInit has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
          Open

          func (p *parser) parseInit() (stmts []goast.Stmt) {
          
              // parse base type
              var baseType []node
              for ; p.ns[p.ident].tok != token.IDENT; p.ident++ {
          Severity: Minor
          Found in fortran/parser.go - 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

          Function explodeFor has 8 return statements (exceeds 4 allowed).
          Open

          func explodeFor(name []node) (out [][]node, ok bool) {
              // have loop
              if len(name) == 0 {
                  return
              }
          Severity: Major
          Found in fortran/parser.go - About 50 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if counter == 0 {
                                    break
                                }
            Severity: Major
            Found in fortran/parser.go - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  switch p.ns[pos].tok {
                                  case token.LPAREN:
                                      counter++
                                  case token.RPAREN:
                                      counter--
              Severity: Major
              Found in fortran/parser.go - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    switch p.ns[p.ident].tok {
                                    case token.LPAREN:
                                        counter++
                                    case token.RPAREN:
                                        counter--
                Severity: Major
                Found in fortran/parser.go - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if counter == 0 {
                                          break
                                      }
                  Severity: Major
                  Found in fortran/parser.go - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if ok {
                                            // add init
                                            var inject []node
                                            inject = append(inject, typ...)
                                            for i := start; i < pos; i++ {
                    Severity: Major
                    Found in fortran/parser.go - About 45 mins to fix

                      Method parser.parseStmt has 6 return statements (exceeds 4 allowed).
                      Open

                      func (p *parser) parseStmt() (stmts []goast.Stmt) {
                          onlyForRecover := p.ident
                      
                          pos := p.ns[p.ident].pos
                      
                      
                      Severity: Major
                      Found in fortran/parser.go - About 40 mins to fix

                        Method strChanger.Visit has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
                        Open

                        func (s strChanger) Visit(node goast.Node) (w goast.Visitor) {
                            if call, ok := node.(*goast.CallExpr); ok {
                                if sel, ok := call.Fun.(*goast.SelectorExpr); ok {
                                    if id, ok := sel.X.(*goast.Ident); ok {
                                        if id.Name == "fmt" || id.Name == "math" {
                        Severity: Minor
                        Found in fortran/parser.go - 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

                        There are no issues that match your filters.

                        Category
                        Status