facebookincubator / electron
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 5,760 units with 63,703 lines of code in units (46.5% of code).
    • 24 very long units (5,812 lines of code)
    • 89 long units (5,992 lines of code)
    • 561 medium size units (16,656 lines of code)
    • 1,096 small units (15,836 lines of code)
    • 3,990 very small units (19,407 lines of code)
9% | 9% | 26% | 24% | 30%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
ts27% | 4% | 24% | 17% | 26%
cc4% | 10% | 27% | 25% | 31%
js25% | 5% | 19% | 27% | 22%
py6% | 16% | 24% | 27% | 24%
mm0% | 13% | 31% | 26% | 28%
h0% | 0% | 12% | 26% | 60%
cpp0% | 0% | 67% | 0% | 32%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
spec-main43% | 1% | 17% | 15% | 22%
shell/browser3% | 11% | 26% | 25% | 33%
spec45% | 2% | <1% | 21% | 29%
shell/common4% | 6% | 30% | 29% | 28%
shell/app21% | 12% | 26% | 15% | 24%
shell/renderer7% | 9% | 30% | 25% | 26%
lib/browser9% | 12% | 24% | 20% | 32%
script7% | 19% | 35% | 23% | 13%
script/release0% | 17% | 42% | 27% | 12%
lib/asar0% | 0% | 72% | 14% | 12%
default_app0% | 0% | 65% | 11% | 23%
script/lib0% | 0% | 27% | 32% | 39%
lib/renderer0% | 0% | 16% | 32% | 51%
build0% | 0% | 30% | 38% | 30%
spec-main/fixtures0% | 0% | 16% | 58% | 25%
spec/fixtures0% | 0% | 12% | 25% | 61%
npm0% | 0% | 0% | 84% | 15%
shell/utility0% | 0% | 0% | 54% | 45%
lib/common0% | 0% | 0% | 35% | 64%
script/zip_manifests0% | 0% | 0% | 100% | 0%
spec/static0% | 0% | 0% | 61% | 38%
lib/sandboxed_renderer0% | 0% | 0% | 57% | 42%
spec/ts-smoke0% | 0% | 0% | 0% | 100%
build/mac0% | 0% | 0% | 0% | 100%
build/fuses0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 50 longest units
Unit# linesMcCabe index# params
949 25 2
824 4 2
671 9 2
343 14 1
225 12 2
199 35 7
190 33 4
189 25 0
188 9 1
177 75 2
161 4 1
157 1 2
143 9 1
141 44 1
139 14 0
138 3 1
137 19 1
137 1 2
133 36 4
122 23 2
120 63 2
111 18 4
110 11 2
108 6 1
100 7 0
98 18 1
96 20 13
96 25 1
96 20 3
96 21 0
94 45 1
90 12 0
89 23 4
88 42 2
88 24 0
87 27 1
86 15 9
83 2 2
80 22 1
80 13 5
78 15 1
77 17 2
77 11 4
76 18 2
75 9 1
75 34 2
75 8 0
74 18 3
74 26 1
73 14 6