tsmetrics

A fast, tree-sitter-powered TypeScript static analyzer written in Rust. Point it at your codebase and get 25+ actionable metrics in seconds.

Rust TypeScript / TSX tree-sitter Parallel MIT

Quick Start

# Option A — npm (no Rust required)
npx tsmetrics analyze ./src

# Option B — cargo (from source)
git clone https://github.com/gabrielrf97/tsmetrics && cd tsmetrics && cargo install --path .

# Run an analysis
tsmetrics analyze ./src

# Export a self-contained HTML report
tsmetrics analyze ./src --format html > report.html

What is tsmetrics?

tsmetrics (TypeScript Static Analyzer) parses TypeScript and TSX files using tree-sitter and computes a comprehensive set of software quality metrics. It is written in Rust and designed for speed, correctness, and scriptability.

Metrics are grouped into five categories:

It also detects four object-oriented design smells inspired by Object-Oriented Metrics in Practice (Lanza & Marinescu): God Class, Brain Method, Feature Envy, and Refused Bequest.

Features

Fast

Files processed in parallel using Rayon. Handles large codebases without breaking a sweat.

🎯

Accurate

Built on tree-sitter's full AST — no regex heuristics. Handles generics, decorators, and TSX.

⚙️

Configurable

Override warning/error thresholds per metric via tsmetrics.yaml. Exclude paths you don't care about.

📤

Multiple Outputs

Table, JSON, CSV, and self-contained HTML report formats.

Edit on GitHub