vorteil/direktiv

View on GitHub
pkg/refactor/gateway/endpoints/tree.go

Summary

Maintainability
F
3 days
Test Coverage

Method node.findRoute has a Cognitive Complexity of 103 (exceeds 20 allowed). Consider refactoring.
Open

func (n *node) findRoute(rctx *Context, method methodTyp, path string) *node {
    nn := n
    search := path

    for t, nds := range nn.children {
Severity: Minor
Found in pkg/refactor/gateway/endpoints/tree.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

Method node.findRoute has 105 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (n *node) findRoute(rctx *Context, method methodTyp, path string) *node {
    nn := n
    search := path

    for t, nds := range nn.children {
Severity: Major
Found in pkg/refactor/gateway/endpoints/tree.go - About 3 hrs to fix

    File tree.go has 539 lines of code (exceeds 500 allowed). Consider refactoring.
    Open

    // nolint
    package endpoints
    
    // This file has been copied and modified from https://github.com/go-chi/chi
    // Radix tree implementation below is a based on the original work by
    Severity: Minor
    Found in pkg/refactor/gateway/endpoints/tree.go - About 2 hrs to fix

      Function patNextSegment has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring.
      Open

      func patNextSegment(pattern string) (nodeTyp, string, string, byte, int, int) {
          ps := strings.Index(pattern, "{")
          ws := strings.Index(pattern, "*")
      
          if ps < 0 && ws < 0 {
      Severity: Minor
      Found in pkg/refactor/gateway/endpoints/tree.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 node.Routes has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
      Open

      func (n *node) Routes() []Route {
          rts := []Route{}
      
          n.walk(func(eps endpoints, subroutes chi.Routes) bool {
              if eps[mSTUB] != nil && eps[mSTUB].handler != nil && subroutes == nil {
      Severity: Minor
      Found in pkg/refactor/gateway/endpoints/tree.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 node.InsertRoute has 58 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (n *node) InsertRoute(method methodTyp, pattern string, handler *core.Endpoint) *node {
          var parent *node
          search := pattern
      
          for {
      Severity: Minor
      Found in pkg/refactor/gateway/endpoints/tree.go - About 1 hr to fix

        Function patNextSegment has 52 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func patNextSegment(pattern string) (nodeTyp, string, string, byte, int, int) {
            ps := strings.Index(pattern, "{")
            ws := strings.Index(pattern, "*")
        
            if ps < 0 && ws < 0 {
        Severity: Minor
        Found in pkg/refactor/gateway/endpoints/tree.go - About 1 hr to fix

          Avoid deeply nested control flow statements.
          Open

                                  if h != nil && h.handler != nil {
                                      rctx.routeParams.Keys = append(rctx.routeParams.Keys, h.paramKeys...)
                                      return xn
                                  }
          Severity: Major
          Found in pkg/refactor/gateway/endpoints/tree.go - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                        if endpoints == mALL || endpoints == mSTUB {
                                            continue
                                        }
            Severity: Major
            Found in pkg/refactor/gateway/endpoints/tree.go - About 45 mins to fix

              Method node.findRoute has 5 return statements (exceeds 4 allowed).
              Open

              func (n *node) findRoute(rctx *Context, method methodTyp, path string) *node {
                  nn := n
                  search := path
              
                  for t, nds := range nn.children {
              Severity: Major
              Found in pkg/refactor/gateway/endpoints/tree.go - About 35 mins to fix

                There are no issues that match your filters.

                Category
                Status