Skip to content

UNI005: Deep nesting

What and why

Method nesting depth >= 4 (Critical: >= 6).

Deep nesting obscures intent and complicates testing.

Threshold: depth >= 4 (Critical: >= 6).

How to fix: use early returns, extract nested blocks, or flatten conditionals.

Default thresholds

Severity Condition
Warning nesting depth >= 4
Critical nesting depth >= 6

Fix guidance

Use guard clauses or extract nested blocks (threshold: depth >= 4).

Tags

maintainability

Suppression

Place // unilyze-disable UNI005 -- reason in the leading trivia of the reported type or method declaration. Metric findings are matched by type or method name, so suppressing one overload also suppresses same-name overloads. For partial types, place the directive on the declaration indexed by unilyze. For project-wide suppression, use "rules": { "UNI005": "off" }; use a baseline to freeze existing findings while reporting new ones.