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 nine 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, the official Kotlin spec ANTLR grammar for Kotlin, 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.2.0.tar.gz (805.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.2.0-py3-none-win_arm64.whl (9.3 MB view details)

Uploaded Python 3Windows ARM64

mehen-1.2.0-py3-none-win_amd64.whl (10.4 MB view details)

Uploaded Python 3Windows x86-64

mehen-1.2.0-py3-none-manylinux_2_28_x86_64.whl (10.0 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

mehen-1.2.0-py3-none-manylinux_2_28_aarch64.whl (9.3 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ ARM64

mehen-1.2.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (9.2 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

mehen-1.2.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl (10.1 MB view details)

Uploaded Python 3manylinux: glibc 2.5+ x86-64

mehen-1.2.0-py3-none-macosx_11_0_arm64.whl (9.2 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

mehen-1.2.0-py3-none-macosx_10_12_x86_64.whl (9.8 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: mehen-1.2.0.tar.gz
  • Upload date:
  • Size: 805.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.2.0.tar.gz
Algorithm Hash digest
SHA256 fae40ca15c0c44fdd1d5f4da431324cd01fdde434c997c3657e64d1c73dfafb6
MD5 62d31e535a19fd3ec2f29be54e8ea3f6
BLAKE2b-256 989d28f118c6ac14c5d93c2bcbf2f97b4f806cf5486fefcb30b411254ca5c64e

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: mehen-1.2.0-py3-none-win_arm64.whl
  • Upload date:
  • Size: 9.3 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.2.0-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 4201613f5d536bfe582e235121a2841281fb188b03b4833dc6985e499b2c6f2b
MD5 f23506b8211374f9c5c836324a951985
BLAKE2b-256 05af49a7ff9efaa311813a2cf5e892f7af235b23cbd5f5f69f718b6a65485ece

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: mehen-1.2.0-py3-none-win_amd64.whl
  • Upload date:
  • Size: 10.4 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.2.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 773c9490f48a6f67eef6c2fb14ad34f141bd53299869f7148e6cb93fb7700dab
MD5 94ef6993819b0a5ad0b99f345800bc23
BLAKE2b-256 b90ee90cfdaf40c11b94700371b8287bff44d1cd4b1eae0feefb595ea3bbaf67

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mehen-1.2.0-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7dff92a173a9c80744de3a9e5cc31abea400a02c6dfb4b5aa05e64a71862b35f
MD5 20d098a39b4a747127e895e809564603
BLAKE2b-256 3aac9b9e0035b59d50cf6094da5acdd562fe5af2e180be3d913d28b78e4a7964

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mehen-1.2.0-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 d8ccc04a5016615493af61fee53ae954fc343b061a104aecee1cb5e6410843d6
MD5 acd2974ad67269dfef197c79e83c8e94
BLAKE2b-256 0badc741b322c26cffaafbaae534313b93688370c45c17d4726db643aec00b64

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mehen-1.2.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 a070e9da029a11b6f6cd528bc31bb8f6769a3fb37eab7568344df4a98827b2a3
MD5 a73e05bf716641e27178ce8a8202d37b
BLAKE2b-256 c38475a080d15381c7e782f6a3bb711282e3aa1360771456a9271b17d8780d44

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mehen-1.2.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 73c390e7a40d25ea8690b546cb93c1f4fe45178be70b769ef33d147bcf4ea4da
MD5 bcd8dcf3daa540ec4c5063b8ffbbb77b
BLAKE2b-256 cd73660ccc7c1cb837f2b65cdf29889ec8a9742ea11e2c1ece0f5706d0cfc700

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: mehen-1.2.0-py3-none-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 9.2 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.2.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 dd9261ba8f3e5244bbd10850bbba27bc0e78beb0059bd76411611c781c4e7818
MD5 29427855c78f40b059f2f72cf7331bc4
BLAKE2b-256 1f4deb7765bc743170a15bdfbe7ce5c44411acb83c53b9b669301c61b5c2b5b3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mehen-1.2.0-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 4712cd5ffef4e3c5bc23b98ef9f143cec84debe2bf84de7a211d97b5c045ef03
MD5 8e78fae2815de523ba4036df3b11711d
BLAKE2b-256 b9e2e4a82ddb5556ed5ebbec61175a3bd7bd82618109c4680f262447c0f5c75a

See more details on using hashes here.

Provenance

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