golang / go
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 33,498 units with 643,739 lines of code in units (65.3% of code).
    • 784 very long units (193,916 lines of code)
    • 1,461 long units (100,376 lines of code)
    • 4,890 medium size units (153,534 lines of code)
    • 6,968 small units (101,329 lines of code)
    • 19,395 very small units (94,584 lines of code)
30% | 15% | 23% | 15% | 14%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
go30% | 15% | 23% | 15% | 14%
js67% | 14% | 4% | 0% | 13%
py0% | 0% | 21% | 30% | 49%
pl0% | 0% | 19% | 41% | 38%
c0% | 0% | 0% | 0% | 100%
h0% | 0% | 0% | 0% | 100%
cc0% | 0% | 0% | 0% | 100%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
src/cmd43% | 16% | 22% | 10% | 7%
src/crypto25% | 18% | 26% | 15% | 13%
src/go21% | 19% | 26% | 16% | 15%
src/runtime7% | 17% | 30% | 18% | 25%
src/net8% | 15% | 30% | 22% | 23%
src/html50% | 6% | 24% | 9% | 9%
src/encoding16% | 17% | 26% | 20% | 19%
src/internal12% | 16% | 30% | 18% | 21%
src/debug26% | 21% | 24% | 12% | 13%
src/image20% | 18% | 25% | 20% | 15%
src/syscall2% | 1% | 6% | 42% | 46%
src/reflect20% | 14% | 25% | 19% | 20%
src/regexp19% | 14% | 32% | 17% | 16%
src/time22% | 12% | 30% | 16% | 18%
src/testing16% | 22% | 24% | 18% | 18%
src/math6% | 23% | 31% | 19% | 19%
src/fmt18% | 16% | 24% | 24% | 15%
src/compress12% | 23% | 33% | 15% | 14%
src/archive13% | 12% | 35% | 19% | 18%
misc/wasm74% | 15% | 0% | 0% | 10%
src/database9% | 10% | 35% | 22% | 22%
src/strconv8% | 33% | 35% | 11% | 10%
src/text0% | 16% | 27% | 24% | 30%
src/os0% | 10% | 37% | 23% | 29%
src/path0% | 30% | 34% | 16% | 18%
src/mime0% | 22% | 39% | 15% | 23%
src/sort0% | 46% | 14% | 20% | 19%
src/bytes0% | 16% | 29% | 30% | 22%
misc/android0% | 62% | 23% | 4% | 9%
src/strings0% | 8% | 47% | 22% | 21%
src/bufio0% | 11% | 46% | 24% | 17%
src/plugin0% | 81% | 0% | 0% | 18%
src/index0% | 4% | 71% | 14% | 9%
src/flag0% | 12% | 18% | 7% | 62%
src/sync0% | 6% | 49% | 24% | 18%
src/log0% | 12% | 18% | 16% | 52%
misc/ios0% | 0% | 71% | 19% | 9%
src/unicode0% | 0% | 60% | 14% | 25%
src/io0% | 0% | 29% | 34% | 36%
src/hash0% | 0% | 17% | 33% | 48%
src/context0% | 0% | 40% | 23% | 35%
misc/linkcheck0% | 0% | 56% | 26% | 16%
src/errors0% | 0% | 43% | 29% | 26%
misc/chrome0% | 0% | 53% | 0% | 46%
src/embed0% | 0% | 12% | 65% | 21%
misc/cgo0% | 0% | 7% | 28% | 63%
src/expvar0% | 0% | 0% | 34% | 65%
src/container0% | 0% | 0% | 26% | 73%
src/builtin0% | 0% | 0% | 100% | 0%
misc/swig0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
func rewriteBlockARM()
in src/cmd/compile/internal/ssa/rewriteARM.go
4892 975 1
func rewriteBlockARM64()
in src/cmd/compile/internal/ssa/rewriteARM64.go
2489 499 1
func populateMaps()
in src/html/entity.go
2235 1 0
func()
in src/cmd/internal/obj/arm64/asm7.go
2042 580 1
func rewriteValueARM64_OpARM64OR()
in src/cmd/compile/internal/ssa/rewriteARM64.go
1947 949 1
func rewriteValueARM64_OpARM64ORshiftLL()
in src/cmd/compile/internal/ssa/rewriteARM64.go
1589 728 1
func rewriteBlockS390X()
in src/cmd/compile/internal/ssa/rewriteS390X.go
1583 438 1
func()
in src/cmd/internal/obj/s390x/asmz.go
1473 479 1
func rewriteValuePPC64_OpPPC64OR()
in src/cmd/compile/internal/ssa/rewritePPC64.go
1458 669 1
func rewriteValueARM64_OpARM64MOVBstore()
in src/cmd/compile/internal/ssa/rewriteARM64.go
1399 622 1
func rewriteValueAMD64_OpAMD64ORQ()
in src/cmd/compile/internal/ssa/rewriteAMD64.go
1398 529 1
func rewriteValueAMD64_OpAMD64ORL()
in src/cmd/compile/internal/ssa/rewriteAMD64.go
1276 487 1
func ssaGenValue()
in src/cmd/compile/internal/ppc64/ssa.go
1270 140 2
func rewriteValuegeneric_OpMove()
in src/cmd/compile/internal/ssa/rewritegeneric.go
1264 322 1
func rewriteValuegeneric_OpAndB()
in src/cmd/compile/internal/ssa/rewritegeneric.go
1222 273 1
func rewriteValuegeneric_OpOrB()
in src/cmd/compile/internal/ssa/rewritegeneric.go
1222 273 1
func rewriteBlockAMD64()
in src/cmd/compile/internal/ssa/rewriteAMD64.go
1191 276 1
func rewriteValueAMD64()
in src/cmd/compile/internal/ssa/rewriteAMD64.go
1166 528 1
func rewriteValueARM64()
in src/cmd/compile/internal/ssa/rewriteARM64.go
1125 492 1
func rewriteValueAMD64_OpAMD64MOVBstore()
in src/cmd/compile/internal/ssa/rewriteAMD64.go
1075 441 1