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

ライブラリとしての利用

big-code-analysis は Rust ライブラリとして crates.io に公開されています。CLI(bca)と REST サーバー(bca-web)はどちらも同じ公開 API の薄いラッパーなので、それらにできることはすべて自分のクレートから直接行えます。

このセクションはタスク指向です。完全な型シグネチャとフィールドのドキュメントは docs.rs の rustdoc を参照してください。

ライブラリを組み込むべきとき

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.
  • インメモリソース。 生成された、前処理済みの、あるいはストリーミングされたソースを、先にディスクへ書き出すことなくスコアリングします。インメモリソースの分析を参照してください。
  • 選択的な走査。 FuncSpace ツリーを独自に走査し、関数ごとのメトリクスを任意のタイミングで抽出します。FuncSpace 結果の走査を参照してください。
  • 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

このライブラリは 2.x 系にあり、明文化された安定性契約のもとで提供されています。公開 API の形状はパッチおよびマイナーバンプの間で安定に保たれ、破壊的変更は次のメジャーバンプまで保留されます。このセクションのすべての例は現在公開中のクレートに対してコンパイルでき、2.x の間は修正なしでコンパイルできることが期待されます。

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.