kubernetes / kube-state-metrics
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 328 units with 7,174 lines of code in units (80.5% of code).
    • 16 very long units (2,908 lines of code)
    • 13 long units (950 lines of code)
    • 53 medium size units (1,338 lines of code)
    • 98 small units (1,292 lines of code)
    • 148 very small units (686 lines of code)
40% | 13% | 18% | 18% | 9%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
go40% | 13% | 18% | 18% | 9%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
internal/store46% | 13% | 19% | 14% | 5%
pkg/app58% | 0% | 29% | 7% | 3%
pkg/metricshandler0% | 44% | 15% | 29% | 10%
pkg/options0% | 24% | 16% | 21% | 37%
pkg/sharding0% | 0% | 41% | 42% | 16%
pkg/allow0% | 0% | 66% | 33% | 0%
pkg/metric0% | 0% | 34% | 42% | 22%
pkg/allowdenylist0% | 0% | 0% | 74% | 25%
pkg/metrics_store0% | 0% | 0% | 59% | 40%
pkg/watch0% | 0% | 0% | 84% | 16%
pkg/metric_generator0% | 0% | 0% | 36% | 63%
pkg/optin0% | 0% | 0% | 66% | 33%
pkg/util0% | 0% | 0% | 90% | 9%
ROOT0% | 0% | 0% | 100% | 0%
pkg/builder0% | 0% | 0% | 0% | 100%
pkg/version0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
func jobMetricFamilies()
in internal/store/job.go
312 22 2
func deploymentMetricFamilies()
in internal/store/deployment.go
257 8 2
func cronJobMetricFamilies()
in internal/store/cronjob.go
221 9 2
func statefulSetMetricFamilies()
in internal/store/statefulset.go
213 3 2
func hpaMetricFamilies()
in internal/store/horizontalpodautoscaler.go
212 16 2
func daemonSetMetricFamilies()
in internal/store/daemonset.go
210 2 2
func persistentVolumeMetricFamilies()
in internal/store/persistentvolume.go
207 16 2
func vpaMetricFamilies()
in internal/store/verticalpodautoscaler.go
195 23 2
func replicaSetMetricFamilies()
in internal/store/replicaset.go
188 7 2
func persistentVolumeClaimMetricFamilies()
in internal/store/persistentvolumeclaim.go
150 7 2
func ingressMetricFamilies()
in internal/store/ingress.go
133 9 2
func podDisruptionBudgetMetricFamilies()
in internal/store/poddisruptionbudget.go
132 2 2
func endpointMetricFamilies()
in internal/store/endpoint.go
131 6 2
func serviceMetricFamilies()
in internal/store/service.go
127 6 2
func RunKubeStateMetrics()
in pkg/app/server.go
118 10 3
func namespaceMetricFamilies()
in internal/store/namespace.go
102 5 2
func secretMetricFamilies()
in internal/store/secret.go
100 2 2
func networkPolicyMetricFamilies()
in internal/store/networkpolicy.go
91 1 2
func csrMetricFamilies()
in internal/store/certificatesigningrequest.go
87 2 2
func configMapMetricFamilies()
in internal/store/configmap.go
85 2 2