Default severity: warning
Reports a function when its cognitive-complexity score exceeds 7. Each control structure adds one plus its nesting depth, so deeply nested decisions cost more than an equivalent sequence of guard clauses.
Bad
func process(items []Item) {
if ready() {
for _, item := range items {
if valid(item) {
for retry(item) {
process(item)
}
}
}
}
}Good
func process(items []Item) {
if !ready() {
return
}
for _, item := range items {
processItem(item)
}
}Configuration
The maximum cognitive-complexity score is fixed at 7. Configure the rule’s
severity and path exclusions in strider.toml:
[checks.cognitive-complexity]
severity = "error"
excludes = ["generated/**"]