microsoft / pxt-microbit
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 844 units with 8,595 lines of code in units (68.1% of code).
    • 3 very long units (483 lines of code)
    • 12 long units (781 lines of code)
    • 101 medium size units (3,138 lines of code)
    • 86 small units (1,282 lines of code)
    • 642 very small units (2,911 lines of code)
5% | 9% | 36% | 14% | 33%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
ts8% | 14% | 31% | 10% | 35%
cs22% | 12% | 21% | 7% | 35%
js0% | 2% | 62% | 21% | 13%
cpp0% | 0% | 9% | 21% | 68%
tsx0% | 0% | 46% | 0% | 53%
h0% | 0% | 0% | 0% | 100%
m0% | 0% | 0% | 0% | 100%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
libs9% | 2% | 20% | 15% | 53%
sim5% | 14% | 34% | 9% | 35%
clients22% | 12% | 21% | 7% | 36%
editor0% | 9% | 55% | 19% | 15%
compiler0% | 56% | 26% | 0% | 17%
pxtwapp0% | 0% | 0% | 57% | 42%
fieldeditors0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
export function iconImage()
in libs/core/icons.ts
251 41 1
private buildDom()
in sim/visuals/microbit.ts
129 5 0
private void InitializeComponent()
in clients/winuploader/Microbit.Uploader/MainForm.Designer.cs
103 1 0
89 21 2
constructor()
in sim/dalboard.ts
80 1 0
78 7 1
private updateTemperature()
in sim/visuals/microbit.ts
64 12 0
62 1 3
61 6 1
private updateLightLevel()
in sim/visuals/microbit.ts
60 13 0
void handleFile()
in clients/winuploader/Microbit.Uploader/MainForm.cs
59 18 1
export function arrowImage()
in libs/core/icons.ts
59 9 1
private updateSoundLevel()
in sim/visuals/microbit.ts
59 10 0
private attachPinsIOEvents()
in sim/visuals/microbit.ts
59 11 0
function wrapHex()
in compiler/combiner.ts
51 17 4
private instantaneousPosture()
in sim/state/accelerometer.ts
49 24 0
void gcProcessStacks()
in libs/core/codal.cpp
48 13 1
47 20 3
private updateTilt()
in sim/visuals/microbit.ts
47 15 0
private updateHardwareVersion()
in sim/visuals/microbit.ts
47 6 0