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 {
- Read upRead up
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 {
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
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 {
- Read upRead up
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 {
- Read upRead up
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 {
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 {
Avoid deeply nested control flow statements. Open
if h != nil && h.handler != nil {
rctx.routeParams.Keys = append(rctx.routeParams.Keys, h.paramKeys...)
return xn
}
Avoid deeply nested control flow statements. Open
if endpoints == mALL || endpoints == mSTUB {
continue
}
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 {