Skip to main content

Tool to compute and export code metrics

Project description

mehen

mehen is a Rust-powered CLI for detecting heuristic source code metrics at scale: complexity, maintainability, lines of code, and more.

It is designed for fast, deterministic analysis over large codebases, helping both human and AI engineers track how complexity evolves over time.

What is Mehen?

In Ophidiarium projects, names matter.

Mehen is a mythical ancient Egyptian serpent associated with guarding Ra. In the same spirit, mehen helps guard your codebase from slowly collapsing under complexity.

Why Teams Use Mehen

Most common usage patterns we see:

  • CI jobs that compute metrics for changed files and publish trend reports
  • Pre-PR / pre-CR hooks that provide immediate quality feedback
  • Automation workflows that enrich pull request templates with a glance view of metric deltas

Current Language Support

Today mehen supports:

  • Python
  • TypeScript
  • TSX
  • Rust
  • Go
  • Ruby
  • Kotlin
  • PowerShell

Planned next: Zig, Starlark and PHP.

A dedicated research effort is underway to expand support to Markdown documentation, with metrics like readability and structural complexity.

We also providing comprehensive support for polyglot monorepos, with per-file language detection and reporting.

What Mehen Computes

mehen provides a broad metric set, including:

  • Cyclomatic complexity
  • Cognitive complexity
  • Maintainability Index
  • Halstead metrics
  • ABC metrics
  • NArgs / NOM / NExit
  • LOC family (SLOC, PLOC, LLOC, CLOC, blanks)
  • NPA / NPM / WMC

Distribution

mehen ships native binaries through both ecosystems:

  • npm (mehen + platform packages)
  • PyPI (mehen via maturin binary packaging)

Quick Start

Run without installation

From npm ecosystem:

bunx mehen --help

From Python/uv ecosystem:

uv tool run mehen --help
# or
uvx mehen --help

Run locally from source

cargo run -- --help

Typical examples

Analyze metrics for a directory:

mehen -m -p src

Export metrics as JSON/TOML/YAML/CBOR:

mehen -m -p src -O json -o ./metrics

GitHub Actions

Use the in-repository action to publish changed-file metric trends on pull requests:

permissions:
  contents: read
  pull-requests: write
  issues: write

steps:
  - uses: actions/checkout@v5
    with:
      fetch-depth: 0

  - uses: ophidiarium/mehen@v1
    with:
      paths: src

For polyglot monorepos, pass each root you want tracked. mehen will analyze only supported languages in changed files under those roots:

- uses: ophidiarium/mehen@v1
  with:
    paths: |
      crates/api/src
      apps/web/src
      tools
    thresholds: |
      cyclomatic=5
      cognitive=4
      loc.lloc=120

Thresholds are optional. When configured, the action fails if an adverse per-file metric delta exceeds the configured limit.

Reporting and Integrations

Current machine-readable outputs:

  • JSON
  • YAML
  • TOML
  • CBOR

Roadmap direction:

  • Native git integration for changed-file detection
  • Rich markdown reports for AI/human review flows
  • More polished console reporting for local developer loops

Implementation Notes

Internally, mehen is built on:

mehen continues in its own CLI-focused direction while preserving and evolving that foundation.

Development

Build and check:

cargo check
cargo build
cargo fmt --all
cargo clippy --all-targets --all-features --locked

Tests:

cargo test --all-targets --locked

Snapshot tests (insta):

cargo insta test --all-features --check --unreferenced reject --test-runner nextest --no-test-runner-fallback --disable-nextest-doctest

See mehen-book/src/developers/ for developer docs, including language and grammar updates.

Contributing

Contributions are welcome via issues and pull requests:

License

mehen is released under the Mozilla Public License v2.0.

Project details


Download files

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

Source Distribution

mehen-0.4.0.tar.gz (4.0 MB view details)

Uploaded Source

Built Distributions

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

mehen-0.4.0-py3-none-win_arm64.whl (3.7 MB view details)

Uploaded Python 3Windows ARM64

mehen-0.4.0-py3-none-win_amd64.whl (3.9 MB view details)

Uploaded Python 3Windows x86-64

mehen-0.4.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.0 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

mehen-0.4.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.8 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

mehen-0.4.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl (4.1 MB view details)

Uploaded Python 3manylinux: glibc 2.5+ x86-64

