WMS bounded contexts · Supporting domain
returns-processing
Returns Processing bounded context (WMS): RMA, return receipt, grading and disposition; hands restockable goods to inventory-storage
Clean code
90%9 / 10 checks
| Check | Source | Target | Measured | Result |
|---|---|---|---|---|
| gofmt-clean tree | the fleet's own gate: `make fmt-check` fails when `gofmt -l .` prints anything | 0 files gofmt would rewrite | 0 files need formatting | pass |
| Small functions | measured: named function length in lines, tests and generated files excluded | <= 2% of named functions longer than 60 lines | 0.51% of 791 functions over 60 lines | pass |
| Flat control flow | measured: nested if/for/range/switch/select statements; a function literal resets the count | 0 functions with control flow nested deeper than 4 | deepest nesting 4 | pass |
| Small files | measured: non-test Go file line counts, generated files excluded | 0 non-test files over 800 lines | longest file 371 lines | pass |
| Documented API surface | measured: exported funcs, types, vars, consts without a doc comment | >= 90% of exported symbols carry a doc comment | 730 of 747 documented (98%) | pass |
| Idiomatic names | measured: exported identifiers containing underscores (scored); package stutter counted, never scored | 0 exported names with underscores | 0 underscore violations · 4 stutter counted, not scored | pass |
| No debt markers | measured: TODO/FIXME/HACK/XXX in comments of code files (AST comments in Go; comment-looking lines elsewhere), tests and fixtures excluded | 0 debt markers | 0 markers | pass |
| No copy-paste functions | measured: identical function bodies (whitespace and comments stripped) of 5+ lines | <= 2% of named functions are exact duplicates | 3.41% of 791 functions are copies | fail |
| Lint wired into the pipeline | counted: golangci-lint / eslint / terraform fmt / ruff / hadolint / actionlint in Makefiles, configs and CI workflows | the repository’s linter runs in CI or pre-commit, not only on a willing machine | golangci-lint · gofmt · fmt-check · go vet | pass |
| Pre-commit hygiene | counted: lefthook.yml with fmt/vet/lint (or equivalent) jobs | lefthook pre-commit runs the fast gates before a commit exists | lefthook (fmt-check, vet, lint, check) | pass |
Findings
- 3.41% of named functions are exact copies of another (27 duplicate bodies) — the classic Duplicated Code smell.
Evidence
Longest functions
cmd/api/main.go—run, 79 linescmd/returns-projector/main.go—run, 73 linescmd/api/main.go—serveUntilSignal, 68 linesinternal/adapters/outbound/telemetry/telemetry.go—Setup, 66 lines
Least-documented files
internal/adapters/kafka/cloudevents/cloudevents.go— 5 exported symbols without a doc commentinternal/adapters/outbound/retailnetwork/refusal_classes.go— 4 exported symbols without a doc commentinternal/adapters/outbound/telemetry/slogotel.go— 4 exported symbols without a doc commentinternal/adapters/inbound/http/idempotency.go— 3 exported symbols without a doc comment
Stuttering names (counted, not scored)
4 exported names repeat the package name, e.g. disposition.DispositionID, disposition.DispositionVersion, disposition.DispositionDecided, disposition.DispositionPolicy. Most are domain events whose names the CloudEvents grammar mandates.
Duplicate function bodies
- 9 identical lines in
internal/adapters/outbound/memory/memory.go#FindByID,internal/adapters/outbound/memory/memory.go#FindByID,internal/adapters/outbound/memory/memory.go#FindByID - 7 identical lines in
cmd/a2a/telemetry.go#loadTelemetryEnv,cmd/api/telemetry.go#loadTelemetryEnv,cmd/mcp/telemetry.go#loadTelemetryEnv,cmd/returns-projector/telemetry.go#loadTelemetryEnv - 6 identical lines in
internal/adapters/outbound/analyticsstore/postgres_projection.go#nullable,internal/adapters/outbound/postgres/rma_repository.go#nullString,internal/application/outbox/payload.go#nullable - 6 identical lines in
cmd/a2a/telemetry.go#orDefault,cmd/api/telemetry.go#orDefault,cmd/mcp/telemetry.go#orDefault,cmd/returns-projector/telemetry.go#orDefault - 6 identical lines in
cmd/api/logsafe.go#sanitizeErr,internal/adapters/outbound/postgres/logsafe.go#sanitizeErr - 6 identical lines in
internal/adapters/outbound/postgres/returns_advice.go#derefString,internal/adapters/outbound/postgres/rma_repository.go#stringOrNull
27 duplicate copies in total.
Wired gates
Makefile— golangci-lint, gofmt, fmt-check, go vet.golangci.yml— gofmtlefthook.yml— fmt-check.github/workflows/ci.yml— golangci-lint, go vet
Pre-commit hooks
lefthook: fmt-check · vet · lint · check