golang / build
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,788 units with 46,183 lines of code in units (73.6% of code).
    • 38 very long units (9,240 lines of code)
    • 113 long units (7,636 lines of code)
    • 410 medium size units (12,684 lines of code)
    • 603 small units (8,730 lines of code)
    • 1,624 very small units (7,893 lines of code)
20% | 16% | 27% | 18% | 17%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
go20% | 16% | 27% | 18% | 17%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
internal35% | 10% | 18% | 18% | 17%
cmd15% | 21% | 33% | 17% | 12%
dashboard68% | 0% | 7% | 9% | 14%
maintner9% | 18% | 23% | 21% | 26%
buildlet21% | 9% | 34% | 17% | 17%
devapp18% | 12% | 42% | 16% | 10%
version0% | 36% | 18% | 16% | 29%
vcs-test0% | 26% | 43% | 15% | 14%
gerrit0% | 10% | 22% | 31% | 34%
ROOT0% | 48% | 29% | 11% | 10%
kubernetes0% | 8% | 39% | 22% | 29%
repos0% | 48% | 20% | 22% | 8%
revdial0% | 0% | 55% | 24% | 20%
cloudfns0% | 0% | 50% | 40% | 8%
pargzip0% | 0% | 19% | 66% | 14%
env0% | 0% | 35% | 64% | 0%
buildenv0% | 0% | 0% | 39% | 61%
tarutil0% | 0% | 0% | 76% | 23%
livelog0% | 0% | 0% | 49% | 50%
types0% | 0% | 0% | 66% | 33%
autocertcache0% | 0% | 0% | 39% | 60%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
func init()
in internal/gophers/gophers.go
3079 1 0
func init()
in dashboard/builders.go
1139 78 0
func file_gomote_proto_init()
in internal/gomote/protos/gomote.pb.go
326 78 0
func()
in cmd/release/release.go
299 80 1
func push()
in cmd/gomote/push.go
233 54 1
func StartNewVM()
in buildlet/gce.go
196 36 5
func()
in maintner/github.go
175 54 1
func main()
in maintner/maintnerd/maintnerd.go
166 41 0
func main()
in cmd/debugnewvm/debugnewvm.go
155 38 0
func main()
in cmd/buildlet/stage0/stage0.go
148 39 0
func()
in cmd/coordinator/remote.go
143 20 1
func StartPod()
in buildlet/kube.go
142 19 5
func()
in cmd/coordinator/buildstatus.go
139 27 1
func SyncBuilds()
in internal/buildstats/buildstats.go
136 35 2
func handleExec()
in cmd/buildlet/buildlet.go
135 30 2
func newTrySet()
in cmd/coordinator/coordinator.go
135 31 1
func()
in maintner/gerrit.go
130 24 1
func()
in cmd/gopherstats/gopherstats.go
129 42 1
func main()
in cmd/coordinator/coordinator.go
127 27 0
func SyncSpans()
in internal/buildstats/buildstats.go
126 32 2