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.4.1.tar.gz (943.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.4.1-py3-none-win_arm64.whl (9.9 MB view details)

Uploaded Python 3Windows ARM64

mehen-1.4.1-py3-none-win_amd64.whl (11.0 MB view details)

Uploaded Python 3Windows x86-64

mehen-1.4.1-py3-none-manylinux_2_28_x86_64.whl (10.5 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

mehen-1.4.1-py3-none-manylinux_2_28_aarch64.whl (9.8 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ ARM64

mehen-1.4.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (9.8 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

mehen-1.4.1-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl (10.6 MB view details)

Uploaded Python 3manylinux: glibc 2.5+ x86-64

mehen-1.4.1-py3-none-macosx_11_0_arm64.whl (9.7 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

mehen-1.4.1-py3-none-macosx_10_12_x86_64.whl (10.4 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: mehen-1.4.1.tar.gz
  • Upload date:
  • Size: 943.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.4.1.tar.gz
Algorithm Hash digest
SHA256 e31908108f0339f8f3e9b1f9cbd62094c5c10acf843933c616d4fcc220b51aeb
MD5 ee313a17d9396235f8b90f876de9d8b4
BLAKE2b-256 b3c7207972eb3f3a5c6cb03c650600a29260b77daf488068608658d0b909f880

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: mehen-1.4.1-py3-none-win_arm64.whl
  • Upload date:
  • Size: 9.9 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.4.1-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 491d4f11f3952378bf0182a7440cdfdc0a185b5dd9ba42f3d6dff6c5762692fc
MD5 99afdb4adb80d2b4c5f759aaab04b5ce
BLAKE2b-256 48c0051407a08eb5e723bfdd6673a31b57e2b40777103000c060b2acb3edc564

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: mehen-1.4.1-py3-none-win_amd64.whl
  • Upload date:
  • Size: 11.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-1.4.1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 f6577b5936eacb5d2f7cef1029f357985a2575efa579b6a861c117da4f2c4ab1
MD5 ef04b1af393bbb8904d99a7a5c2997b6
BLAKE2b-256 c0486e8fa8918e6b8c50bf0a35c6b3610afefbb1ce09cbb6d6935cb7076c7bd0

See more details on using hashes here.

Provenance

The following attestation bundles were made for mehen-1.4.1-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.4.1-py3-none-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for mehen-1.4.1-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 791848ef7c7c6eb648881518f82abe6c5768b21db520cfa842d9d870bf01d1d9
MD5 52456d15b1d784ab44e6397945e6fb9c
BLAKE2b-256 c634f2b8400b9758dcb8a4026892b7d85327e4167d46111bd20afa78e8997db1

See more details on using hashes here.

Provenance

The following attestation bundles were made for mehen-1.4.1-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.4.1-py3-none-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for mehen-1.4.1-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 ec8493e5ee1d8783f904385bf358159139085c0fe63216d5b0e5d4f929748012
MD5 db2296dd468763101dd78b83ab855518
BLAKE2b-256 9cd3d44fe19133262ad5570653da1fc5b6a3ef6ae62b036dc3d6d98441a8e663

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mehen-1.4.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 88304e518639518017435ac48581454162093984766ddcc5e353782005eb3e44
MD5 e9a20153ea7eeafea2e161d486a0e4f6
BLAKE2b-256 83716f5ac17b62a869c5268909d0b2f8bd170e9c38f01b9cb852286281b2a073

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mehen-1.4.1-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 559982b3ff3359daf7956aa3e5ea1a3bd0e55753a2851b74284d9c8e012767ee
MD5 ecdab2b178a54e0cd4970379f5a61997
BLAKE2b-256 a3bf684fd32210c001526489fc063de03ae218295e6d280ed02a84a11888fefe

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: mehen-1.4.1-py3-none-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 9.7 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.4.1-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1732dd63c42dbbd4e87cd95a9bf8a1253025c9848a4d789768364ab4f7ce2008
MD5 6dc58ec99fc396672de1d401a09fdaaf
BLAKE2b-256 bf36cbb629cb1edbbf811eb4766b72c77ad3f02bc0f6842c22ae2330b0cd9dd2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mehen-1.4.1-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 17af776c969a02ca750a738f1a069ab76db0cc6daca6a14c4ed06411fdacac64
MD5 768c32fbc23862e23e03f3f487fa834e
BLAKE2b-256 ddbfa25638b8731f8e10ffa2327b8cfe7b41e2efb631d4e8f39660ad4fa813e4

See more details on using hashes here.

Provenance

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