Commit Graph
8 Commits
Author SHA1 Message Date
Cursor AgentandRobert C. Martin 7a0b1613f5 Document Swift region spans and the Mac llvm-cov commands.
The manual export no longer passes -format=json, finds llvm-cov with xcrun,
and looks for the test binary under swift build --show-bin-path. The region
shape is (start_line, end_line, count), and line_covered uses the innermost
region so a nested zero count leaves those lines uncovered.

Proved by reading the README against the commands and SwiftFile docstring.

Co-authored-by: Robert C. Martin <[email protected]>
2026-11-26 01:37:40 +00:00
Cursor AgentandRobert C. Martin ccbac08c2b Export llvm-cov against the Swift test executable.
The first sorted `*PackageTests` file is the Mach-O inside a .dSYM, and
the Linux executable is named `*PackageTests.xctest`, so llvm-cov was
pointed at debug info or at nothing. Paths under a `.dSYM` bundle are
skipped, and the `.xctest` file is accepted. One test expects the
Contents/MacOS executable when a dSYM is beside it; the other expects
the Linux file.

Co-authored-by: Robert C. Martin <[email protected]>
2026-11-26 00:03:03 +00:00
Cursor AgentandRobert C. Martin 95c17c42ab Name a Swift module after the workspace when both bundles exist.
Coverage already runs the .xcworkspace instead of the .xcodeproj beside
it, but the module name came from the project. A file next to
Proj.xcodeproj and Work.xcworkspace was Demo'd as Proj.ContentView.
The namer now checks the workspace first, and that test expects
Work.ContentView. A directory with only a project is unchanged.

Co-authored-by: Robert C. Martin <[email protected]>
2026-11-26 00:02:40 +00:00
Cursor AgentandRobert C. Martin ccbf312645 Skip Swift requirements that have no statements.
Protocol subscripts and `{ get set }` properties were scored as functions
even though they contain no executable body, unlike protocol methods.
The new test lists those requirements and a real subscript, and failed
until entries required a statements node. Accessor tests still pass.

Co-authored-by: Robert C. Martin <[email protected]>
2026-11-26 00:00:54 +00:00
Cursor AgentandRobert C. Martin 10c4e43f7b Add Swift function CRAP scores, coverage, and test discovery.
Swift packages and iOS apps had no per-function complexity or coverage join, so crapper could not write a .metrics/crap.edn entry that uml-viewer and mutator can attach to a function. The Swift reader scores top-level functions, methods, initializers, subscripts, computed properties, and closures bound with let or var. Nested closures stay inside the enclosing function. Decision points match the other languages: if, guard, loops, catch, ternary, each switch case, &&, ||, ??, and optional chaining.

Coverage reads llvm-cov JSON from swift test and xccov JSON from xcodebuild, joined on the file suffix and the function's line span. A package runs swift test --enable-code-coverage; an Xcode project runs xcodebuild and xcrun xccov view --report --json.

Proved by tests/test_swift.py against checked-in llvm-cov and xccov fixtures, the existing suite (174 passed), crapper with every function under CRAP 10, dryer with no duplicate at 0.8 or above, and mutator killing every mutant in the Swift reader.

Co-authored-by: Robert C. Martin <[email protected]>
2026-11-25 23:45:32 +00:00
Robert C. Martin c757ec79a6 Find Go coverage by module import path.
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.
2026-11-10 12:38:04 -06:00
Robert C. Martin f0cb973110 Count ?? and ?., Express handlers, and JavaScript files, and score missing coverage as 0%. 2026-10-03 08:49:10 -05:00
Robert C. Martin a4b5fc2aed Add a multi-language CRAP tool that writes .metrics/crap.edn for uml-viewer.
Score Clojure, Java, Go, TypeScript, Rust, and Python with each language's complexity rules and coverage report.
2026-09-30 08:21:44 -05:00