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

Uploaded Python 3Windows ARM64

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

Uploaded Python 3Windows x86-64

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

Uploaded Python 3macOS 11.0+ ARM64

mehen-0.4.3-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.3.tar.gz.

File metadata

  • Download URL: mehen-0.4.3.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.3.tar.gz
Algorithm Hash digest
SHA256 8b0f19a0f7b1dbd6e2795fa2c8d8182eb00fdecb3901533c8817ed0e8fd31e4a
MD5 9e94b148beeeb57fd88c57b036fa3aea
BLAKE2b-256 d05a40d43945c8fdee2162e3cda1e3688dfe1e1038763ac3278d5c3f0d51c74c

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: mehen-0.4.3-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.3-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 a8841c060416a90eec0437ac7748e76df0e541a108da551e31002b89b77d242e
MD5 a35a116272ef459984b489e10268df9d
BLAKE2b-256 6337a4b96b3353798a0727c5e705ba6eabffdbcc077412e610988c03ee53794d

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: mehen-0.4.3-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.3-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 24596fa9f98cb003a67f6e6ae9d9633def45414ef99e7a75e8c0b5720e0e03ea
MD5 4861928f801112fd7ddf7dd41b2255ce
BLAKE2b-256 647df856a2e90a5272ac98279290ac2de035717aee0a81d38db7419804f1e0d1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mehen-0.4.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bcd798f3c559005184bd252522e27c592b53ea524394a06c7600c373cafecd7a
MD5 bd97d4962c0b48f08c877050c39f9b2e
BLAKE2b-256 1b611d070b6fc46deea5e27670df6819dc4803642d984c264675d2ad1eabee75

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mehen-0.4.3-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 b76c98f4612ccd8b8387f63d11a80185c8890f7ea1a52e106c23e7cb1fdc9a4d
MD5 b28d34ae7cd732c33b6bddbb10e6aa02
BLAKE2b-256 316ae1dc622eba326152631bb98decf19153307d8db68c1257a633ea37b8fa2f

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: mehen-0.4.3-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.3-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fc9a36bb242f104d3240e2e91cfeb80ae7ecf118174c34de39bd71e5cec86fdf
MD5 992e5963f0fcc187eae55753193c46dd
BLAKE2b-256 203218c60049b5886c51fe6d70ee21f42c29f49bc577e9a92ed070893f8086f8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mehen-0.4.3-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 7de39212aed0c774d2f6cc8c83c6f92fdd6b0467cad8040145120d3e7dc4efc1
MD5 7257fb36cc126e5f5de4dbfdb551813f
BLAKE2b-256 568b4d07227e50720ef6844d7c03f4b5b01b98372d2c70ce1bd559b056b9d374

See more details on using hashes here.

Provenance

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