big-code-analysis 1.1.0

Tool to compute and export code metrics
Documentation
[workspace]
resolver = "3"
members = [
  "big-code-analysis-cli",
  "big-code-analysis-py",
  "big-code-analysis-web",
  "xtask",
]
# `xtask` and `big-code-analysis-py` are intentionally excluded from
# `default-members`. `xtask` is a build-time helper that renders man
# pages from the live clap definitions (see `xtask/src/main.rs` and
# `man/`); `big-code-analysis-py` is a PyO3 cdylib that requires
# Python headers and is built via `maturin`, not pure cargo. Both
# build cleanly under `cargo build --workspace`, but a bare
# `cargo build` at the repo root should not pull in artefacts that
# have no shipping counterpart in a Rust-only build.
default-members = [".", "big-code-analysis-cli", "big-code-analysis-web"]
exclude = [
  "enums",
  "tree-sitter-ccomment",
  "tree-sitter-mozcpp",
  "tree-sitter-mozjs",
  "tree-sitter-preproc",
  "tree-sitter-tcl",
]

[workspace.package]
version = "1.1.0"
edition = "2024"
rust-version = "1.94"
license = "MPL-2.0"
repository = "https://github.com/dekobon/big-code-analysis"
authors = [
  "Calixte Denizet <cdenizet@mozilla.com>",
  "Elijah Zupancic <elijah@zupancic.name>",
]

# Pins below mirror enums/Cargo.toml. The `enums` crate is excluded from
# this workspace (see [workspace].exclude above) and cannot inherit these
# entries via `.workspace = true`, so any grammar bump here MUST be
# applied to enums/Cargo.toml in lockstep (see recreate-grammars.sh).
[workspace.dependencies]
tree-sitter = "=0.26.9"
tree-sitter-bash = "=0.25.1"
tree-sitter-c-sharp = "=0.23.5"
tree-sitter-elixir = "=0.3.5"
tree-sitter-go = "=0.25.0"
dekobon-tree-sitter-groovy = "=0.2.0"
tree-sitter-java = "=0.23.5"
tree-sitter-javascript = "=0.25.0"
tree-sitter-kotlin-ng = "1.1.0"
tree-sitter-lua = "=0.5.0"
tree-sitter-perl = "=1.1.2"
tree-sitter-php = "=0.24.2"
tree-sitter-python = "=0.25.0"
tree-sitter-ruby = "=0.23.1"
tree-sitter-rust = "=0.24.2"
tree-sitter-typescript = "=0.23.2"
# Vendored grammar forks. Each is published under a `bca-tree-sitter-*`
# package name (so we do not collide with the upstream Mozilla / community
# crates on crates.io), but the produced Rust crate keeps its original
# `tree_sitter_<lang>` import path via `[lib] name = ...` in the leaf
# manifest. Cargo's `package = ...` alias here means consumer code that
# pulls in the dep as `tree-sitter-<lang>` continues to work unchanged.
# Rationale and the rejected alternatives live on the umbrella
# issue (dekobon/big-code-analysis#149); the operational details
# (publish order, first-bootstrap workflow) live in `RELEASING.md`.
tree-sitter-ccomment = { package = "bca-tree-sitter-ccomment", path = "./tree-sitter-ccomment", version = "=1.1.0" }
tree-sitter-mozcpp = { package = "bca-tree-sitter-mozcpp", path = "./tree-sitter-mozcpp", version = "=1.1.0" }
tree-sitter-mozjs = { package = "bca-tree-sitter-mozjs", path = "./tree-sitter-mozjs", version = "=1.1.0" }
tree-sitter-preproc = { package = "bca-tree-sitter-preproc", path = "./tree-sitter-preproc", version = "=1.1.0" }
tree-sitter-tcl = { package = "bca-tree-sitter-tcl", path = "./tree-sitter-tcl", version = "=1.1.0" }

# PyO3 powers the `big-code-analysis-py` cdylib. Pinned to a major
# series; bumping is a deliberate, separate change because the Bound
# API shape changed across minors.
pyo3 = "=0.28.3"
serde = { version = "^1.0", features = ["derive"] }
serde_json = "^1.0"

# Workspace-wide lint posture. The allow set is intentionally minimal
# — additional allows go at file or function level so the carve-out
# stays visible at the affected site rather than weakening the whole
# workspace.
[workspace.lints.rust]
missing_docs = "warn"

[workspace.lints.clippy]
pedantic = { level = "warn", priority = -1 }
module_name_repetitions = "allow"

[package]
name = "big-code-analysis"
version.workspace = true
authors.workspace = true
edition.workspace = true
rust-version.workspace = true
repository.workspace = true
license.workspace = true
documentation = "https://docs.rs/big-code-analysis/"
readme = "README.md"
keywords = ["metrics"]
description = "Tool to compute and export code metrics"
# Whitelist what ends up in the published .crate. Without this,
# cargo picks up the entire repo — including tests/repositories/
# (30k+ files of real-world corpora used for snapshot tests, ~130
# MiB compressed) and the mdBook source. None of that is needed by
# downstream consumers.
include = [
  "/src/**/*",
  "/Cargo.toml",
  "/README.md",
  "/LICENSE",
  "/CHANGELOG.md",
]

