Showing 65 of 81 total issues
Method scanner.scanTokensAfter
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
Open
func (s *scanner) scanTokensAfter() {
entities := []struct {
tok token.Token
pattern []string
}{
- 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
Avoid deeply nested control flow statements. Open
Open
switch p.ns[pos].tok {
case token.LPAREN:
counter++
case token.RPAREN:
counter--
Avoid deeply nested control flow statements. Open
Open
if par2, ok := par.X.(*goast.ParenExpr); ok {
if st, ok := par2.X.(*goast.StarExpr); ok {
call.Args[i] = st.X
}
}
Avoid deeply nested control flow statements. Open
Open
if en < len(e.Value.(*node).b) &&
(isFloatLetter(e.Value.(*node).b[en])) {
if en+1 < len(e.Value.(*node).b) &&
(e.Value.(*node).b[en+1] == '+' || e.Value.(*node).b[en+1] == '-') {
en++
Avoid deeply nested control flow statements. Open
Open
if rightPart[rightSeparator].tok == token.LPAREN {
counter++
}
Avoid deeply nested control flow statements. Open
Open
if rightSeparator+1 <= len(rightPart) {
for {
if rightPart[rightSeparator].tok == token.LBRACK {
counter++
}
Avoid deeply nested control flow statements. Open
Open
if len(f.b) > 1 {
s += "%" + string(f.b[1:]) + "s"
} else {
s += "%s"
}
Avoid deeply nested control flow statements. Open
Open
if i+1 < len(fs) && fs[i+1].tok == token.INT {
s += string(fs[i+1].b)
i += 1
}
Avoid deeply nested control flow statements. Open
Open
if rightPart[rightSeparator].tok == token.RPAREN {
counter--
}
Avoid deeply nested control flow statements. Open
Open
switch p.ns[p.ident].tok {
case token.LPAREN:
counter++
case token.RPAREN:
counter--
Avoid deeply nested control flow statements. Open
Open
if strings.Contains(arg.Name, "func()*[]byte{y:=[]byte(") {
arg.Name = arg.Name[17:]
index := strings.LastIndex(arg.Name, "\")")
arg.Name = arg.Name[:index+2]
if i > 1 {
Avoid deeply nested control flow statements. Open
Open
if len(arg.Name) > 3 && arg.Name[:2] == "&(" {
arg.Name = arg.Name[2 : len(arg.Name)-1]
continue
}
Avoid deeply nested control flow statements. Open
Open
if e.Value.(*node).b[en] == '.' {
for en = en + 1; en < len(e.Value.(*node).b); en++ {
if !isDigit(e.Value.(*node).b[en]) {
break
}
Avoid deeply nested control flow statements. Open
Open
if i+1 < len(fs) && fs[i+1].tok == token.INT {
s += string(fs[i+1].b)
i += 1
}
Avoid deeply nested control flow statements. Open
Open
if counter == 0 {
break
}
Avoid deeply nested control flow statements. Open
Open
if st, ok := par.X.(*goast.StarExpr); ok {
call.Args[i] = st.X
}
Avoid deeply nested control flow statements. Open
Open
if !isDigit(e.Value.(*node).b[en]) {
break
}
Avoid deeply nested control flow statements. Open
Open
if par, ok := un.X.(*goast.ParenExpr); ok {
if id, ok := par.X.(*goast.IndexExpr); ok {
call.Args[i] = id
continue
}
Avoid deeply nested control flow statements. Open
Open
if counter == 0 {
break
}
Avoid deeply nested control flow statements. Open
Open
if len(arg.Name) > 10 && arg.Name[:7] == "func()*" {
arg.Name = "*" + arg.Name
continue
}