Skip to main content

Metrolith

PyPI Build & smoke License: Apache-2.0

Evidence, not scores.

Metrolith is a local-first, multi-language static-analysis CLI. It produces versioned code metrics and offline reports so you can investigate a source tree, inspect complex functions, and compare changes between revisions. Optional duplication and history analyses provide additional evidence; you choose which analyses and rules to run.

Inspect what was measured, what was excluded, and where results are partial or unavailable before deciding what to change.

Languages: Python, Java, JavaScript/TypeScript and Go. Parsing and measurement coverage are language-specific.

Try online · Explore a recorded demo · Install from PyPI · Read the guide

Three questions to start with

  • What is in this source tree? Inspect languages, files, code size, classes/structs and methods/functions alongside inclusion reasons and explicit measurement coverage.
  • Where should I look more closely? Read callable complexity, then request lexical or structural duplication evidence separately. Their populations can overlap; their group counts are not a combined defect total.
  • What changed between revisions? Use revision Diff or existing-Run comparisons, and Changed Code for explicit base/head revisions. Evaluate a Policy of rules you select; measurements do not infer architecture quality.

For how these pieces fit together, see Architecture.

Quickstart from PyPI

Install in a fresh virtual environment, check the environment, then run a tiny bundled example. CPython 3.13 is required (>=3.13,<3.14); 3.13.9 is the verified patch on Windows and Ubuntu. Git must be on PATH, including for local directory snapshots. Your analyzed directory need not be a Git repository.

Start in an empty working directory outside your project's source. Use an unused metrolith-user environment directory. Installation can download dependencies; the bundled local example is network-free afterward.

PowerShellpython must resolve to CPython 3.13:

python --version
git --version
python -m venv "metrolith-user"
& "./metrolith-user/Scripts/python.exe" -m pip install "metrolith==4.0.0"
$env:PATH = "$((Resolve-Path './metrolith-user/Scripts').Path);$env:PATH"
metrolith doctor --format text
metrolith example run --local

Ubuntu / POSIX shell:

python3.13 --version
git --version
python3.13 -m venv "metrolith-user"
"./metrolith-user/bin/python" -m pip install "metrolith==4.0.0"
. "./metrolith-user/bin/activate"
metrolith doctor --format text
metrolith example run --local

Stop if a prerequisite check or installation fails. PowerShell changes PATH only for this session; no execution-policy change is needed.

With published Metrolith 4.0.0, the bundled example measures 22 code lines, 2 source files, 0 classes/structs and 4 methods/functions, with complete core metrics. Zero classes is a measured result. The Run path printed by example run --local belongs to this example; open its summary.md to inspect these values.

Next, in the same configured shell, change to your project's source directory and run:

metrolith analyze . --workspace "../metrolith-results"

Choose an output workspace outside the analyzed source. This command prints a new Run directory for your project under WORKSPACE/metrolith-output/runs/. metrolith analyze . also works; its default workspace is METROLITH_HOME or the current directory. Analysis reads source and writes outputs/cache state in the workspace. See source modes and locations.

Read your first Run

Open summary.md in the Run directory for the source you want to inspect. Each invocation prints its own path; use your project's path when reading your project.

Replace RUN below with the printed directory, keeping quotes:

metrolith report "RUN"
metrolith explain "RUN"
metrolith validate "RUN"

report writes the derived offline view at RUN/report.html; open it in a browser. explain describes recorded scope and availability. validate checks required artifacts and cross-file consistency; it does not rerun analysis or prove source authenticity. Keep the Run's JSON/CSV evidence and fact sheets with the report.

Completion does not mean every measurement is complete. Read partial, unavailable, not requested, and not applicable separately from measured zero. Optional analyses are not all executed by analyze.

Evidence and boundaries

Directory snapshots, working snapshots and exact Git revisions record different source identities. A working snapshot is not proof of committed bytes. A Policy contains your rules; a Ratchet compares selected measurements with a retained baseline and chosen tolerances. Neither supplies universal quality thresholds. Local PASS does not establish protected organizational approval.

pip install metrolith installs the CLI and offline reporting. The hosted Story/Explorer is a separate companion to the CLI's offline HTML report. Local source processing and the website's server-side repository processing have different privacy and feasibility boundaries; see the website guide.

Choose your next path

The deprecated archlens/arch-bench commands and frozen ArchLens format identifiers remain compatibility contracts.

License, citation and contact

Apache-2.0 · Software citation · Issues

Maintainer: Ali Sajedifarits.alisajedifar@gmail.com.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

metrolith-4.0.1.tar.gz (9.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

metrolith-4.0.1-py3-none-any.whl (1.0 MB view details)

Uploaded Python 3

File details

Details for the file metrolith-4.0.1.tar.gz.

File metadata

  • Download URL: metrolith-4.0.1.tar.gz
  • Upload date:
  • Size: 9.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for metrolith-4.0.1.tar.gz
Algorithm Hash digest
SHA256 002468f5663b019251e09ce8cdfb68242efd46520519c06f2ca1c73b2939ff7f
MD5 fcbd4291244f70997d757a2a6c270a44
BLAKE2b-256 fd3a029e9db4ec03b5a4e6167f3b23ce2345fd9ac852ec6f12a1b17a8506613d

See more details on using hashes here.

Provenance

The following attestation bundles were made for metrolith-4.0.1.tar.gz:

Publisher: publish-pypi.yml on AliSajedifar/metrolith

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file metrolith-4.0.1-py3-none-any.whl.

File metadata

  • Download URL: metrolith-4.0.1-py3-none-any.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for metrolith-4.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f4e62135b24aa1c3a932776844e960a76e66b10133f16af3570980f8fe29172d
MD5 e9bcf74ea7da07d795369293bbb07610
BLAKE2b-256 d1487a8c0b329fb5fb4c6eccbf6b9823aba152b1866100eecdcb70b2967117b9

See more details on using hashes here.

Provenance

The following attestation bundles were made for metrolith-4.0.1-py3-none-any.whl:

Publisher: publish-pypi.yml on AliSajedifar/metrolith

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

4.0.1 This release

2 files

4.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page