golang / exp
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 2,031 units with 28,215 lines of code in units (57.6% of code).
    • 13 very long units (2,142 lines of code)
    • 68 long units (4,558 lines of code)
    • 301 medium size units (9,228 lines of code)
    • 446 small units (6,441 lines of code)
    • 1,203 very small units (5,846 lines of code)
7% | 16% | 32% | 22% | 20%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
go7% | 16% | 31% | 22% | 20%
c0% | 5% | 52% | 22% | 19%
m0% | 0% | 45% | 0% | 54%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
shiny12% | 18% | 27% | 20% | 20%
errors12% | 21% | 24% | 24% | 16%
cmd12% | 24% | 43% | 12% | 6%
winfsnotify26% | 0% | 30% | 37% | 5%
sumdb0% | 26% | 35% | 22% | 15%
slices0% | 37% | 14% | 33% | 14%
shootout0% | 9% | 45% | 22% | 22%
vulncheck0% | 13% | 53% | 18% | 14%
vulndb0% | 9% | 44% | 33% | 13%
apidiff0% | 14% | 26% | 29% | 29%
utf8string0% | 53% | 23% | 13% | 9%
event0% | 3% | 23% | 29% | 42%
jsonrpc20% | 0% | 45% | 18% | 35%
mmap0% | 0% | 59% | 27% | 13%
ebnf0% | 0% | 37% | 21% | 40%
io0% | 0% | 34% | 24% | 40%
internal0% | 0% | 22% | 37% | 40%
rand0% | 0% | 16% | 28% | 55%
ebnflint0% | 0% | 62% | 25% | 12%
maps0% | 0% | 0% | 36% | 63%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
func()
in shiny/widget/flex/flex.go
322 104 1
func convVirtualKeyCode()
in shiny/driver/internal/win32/key.go
291 171 1
func cocoaKeyCode()
in shiny/driver/gldriver/cocoa.go
228 112 1
func decodeDrawing()
in shiny/iconvg/decode.go
193 65 3
func()
in errors/fmt/print.go
160 52 1
func()
in errors/fmt/print.go
143 42 1
func upgradeDrawing()
in shiny/iconvg/upgrade.go
142 33 3
func prepareLoadDir()
in cmd/gorelease/gorelease.go
124 34 6
func()
in shiny/driver/x11driver/screen.go
110 36 1
func loadLocalModule()
in cmd/gorelease/gorelease.go
109 31 4
func()
in winfsnotify/winfsnotify.go
109 29 1
func upgradeStyling()
in shiny/iconvg/upgrade.go
109 30 3
func createEGLSurface()
in shiny/driver/gldriver/win32.go
102 12 2
func()
in sumdb/internal/sumweb/server.go
100 21 1
func()
in sumdb/internal/tlog/tile.go
98 25 1
func()
in errors/fmt/scan.go
95 34 1
func()
in errors/fmt/format.go
93 31 1
func()
in shiny/iconvg/upgrade.go
92 22 1
func()
in apidiff/correspondence.go
90 43 1
func main()
in shiny/example/fluid/main.go
89 24 0