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, documentation health, and more.

It is designed for fast, deterministic analysis over large codebases, helping both human and AI engineers track how complexity evolves over time.

📚 Documentation: https://mehen.ophi.dev

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

  • Polyglot by design — per-file language detection across eleven source languages plus Markdown and SQL. Useful for monorepos.
  • Real language parsers — Ruff for Python, Oxc for TS/JS/JSX/TSX, Mago for PHP, Prism for Ruby, ra_ap_syntax for Rust, ANTLR (Kotlin spec grammar for Kotlin, grammars-v4 for Java), pulldown-cmark for Markdown, sqruff for SQL, tree-sitter for Go, C, PowerShell.
  • Code, documentation, and SQL in one tool — source-code complexity, Markdown documentation health, and a dedicated relational metric family for .sql files.
  • Deterministic, no network — pure static analysis. Same input → same output. Safe for air-gapped CI.
  • Pull-request native — built-in mehen diff plus a sticky comment GitHub Action.

Install

# npm
npm install -g mehen

# PyPI / uv
uv tool install mehen
# or: pip install mehen

# cargo binstall
cargo binstall --git https://github.com/ophi-dev/mehen mehen

Full installation guide: https://mehen.ophi.dev/installation.

Quick start

# Analyze a single file
mehen metrics src/main.py --pretty

# Rank the worst offenders in a tree
mehen top-offenders src --metric cognitive

# Diff metrics against main
mehen diff --from main --to HEAD --paths src --output-format markdown

Quickstart: https://mehen.ophi.dev/quickstart.

GitHub Action

Drop the action into a workflow to publish per-PR metric trends:

permissions:
  contents: read
  pull-requests: write
  issues: write

steps:
  - uses: actions/checkout@v6
    with:
      fetch-depth: 0
  - uses: ophi-dev/mehen@v1
    with:
      paths: src

Full reference: https://mehen.ophi.dev/guides/github-action.

Documentation

Everything else lives in the docs site:

  • Code metrics — cyclomatic, cognitive, Halstead, MI, ABC, LOC family, NOM, NPA, NPM, WMC.
  • Markdown metrics — DMI, MRPC, MCC, link debt, filler/lazy risk, English/Japanese prose layer.
  • SQL metrics — CTE graphs, join/subquery structure, object-touch risk, SQL Halstead, and composite scores via mehen-sql (sqruff-backed).
  • Commandsmehen metrics, mehen diff, mehen top-offenders.
  • Developers guide — build, test, contribute, add a language.

Contributing

Issues and pull requests welcome at https://github.com/ophi-dev/mehen/issues.

License

