facebook / jest
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,126 units with 20,570 lines of code in units (48.3% of code).
    • 22 very long units (3,795 lines of code)
    • 56 long units (3,824 lines of code)
    • 204 medium size units (6,394 lines of code)
    • 228 small units (3,391 lines of code)
    • 616 very small units (3,166 lines of code)
18% | 18% | 31% | 16% | 15%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
ts20% | 17% | 31% | 15% | 15%
js0% | 28% | 31% | 24% | 15%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
packages/jest-mock76% | 0% | 11% | 5% | 5%
packages/jest-core33% | 11% | 26% | 11% | 16%
packages/jest-config40% | 18% | 21% | 8% | 11%
packages/jest-haste-map16% | 16% | 32% | 18% | 17%
packages/jest-jasmine212% | 2% | 33% | 15% | 35%
packages/jest-runner48% | 33% | 10% | 6% | 1%
packages/jest-reporters20% | 21% | 32% | 13% | 11%
packages/expect9% | 28% | 39% | 15% | 7%
packages/jest-runtime15% | 33% | 19% | 20% | 10%
packages/jest-diff20% | 26% | 35% | 8% | 10%
packages/expect-utils62% | 0% | 0% | 16% | 20%
website/src0% | 45% | 25% | 18% | 10%
packages/jest-transform0% | 29% | 51% | 11% | 7%
scripts0% | 55% | 8% | 29% | 6%
packages/jest-cli0% | 70% | 24% | 0% | 5%
packages/jest-resolve0% | 14% | 46% | 21% | 17%
packages/jest-repl0% | 100% | 0% | 0% | 0%
packages/pretty-format0% | 16% | 62% | 10% | 10%
packages/jest-environment-node0% | 79% | 0% | 12% | 8%
packages/diff-sequences0% | 69% | 0% | 0% | 30%
packages/jest-environment-jsdom0% | 61% | 0% | 20% | 17%
packages/jest-snapshot0% | 13% | 48% | 27% | 10%
packages/jest-changed-files0% | 68% | 28% | 0% | 3%
packages/jest-worker0% | 0% | 40% | 36% | 22%
packages/jest-util0% | 0% | 54% | 17% | 27%
packages/jest-circus0% | 0% | 59% | 0% | 40%
packages/jest-docblock0% | 0% | 82% | 0% | 17%
packages/jest-watcher0% | 0% | 72% | 10% | 16%
packages/jest-matcher-utils0% | 0% | 50% | 38% | 11%
packages/jest-console0% | 0% | 64% | 0% | 35%
packages/babel-jest0% | 0% | 29% | 51% | 19%
packages/jest-get-type0% | 0% | 100% | 0% | 0%
packages/jest-leak-detector0% | 0% | 62% | 0% | 37%
packages/jest-each0% | 0% | 24% | 58% | 17%
packages/jest-fake-timers0% | 0% | 9% | 63% | 26%
packages/jest-phabricator0% | 0% | 80% | 0% | 19%
packages/babel-plugin-jest-hoist0% | 0% | 0% | 69% | 30%
packages/jest-create-cache-key-function0% | 0% | 0% | 82% | 17%
packages/jest-source-map0% | 0% | 0% | 51% | 48%
website0% | 0% | 0% | 64% | 36%
packages/test-utils0% | 0% | 0% | 46% | 53%
packages/jest-message-util0% | 0% | 0% | 57% | 42%
packages/jest-validate0% | 0% | 0% | 22% | 77%
packages/jest-serializer0% | 0% | 0% | 0% | 100%
packages/jest-expect0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 50 longest units
Unit# linesMcCabe index# params
453 119 4
333 42 6
237 31 6
199 21 2
198 10 1
184 29 2
180 29 2
177 31 1
176 29 2
172 29 3
165 29 2
161 29 2
159 11 1
142 22 5
113 17 1
110 23 1
108 23 4
107 24 4
106 12 3
106 23 1
106 46 6
103 15 5
100 14 5
99 13 2
98 19 1
93 1 0
93 18 3
92 15 2
90 24 6
89 16 1
86 11 4
85 17 1
80 18 2
78 9 1
78 17 1
76 17 2
74 17 1
71 22 3
71 10 2
71 12 3
70 13 3
69 19 8
69 12 2
67 59 1
66 3 0
66 8 0
65 7 4
64 6 2
64 16 4
64 15 1