[[Property:title|CA010 - High complexity of nested branches and loops]]
[[Property:link_title|CA010]]
[[Property:weight|0]]
[[Property:uuid|8b9aeeae-19cb-c0ce-4de9-ba3b0bbd7dca]]
__NOTOC__
=Description=
When the number of nested branches or loops increases, the source code is less readable. This warning is controlled by a complexity threshold preference.
:{| class="doctable"
|-
| '''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
=Recommendation=
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