Skip to content

Releases: JordanCoin/crap4swift

v0.1.1

Choose a tag to compare

@JordanCoin JordanCoin released this 29 Jul 13:14

crap4swift v0.1.1 — a maintenance release, driven by the tool auditing itself.

crap4swift flagged its own main() at CRAP 1482 (cyclomatic complexity 38, untested). So this release extracts the CLI's argument parsing (Options.parse) and source discovery (SourceFiles.discover) into the library and unit-tests them:

  • main() drops from CC 38 → 9
  • argument parsing goes from untested → 84% covered
  • No behavior changes — same flags, same output.

Also: README now leads with the one-command --spm usage and consolidates options into tables. 73 tests.

brew upgrade crap4swift    # or: brew install JordanCoin/tap/crap4swift

Universal (arm64 + x86_64) macOS binary attached. Full list: CHANGELOG.

v0.1.0 — crap4swift

Choose a tag to compare

@JordanCoin JordanCoin released this 29 Jul 01:50

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 interfaceswift test/llvm-cov (SPM, server-side) and Xcode xccov/.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 review fuses 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_request workflow (Linux) that posts a risk-map comment, uploads SARIF, and gates. Exit codes: 0 clean · 1 usage · 2 over threshold.

Install (macOS)

brew install JordanCoin/tap/crap4swift

Universal 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.