golang / website
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,130 units with 32,369 lines of code in units (33.7% of code).
    • 5 very long units (696 lines of code)
    • 47 long units (3,013 lines of code)
    • 281 medium size units (8,422 lines of code)
    • 651 small units (9,237 lines of code)
    • 2,146 very small units (11,001 lines of code)
2% | 9% | 26% | 28% | 33%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
go1% | 9% | 25% | 28% | 34%
js6% | 9% | 29% | 29% | 24%
cjs0% | 0% | 0% | 100% | 0%
java0% | 0% | 0% | 0% | 100%
py0% | 0% | 0% | 0% | 100%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
_content/talks1% | 3% | 18% | 35% | 40%
internal/screentest29% | 17% | 42% | 4% | 5%
internal/webtest37% | 14% | 25% | 10% | 11%
internal/backport1% | 11% | 36% | 22% | 27%
internal/pkgdoc0% | 40% | 27% | 16% | 15%
internal/gitfs0% | 32% | 34% | 17% | 15%
internal/codewalk0% | 54% | 25% | 15% | 4%
internal/web0% | 17% | 42% | 24% | 15%
internal/texthtml0% | 31% | 31% | 31% | 6%
internal/api0% | 77% | 14% | 7% | 0%
_content/js0% | 9% | 25% | 32% | 33%
cmd/locktrigger0% | 63% | 0% | 25% | 11%
cmd/golangorg0% | 12% | 55% | 20% | 11%
internal/tmplfunc0% | 23% | 45% | 16% | 14%
internal/talks0% | 40% | 16% | 9% | 32%
internal/dl0% | 13% | 44% | 25% | 16%
internal/blog0% | 36% | 53% | 8% | 2%
internal/short0% | 40% | 27% | 19% | 13%
_content/blog0% | 0% | 30% | 28% | 41%
_content/doc0% | 0% | 16% | 31% | 52%
internal/tour0% | 0% | 51% | 35% | 13%
internal/play0% | 0% | 59% | 15% | 25%
internal/history0% | 0% | 73% | 0% | 26%
internal/redirect0% | 0% | 34% | 41% | 23%
cmd/versionprune0% | 0% | 44% | 51% | 4%
cmd/events0% | 0% | 45% | 35% | 19%
_content/tour0% | 0% | 3% | 26% | 70%
cmd/screentest0% | 0% | 100% | 0% | 0%
internal/spec0% | 0% | 24% | 27% | 48%
cmd/googlegolangorg0% | 0% | 50% | 23% | 25%
internal/memcache0% | 0% | 0% | 33% | 66%
cmd/admingolangorg0% | 0% | 0% | 61% | 38%
ROOT0% | 0% | 0% | 51% | 48%
internal/env0% | 0% | 0% | 78% | 21%
tour0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
func readTests()
in internal/screentest/screentest.go
182 48 2
func parseScript()
in internal/webtest/webtest.go
153 42 2
function keyDown()
in _content/talks/2010/support/slidy.js
131 46 1
function addToolbar()
in _content/talks/2010/support/slidy.js
126 7 0
func compare()
in internal/backport/fmtsort/sort.go
104 33 2
func()
in internal/web/render.go
98 22 1
func()
in internal/pkgdoc/doc.go
90 22 1
func unpackObject()
in internal/gitfs/pack.go
87 20 3
func()
in internal/backport/html/template/escape.go
83 28 1
func addrToByteRange()
in internal/codewalk/codewalk.go
83 23 3
func goLinksFor()
in internal/texthtml/ast.go
82 34 1
func()
in internal/gitfs/git.go
80 21 1
func main()
in cmd/locktrigger/main.go
78 19 0
func()
in internal/backport/text/template/parse/node.go
78 23 1
func()
in internal/pkgdoc/doc.go
77 20 1
func()
in internal/backport/text/template/exec.go
72 21 1
func replaceLeadingIndentation()
in internal/pkgdoc/funcs.go
72 19 3
func addrNumber()
in internal/codewalk/codewalk.go
72 29 6
func NewHandler()
in cmd/golangorg/server.go
71 12 2
func()
in internal/web/page.go
67 20 1