mehen is released under the GNU Affero General Public License v3.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-1.3.0.tar.gz (946.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

mehen-1.3.0-py3-none-win_arm64.whl (10.0 MB view details)

Uploaded Python 3Windows ARM64

mehen-1.3.0-py3-none-win_amd64.whl (11.2 MB view details)

Uploaded Python 3Windows x86-64

mehen-1.3.0-py3-none-manylinux_2_28_x86_64.whl (10.7 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

mehen-1.3.0-py3-none-manylinux_2_28_aarch64.whl (9.9 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ ARM64

mehen-1.3.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (9.9 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

mehen-1.3.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl (10.8 MB view details)

Uploaded Python 3manylinux: glibc 2.5+ x86-64

mehen-1.3.0-py3-none-macosx_11_0_arm64.whl (9.8 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

mehen-1.3.0-py3-none-macosx_10_12_x86_64.whl (10.5 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for mehen-1.3.0.tar.gz
Algorithm Hash digest
SHA256 f3c7ba51aa4f67f16143cb102a27e8538c6bc5ed701f8331f1e63ae50bb44983
MD5 588c435c56455da40f7cb2ed69bed1c9
BLAKE2b-256 3f12246b272daff9acffca209055b1c66319a3944e65055ca504e600048971db

See more details on using hashes here.

Provenance

The following attestation bundles were made for mehen-1.3.0.tar.gz:

Publisher: release.yml on ophi-dev/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-1.3.0-py3-none-win_arm64.whl.

File metadata

  • Download URL: mehen-1.3.0-py3-none-win_arm64.whl
  • Upload date:
  • Size: 10.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-1.3.0-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 10556a1978e9640985a998eff3ead61b89e443efddb3ee55ee9aff6cd9c2a408
MD5 c3255139b11db6f6ba4b459fdc64ae0a
BLAKE2b-256 ee799dd55ca6a9f4d0fe9e415e66244dea0f7f0efac44f70c3f63968b10d0a48

See more details on using hashes here.

Provenance

The following attestation bundles were made for mehen-1.3.0-py3-none-win_arm64.whl:

Publisher: release.yml on ophi-dev/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-1.3.0-py3-none-win_amd64.whl.

File metadata

  • Download URL: mehen-1.3.0-py3-none-win_amd64.whl
  • Upload date:
  • Size: 11.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-1.3.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 3652da2ebc283ccf66919fbc30edfb0f7a3b407637214d982be74a52ebe48954
MD5 9cfa3a82436523593489b3a36116bdd9
BLAKE2b-256 64c0fa1fe9990af73a822afd1f822894c3a1b6309c493bd25eb5b0de197519d0

See more details on using hashes here.

Provenance

The following attestation bundles were made for mehen-1.3.0-py3-none-win_amd64.whl:

Publisher: release.yml on ophi-dev/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-1.3.0-py3-none-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for mehen-1.3.0-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 91f0d657ab8b30df7d1c222dd34d91ad9ae0ed373eb3aee3ac2dab4373b96794
MD5 ac603e4d79b5d140c4aa17da710acb4c
BLAKE2b-256 24845bdebb6616fa1fb5ee34c3e434cc74461969987d08ffd1dcb25c0768ace0

See more details on using hashes here.

Provenance

The following attestation bundles were made for mehen-1.3.0-py3-none-manylinux_2_28_x86_64.whl:

Publisher: release.yml on ophi-dev/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-1.3.0-py3-none-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for mehen-1.3.0-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 f6a59f138097a0f7c02b24599b1d6ac5a40df037ac7c7e491011a27339ce51a3
MD5 c2258d8be4af26cb33bbf02b6589fb7a
BLAKE2b-256 1896a1508b3e8ae0a84c27b045dec089085013d110b7f963c5e31a9d871ffbf9

See more details on using hashes here.

Provenance

The following attestation bundles were made for mehen-1.3.0-py3-none-manylinux_2_28_aarch64.whl:

Publisher: release.yml on ophi-dev/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-1.3.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for mehen-1.3.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5a63c3ca8f9a3620ad26ff589df843e08cb3f5422e368d34b8e7187c5872931b
MD5 3227cc13b955a0deb13757ee652617ae
BLAKE2b-256 50bd2ab86c449380a463390b03d8425e7e7ab620121f953e7826228a63f1d7bb

See more details on using hashes here.

Provenance

The following attestation bundles were made for mehen-1.3.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on ophi-dev/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-1.3.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for mehen-1.3.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 91f046496e7f709c3140f6306b218304831928c520fa0732330351128515f872
MD5 c438c3540878c62c492bbe47e4c1b7e5
BLAKE2b-256 3f136b83e069dbdf4328e6ed1d412d0806108bb64f74451896b9eae03db45ff7

See more details on using hashes here.

Provenance

The following attestation bundles were made for mehen-1.3.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl:

Publisher: release.yml on ophi-dev/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-1.3.0-py3-none-macosx_11_0_arm64.whl.

File metadata

  • Download URL: mehen-1.3.0-py3-none-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 9.8 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-1.3.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a971f89103f029e305d2f222e2cf7a0ae97ae4dbf6defddd71b2e7b6f5e528ea
MD5 304030e3c04cc6ad6b16abbac5f0ff59
BLAKE2b-256 95eeec44f3cae505e98d83c2510a704e7dadbc1cec3ed06986f745066ad7bef0

See more details on using hashes here.

Provenance

The following attestation bundles were made for mehen-1.3.0-py3-none-macosx_11_0_arm64.whl:

Publisher: release.yml on ophi-dev/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-1.3.0-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for mehen-1.3.0-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 259be16e79e41cfdccc5169cf4ec2c3ee5a9eba1437ecbebc6623094e2efbc8c
MD5 eaad10ac3a90ec7cba7a73266f721747
BLAKE2b-256 32faa617cc874e53f9396f0938781784bdc9a41736611f6faf50612925fc54bf

See more details on using hashes here.

Provenance

The following attestation bundles were made for mehen-1.3.0-py3-none-macosx_10_12_x86_64.whl:

Publisher: release.yml on ophi-dev/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