Try block is too long

CachéQuality release 
1.0.0
Id 
OS0042
Rule type 
Severity 

Major

Major
SQALE characteristic 
  • Changeability
    • Logic
Tags 
design, maintainability
Remediation function 
Constant/issue
Remediation cost 
2h

It is common to see code such as this:

    try {
        // very large block of code here
    } catch (e) {
        // handle exception
    }

This, however, is often a misdesign: in all the statements inside the try block, it frequently happens that only one or two actually throw an exception.

It is therefore advised, both for readability and understandability, to keep try blocks as small and self-contained as possible.