mirror of
https://github.com/unclebob/crapper.git
synced 2026-11-12 04:13:49 +00:00
Why: `go test -coverprofile` names each file by its module import path. crapper found it only by path suffix, which works when the module path happens to end with the project-relative path. A module in a subdirectory whose name differs from its directory (`svc/go.mod` declaring `module example.com/api`) scored 0% for every function. What: `go_import_name` builds the profile's name for a file from the nearest go.mod's module line and the path inside the module. The bundle remembers its root and looks a Go file up by that name first, then by the old suffix match. `_nearest` becomes the shared `nearest_marker` so coverage and the runners find go.mod the same way. mutator uses `go_import_name` so the two tools cannot drift. Proof: three new coverage specs (nested module with a different name, quoted module path, fallback without a module line) failed first, now pass; 147 pass, the 2 bb/uml environment failures are unchanged. crapper on changed code: max CRAP 9.0 (percent_for, unchanged), new functions <= 7.0. dryer: no candidates in changed files. mutator on the changed lines: 13/13 killed.