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.1.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.1-py3-none-win_arm64.whl (3.7 MB view details)

Uploaded Python 3Windows ARM64

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

Uploaded Python 3Windows x86-64

mehen-0.4.1-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.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.8 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

mehen-0.4.1-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.1-py3-none-macosx_11_0_arm64.whl (3.9 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

mehen-0.4.1-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.1.tar.gz.

File metadata

  • Download URL: mehen-0.4.1.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.1.tar.gz
Algorithm Hash digest
SHA256 8330cf8945206bc3f4d79584fac736c9ce2e918800113eb9329862cb235f0cf3
MD5 7c2727b8fc4dea1562a8d47a26dd0f12
BLAKE2b-256 b3f359a449972b941a8fe2af52e6dd81fe72d138d918539bae41f9f640dce7cb

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: mehen-0.4.1-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.1-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 873583358873ff8076402782b7222f98a6d437272f8311eb6d1b9909fce712f6
MD5 1010287d99822e30a36366043ad414c8
BLAKE2b-256 24a85c1a2e132b3c6c583f9e573e429697a523615b38ee5c05e8a90361e4d56a

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: mehen-0.4.1-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.1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 30126fa4f609677ef7f34721150a9e551dcd8b9c294e9ff6f2ef541d51500f35
MD5 a886bdf0723bfaa2eea3266f57a705ea
BLAKE2b-256 4a1dc092235114badc902ba817c719f683f7c1009952cbf229105e97e77baa11

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mehen-0.4.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 402b5e21c6206ebae2efa01e97e72b6661faa002842a152f1c267dcbcfff766f
MD5 86adbabe3b61c7d868a740487958f1bd
BLAKE2b-256 115963e96d95d72f1922e74567d44fbafbfb9b09386c393c72b0dcadf4a0bec3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mehen-0.4.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 65c9443e4905856fb716fb17a41993a7300dfbdbebfe84c2bae0aed94134dc26
MD5 813feb9ac564c2ae13942a3be71d824a
BLAKE2b-256 ffc0080f6da3f9432beced445f7e348815f9c80a840d49d0ffe1b6c9e668211a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mehen-0.4.1-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 672383d50c6d485732d873717ada0859a9a10de9ccbe4ed26d4be659f3fd0d47
MD5 916665e965dcfbe12ff1b8de035d9d5d
BLAKE2b-256 c7eb5bfa79756a29f7f838eea84198f3db78582152a6cd8ce8b7a02c2b5367da

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: mehen-0.4.1-py3-none-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 3.9 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.1-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1e220674fb71a5ac24cdfe8ff66aa03e4604e183695324eee53013ae01eacf51
MD5 52efde573e926048735da32a4ef4a087
BLAKE2b-256 4e85b32a117820dc5cb8bd5cba2989509505c66fe06935199958f16cb302d94b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mehen-0.4.1-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 7290eb539a94bb36d285b7ebb5cdb2a9daf03c5f3151672cb629f23637f3d1b9
MD5 5a3328ccd986fedeb4b5b21e5088d56c
BLAKE2b-256 c4c7a6b97b180480a82057ebb5b11c34aa1ad14b8e06ff55599b47624c26191a

See more details on using hashes here.

Provenance

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