Skip to main content

Code quality diagnosis toolkit — 5-dimension maintainability profiling for Python and TypeScript

Project description

Huatuo

Dr. Huatuo

Code Quality Diagnosis Toolkit

5-dimension quality profiling for Python and TypeScript. Named after the legendary physician Hua Tuo (华佗) — it diagnoses code health.

PyPI CI Python 3.11+ MIT License


What is dr-huatuo?

dr-huatuo orchestrates static analysis tools into a unified quality profile with 5 independent dimensions. No single aggregate score — each dimension gets its own grade so you know exactly what to fix.

  • Multi-Language — Python (ruff, radon, bandit, mypy, pylint, complexipy) and TypeScript (eslint, tsc, escomplex)
  • 5-Dimension Quality Profile — Maintainability, Complexity, Code Style, Documentation, Security
  • CI Quality Gate--fail-on D exits non-zero for CI/CD integration
  • Multiple Output Formats — Terminal (rich), HTML (interactive with Chart.js), JSON, Markdown
  • Plugin Architecture — Language-agnostic protocol, register new analyzers with one line

Quick Start

pip install dr-huatuo
# or
pipx install dr-huatuo

# Check a Python file
ht check myfile.py

# Check a TypeScript project
ht check frontend/src/ --language typescript

# Check a mixed project (auto-detects Python + TypeScript)
ht check src/ --fail-on D

# Generate interactive HTML report
ht report src/ -f html -o report.html

# Show version and tool status
ht version

Screenshots

Terminal Report (ht report src/)

Terminal report showing file scores, complexity, and suggested actions

HTML Report (ht report src/ -f html)

Interactive HTML report with complexity hotspots and security issues

Quality Dimensions

Dimension Metrics Grades
Maintainability Maintainability Index (MI) A: ≥40, B: ≥20, C: ≥10, D: <10
Complexity Cognitive complexity + nesting depth A: ≤5/≤2, D: >25/≥6
Code Style Lint violations (ruff) + linter score (pylint) A: 0 violations + ≥9.0
Documentation Docstring + comment density A: ≥80% docstrings + 10-30% comments
Security Bandit HIGH/MEDIUM findings PASS / WARN / FAIL gate

Type safety (mypy errors) is reported as informational — not rated.

CLI Reference

# Quality check (5-dimension profile)
ht check <path>                          # analyze file or directory
ht check src/ --fail-on D               # CI gate: fail on D or F
ht check src/ --fail-on C               # stricter: fail on C, D, or F
ht check src/ --fail-on WARN            # fail on any security warning
ht check src/ --fail-on D --dimension Security  # gate single dimension
ht check src/ -e .venv tests docs       # exclude directories
ht check src/ --language typescript     # filter by language

# Project reports
ht report <path>                         # terminal output (default)
ht report src/ -f html -o report.html   # interactive HTML with Chart.js
ht report src/ -f json -o report.json   # machine-readable JSON
ht report src/ -f markdown -o report.md # markdown for docs

# Info
ht version                               # show version + tool status

Scoring System

Score starts at 100, with deductions per category:

Category Deduction Cap
Lint violations -2 each -30
Complexity >10 (cc-10) × 5 -20
Security HIGH -15 each -30
Security MEDIUM -5 each -15
Type errors -1 each -10

Grades: A (90+) Excellent, B (80+) Good, C (70+) Fair, D (60+) Pass, F (<60) Fail

Tools Orchestrated

Python

Tool What it checks
ruff Lint violations (fast Python linter)
radon Cyclomatic complexity, maintainability index, Halstead metrics
bandit Security vulnerabilities
mypy Type errors
pylint Code quality score
complexipy Cognitive complexity

Python tools are installed automatically as pip dependencies.

TypeScript

Tool What it checks
eslint Lint violations, security rules (eslint-plugin-security)
tsc Type errors (via tsconfig.json)
escomplex Cyclomatic complexity, maintainability index

TypeScript tools require Node.js. Install locally: npm install --save-dev eslint typescript typhonjs-escomplex

Roadmap

  • Foundation — single-file analyzer, project reporter, tests, CI/CD, PyPI
  • Quality Profile & CLI — 5-dimension profile, ht CLI, quality gate, HTML drilldown
  • Scoring Consistency — unified scoring formula, tool detection fix
  • Analyzer Unification — plugin protocol, PythonAnalyzer, generic field names
  • Multi-Language — TypeScript analyzer, mixed-project support
  • Research Pipeline — dataset annotation, deduplication, BugsInPy validation

License

MIT

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

dr_huatuo-0.5.0.tar.gz (895.9 kB view details)

Uploaded Source

Built Distribution

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

dr_huatuo-0.5.0-py3-none-any.whl (78.3 kB view details)

Uploaded Python 3

File details

Details for the file dr_huatuo-0.5.0.tar.gz.

File metadata

  • Download URL: dr_huatuo-0.5.0.tar.gz
  • Upload date:
  • Size: 895.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dr_huatuo-0.5.0.tar.gz
Algorithm Hash digest
SHA256 a87335db69e9303b73bfdf5c1790fb2a760e6bb5b5b3d5171428cbc0ea2c3b64
MD5 07c5523b39d092c8e352680a47978ce0
BLAKE2b-256 f4778dd644d0c9a61e4253355d678150e8f166bc85eddbba5d724d87e14735fd

See more details on using hashes here.

Provenance

The following attestation bundles were made for dr_huatuo-0.5.0.tar.gz:

Publisher: publish.yml on frankyxhl/dr-huatuo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dr_huatuo-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: dr_huatuo-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 78.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dr_huatuo-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9bd99e8cc64d47626552e3e8e5f9694b868892dfb588f5c59c5beda5b0409a93
MD5 99ea4ba909fee07bc51efa77b7b85a78
BLAKE2b-256 666446fb3f13671a43edc0aefdf6a92704bd07e353342ad98246cb52ff61fd4d

See more details on using hashes here.

Provenance

The following attestation bundles were made for dr_huatuo-0.5.0-py3-none-any.whl:

Publisher: publish.yml on frankyxhl/dr-huatuo

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