microsoft / pxt-common-packages
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,357 units with 30,358 lines of code in units (65.1% of code).
    • 7 very long units (1,215 lines of code)
    • 44 long units (3,051 lines of code)
    • 249 medium size units (7,550 lines of code)
    • 486 small units (7,111 lines of code)
    • 2,571 very small units (11,431 lines of code)
4% | 10% | 24% | 23% | 37%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
ts4% | 7% | 22% | 22% | 43%
cpp4% | 13% | 28% | 25% | 28%
js0% | 0% | 57% | 32% | 9%
h0% | 0% | 5% | 13% | 80%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
libs/game7% | 12% | 25% | 18% | 35%
libs/core---vm15% | 10% | 17% | 31% | 25%
libs/mixer27% | 12% | 23% | 11% | 24%
libs/screen8% | 13% | 29% | 23% | 24%
libs/screen---linux61% | 0% | 12% | 12% | 13%
libs/base0% | 9% | 26% | 25% | 39%
libs/storage0% | 19% | 41% | 17% | 21%
libs/screen---st77350% | 28% | 29% | 23% | 18%
libs/settings0% | 16% | 27% | 20% | 35%
scripts/snorfs0% | 42% | 28% | 14% | 14%
libs/esp320% | 12% | 23% | 25% | 38%
libs/core0% | 5% | 21% | 23% | 49%
scripts/raffs0% | 36% | 21% | 17% | 24%
libs/mqtt0% | 19% | 21% | 29% | 29%
libs/net0% | 14% | 22% | 23% | 38%
libs/radio0% | 10% | 15% | 20% | 54%
libs/display0% | 21% | 22% | 25% | 30%
libs/wifi---esp320% | 8% | 18% | 34% | 38%
libs/lora0% | 13% | 13% | 31% | 41%
libs/light0% | 0% | 35% | 25% | 38%
libs/core---esp320% | 0% | 37% | 25% | 36%
libs/accelerometer0% | 0% | 35% | 42% | 22%
libs/pulse0% | 0% | 37% | 27% | 34%
scripts/font-compiler0% | 0% | 57% | 39% | 3%
libs/azureiot0% | 0% | 29% | 25% | 45%
libs/serial---linux0% | 0% | 51% | 32% | 15%
cpptests0% | 0% | 69% | 15% | 15%
libs/net-game0% | 0% | 71% | 10% | 18%
libs/lcd0% | 0% | 21% | 22% | 56%
libs/core---linux0% | 0% | 20% | 22% | 56%
cpptests/screen0% | 0% | 57% | 0% | 42%
libs/color-coded-tilemap0% | 0% | 18% | 29% | 51%
libs/screen---ext0% | 0% | 43% | 30% | 26%
libs/color0% | 0% | 31% | 20% | 47%
libs/datalogger0% | 0% | 31% | 28% | 40%
libs/buttons0% | 0% | 26% | 10% | 62%
libs/music0% | 0% | 10% | 27% | 62%
libs/controller0% | 0% | 12% | 24% | 62%
libs/matrix-keypad0% | 0% | 30% | 23% | 46%
libs/color-sensor0% | 0% | 34% | 0% | 65%
libs/light-spectrum-sensor0% | 0% | 20% | 27% | 52%
libs/text-to-speech0% | 0% | 28% | 23% | 48%
libs/storyboard0% | 0% | 0% | 71% | 28%
libs/keyboard0% | 0% | 0% | 53% | 46%
libs/settings---esp320% | 0% | 0% | 75% | 24%
libs/gamepad0% | 0% | 0% | 63% | 36%
libs/proximity0% | 0% | 0% | 54% | 45%
libs/settings---files0% | 0% | 0% | 52% | 47%
libs/thermometer0% | 0% | 0% | 57% | 42%
libs/serial0% | 0% | 0% | 12% | 87%
libs/rotary-encoder0% | 0% | 0% | 55% | 44%
libs/music---linux0% | 0% | 0% | 71% | 28%
libs/sprite-scaling0% | 0% | 0% | 45% | 55%
libs/core---nrf520% | 0% | 0% | 47% | 52%
libs/music---pwm0% | 0% | 0% | 100% | 0%
libs/animation0% | 0% | 0% | 25% | 74%
libs/mouse0% | 0% | 0% | 24% | 75%
libs/cable0% | 0% | 0% | 11% | 88%
libs/infrared0% | 0% | 0% | 11% | 88%
libs/switch0% | 0% | 0% | 44% | 55%
libs/mixer---ext0% | 0% | 0% | 85% | 14%
libs/touch0% | 0% | 0% | 0% | 100%
libs/servo0% | 0% | 0% | 0% | 100%
libs/core---stm320% | 0% | 0% | 0% | 100%
libs/edge-connector0% | 0% | 0% | 0% | 100%
libs/lightsensor0% | 0% | 0% | 0% | 100%
libs/microphone0% | 0% | 0% | 0% | 100%
libs/game---light0% | 0% | 0% | 0% | 100%
libs/core---samd0% | 0% | 0% | 0% | 100%
libs/palette0% | 0% | 0% | 0% | 100%
libs/power0% | 0% | 0% | 0% | 100%
libs/controller---none0% | 0% | 0% | 0% | 100%
libs/pixel0% | 0% | 0% | 0% | 100%
libs/core---rp20400% | 0% | 0% | 0% | 100%
libs/radio-broadcast0% | 0% | 0% | 0% | 100%
libs/mixer---linux0% | 0% | 0% | 0% | 100%
scripts0% | 0% | 0% | 0% | 100%
libs/mixer---none0% | 0% | 0% | 0% | 100%
libs/mixer---nrf520% | 0% | 0% | 0% | 100%
libs/mixer---rp20400% | 0% | 0% | 0% | 100%
libs/mixer---samd0% | 0% | 0% | 0% | 100%
libs/mixer---stm320% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
void validateFunction()
in libs/core---vm/vm.cpp
219 106 3
play()
in libs/mixer/melody.ts
212 68 1
protected tilemapCollisions()
in libs/game/physics.ts
206 43 2
static drawSayFrame()
in libs/game/spritesay.ts
189 16 8
bool drawImageCore()
in libs/screen/image.cpp
175 55 5
private static generateNode()
in libs/game/animation.ts
112 23 5
void WDisplay::updateLoop()
in libs/screen---linux/screen.cpp
102 27 0
int HF2::endpointRequest()
in libs/core/hf2.cpp
98 19 0
int WSynthesizer::fillSamples()
in libs/mixer/melody.cpp
97 16 2
int main()
in scripts/raffs/raffs-test.cpp
97 15 0
static void sweep()
in libs/base/gc.cpp
88 18 1
void JDDisplay::step()
in libs/screen---st7735/jddisplay.cpp
88 18 0
export function showLongText()
in libs/game/textDialogs.ts
86 18 2
bool FS::tryGC()
in libs/settings/RAFFS.cpp
84 19 2
drawPlayer()
in libs/game/info.ts
83 22 0
protected createMovingSprite()
in libs/game/physics.ts
83 13 3
bool FS::readHeaders()
in libs/storage/SNORFS.cpp
81 19 0
private handleMessage()
in libs/mqtt/mqtt.ts
79 23 1
constructor()
in libs/game/particlefactories.ts
78 1 2
void JDDisplay::handleIncoming()
in libs/screen---st7735/jddisplay.cpp
77 33 1