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 metric deltas

Current Language Support

Today mehen supports:

  • Python
  • TypeScript
  • TSX
  • Rust
  • Go
  • Ruby

Planned next: PHP.

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.2.0.tar.gz (3.3 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.2.0-py3-none-win_arm64.whl (3.0 MB view details)

Uploaded Python 3Windows ARM64

mehen-0.2.0-py3-none-win_amd64.whl (3.2 MB view details)

Uploaded Python 3Windows x86-64

mehen-0.2.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.3 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

mehen-0.2.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.2 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

mehen-0.2.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl (3.4 MB view details)

Uploaded Python 3manylinux: glibc 2.5+ x86-64

mehen-0.2.0-py3-none-macosx_11_0_arm64.whl (3.1 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

mehen-0.2.0-py3-none-macosx_10_12_x86_64.whl (3.2 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for mehen-0.2.0.tar.gz
Algorithm Hash digest
SHA256 b8364d25ef096e3122e677dd81a7c36f69245a79180e651023aa4f495953aa80
MD5 6aec94bdf3d0cfaf08bb565c4f6e30ff
BLAKE2b-256 9246c015b614f78320b4321b8985b2a997f39e7706c9131b45395ca03bf59eed

See more details on using hashes here.

Provenance

The following attestation bundles were made for mehen-0.2.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.2.0-py3-none-win_arm64.whl.

File metadata

  • Download URL: mehen-0.2.0-py3-none-win_arm64.whl
  • Upload date:
  • Size: 3.0 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.2.0-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 94a14e50154ba613631ebced5cb9a07c55346a6d924f6cafcc369a34fbc5ce09
MD5 dca9bf7df32da21e68f1e9cbeb774b91
BLAKE2b-256 f9f936151b79fd208330032fcf340248ef2335a131f4dc57795de935c030ba9f

See more details on using hashes here.

Provenance

The following attestation bundles were made for mehen-0.2.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.2.0-py3-none-win_amd64.whl.

File metadata

  • Download URL: mehen-0.2.0-py3-none-win_amd64.whl
  • Upload date:
  • Size: 3.2 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.2.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 baa40d082dde9227be09ff15a9d8e28c8977989f04219bb49a1a689ac030e7c5
MD5 d37ccc4fcc309ab6b96c04a2d380bc17
BLAKE2b-256 61bfb844548057862f92bdefb2c41e8832278ec36763fa40e0b1b635759e9eb5

See more details on using hashes here.

Provenance

The following attestation bundles were made for mehen-0.2.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.2.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mehen-0.2.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 70e4d6d64611c031493c2a4f21d7edf7af3b13d64ac1a816449dfc17c688dd4f
MD5 44f73e1c63dfcea0f6158fc345984009
BLAKE2b-256 d02f2d29456291d062e7772a938b8b598c861824ff42c0534bfdd66cfacf3342

See more details on using hashes here.

Provenance

The following attestation bundles were made for mehen-0.2.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.2.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for mehen-0.2.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 6ff30f215d18785b4524b0de9b9ff73718bcbb9c07e55d956573c76ff070a1c5
MD5 68c6090175bb79bac76382801184304c
BLAKE2b-256 b9dc17acdfbf7aeb37821386e0a1c66e19f3cd6ba25e3098681cf239d19d28db

See more details on using hashes here.

Provenance

The following attestation bundles were made for mehen-0.2.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.2.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for mehen-0.2.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 1d2e10a0cd35d47de7c327e7166a79982a8447f914ae7e2cc1043acbbfa193f5
MD5 28eeed4ecd8d1dac66458474eed99b52
BLAKE2b-256 64ed41acc88d5b12fdf3def8d5b7882c35acf2e5c79393140b776a0a4ec1ff5e

See more details on using hashes here.

Provenance

The following attestation bundles were made for mehen-0.2.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.2.0-py3-none-macosx_11_0_arm64.whl.

File metadata

  • Download URL: mehen-0.2.0-py3-none-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 3.1 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.2.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4fe4f64f74f980823cee17e612447e55d773ae4250ad19bffb3f6628dc4f254d
MD5 698d50fb6e044cc7cadd129e1d845b23
BLAKE2b-256 cd2420a96eac3631366c640ce007b5b9043791a46916628a777326ea8d039459

See more details on using hashes here.

Provenance

The following attestation bundles were made for mehen-0.2.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.2.0-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for mehen-0.2.0-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 5329f84372e68e7d9f0164c2d7085c1bea0daf7e167498312fd9f8aa8b62644f
MD5 4e6d0de49cc57b69f868554f5031d79d
BLAKE2b-256 f099c36f6cd0149a1ec5257f3d450b1523d881d10b4a50aa15cb6ca3ba257823

See more details on using hashes here.

Provenance

The following attestation bundles were made for mehen-0.2.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