facebookincubator / katran
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 1,098 units with 14,147 lines of code in units (53.0% of code).
    • 3 very long units (350 lines of code)
    • 31 long units (2,111 lines of code)
    • 172 medium size units (5,266 lines of code)
    • 227 small units (3,310 lines of code)
    • 665 very small units (3,110 lines of code)
2% | 14% | 37% | 23% | 21%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py2% | 11% | 35% | 22% | 27%
cpp1% | 17% | 42% | 22% | 15%
h20% | 0% | 20% | 4% | 54%
c0% | 49% | 24% | 23% | 2%
go0% | 11% | 25% | 43% | 19%
lua0% | 0% | 0% | 0% | 100%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
build/fbcode_builder2% | 11% | 36% | 22% | 28%
katran/lib1% | 20% | 40% | 19% | 18%
tools/xdpdump20% | 14% | 22% | 26% | 15%
example_grpc/goclient0% | 21% | 25% | 32% | 21%
example/client0% | 16% | 43% | 22% | 17%
tools/tcpdump_encap_helper0% | 32% | 50% | 8% | 8%
example_grpc0% | 0% | 33% | 43% | 23%
example0% | 0% | 36% | 39% | 24%
katran/decap0% | 0% | 72% | 25% | 1%
tools/start_katran0% | 0% | 25% | 57% | 16%
tools/wireshark0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 50 longest units
Unit# linesMcCabe index# params
128 13 3
113 22 4
109 24 5
92 23 2
88 12 3
88 8 1
85 15 1
83 24 2
81 22 0
78 1 1
78 7 0
77 14 2
76 25 4
76 14 2
75 15 2
74 11 3
73 19 2
73 10 3
65 14 2
64 1 2
63 1 1
62 22 1
58 9 6
57 1 0
57 1 2
57 8 4
57 3 8
56 23 0
56 10 1
55 16 4
52 6 1
52 12 1
52 8 1
51 11 0
50 3 0
50 12 4
50 6 3
47 5 0
47 8 2
47 10 0
47 12 2
46 8 2
46 9 2
46 11 0
45 8 2
44 16 3
44 8 1
44 5 2
44 9 2
43 6 3