Method is too deeply nested

CachéQuality release 
1.0.0
Id 
OS0021
Rule type 
Severity 

Critical

Critical
SQALE characteristic 
  • Changeability
    • Logic
Tags 
design, maintainability
Remediation function 
Constant/issue
Remediation cost 
3d

This rule checks for the nesting depth of methods.

Methods which are too deeply nested are usually an indication that one, or several, of the below problems apply:

  • the method tries to do too many things;
  • objects used by this method lack isolation;
  • the code in the method fails to account for early exit conditions.

The first of those conditions above is the most frequent one; the suggested fix is therefore to split the logic of this particular method into several methods.