whatsapp / otp
Unit Size

The distribution of size of units (measured in lines of code).

Intro
  • Unit size measurements show the distribution of size of units of code (methods, functions...).
  • Units are classified in four categories based on their size (lines of code): 1-20 (small units), 20-50 (medium size units), 51-100 (long units), 101+ (very long units).
  • You should aim at keeping units small (< 20 lines). Long units may become "bloaters", code that have increased to such gargantuan proportions that they are hard to work with.
Learn more...
Unit Size Overall
  • There are 9,306 units with 177,746 lines of code in units (12.1% of code).
    • 193 very long units (53,136 lines of code)
    • 405 long units (27,750 lines of code)
    • 1,518 medium size units (47,692 lines of code)
    • 1,765 small units (25,855 lines of code)
    • 5,425 very small units (23,313 lines of code)
29% | 15% | 26% | 14% | 13%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
c28% | 18% | 27% | 15% | 9%
cpp52% | 8% | 18% | 12% | 9%
h6% | 7% | 36% | 10% | 38%
java3% | 7% | 24% | 24% | 40%
inc0% | 8% | 46% | 22% | 22%
py0% | 22% | 52% | 7% | 17%
js0% | 15% | 16% | 34% | 33%
hpp0% | 0% | 19% | 33% | 47%
cc0% | 0% | 0% | 48% | 51%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
erts/emulator30% | 14% | 26% | 15% | 14%
lib/wx86% | 1% | 4% | 2% | 4%
erts/etc39% | 20% | 25% | 9% | 5%
lib/crypto31% | 30% | 23% | 8% | 5%
lib/erl_interface15% | 34% | 30% | 10% | 9%
erts/lib_src13% | 9% | 17% | 39% | 19%
erts/epmd44% | 12% | 29% | 6% | 6%
lib/asn133% | 14% | 37% | 9% | 5%
lib/odbc13% | 44% | 29% | 9% | 3%
lib/jinterface3% | 7% | 24% | 24% | 40%
lib/os_mon7% | 45% | 34% | 8% | 5%
erts/include0% | 15% | 74% | 5% | 4%
lib/runtime_tools0% | 25% | 43% | 16% | 13%
lib/hipe0% | 8% | 46% | 22% | 22%
lib/erl_docgen0% | 15% | 16% | 34% | 33%
system/doc0% | 16% | 40% | 22% | 20%
erts/example0% | 0% | 46% | 33% | 20%
lib/tools0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 50 longest units
Unit# linesMcCabe index# params
7045 913 6
3121 797 5
1818 1 1
971 3 3
828 1 2
751 167 1
743 188 8
739 163 4
735 162 8
722 1 1
695 215 2
637 202 2
584 62 2
565 125 2
546 1 1
502 111 1
460 79 7
408 100 2
378 122 5
376 69 1
372 113 4
372 140 5
343 102 1
341 1 1
336 64 8
326 52 9
316 94 2
303 72 2
303 79 2
302 4 1
291 60 5
290 50 5
289 85 1
287 51 1
287 68 1
285 41 2
278 35 1
275 3 0
272 52 1
269 47 1
268 77 3
267 71 2
265 62 1
258 83 2
258 46 4
258 52 4
254 52 1
252 59 0
250 40 2
248 44 2