Aller au contenu

Deep Nesting (ARCH9184)

Ce contenu n’est pas encore disponible dans votre langue.

Key swift.quality.deep-nesting · Severity warning · Category quality

Flags control flow nested deeper than three levels. An else-if chain is one level: it reads flat even though the tree nests it.

if a { if b { for x in xs { if x.ok { doIt() } } } }
guard a, b else { return }
xs.filter(\.ok).forEach { doIt($0) }

Use guard / early returns, extract functions, or collection operations.