[dependencies]
aho-corasick = "^1.0"
crossbeam = { version = "^0.8", features = ["crossbeam-channel"] }
csv = "=1.4.0"
globset = "^0.4"
num = "^0.4"
num-derive = "^0.4"
num-format = "^0.4"
num-traits = "^0.2"
petgraph = "^0.8"
regex = "^1.7"
serde.workspace = true
serde_json.workspace = true
termcolor = "^1.2"
walkdir = "^2.3"

tree-sitter.workspace = true
# Grammar crates are gated behind per-language Cargo features (see
# `[features]` below). The default feature set `all-languages` enables
# every grammar so a bare `cargo build` matches the historical
# behaviour; consumers that only need a subset of languages can opt
# into a narrower set with `--no-default-features --features rust,…`.
tree-sitter-bash = { workspace = true, optional = true }
tree-sitter-c-sharp = { workspace = true, optional = true }
tree-sitter-elixir = { workspace = true, optional = true }
tree-sitter-go = { workspace = true, optional = true }
dekobon-tree-sitter-groovy = { workspace = true, optional = true }
tree-sitter-java = { workspace = true, optional = true }
tree-sitter-javascript = { workspace = true, optional = true }
tree-sitter-kotlin-ng = { workspace = true, optional = true }
tree-sitter-lua = { workspace = true, optional = true }
tree-sitter-perl = { workspace = true, optional = true }
tree-sitter-php = { workspace = true, optional = true }
tree-sitter-python = { workspace = true, optional = true }
tree-sitter-ruby = { workspace = true, optional = true }
tree-sitter-rust = { workspace = true, optional = true }
tree-sitter-typescript = { workspace = true, optional = true }
tree-sitter-ccomment = { workspace = true, optional = true }
tree-sitter-mozcpp = { workspace = true, optional = true }
tree-sitter-mozjs = { workspace = true, optional = true }
tree-sitter-preproc = { workspace = true, optional = true }
tree-sitter-tcl = { workspace = true, optional = true }

# Per-language Cargo features. `default = ["all-languages"]` keeps the
# library's historical "every grammar compiled in" behaviour for
# callers that take the crate as a black box (the CLI and web crates
# pin to `features = ["all-languages"]` for exactly this reason).
#
# Each language feature pulls in only the grammar crate(s) the
# matching `src/languages/language_*.rs` module needs at runtime — the
# token enums themselves carry no grammar-crate references and stay
# unconditionally compiled, so the `LANG` enum, the per-language
# `*Code` / `*Parser` tags, and the `Tree::new` / `analyze` dispatch
# surface remain identical across feature sets. Disabling a feature
# strips the grammar crate from the dep graph; calling into a
# disabled variant produces `Err(MetricsError::LanguageDisabled(LANG))`
# from every entry point that returns a `Result`.
#
# `cpp` shares grammar crates with `mozcpp` (`tree-sitter-mozcpp`,
# `tree-sitter-ccomment`, `tree-sitter-preproc`); listing the deps on
# both leaves their union enabled when either feature is on.
[features]
default = ["all-languages"]
all-languages = [
  "bash",
  "cpp",
  "csharp",
  "elixir",
  "go",
  "groovy",
  "java",
  "javascript",
  "kotlin",
  "lua",
  "mozjs",
  "perl",
  "php",
  "python",
  "ruby",
  "rust",
  "tcl",
  "typescript",
]
bash = ["dep:tree-sitter-bash"]
# The `Cpp` LANG variant uses `tree-sitter-mozcpp` as its grammar
# (see `get_language!(tree_sitter_cpp)` in `src/macros.rs`); the
# `Ccomment` and `Preproc` LANG variants share the `cpp` feature
# because they are internal helpers for the C/C++ pipeline. There
# is no standalone `mozcpp` feature because no LANG variant rides
# it independently of `cpp` — adding one would be a SemVer break
# documented in the changelog.
cpp = [
  "dep:tree-sitter-mozcpp",
  "dep:tree-sitter-ccomment",
  "dep:tree-sitter-preproc",
]
csharp = ["dep:tree-sitter-c-sharp"]
elixir = ["dep:tree-sitter-elixir"]
go = ["dep:tree-sitter-go"]
groovy = ["dep:dekobon-tree-sitter-groovy"]
java = ["dep:tree-sitter-java"]
javascript = ["dep:tree-sitter-javascript"]
kotlin = ["dep:tree-sitter-kotlin-ng"]
lua = ["dep:tree-sitter-lua"]
mozjs = ["dep:tree-sitter-mozjs"]
perl = ["dep:tree-sitter-perl"]
php = ["dep:tree-sitter-php"]
python = ["dep:tree-sitter-python"]
ruby = ["dep:tree-sitter-ruby"]
rust = ["dep:tree-sitter-rust"]
tcl = ["dep:tree-sitter-tcl"]
typescript = ["dep:tree-sitter-typescript"]

[lints]
workspace = true

[dev-dependencies]
insta = { version = "1.29.0", features = ["yaml", "json", "redactions"] }
jsonschema = "^0.46"
tempfile = "^3.0"
pretty_assertions = "^1.3"
quick-xml = "^0.39"

[profile.dev.package.insta]
opt-level = 3

[profile.dev.package.similar]
opt-level = 3

[profile.release]
opt-level = 3
debug = "line-tables-only"
rpath = false
lto = true
debug-assertions = false
codegen-units = 1
panic = "unwind"
incremental = false
overflow-checks = false