facebookincubator / spectrum
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,542 units with 12,244 lines of code in units (38.5% of code).
    • 1 very long units (119 lines of code)
    • 7 long units (415 lines of code)
    • 90 medium size units (2,506 lines of code)
    • 240 small units (3,466 lines of code)
    • 1,204 very small units (5,738 lines of code)
<1% | 3% | 20% | 28% | 46%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
cpp1% | 5% | 25% | 33% | 33%
java0% | 0% | 11% | 23% | 65%
mm0% | 0% | 27% | 41% | 31%
m0% | 0% | 58% | 21% | 20%
swift0% | 0% | 12% | 15% | 72%
kt0% | 0% | 20% | 30% | 48%
js0% | 0% | 70% | 0% | 29%
h0% | 0% | 1% | 10% | 88%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
cpp/spectrum2% | 6% | 29% | 35% | 26%
android/src0% | 2% | 8% | 24% | 64%
androidLibs/fbjni0% | 2% | 10% | 15% | 72%
ios/SpectrumKit0% | 0% | 27% | 29% | 43%
android/spectrumtestutils0% | 0% | 29% | 27% | 43%
cpp/testutils0% | 0% | 22% | 43% | 33%
android/sample0% | 0% | 20% | 30% | 48%
ios/SpectrumKitSample0% | 0% | 10% | 19% | 70%
website/pages0% | 0% | 82% | 0% | 17%
android/spectrumpluginplatform0% | 0% | 16% | 19% | 63%
android/spectrumpluginwebp0% | 0% | 0% | 32% | 67%
android/spectrumpluginpng0% | 0% | 0% | 26% | 73%
android/spectrumpluginjpeg0% | 0% | 0% | 26% | 73%
android/spectrumpluginavif0% | 0% | 0% | 26% | 73%
website/core0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 50 longest units
Unit# linesMcCabe index# params
119 32 3
82 24 0
67 20 0
59 16 0
52 4 1
52 3 0
52 1 1
51 10 4
48 9 0
48 5 5
47 10 4
46 6 2
45 4 0
42 1 1
39 4 0
39 6 0
39 28 1
36 2 0
35 5 0
35 6 5
34 3 3
33 2 0
33 4 1
33 6 2
33 6 2
33 6 2
33 11 2
32 3 1
32 3 5
32 5 2
32 1 0
32 10 2
31 11 1
30 6 2
30 4 3
30 1 14
30 1 2
30 8 2
29 4 0
29 1 5
29 5 0
29 1 2
28 4 1
28 1 5
28 4 2
28 4 3
28 1 1
27 6 0
27 1 0
26 6 1