mehen-0.4.0-py3-none-macosx_11_0_arm64.whl (3.8 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

mehen-0.4.0-py3-none-macosx_10_12_x86_64.whl (3.9 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

Details for the file mehen-0.4.0.tar.gz.

File metadata

  • Download URL: mehen-0.4.0.tar.gz
  • Upload date:
  • Size: 4.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mehen-0.4.0.tar.gz
Algorithm Hash digest
SHA256 dea97a78fe6afd808415174c02ce3496d5de301d168a7efb9f47353dac07c6bc
MD5 290e3665e894e3941b792501aa4d571b
BLAKE2b-256 d441ee371cd1f49f305a7d6e31c1e3635624331345dd525af524f865f2c6b590

See more details on using hashes here.

Provenance

The following attestation bundles were made for mehen-0.4.0.tar.gz:

Publisher: release.yml on ophidiarium/mehen

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

File details

Details for the file mehen-0.4.0-py3-none-win_arm64.whl.

File metadata

  • Download URL: mehen-0.4.0-py3-none-win_arm64.whl
  • Upload date:
  • Size: 3.7 MB
  • Tags: Python 3, Windows ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mehen-0.4.0-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 606e5798dfff4f7780067bee5a0c3c658673c29fe7d27aeb2a6c11e4a9550f42
MD5 f1e17e48b754c851fa137c946dc47090
BLAKE2b-256 bc5c4f26e47361ad83a1a41da3bc71a5f693526decfc080a1b7d3de95401b1e8

See more details on using hashes here.

Provenance

The following attestation bundles were made for mehen-0.4.0-py3-none-win_arm64.whl:

Publisher: release.yml on ophidiarium/mehen

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

File details

Details for the file mehen-0.4.0-py3-none-win_amd64.whl.

File metadata

  • Download URL: mehen-0.4.0-py3-none-win_amd64.whl
  • Upload date:
  • Size: 3.9 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mehen-0.4.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 8c755867e6627667668863a897cd0740eef51aa871625db28354ab113164ac4f
MD5 a2d48223e14afb5c23a126ffc0e81993
BLAKE2b-256 152e4a0a5392e7f358b68d675b5d5dd7a66a05e5cb2cdace870cb307cec1c4ed

See more details on using hashes here.

Provenance

The following attestation bundles were made for mehen-0.4.0-py3-none-win_amd64.whl:

Publisher: release.yml on ophidiarium/mehen

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

File details

Details for the file mehen-0.4.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mehen-0.4.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 645fbb2928ad47be82236a8868bc62b9c1f2960827ca9165dbe39570f3a5ead3
MD5 ce595754a0bfa033eb237e7e9dcbcff4
BLAKE2b-256 cf1648d04ac62267265d153303a2962d8022ab3dd3a54ef90c14d978b1c744b7

See more details on using hashes here.

Provenance

The following attestation bundles were made for mehen-0.4.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on ophidiarium/mehen

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

File details

Details for the file mehen-0.4.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for mehen-0.4.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 8332d23680003231d98322e7ccc9642cd21a8720c27546861d815906763dd9a6
MD5 8b97e29445a3012f1191fa9571d36166
BLAKE2b-256 9ad0ee7f08dafb5a6b7219e2bae458d321032b49dda3cb36f4e2677394b0cd02

See more details on using hashes here.

Provenance

The following attestation bundles were made for mehen-0.4.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on ophidiarium/mehen

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

File details

Details for the file mehen-0.4.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for mehen-0.4.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 a04fd6ff160e5532084c171f615754cba0cb13f0e9eec9e02d1c14df54c14517
MD5 c4db5dba7aa2583536ffe3fea03b258d
BLAKE2b-256 2e8e6b39b67adc22243db1773b5d9ca47dbf2065e69b315b05ebcf8c988f8bb6

See more details on using hashes here.

Provenance

The following attestation bundles were made for mehen-0.4.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl:

Publisher: release.yml on ophidiarium/mehen

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

File details

Details for the file mehen-0.4.0-py3-none-macosx_11_0_arm64.whl.

File metadata

  • Download URL: mehen-0.4.0-py3-none-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 3.8 MB
  • Tags: Python 3, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mehen-0.4.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 dc482da87a4fce89d87ad2e5ce8e0a71ec5da65a323cafed7e3c3f91367a3bd7
MD5 309174242b197e0bfa66cc1d3835e080
BLAKE2b-256 8e996ac22ab2ef4e1726272699b9568f1fbf53ba65294d9e548b2be69d231224

See more details on using hashes here.

Provenance

The following attestation bundles were made for mehen-0.4.0-py3-none-macosx_11_0_arm64.whl:

Publisher: release.yml on ophidiarium/mehen

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

File details

Details for the file mehen-0.4.0-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for mehen-0.4.0-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 c2f54885fe32a12debb03ae95c709670d679e8ffd397acfa50c4b17b55903a1f
MD5 f7fbecdb6dfa1ddd5c9c8f69d128fd59
BLAKE2b-256 5fb5820ca07ab49facb5dbce0ff302069841a0c26960a684274e1ba9e0c9357e

See more details on using hashes here.

Provenance

The following attestation bundles were made for mehen-0.4.0-py3-none-macosx_10_12_x86_64.whl:

Publisher: release.yml on ophidiarium/mehen

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

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page