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.5.1.tar.gz (1.1 MB view details)

Uploaded Source

Built Distributions

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

mehen-1.5.1-py3-none-win_arm64.whl (9.5 MB view details)

Uploaded Python 3Windows ARM64

mehen-1.5.1-py3-none-win_amd64.whl (10.6 MB view details)

Uploaded Python 3Windows x86-64

mehen-1.5.1-py3-none-manylinux_2_28_x86_64.whl (10.2 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

mehen-1.5.1-py3-none-manylinux_2_28_aarch64.whl (9.5 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ ARM64

mehen-1.5.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (9.5 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

mehen-1.5.1-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl (10.3 MB view details)

Uploaded Python 3manylinux: glibc 2.5+ x86-64

mehen-1.5.1-py3-none-macosx_11_0_arm64.whl (9.4 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

mehen-1.5.1-py3-none-macosx_10_12_x86_64.whl (10.1 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for mehen-1.5.1.tar.gz
Algorithm Hash digest
SHA256 db653b4e9cfeb397fd20db34e00f5ce05ef98769868f03f250f607bc219f0dfe
MD5 60c9020cb8452811edd60b65ce62fd67
BLAKE2b-256 41ff9e7109bb15d878f593d51f6a6dc237c398d2041e5ccb755730f0887c07ae

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: mehen-1.5.1-py3-none-win_arm64.whl
  • Upload date:
  • Size: 9.5 MB
  • Tags: Python 3, Windows ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for mehen-1.5.1-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 badcc1aa18fc7a14bc8acbaa1452cf6d05ff13abb9cef49025730d7b7803b68d
MD5 326f0dfda6ee04b6aea3ed68576bf58f
BLAKE2b-256 bf262df193918b4497b3fe23f497c03ebc5870cfb17b7b0143d5a38d217b8dff

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: mehen-1.5.1-py3-none-win_amd64.whl
  • Upload date:
  • Size: 10.6 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for mehen-1.5.1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 8511622ce87baae6519cea902afa50737d7cbf2cb8ca5dc16461575f4507110a
MD5 dc56c5b222e480f393d3bd3d47f196af
BLAKE2b-256 953281e08b14a036b56da9159cd10710ebdf24b94ac19aa0666d3c3035f5829e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mehen-1.5.1-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 24131cff87f79fb0db4ec4261d51d1dd890bcbb199f0025958b95e76dc0e0929
MD5 ad8d38e6f178ea910946afc848a5f4c2
BLAKE2b-256 183abdd6d20e5d1ef60aadc08df9e1bd264fbc1e41db7d8282c067a44aedc6bf

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mehen-1.5.1-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 60ccbf0d0093404cf98a08a619a423fb20c1310df826040d1df3ab08bf03b4ca
MD5 a215eae9f4552ab4b1f7aebd2433114d
BLAKE2b-256 2ba11106f2b21de0405e99ed3a11a0b4f2be6df57fbce7a43dbf3fc901d61a4a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mehen-1.5.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 25c4c117cea71f47a4fb9110835954ae1357a1459537f6cc6525c83bfc863636
MD5 da347420792d339a41bd3482ba6d35fb
BLAKE2b-256 6d6e5ed18a587332ff417a48938f8066e505723a7ada2911cf5f99c3afd3c5fe

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mehen-1.5.1-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 5e61972954dbec9657fe24d6f63736fdd3ded974e79361cf1a0d8bbeec555af8
MD5 f6e1703f1b5553f9b005bb1447507af3
BLAKE2b-256 96c7f7c04e6540fb42c76e724d038c25e55f478418f30960541b8be842e85f91

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: mehen-1.5.1-py3-none-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 9.4 MB
  • Tags: Python 3, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for mehen-1.5.1-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 eb03150175c9873d5da8222da8e864a029358633ce4a858f684c854479aca46d
MD5 df5355e011add10ef4cfde29a78ae911
BLAKE2b-256 e8f82678e27f065947e1625b3cc9c37823bf96cfea1f9ac11ca4a107a9dc3347

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mehen-1.5.1-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 8cc8e6a256f1511fe740b5614a5b4131f18cf12c6efa264689bfda663fdb92a4
MD5 47a8137d53a77658058ced882253ada3
BLAKE2b-256 0fe2904111e9367804953c2fb611ac39122f13272c74352e7a767b56a901a9e1

See more details on using hashes here.

Provenance

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