The Total Coverage Percentage is calculated as follows:
TPC = (BT + BF + SC + MC)/(2*B + S + M) * 100% where BT - branches that evaluated to "true" at least once BF - branches that evaluated to "false" at least once SC - statements covered MC - methods entered B - total number of branches S - total number of statements M - total number of methods
The average method complexity of code in the given context. In case of:
Cyclomatic complexity of code in the given context.
Cyclomatic complexity of a single method. It's calculated as follows:
Complexity Density is the average number of paths in your code per statement in given context (method, class, package). It's calculated as follows:
Cmp Density = Complexity / number of statements
Lines Of Code (including comment lines).
Non-Commented Lines Of Code. Lines of code that contain comments are not counted in this metric, leaving only the actual functioning code itself.
Clover currently does not calculate NCLOC for Groovy code (CLOV-1805).
// # of statements, # of branches, Method Cyclomatic Complexity // 0, 0, 1 void A() {} // 1, 0, 1 void A() { a(); } // 1 ,0 ,1 void A() { a = (6 < 7); } // 3, 0, 1 void A() { a(); b(); c(); } // 3, 2, 2 void A() { if (a()) b(); else c(); } // 2, 2, 3 void A() { if (a() || b()) c(); } // 2, 0, 1 void A() { if (1 + 2 == 4) c(); } // 2, 2, 2 void A() { for (; a(); ) b(); } // 2, 2, 3 void A() { for (; a() || b(); ) c(); } // 2, 0, 1 void A() { for (; 1 + 2 == 4; ) c(); } // 2, 2, 2 void A() { while (a()) b(); } // 2, 2, 3 void A() { while (a() || b()) c(); } // 2, 0, 1 void A() { while (1 + 2 == 4) c(); } // 3, 0, 2 void A() { switch (a()) { case 1: b();} } // 5, 0, 3 void A() { switch (a()) { case 1: b(); case 2: c();} } // 1, 2, 2 void A() { a() ? 1 : 2; } // 1, 2, 3 void A() { a() || b()? 1 : 2; } // 1, 6, 4 void A() { a() ? b() ? c()? 1 : 2 : 3 : 4; }