Unit Size Overall
  • There are 15,820 units with 215,584 lines of code in units (52.6% of code).
    • 118 very long units (20,558 lines of code)
    • 465 long units (31,418 lines of code)
    • 2,099 medium size units (63,722 lines of code)
    • 3,356 small units (48,940 lines of code)
    • 9,782 very small units (50,946 lines of code)
9% | 14% | 29% | 22% | 23%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
ts6% | 13% | 30% | 24% | 24%
tsx28% | 18% | 23% | 13% | 15%
nsh78% | 18% | 2% | 0% | 0%
py8% | 21% | 29% | 21% | 18%
cpp0% | 87% | 0% | 4% | 7%
js0% | 54% | 22% | 7% | 16%
c0% | 22% | 42% | 16% | 18%
h0% | 10% | 30% | 39% | 19%
cjs0% | 0% | 50% | 0% | 49%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
packages9% | 14% | 29% | 22% | 23%
apps16% | 14% | 27% | 17% | 23%
scripts5% | 16% | 33% | 24% | 20%
.agents49% | 0% | 12% | 11% | 25%
snapshots6% | 9% | 36% | 20% | 26%
benchmarks0% | 17% | 18% | 31% | 32%
website0% | 32% | 21% | 18% | 26%
python0% | 8% | 32% | 32% | 25%
native0% | 19% | 36% | 21% | 22%
.github0% | 0% | 42% | 50% | 7%
ROOT0% | 0% | 0% | 77% | 22%
Alternative Visuals
Longest Units
Top 50 longest units
Unit# linesMcCabe index# params
740 166 25
505 102 7
441 109 5
403 93 22
396 67 1
386 80 1
355 1 0
350 132 0
337 97 26
301 118 0
280 89 2
277 43 2
271 50 1
265 53 12
261 44 6
259 58 3
255 53 1
253 107 1
246 62 2
224 46 2
222 52 2
217 90 2
213 90 0
205 73 4
203 72 15
203 35 1
203 1 0
202 57 15
193 51 3
193 18 1
192 79 2
185 34 14
183 27 2
173 9 2
172 88 2
172 38 4
170 4 1
169 51 1
168 35 7
167 1 0
166 35 14
162 59 4
162 54 1
160 17 8
159 24 25
158 36 0
158 33 7
157 44 1
156 19 1
155 17 2
About This Analysis
  • 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...
  • To learn more about unit size, the Sokrates recommends the following resources:
    • Function Length, MartinFowler.com
      • "If you have to spend effort into looking at a fragment of code to figure out what it's doing, then you should extract it into a function and name the function after that 'what'."
    • Stack Overflow Discussion on Unit Size, stackoverflow.com
      • "Use common sense, stick to small function sizes in most instances but don't be dogmatic about it if you have a genuinely good reason to make an unusually big function."
    • Coding Smells, codinghorror.com
      • "All other things being equal, a shorter method is easier to read, easier to understand, and easier to troubleshoot. Refactor long methods into smaller methods if you can."
    • Clean Code: A Handbook of Agile Software Craftsmanship, by Robert Martin
      • "The first rule of functions is that they should be small. The second rule of functions is that they should be smaller than that. Functions should not be 100 lines long. Functions should hardly ever be 20 lines long."