simonmittag/jabba

View on GitHub
route.go

Summary

Maintainability
A
3 hrs
Test Coverage
A
93%

Method Route.validHostPattern has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
Open

func (route *Route) validHostPattern() (bool, error) {
    //first check the name is a valid idna name.
    p := idna.New(
        idna.ValidateLabels(true),
        //this has to be off it disallows * for registration
Severity: Minor
Found in route.go - About 55 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 Route.validHostPattern has 8 return statements (exceeds 4 allowed).
Open

func (route *Route) validHostPattern() (bool, error) {
    //first check the name is a valid idna name.
    p := idna.New(
        idna.ValidateLabels(true),
        //this has to be off it disallows * for registration
Severity: Major
Found in route.go - About 50 mins to fix

    Method Route.validPath has 8 return statements (exceeds 4 allowed).
    Open

    func (route *Route) validPath() (bool, error) {
        const fakeHost = "http://127.0.0.1"
        defaultError := errors.New(fmt.Sprintf("route %v not a valid URL path", route.Path))
    
        _, err := url.ParseRequestURI(fakeHost + route.Path)
    Severity: Major
    Found in route.go - About 50 mins to fix

      Avoid deeply nested control flow statements.
      Open

                  if w[0] == STAR {
                      less = false
                  } else {
                      less = true
                  }
      Severity: Major
      Found in route.go - About 45 mins to fix

        There are no issues that match your filters.

        Category
        Status