Complexity coverage

34 views
Skip to first unread message

Márcio Eduardo Delamaro

unread,
May 16, 2022, 10:43:11 AM5/16/22
to JaCoCo and EclEmma Users
In the coverage count description page

one can read:

 The formal definition of the cyclomatic complexity v(G) is based on the representation of a method's control flow graph as a directed graph:

    v(G) = E - N + 2

but I think this is correct only if the graph has a single exit node. Otherwise, this is incorrect.
I hope this is only a documentation issue and it is not used to compute the complexity of our programs.

Dela

Marc Hoffmann

unread,
May 16, 2022, 11:46:09 AM5/16/22
to JaCoCo and EclEmma Users
Hi,

internally a different but equivalent computation is applied: We start with complexity 1. At any branching point (if or switch) we add the number of branches - 1.

In Java every function only has a single exit node (which is the caller). You cannot exit to different paths. Think of every return statement has an edge to that single exit node.

Cheers,
-marc






--
You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/0398b4f8-7029-4996-88c7-d9ecf79a60dfn%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages