CA010 - High complexity of nested branches and loops


When the number of nested branches or loops increases, the source code is less readable. This warning is controlled by a complexity threshold preference.

Scope feature
Status Enabled
Severity Suggestion
Applicability All
Score 60
Complexity threshold 5

Example of violation

if a > 0 then from j = 1 until j >= s loop from k = 7 until k < 0 loop if enable_check = True then foo (k, j-1) if log_level = 3 then foobar end else bar (2 * j) end k := k - 1 end j := j + 1 end end


Encapsulate some of the inner branches or loops into a reusable routine.

In the example, it can simply be: if attached a_local then a_local.do_something end

cached: 06/22/2024 6:36:12.000 AM