Skip to main content

Calculate a health score for any Git repository

Project description

codebase-health-score

PyPI version Python Versions License: MIT

Calculate a health score for any Git repository. Analyzes code complexity, documentation coverage, dependency freshness, test presence, and contributor bus factor.

Installation

Install via pip:

pip install codebase-health-score

Quick Start

Analyze a repository:

codebase-health analyze /path/to/repo

Sample output:

Repository Health Analysis: /path/to/repo

Overall Score: 73/100 (Good)

┏━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━┓
┃ Dimension            ┃ Score  ┃ Status    ┃
┡━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━┩
│ Code Complexity      │ 18/25  │ Good      │
│ Documentation        │ 16/20  │ Good      │
│ Test Coverage        │ 15/20  │ Fair      │
│ Dependency Health    │ 12/15  │ Fair      │
│ Git & Collaboration  │ 12/20  │ Fair      │
└──────────────────────┴────────┴───────────┘

Key Findings:
• Repository has 42 Python files with average size of 124 lines
• README.md exists, but CONTRIBUTING.md is missing
• Test directory present: 18 test files found
• 6 active contributors, bus factor at 34% (top contributor)
• Last commit 2 days ago

Generate detailed reports:

# Table format (default)
codebase-health report /path/to/repo --format table

# JSON format for integration
codebase-health report /path/to/repo --format json

# Markdown format
codebase-health report /path/to/repo --format markdown

# Save to file
codebase-health report /path/to/repo --output-file health_report.json

How Scoring Works

Code Complexity (25 points)

Evaluates the structural complexity of your codebase:

  • File Size: Measures average and maximum file sizes. Large files indicate potential complexity.
  • Directory Depth: Checks nesting levels. Excessive nesting suggests organizational issues.
  • File Count: Considers total files. Very small or very large codebases may have organization concerns.

Good: Average file size 100-200 lines, max file under 500 lines, directory depth under 5 levels

Documentation (20 points)

Assesses how well your project is documented:

  • README: Presence of README.md is essential
  • Contributing Guide: CONTRIBUTING.md indicates mature projects
  • Docstrings: Ratio of documented functions/classes
  • Code Comments: Inline comment density in source files

Good: README present, some docstrings, reasonable comment coverage

Test Coverage Indicators (20 points)

Evaluates testing infrastructure:

  • Test Directory: Presence of tests/ or test directory
  • Test File Ratio: Proportion of test files to source files
  • CI Configuration: Presence of .github/workflows, .gitlab-ci.yml, etc.

Good: 1 test file per 3-4 source files, CI pipeline configured

Dependency Health (15 points)

Checks dependency management practices:

  • Lock File: Presence of requirements.txt, poetry.lock, package-lock.json, etc.
  • Dependency Count: Reasonable number of direct dependencies
  • Freshness: Heuristic based on repository age and activity

Good: Lock file present, under 50 direct dependencies, recent updates

Git & Collaboration (20 points)

Analyzes repository health and team dynamics:

  • Commit Frequency: Regular commits indicate active maintenance
  • Contributor Count: Diversity of contributors
  • Bus Factor: Risk mitigation - not overly dependent on single contributor
  • Recent Activity: Last commit within reasonable timeframe

Good: Multiple commits per month, 5+ contributors, bus factor below 40%, active within 30 days

Available Commands

# Analyze a repository with default settings
codebase-health analyze .

# Analyze with verbose output
codebase-health analyze /path/to/repo --verbose

# Generate detailed report in JSON format
codebase-health report . --format json

# Save markdown report
codebase-health report . --format markdown --output-file report.md

# See help
codebase-health --help
codebase-health analyze --help

Requirements

  • Python 3.8+
  • Git (for repository analysis)

Built With

  • GitPython - Python Git bindings
  • Click - CLI framework
  • Rich - Beautiful terminal rendering

Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see LICENSE file for details.


Built by Glue — AI codebase intelligence for product teams. If you want deeper analysis including feature discovery, tribal knowledge extraction, and natural language querying, check out Glue.

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

codebase_health_score-1.0.0.tar.gz (20.5 kB view details)

Uploaded Source

Built Distribution

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

codebase_health_score-1.0.0-py3-none-any.whl (20.1 kB view details)

Uploaded Python 3

File details

Details for the file codebase_health_score-1.0.0.tar.gz.

File metadata

  • Download URL: codebase_health_score-1.0.0.tar.gz
  • Upload date:
  • Size: 20.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for codebase_health_score-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f9a8ab4ecc61a48c01991ac74bad00ffa9495100d98d329aaa5f9bc57cdd6c7b
MD5 1b01cd6df4e63ef0967b506c0db74556
BLAKE2b-256 533738526ebc62e0cacfba34c48ec120d316115470ff0a6fb3a8a8ba12f1678c

See more details on using hashes here.

File details

Details for the file codebase_health_score-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for codebase_health_score-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d9f4f67026e0db8581428060ded35052e573ba37d4281eb2189889b15386c4a7
MD5 39ac62085abe7072e760edea65230634
BLAKE2b-256 a13727d26f38409c9c9c9f7c87ce5ec25c7a21ea5ce3f6a37610eac65984ccf0

See more details on using hashes here.

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