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

Uploaded Python 3Windows ARM64

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

Uploaded Python 3Windows x86-64

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

Uploaded Python 3manylinux: glibc 2.28+ x86-64

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

Uploaded Python 3manylinux: glibc 2.28+ ARM64

mehen-1.4.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (9.7 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

mehen-1.4.0-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.0-py3-none-macosx_11_0_arm64.whl (9.7 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

mehen-1.4.0-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.0.tar.gz.

File metadata

  • Download URL: mehen-1.4.0.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.0.tar.gz
Algorithm Hash digest
SHA256 b325821aac24e26fa3d352df759d083124a38e2aa9b2cbd9c103f5afc4779314
MD5 ba2178189130906e7c7275ab021c5cc6
BLAKE2b-256 4681f957a94e00226e12d569e5641932701342d977e67818bd66a29ecb82df93

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: mehen-1.4.0-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.0-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 e96636aaf219addd68773d2f0e911b6acd49ddbd81cdfec6931bb1809b31de48
MD5 96b62971715aedc8e9c1064b448bab1f
BLAKE2b-256 2505b6cf28e2596942c77d9a811ec97f2bba791b8d966d7a605217cc876f2cc8

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: mehen-1.4.0-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.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 262a0f1df7526bbf6af409de281006c54bd4c1be2520a05d5e07e2f2d1f0f9b0
MD5 27bbe6cc797467c2856a2613d92bff00
BLAKE2b-256 c868a2f0dafbd49af0d6c4fa0f3d80bee329ff6e180c374bbb62ce4fbf3bebcd

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mehen-1.4.0-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4c5166f4e379a3ccbe532c1d42efd0c07050606823ae0e3b132b1db7c44c9b33
MD5 7646f42c72c0f2cb257292f6627f90ba
BLAKE2b-256 7d96bb802763b79bd8e7ad52e714c96d004af9781e9b674ea6e875b300e7e4b3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mehen-1.4.0-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 4bbf8e0da9063d2681d987ee46697f840b7702ec70f7d9399df6deb761281503
MD5 ab6f914f80110fa9859244edbdb48fa1
BLAKE2b-256 93118dfcaae33bdb76d153a9a6eabef9fe33f768b9960e6b01acddcc893b2a32

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mehen-1.4.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 4822b8935f48c5bfff26cc1c3ed48dfc932358758a129e5e38e43170f97283af
MD5 39cd05699e683fa326772e6ffb112a3e
BLAKE2b-256 6db0ee299537c5987a9d27258623c63e1643d99cd94ef13edcc5131a79903de6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mehen-1.4.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 700625656816bf9126e85b3ecc2a049d6a93c2a849c8ed80ed894c40aacd5d74
MD5 356b7a72534bb1b1e52b5203756f1e3d
BLAKE2b-256 709d22dd404948b96e9dbd5bb10807a418b003bd4d5bf24093085dc630caf94a

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: mehen-1.4.0-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.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1dadc9e67cd980cf8e93f8baf8d8898c8b342602c7d9eed3c615ea7ae97182a5
MD5 76850c29f50973d1d15dcce268f8efc5
BLAKE2b-256 7ce25251fb52794933f6a6fe39d01e6e44391adcc2241d7da656cc5e21ca061e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mehen-1.4.0-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 edaa1ea62abaccfade239c08b20fcd90b378e772e871a527ae8ba2721699ce1d
MD5 60c7a39f01d4a7b522e952ba0baf719c
BLAKE2b-256 3c826feccc54feef961a11baed55ac95c090beef980e86e0be7736e5f74ea2a6

See more details on using hashes here.

Provenance

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