Saturday, June 13, 2015

Example of Cyclomatic complexity analysis over real projects

Processed by:
1) launch of https://github.com/checkstyle/contribution/tree/master/checkstyle-tester generate HTML report

2) html2text target/site/index.html | grep "Cyclomatic Complexity is" | cut -d' ' -f7 | sort | uniq --count | sort -h -k 2

3) % is calculated as "=TRUNC(((B2)/B$47)*100)"

So amount of methods the complicated then 10 (from all method that complicated than 5) in the project is about 5%.  Below is tables for: Checkstyle , Spring Framework, Open JDK 7.

Checkstyle 6.7 Cynclomatic complexity analysis:

               CC           Count                  %
5 130 15
6 83 12
7 66 9
8 52 10
9 53 4
10 22 4
11 23 4
12 25 1
13 7 0
14 3 1
15 8 0
16 4 0
17 2 0
18 5 1
19 10 0
20 1 2
21 13 0
22 1 0
23 5 0
24 1 0
27 1 0
29 1 0
30 1 0
32 1 0
34 2 0
44 2 0
47 2 0
81 1 100

Total: 525


Spring frameworks v4.1.6.RELEASE Cyclomatic complexity analysis:
               CC           Count                 %
5 746 30
6 450 18
7 312 12
8 215 8
9 157 6
10 109 4
11 80 3
12 55 2
13 52 2
14 34 1
15 33 1
16 25 1
17 18 0
18 19 0
19 14 0
20 17 0
21 11 0
22 8 0
23 9 0
24 6 0
25 7 0
26 11 0
27 1 0
28 2 0
29 1 0
31 3 0
32 2 0
33 5 0
34 3 0
35 2 0
36 3 0
37 1 0
38 1 0
40 2 0
41 1 0
44 1 0
47 1 0
48 1 0
50 2 0
55 1 0
60 1 0
61 1 0
81 2 0
127 1 0
184 1 0

Total:2427

OpenJdk7 Cyclomatic complexity analysis: 

               CC           Count                 %
5 4650 25
6 2947 16
7 2234 12
8 1542 8
9 1161 6
10 932 5
11 706 3
12 574 3
13 505 2
14 383 2
15 332 1
16 261 1
17 230 1
18 200 1
19 183 1
20 128 0
21 119 0
22 121 0
23 102 0
24 78 0
25 58 0
26 60 0
27 57 0
28 47 0
29 30 0
30 29 0
31 27 0
32 30 0
33 22 0
34 30 0
35 11 0
36 19 0
37 27 0
38 12 0
39 17 0
40 10 0
41 16 0
42 12 0
43 11 0
44 14 0
45 6 0
46 11 0
47 14 0
48 9 0
49 7 0
50 12 0
51 11 0
52 6 0
53 6 0
54 8 0
55 6 0
56 5 0
57 2 0
58 4 0
59 1 0
60 3 0
62 6 0
63 3 0
64 4 0
66 4 0
67 6 0
68 2 0
69 1 0
70 2 0
71 1 0
72 2 0
73 3 0
74 7 0
75 4 0
76 3 0
77 3 0
78 2 0
79 1 0
80 4 0
81 1 0
82 5 0
83 1 0
85 1 0
86 2 0
87 1 0
88 3 0
93 2 0
95 3 0
96 1 0
97 1 0
100 1 0
101 1 0
103 1 0
109 1 0
110 1 0
111 1 0
121 1 0
124 1 0
125 1 0
130 2 0
140 1 0
145 1 0
149 1 0
164 1 0
186 1 0
219 1 0
256 1 0
281 1 0

Total:18136

No comments:

Post a Comment