golang / pkgsite
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 1,633 units with 28,186 lines of code in units (63.0% of code).
    • 12 very long units (1,422 lines of code)
    • 62 long units (4,316 lines of code)
    • 367 medium size units (11,076 lines of code)
    • 461 small units (6,859 lines of code)
    • 731 very small units (4,513 lines of code)
5% | 15% | 39% | 24% | 16%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
go5% | 15% | 39% | 23% | 15%
ts0% | 18% | 24% | 37% | 19%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
internal/godoc5% | 7% | 47% | 20% | 18%
internal/fetch22% | 18% | 25% | 21% | 12%
internal/postgres4% | 21% | 52% | 15% | 6%
internal/config37% | 0% | 13% | 18% | 30%
cmd/frontend70% | 0% | 0% | 5% | 23%
internal/worker8% | 21% | 33% | 22% | 13%
internal/frontend2% | 21% | 36% | 27% | 11%
internal/symbol0% | 53% | 22% | 17% | 7%
static/shared0% | 23% | 23% | 33% | 20%
devtools/cmd0% | 37% | 12% | 37% | 12%
internal/licenses0% | 28% | 23% | 33% | 14%
cmd/worker0% | 64% | 21% | 9% | 3%
internal/source0% | 16% | 28% | 39% | 16%
internal/database0% | 7% | 38% | 29% | 24%
cmd/pkgsite0% | 43% | 43% | 0% | 13%
internal/stdlib0% | 11% | 37% | 25% | 24%
internal/testing0% | 9% | 16% | 39% | 34%
internal/middleware0% | 0% | 38% | 31% | 29%
internal/proxy0% | 0% | 35% | 35% | 29%
internal/queue0% | 0% | 95% | 0% | 4%
internal/memory0% | 0% | 76% | 20% | 3%
internal/fetchdatasource0% | 0% | 32% | 53% | 13%
static/frontend0% | 0% | 33% | 49% | 17%
internal/version0% | 0% | 49% | 29% | 20%
internal/static0% | 0% | 100% | 0% | 0%
cmd/internal0% | 0% | 58% | 34% | 7%
internal/dcensus0% | 0% | 32% | 41% | 25%
internal0% | 0% | 14% | 41% | 44%
internal/log0% | 0% | 14% | 36% | 49%
internal/derrors0% | 0% | 0% | 48% | 51%
internal/auth0% | 0% | 0% | 72% | 27%
internal/index0% | 0% | 0% | 78% | 21%
internal/cookie0% | 0% | 0% | 64% | 35%
internal/secrets0% | 0% | 0% | 100% | 0%
internal/poller0% | 0% | 0% | 42% | 57%
static/worker0% | 0% | 0% | 56% | 43%
static0% | 0% | 0% | 100% | 0%
internal/experiment0% | 0% | 0% | 0% | 100%
internal/xcontext0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
func Init()
in internal/config/config.go
154 20 1
func extractPackages()
in internal/fetch/package.go
137 26 6
func main()
in cmd/frontend/main.go
133 18 0
func OneLineNodeDepth()
in internal/godoc/dochtml/internal/render/synopsis.go
127 45 3
func playExample()
in internal/godoc/internal/doc/example.go
114 33 3
func()
in internal/postgres/unit.go
113 19 1
func upsertPackageSymbolsReturningIDs()
in internal/postgres/symbol.go
111 18 6
func findDeclsAndUnresolved()
in internal/godoc/internal/doc/example.go
110 37 3
func loadPackage()
in internal/fetch/load.go
108 18 6
func()
in internal/worker/fetch.go
108 21 1
func fetchMainDetails()
in internal/frontend/main.go
106 20 6
func()
in internal/godoc/dochtml/internal/render/linkify.go
101 25 1
func main()
in cmd/worker/main.go
100 13 0
func()
in internal/postgres/insert_module.go
99 26 1
func()
in internal/frontend/unit.go
97 20 1
func upsertSymbolHistory()
in internal/postgres/insert_symbol_history.go
89 18 8
func()
in internal/symbol/generate.go
89 20 1
func()
in internal/frontend/search.go
88 17 1
func()
in internal/worker/fetch.go
88 14 1
func()
in internal/worker/pages.go
88 9 1