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 / JavaScript (.ts, .mts, .cts, .js, .mjs, .cjs)
  • TSX / JSX (.tsx, .jsx)
  • Rust
  • Go
  • Ruby
  • Kotlin
  • PowerShell
  • C (.c, .h)

Because TypeScript is a superset of JavaScript, mehen analyzes .js/.mjs/.cjs files through the TypeScript grammar and .jsx files through the TSX grammar.

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.5.0.tar.gz (4.2 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.5.0-py3-none-win_arm64.whl (3.8 MB view details)

Uploaded Python 3Windows ARM64

mehen-0.5.0-py3-none-win_amd64.whl (4.0 MB view details)

Uploaded Python 3Windows x86-64

mehen-0.5.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.1 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

mehen-0.5.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.9 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

mehen-0.5.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl (4.2 MB view details)

Uploaded Python 3manylinux: glibc 2.5+ x86-64

mehen-0.5.0-py3-none-macosx_11_0_arm64.whl (3.9 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

mehen-0.5.0-py3-none-macosx_10_12_x86_64.whl (4.0 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for mehen-0.5.0.tar.gz
Algorithm Hash digest
SHA256 42a425aef927c894d9c30b8059eae10ee1097a6cb28f79554fd43b3376da3833
MD5 0685dc46a4843422eff24f3ed07db918
BLAKE2b-256 9a77fec1ec0249de2325b3494fb2c9f1f72fade5a4d8b9f023a536a79dcc4150

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: mehen-0.5.0-py3-none-win_arm64.whl
  • Upload date:
  • Size: 3.8 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.5.0-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 af0fb7776c3f479d3ff9b1c17ed4dc4ce93d038df9b7a1fe5cb284b39631c252
MD5 62816ecf7e5f42c1373d98699965181f
BLAKE2b-256 9b7d5ee6eff07172c55c0bd3b775ab19e5c1d45fa09b17d26707c4eeeed47231

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: mehen-0.5.0-py3-none-win_amd64.whl
  • Upload date:
  • Size: 4.0 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.5.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 1fc3ca13b18f4681d46b58649e9701e42b13275f20769fb560d17a6d2efb718f
MD5 1d8a6b78a5ce9e2f596cefc2c5951a67
BLAKE2b-256 f7ec09fe9ea0e7c7db0b1b019cbc9cb7711c501d1b2c136dbc69baa8bcfda5e5

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mehen-0.5.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7afa180f6111ea8b2916fa8c99e5713c7128eea3b3959aef0bd7d37de4d14e0b
MD5 c06c685321bf4ec36c078705c985a624
BLAKE2b-256 79b1f520da92b6095ff96da438832c9d60a522619e35f740ee4b66904d49c20b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mehen-0.5.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 0814f3cfb46b9a2918fea2a3cb36fd238ee4a65cf8baf3686ad19b0ebb9aad1a
MD5 32dd8fe7f3fe25400d22c72a81c3cd4e
BLAKE2b-256 d22dd675af7793c3d2d2c46d9c78dde66e7a2006ff5a8e8cd04618e60a72c8e5

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mehen-0.5.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 ea187d2a99efa5e75e997daaac7ca1c3bb9224f0fbf7a97321e23b32f040c075
MD5 bbcb4e728967c75db105bd13938a3371
BLAKE2b-256 38abf86ce3a9dd3b7f89dd7a97ced62eba8ae28bbf4903994de1f71e0fc616d7

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: mehen-0.5.0-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.5.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 00af50729ca273d7156e2a1461430309ecc3c6373ad37dc146170cf0c51650b4
MD5 4d86966c4b8617128a9513b2816d23ef
BLAKE2b-256 094149db5e7d92a04517ef66da1a4a906c0782a7e4d2263e5f92e1b92881a86e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mehen-0.5.0-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 7e3c14c2b45fe546760ef22ea8b94422673120c9f79e76463580b087e6e0e554
MD5 d36ac393170a51f01f73f0996adac29e
BLAKE2b-256 01bb55ecf4a7b82e3ee30046f542160cdcac5f54ce15f7760d024cf653ef801a

See more details on using hashes here.

Provenance

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