Multi-Factor Code Quality Index

A single quality score for Python

Gauge your codebase quality from a geometric mean of evidence-based metrics.

$ pipx install mfcqi

Working in Java or Kotlin? Meet the JVM edition ↗

The Drake Equation for Code Quality

The score is a geometric mean — a normalized product of independent metrics.

// Drake equation
N = R · fp · ne · fl · fi · fc · L

Estimates a quantity as a product of independent factors. If any single factor is near zero, the whole product collapses toward zero.

// MFCQI
MFCQI = (M₁ × M₂ × … × Mₙ)^(1/n)

A geometric mean is a normalized product of the quality metrics. One weak metric pulls the whole score down — so it is non-compensatory.

Just as the Drake equation reaches its estimate by multiplying independent terms — where a single small factor dominates the outcome — MFCQI multiplies its quality metrics. A codebase can't trade a failing dimension for strong ones; every factor has to hold up.

What it does

Single score

One number in [0, 1] for overall quality — track it in CI, gate on it, badge it.

Non-compensatory

The geometric mean means a weak metric isn't offset by strong ones.

Python 3.10+

Install in one command with pipx, uv, or pip. The reference implementation of MFCQI.

AI recommendations

Bring your own key (BYOK) for recommendations — Anthropic, OpenAI, or a local Ollama model. Scoring itself needs no key.

Real tooling

Wraps trusted analyzers — Bandit, Pylint, Radon, pip-audit, and detect-secrets — behind one score.

Quality gates

Configurable thresholds via YAML; a non-zero exit code on failure.

Machine-readable

JSON and SARIF output, plus shields.io badges for your README.

Security included

Bandit SAST, pip-audit dependency CVEs, secret scanning, and code-smell density — in the score.

Evidence-based, paradigm-aware

Core metrics apply everywhere; object-oriented metrics are added only when the code is object-oriented, so procedural Python isn't penalized for lacking classes.

Complexity & maintainability

Cyclomatic Cognitive Halstead Volume Maintainability Index

Coverage

Documentation Code Duplication

Security

Bandit SAST pip-audit (SCA) Secrets Exposure Code-Smell Density

Object-oriented design

RFC DIT MHF CBO LCOM