Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Using as a Library

big-code-analysis is published on crates.io as a Rust library. The CLI (bca) and REST server (bca-web) are both thin wrappers around the same public API, so anything they can do you can do directly from your own crate.

This section is task-oriented. For full type signatures and field docs, follow the rustdoc on docs.rs.

When to embed the library

Use the library instead of shelling out to bca when you want any of the following:

  • In-process analysis. Avoid spawning a subprocess per file when scoring thousands of files in a custom tool, IDE plugin, or static-analysis pipeline.
  • In-memory source. Score generated, pre-processed, or streamed source without writing it to disk first. See Analyzing in-memory source.
  • Selective walking. Drive a custom traversal over the FuncSpace tree to extract per-function metrics on your own schedule. See Walking FuncSpace results.
  • Custom output. Skip the bca serializers (JSON / YAML / TOML / CBOR in the CLI, CSV / SARIF / Checkstyle in the library’s output module) and emit your own format, such as a database row.

If you only want a Markdown quality report or a CI threshold gate, the bca CLI is faster to wire up.

Pages in this section

API stability

The library is on the 2.x line and ships under a written stability contract: the shape of the public API is held stable across patch and minor bumps, and breaking changes are reserved for the next major bump. Every example in this section compiles against the current published crate and is expected to keep compiling across 2.x without edits.

Metric values may still drift across minor bumps when a grammar pin moves or a metric definition is fixed; see STABILITY.md § What is stable in value for the carve-out. Each drift is called out in the changelog entry that introduces it.