Releases: StrangeDaysTech/arborist
Releases · StrangeDaysTech/arborist
Arborist v0.1.0
Arborist v0.1.0
Multi-language code complexity metrics powered by tree-sitter.
Computes cognitive complexity (SonarSource), cyclomatic complexity (McCabe), and source lines of code (SLOC) for functions and methods — all from a single, embeddable Rust library.
Supported Languages (12)
| Tier | Languages | Feature flags |
|---|---|---|
| Tier 1 (default: ★) | Rust★, Python★, JavaScript★, TypeScript★, Java★, Go★, C#, C++, C, PHP | default = 6 most popular |
| Tier 2 | Kotlin, Swift | kotlin, swift |
features = ["all"] enables all 12 languages.
Highlights
- SonarSource-compliant cognitive complexity: nesting penalties, boolean operator sequences, flat else-if, lambda nesting, recursive call detection
- McCabe cyclomatic complexity: per-arm counting for match/switch constructs
- Feature-gated compilation: only compile the grammars you need
- JSON serialization:
FileReportandFunctionMetricsimplementSerialize/Deserialize - Configurable thresholds: flag functions exceeding a cognitive complexity limit
- 177 tests across all languages, clippy clean
Installation
[dependencies]
arborist = "0.1" # default: Rust, Python, JS, TS, Java, Go
arborist = { version = "0.1", features = ["all"] } # all 12 languagesQuick Example
use arborist::{analyze_file, FileReport};
let report: FileReport = analyze_file("src/main.rs")?;
for func in &report.functions {
println!("{}: cognitive={}, cyclomatic={}, sloc={}",
func.name, func.cognitive, func.cyclomatic, func.sloc);
}Known Limitations
- Recursion detection is not supported for Kotlin and Swift (their tree-sitter grammars lack a named field on call expression nodes)
- Halstead metrics are planned for v0.2.0