microsoft / pxt-brainpad
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 705 units with 6,311 lines of code in units (54.8% of code).
    • 2 very long units (282 lines of code)
    • 7 long units (481 lines of code)
    • 56 medium size units (1,779 lines of code)
    • 98 small units (1,376 lines of code)
    • 542 very small units (2,393 lines of code)
4% | 7% | 28% | 21% | 37%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
cpp8% | 14% | 22% | 19% | 34%
ts2% | 4% | 30% | 22% | 39%
h0% | 0% | 0% | 45% | 54%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
libs/screen19% | 14% | 23% | 21% | 21%
libs/game6% | 5% | 33% | 15% | 38%
libs/core0% | 6% | 21% | 24% | 48%
libs/infrared0% | 47% | 0% | 10% | 41%
sim/visuals0% | 13% | 40% | 29% | 17%
libs/display0% | 16% | 36% | 22% | 24%
libs/neopixel0% | 0% | 46% | 26% | 27%
libs/accelerometer0% | 0% | 32% | 32% | 34%
libs/leds0% | 0% | 100% | 0% | 0%
sim0% | 0% | 61% | 17% | 21%
libs/brainbot0% | 0% | 21% | 32% | 45%
libs/base0% | 0% | 50% | 0% | 50%
sim/state0% | 0% | 32% | 0% | 67%
libs/controller0% | 0% | 28% | 11% | 60%
libs/sonar0% | 0% | 100% | 0% | 0%
libs/music0% | 0% | 10% | 29% | 59%
libs/braingamer0% | 0% | 0% | 60% | 40%
libs/animation0% | 0% | 0% | 42% | 57%
libs/lightbulb0% | 0% | 0% | 32% | 67%
libs/settings0% | 0% | 0% | 32% | 67%
libs/cptest0% | 0% | 0% | 27% | 72%
libs/led0% | 0% | 0% | 0% | 100%
libs/buttons0% | 0% | 0% | 0% | 100%
libs/thermometer0% | 0% | 0% | 0% | 100%
editor0% | 0% | 0% | 0% | 100%
libs/brainpad0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
bool drawImageCore()
in libs/screen/image.cpp
175 55 5
say()
in libs/game/sprite.ts
107 22 4
public moveSprite()
in libs/game/physics.ts
82 30 4
int HF2::endpointRequest()
in libs/core/hf2.cpp
76 15 0
void ReceiverIR::isr_changed()
in libs/infrared/receiverir.cpp
73 16 1
void drawLine()
in libs/screen/image.cpp
71 21 6
void fillRect()
in libs/screen/image.cpp
63 23 6
function generateSteps()
in libs/display/graph.ts
58 7 3
private updateLightLevel()
in sim/visuals/board.ts
58 12 0
init()
in libs/game/scene.ts
50 8 0
private instantaneousPosture()
in libs/accelerometer/sim/accelerometer.ts
49 24 0
constructor()
in sim/dalboard.ts
49 2 0
export function mkNeoPixelPart()
in libs/core/sim/neopixel.ts
48 1 2
function initHUD()
in libs/game/info.ts
48 18 0
setImage()
in libs/game/sprite.ts
48 19 1
showRainbow()
in libs/neopixel/neopixel.ts
47 7 2
public update()
in libs/core/sim/neopixel.ts
46 12 1
private UpdateScreen()
in sim/visuals/board.ts
44 9 0
void setMatrixLeds()
in libs/display/leds.cpp
43 10 2
43 14 1