Skip to content

max-control-nesting

Limit nested control structures.

Updated View as Markdown

Default severity: warning

Reports control flow nested more than five levels deep. Guard clauses and cohesive helper functions usually make the same decisions easier to follow.

Bad

if first {
	if second {
		if third {
			if fourth {
				if fifth {
					if sixth {
						process()
					}
				}
			}
		}
	}
}

Good

if !ready {
	return
}
for _, item := range items {
	process(item)
}
Navigation

Type to search…

↑↓ navigate↵ selectEsc close