Helcaraxan/gomod

View on GitHub

Showing 16 of 18 total issues

sliceArrayEncoder has 23 methods (exceeds 20 allowed). Consider refactoring.
Open

type sliceArrayEncoder struct {
    elems []interface{}
}
Severity: Minor
Found in internal/logger/encoder.go - About 2 hrs to fix

    Method DepGraph.computeSetGraphTraversal has 72 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (g *DepGraph) computeSetGraphTraversal(log *logger.Logger, expr query.FuncExpr, direction traversalDirection, level Level) (nodeSet, error) {
        args := expr.Args()
        if len(args.Args()) == 0 {
            return nil, &queryErr{
                err:  "expected at least one argument but received none",
    Severity: Minor
    Found in internal/depgraph/query.go - About 1 hr to fix

      Method tokenizer.next has 69 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (t *tokenizer) next() (tkn token, err error) {
          var s tokenString
          var r rune
          var p int64
      
      
      Severity: Minor
      Found in internal/query/tokenizer.go - About 1 hr to fix

        Method DepGraph.computeSetGraphTraversal has a Cognitive Complexity of 22 (exceeds 15 allowed). Consider refactoring.
        Open

        func (g *DepGraph) computeSetGraphTraversal(log *logger.Logger, expr query.FuncExpr, direction traversalDirection, level Level) (nodeSet, error) {
            args := expr.Args()
            if len(args.Args()) == 0 {
                return nil, &queryErr{
                    err:  "expected at least one argument but received none",
        Severity: Minor
        Found in internal/depgraph/query.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.shiftPunctuation has a Cognitive Complexity of 21 (exceeds 15 allowed). Consider refactoring.
        Open

        func (p *parser) shiftPunctuation(next punctuationToken) (bool, error) {
            switch next.(type) {
            case *tokenComma:
                if len(p.exprStack) == 0 {
                    return false, &parserError{
        Severity: Minor
        Found in internal/query/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 tokenizer.next has a Cognitive Complexity of 21 (exceeds 15 allowed). Consider refactoring.
        Open

        func (t *tokenizer) next() (tkn token, err error) {
            var s tokenString
            var r rune
            var p int64
        
        
        Severity: Minor
        Found in internal/query/tokenizer.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 tokenizer.next has 10 return statements (exceeds 5 allowed).
        Open

        func (t *tokenizer) next() (tkn token, err error) {
            var s tokenString
            var r rune
            var p int64
        
        
        Severity: Major
        Found in internal/query/tokenizer.go - About 55 mins to fix

          Method DepGraph.sharedFunc has a Cognitive Complexity of 18 (exceeds 15 allowed). Consider refactoring.
          Open

          func (g *DepGraph) sharedFunc(log *logger.Logger, expr query.FuncExpr, level Level) (nodeSet, error) {
              args := expr.Args()
              if len(args.Args()) != 1 {
                  return nil, &queryErr{
                      err:  fmt.Sprintf("expected a single argument but received '%v'", len(args.Args())),
          Severity: Minor
          Found in internal/depgraph/query.go - About 45 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

          Method DepGraph.computeSetGraphTraversal has 7 return statements (exceeds 5 allowed).
          Open

          func (g *DepGraph) computeSetGraphTraversal(log *logger.Logger, expr query.FuncExpr, direction traversalDirection, level Level) (nodeSet, error) {
              args := expr.Args()
              if len(args.Args()) == 0 {
                  return nil, &queryErr{
                      err:  "expected at least one argument but received none",
          Severity: Major
          Found in internal/depgraph/query.go - About 40 mins to fix

            Method parser.parse has 6 return statements (exceeds 5 allowed).
            Open

            func (p *parser) parse() (Expr, error) {
                for p.streamIdx < len(p.stream) {
                    r, err := p.shift(p.stream[p.streamIdx])
                    if err != nil {
                        return nil, err
            Severity: Major
            Found in internal/query/parser.go - About 35 mins to fix

              Function GetGraph has a Cognitive Complexity of 17 (exceeds 15 allowed). Consider refactoring.
              Open

              func GetGraph(dl *logger.Builder, path string) (*DepGraph, error) {
                  if dl == nil {
                      dl = logger.NewBuilder(os.Stderr)
                  }
                  log := dl.Domain(logger.GraphDomain)
              Severity: Minor
              Found in internal/depgraph/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

              Method parser.shiftPunctuation has 6 return statements (exceeds 5 allowed).
              Open

              func (p *parser) shiftPunctuation(next punctuationToken) (bool, error) {
                  switch next.(type) {
                  case *tokenComma:
                      if len(p.exprStack) == 0 {
                          return false, &parserError{
              Severity: Major
              Found in internal/query/parser.go - About 35 mins to fix

                Method HierarchicalDigraph.AddEdge has 6 return statements (exceeds 5 allowed).
                Open

                func (g *HierarchicalDigraph) AddEdge(src Node, dst Node) error {
                    if g == nil {
                        return ErrNilGraph
                    } else if nodeIsNil(src) || nodeIsNil(dst) {
                        return ErrNilNode
                Severity: Major
                Found in internal/graph/graph.go - About 35 mins to fix

                  Method DepGraph.retrievePackageInfo has a Cognitive Complexity of 17 (exceeds 15 allowed). Consider refactoring.
                  Open

                  func (g *DepGraph) retrievePackageInfo(log *logger.Logger, pkgs []string) (imports []string, err error) {
                      stdout, _, err := util.RunCommand(log, g.Main.Info.Dir, "go", append([]string{"list", "-json", "-mod=mod"}, pkgs...)...)
                      if err != nil {
                          log.Error("Failed to list imports for packages.", zap.Strings("packages", pkgs), zap.Error(err))
                          return nil, err
                  Severity: Minor
                  Found in internal/depgraph/deps_pkg.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

                  Method graphClusters.clusterDepthMap has a Cognitive Complexity of 16 (exceeds 15 allowed). Consider refactoring.
                  Open

                  func (c *graphClusters) clusterDepthMap(nodeHash string) map[string]int {
                      if m, ok := c.cachedDepthMaps[nodeHash]; ok {
                          return m
                      }
                  
                  
                  Severity: Minor
                  Found in internal/printer/clustering.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

                  Method DepGraph.buildImportGraph has a Cognitive Complexity of 16 (exceeds 15 allowed). Consider refactoring.
                  Open

                  func (g *DepGraph) buildImportGraph(dl *logger.Builder) error {
                      log := dl.Domain(logger.PackageInfoDomain)
                      log.Debug("Building initial dependency graph based on the import graph.")
                  
                      err := g.retrieveTransitiveImports(log, []string{fmt.Sprintf("%s/...", g.Main.Info.Path)})
                  Severity: Minor
                  Found in internal/depgraph/deps_pkg.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

                  Severity
                  Category
                  Status
                  Source
                  Language