v0.1.0 — crap4swift
crap4swift v0.1.0 — the first release of Change Risk Anti-Patterns for Swift.
Finds functions that are risky to change (complex and under-tested), and hands an AI reviewer a measured risk map instead of a blind diff.
CRAP(f) = CC(f)² · (1 − coverage(f))³ + CC(f)
What's in it
- Complexity via SwiftSyntax (SwiftLint-compatible rules) — result builders, macros, SwiftUI DSL parse exactly.
- Coverage from two worlds behind one interface —
swift test/llvm-cov(SPM, server-side) and Xcodexccov/.xcresult(iOS apps). - Two doors:
--spm <dir>and--xcodeproj <p> --scheme <s>run the tests themselves; or feed pre-generated coverage. - PR-native:
--changed <base>scopes to touched functions;--format reviewfuses CRAP + SwiftLint into agent-ready JSON. - Five formats:
human,json,review,sarif(GitHub Code Scanning),html(dashboard). - Regression gate:
--baseline+--fail-regression— fail only if a function got worse. - CI: a
pull_requestworkflow (Linux) that posts a risk-map comment, uploads SARIF, and gates. Exit codes:0clean ·1usage ·2over threshold.
Install (macOS)
brew install JordanCoin/tap/crap4swiftUniversal binary (arm64 + x86_64) attached below. Linux / from source: swift build -c release.
Credits
The CRAP metric is by Alberto Savoia & Bob Evans (crap4j, 2007). Inspired by unclebob/crap4java and minikin/cargo-crap.