facebook / react
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 3,943 units with 74,410 lines of code in units (69.9% of code).
    • 100 very long units (19,339 lines of code)
    • 199 long units (13,536 lines of code)
    • 607 medium size units (19,464 lines of code)
    • 774 small units (11,101 lines of code)
    • 2,263 very small units (10,970 lines of code)
25% | 18% | 26% | 14% | 14%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
js26% | 18% | 26% | 14% | 14%
cpp0% | 14% | 14% | 40% | 30%
h0% | 0% | 0% | 25% | 74%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
packages/react-reconciler24% | 24% | 27% | 14% | 8%
scripts/bench49% | 6% | 18% | 9% | 16%
fixtures/legacy-jsx-runtimes21% | 18% | 34% | 14% | 11%
packages/eslint-plugin-react-hooks39% | 13% | 27% | 11% | 7%
fixtures/dom18% | 12% | 25% | 19% | 23%
scripts/jest35% | 0% | 21% | 12% | 30%
fixtures/fiber-debugger33% | 19% | 11% | 27% | 8%
fixtures/attribute-behavior6% | 6% | 12% | 4% | 70%
packages/react5% | 29% | 31% | 14% | 18%
fixtures/concurrent51% | 0% | 22% | 14% | 11%
packages/scheduler0% | 21% | 24% | 28% | 26%
packages/shared0% | 31% | 18% | 34% | 16%
scripts/rollup0% | 16% | 44% | 24% | 14%
packages/use-sync-external-store0% | 88% | 0% | 0% | 11%
scripts/flow0% | 73% | 0% | 0% | 26%
scripts/merge-fork0% | 79% | 18% | 0% | 2%
scripts/error-codes0% | 80% | 0% | 0% | 19%
scripts/perf-counters0% | 10% | 10% | 36% | 42%
scripts/eslint-rules0% | 10% | 53% | 15% | 20%
fixtures/flight0% | 16% | 39% | 20% | 24%
packages/dom-event-testing-library0% | 0% | 33% | 30% | 36%
scripts/release0% | 0% | 63% | 6% | 29%
scripts/devtools0% | 0% | 35% | 47% | 16%
packages/jest-react0% | 0% | 53% | 32% | 13%
fixtures/blocks0% | 0% | 49% | 36% | 14%
packages/use-subscription0% | 0% | 87% | 0% | 12%
fixtures/nesting0% | 0% | 36% | 35% | 27%
fixtures/ssr0% | 0% | 39% | 16% | 44%
fixtures/stacks0% | 0% | 30% | 32% | 37%
scripts/eslint0% | 0% | 62% | 20% | 17%
scripts/babel0% | 0% | 35% | 31% | 33%
scripts/shared0% | 0% | 69% | 30% | 0%
packages/create-subscription0% | 0% | 41% | 16% | 41%
fixtures/ssr20% | 0% | 16% | 42% | 40%
fixtures/devtools0% | 0% | 19% | 45% | 34%
scripts/print-warnings0% | 0% | 51% | 48% | 0%
scripts/tasks0% | 0% | 0% | 70% | 29%
fixtures/eslint0% | 0% | 0% | 62% | 37%
ROOT0% | 0% | 0% | 63% | 36%
packages/react-dom0% | 0% | 0% | 0% | 100%
fixtures/packaging0% | 0% | 0% | 0% | 100%
fixtures/expiration0% | 0% | 0% | 0% | 100%
fixtures/art0% | 0% | 0% | 0% | 100%
packages/react-devtools-shared0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 50 longest units
Unit# linesMcCabe index# params
611 30 0
611 30 1
611 30 1
560 150 3
560 150 3
535 104 1
471 30 0
373 1 1
359 30 1
359 30 1
335 26 0
335 26 1
335 26 1
278 73 4
278 73 4
238 50 3
238 50 3
232 29 0
232 29 1
232 29 1
230 33 0
230 33 1
230 33 1
226 56 3
226 56 3
215 26 3
215 26 3
212 22 0
212 22 1
212 22 1
212 43 3
212 43 3
189 38 3
189 38 3
183 43 2
183 43 2
183 36 3
182 38 4
182 38 4
159 50 3
159 50 3
154 35 4
154 35 4
149 11 0
149 11 1
149 11 1
149 45 5
149 45 5
149 8 1
147 30 3