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.1.0.tar.gz (3.4 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.1.0-py3-none-win_arm64.whl (3.1 MB view details)

Uploaded Python 3Windows ARM64

mehen-0.1.0-py3-none-win_amd64.whl (3.3 MB view details)

Uploaded Python 3Windows x86-64

mehen-0.1.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.4 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

mehen-0.1.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl (3.5 MB view details)

Uploaded Python 3manylinux: glibc 2.5+ x86-64

mehen-0.1.0-py3-none-macosx_11_0_arm64.whl (3.2 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

mehen-0.1.0-py3-none-macosx_10_12_x86_64.whl (3.3 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for mehen-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6e6bd613f97f01bace2420263b41b27cd866582aa11fd474bf36fa67bdab5629
MD5 5d9e62e167b2fbd47042574f9e33aa56
BLAKE2b-256 9c6257ea888d953ad0b1ce110ceaacd5e47c1826fba884100c9ed1a8f1008e40

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: mehen-0.1.0-py3-none-win_arm64.whl
  • Upload date:
  • Size: 3.1 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.1.0-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 1f00d357addd6fc482e94c47448715b8f434e05742bb29a4e6f40c3f5c73a87b
MD5 55b3a1c5e7330f553de67974ce76a03e
BLAKE2b-256 f351243e7c3e80aa0c7afce370c67b77a87486bfdd9d2fb8d483a00659d30165

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: mehen-0.1.0-py3-none-win_amd64.whl
  • Upload date:
  • Size: 3.3 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.1.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 41b688b052f88673292930a4eaeff63433d9c931c052cab630f0652aa83a9306
MD5 c1e04a4cdf7875c212209dd204752d6c
BLAKE2b-256 89444f401f5ff04832a02cb581f4e0df04e17bc72c1218ac56daf2408bc5b0e2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mehen-0.1.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 14c5737a4a9bc68761894b906cc1bff6f4c60c93d782cf1080c3473d918230e7
MD5 e4354343ab3706147418eec34301c9b1
BLAKE2b-256 4f38b1a302806fbc0a330b8bdff155b0040dd7c3476ff42f06130585c44c06f8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mehen-0.1.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 ae13e368f1c7e60ef0e282e3c85625f04beeed70ce978db09afc064d34d8b8ee
MD5 1783a3cc81d574945706cf96489f6324
BLAKE2b-256 99c62fcdfb61f5d4b0d47b536cfbf4e1fd9a9b0c980d7de90b9b76fc61659173

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: mehen-0.1.0-py3-none-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 3.2 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.1.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b6373f7eeb0bc1b4cf39c3b2dc89eee31ef3685ee45522797aed78f434bca148
MD5 82342bd23e33b10274ffe3ed4fb64ed1
BLAKE2b-256 049cdf1b4979d8db74c95b257327beaac843457a4acee3ea0b9d2333a46ce881

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mehen-0.1.0-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 5e64fd1d6e20ef717f2277fed14a5529e346f71dc765d58197e78200f689d896
MD5 3bbb75863b4ac985dc7d5fff3a81e2b3
BLAKE2b-256 13eb5a4d4cda3a44a0a24488a6dd68c92d8a8d054e36ccbc57b94ecdc641f3b7

See more details on using hashes here.

Provenance

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