microsoft / pxt
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 7,793 units with 109,261 lines of code in units (72.5% of code).
    • 84 very long units (13,799 lines of code)
    • 235 long units (15,832 lines of code)
    • 1,036 medium size units (31,996 lines of code)
    • 1,506 small units (21,805 lines of code)
    • 4,932 very small units (25,829 lines of code)
12% | 14% | 29% | 19% | 23%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
ts13% | 14% | 28% | 20% | 22%
tsx8% | 15% | 29% | 18% | 28%
js14% | 0% | 40% | 19% | 24%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
webapp11% | 13% | 28% | 19% | 27%
pxtcompiler19% | 17% | 27% | 17% | 17%
pxtlib13% | 11% | 29% | 22% | 23%
cli21% | 20% | 27% | 15% | 14%
pxtblocks7% | 17% | 31% | 21% | 22%
pxtsim10% | 13% | 24% | 19% | 32%
pxteditor24% | 6% | 23% | 10% | 33%
pxtpy3% | 17% | 33% | 24% | 20%
skillmap3% | 10% | 37% | 25% | 23%
pxtrunner0% | 15% | 45% | 21% | 17%
react-common0% | 48% | 11% | 23% | 16%
pxtwinrt0% | 0% | 55% | 17% | 26%
docfiles0% | 0% | 42% | 21% | 35%
libs0% | 0% | 18% | 28% | 52%
ROOT0% | 0% | 52% | 33% | 14%
pxt-cli0% | 0% | 72% | 27% | 0%
scripts0% | 0% | 46% | 28% | 25%
pxtwapp0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
599 5 0
465 5 0
364 71 1
header: lf()
in webapp/src/app.tsx
324 80 1
function getCallStatement()
in pxtcompiler/emitter/decompiler.ts
276 93 2
270 63 1
private buildDom()
in pxtsim/visuals/breadboard.ts
268 18 0
260 54 1
ariaLabel: lf()
in webapp/src/tutorial.tsx
257 35 1
247 51 1
export function getCompletions()
in pxtcompiler/emitter/languageservice.ts
237 60 1
header: lf()
in webapp/src/cmds.ts
236 49 1
body: lf()
in webapp/src/cmds.ts
235 49 2
export function bindEditorMessages()
in pxteditor/editorcontroller.ts
229 63 1
export function prepTemplate()
in pxtlib/docsrender.ts
223 58 1
renderCore()
in webapp/src/share.tsx
215 84 0
SmoothieChart.prototype.render = function()
in webapp/public/smoothie/smoothie.js
213 50 2
export function renderMarkdown()
in pxtlib/docsrender.ts
186 49 1
export function defaultFiles()
in pxtlib/initprj.ts
186 4 0
name: lf()
in webapp/src/blocksSnippets.ts
186 1 1