Software-testing-dictionary-cyclomatic-complexity
提供:Dev Guides
巡回複雑度
循環的複雑度とは何ですか?
循環的複雑度は、多くのコーディングエラーと相関しているソースコードの複雑度の測定値です。 これは、プログラムモジュールを通る線形独立パスの数を測定するコードの制御フローグラフを開発することによって計算されます。
プログラムの循環的複雑度を下げ、修正するリスクを減らし、理解しやすくします。 次の式を使用して表すことができます。
Cyclomatic complexity = E - N + 2*P
where,
E = number of edges in the flow graph.
N = number of nodes in the flow graph.
P = number of nodes that have exit points
例:
IF A = 10 THEN
IF B > C THEN
A = B
ELSE
A = C
ENDIF
ENDIF
Print A
Print B
Print C
フローグラフ:
循環的複雑度は、7つのノード(形状)と8つのエッジ(線)を示す上記の制御フロー図を使用して計算されるため、循環的複雑度は8-7 + 2 = 3です。