i042416 commented on Feb 17, 2017

Let’s look at the definition of code loop complexity in software engineering.

the cyclomatic complexity of a program is defined with reference to the control flow graph of the program, a directed graph containing the basic blocks of the program, with an edge between two basic blocks if control may pass from the first to the second. The complexity M is then defined as: M = E − N + 2, where E = the number of edges of the graph. N = the number of nodes of the graph. Take this very simple report for example, it has cyclomatic complexity calculated as 3 by code inspector.

IF lv_value = 1.
  WRITE: / 'always happend'.
ELSEIF lv_value = 2.
  WRITE: / 'not possible'.
ELSE.
  WRITE: / 'even not possible'.
ENDIF.
Copy the code

Why calculated as 3? See the directed graph for this simple report below:

[images]

For more of Jerry’s original articles, please follow the public account “Wang Zixi “: