Skip to content

Nesting ​

Maximum Nesting Depth ​

nesting.max_depth — Deepest nesting of control structures.

ItemValue
DefinitionMaximum over control structures (branch, loop, case, catch) of 1 + the number of control structures enclosing it.
Scopefunction, file, project
InputNode kinds and parent links
Calculationelse if / elif continue their if-chain and do not add a level. Nesting restarts at function boundaries. 0 when there is no control structure. File / Project: maximum.
Unitlevels
Language Applicabilitylanguage_independent
LimitationsA branch directly inside a branch without a block (C if (a) if (b) x;) is treated as an if-chain continuation.
Reference-

Average Nesting Depth ​

nesting.avg_depth — Mean nesting level of statements.

ItemValue
DefinitionMean over statements of the number of control structures enclosing the statement.
Scopefunction, file, project
InputNode kinds and parent links
CalculationStatements as in size.statement_count. not_applicable when there are no statements. File / Project: mean over all their statements.
Unitlevels
Language Applicabilitylanguage_independent
LimitationsInherits the statement differences of size.statement_count.
Reference-