Skip to main content

Code quality metrics tracking tool that combines Ruff, Radon, and cloc to generate detailed trends over time

Project description

Code Metrics Tracker

PyPI Version License: MIT Python Versions

A powerful code quality metrics tracking tool for Python projects that helps teams monitor and improve their codebase over time. Code Metrics Tracker leverages three specialized tools to provide comprehensive analysis:

  • cloc: Counts lines of code, comments, and blank lines across programming languages
  • Ruff: Identifies linting issues, code style violations, and potential bugs with fast performance
  • Radon: Analyzes code complexity (cyclomatic complexity) and maintainability

The tracker generates detailed reports focusing on:

  • Lines of code statistics: Track code volume and distribution by language
  • Linting issues: Detect and monitor code style, potential bugs, and anti-patterns
  • Cyclomatic complexity: Identify complex functions and methods that need refactoring
  • Maintainability index: Measure how maintainable your code is over time

Results are stored in two complementary formats:

  1. JSON snapshots: Detailed metrics data stored in versioned JSON files for programmatic analysis
  2. Markdown reports: Human-readable CODE_METRICS.md file that tracks metrics over time with trend indicators

Perfect for teams that want to:

  • Track code quality trends over time
  • Identify problematic areas in the codebase
  • Make data-driven refactoring decisions
  • Establish quality standards with measurable metrics
  • Integrate metrics tracking into CI/CD pipelines

Installation

pip install code-metrics-tracker

Quick Start

  1. Initialize code quality tracking in your project:
codeqa init
  1. Create a code quality snapshot:
codeqa snapshot
  1. View the generated CODE_METRICS.md file for detailed metrics.

Features

  • Track code quality metrics over time
  • Generate formatted Markdown reports
  • Compare snapshots to identify trends
  • Highlight critical issues to address
  • Configurable for different project structures

Commands

  • codeqa init - Initialize code quality tracking in your project
  • codeqa snapshot - Create a new code quality snapshot
  • codeqa list - List all available snapshots
  • codeqa compare - Compare two snapshots to see trends
  • codeqa report - Generate a standalone report from a snapshot

Configuration

The tool uses a codeqa.json configuration file to determine which directories to analyze, focusing only on code maintained by your team.

Example configuration:

{
  "include_paths": ["src", "tests"],
  "exclude_patterns": ["venv", "site-packages", "__pycache__", ".pyc"]
}

GitHub Actions Integration

Add this to your GitHub Actions workflow to automatically track code quality metrics:

name: Code Quality Metrics

on:
  push:
    branches: [ main ]

jobs:
  code-quality:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-python@v4
        with:
          python-version: '3.10'
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install codeqa
      - name: Generate code quality snapshot
        run: codeqa snapshot
      - name: Commit updated CODE_METRICS.md
        uses: stefanzweifel/git-auto-commit-action@v4
        with:
          commit_message: "Update code quality metrics"
          file_pattern: CODE_METRICS.md generated/metrics/*

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

code_metrics_tracker-0.1.2.tar.gz (15.0 kB view details)

Uploaded Source

Built Distribution

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

code_metrics_tracker-0.1.2-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

Details for the file code_metrics_tracker-0.1.2.tar.gz.

File metadata

  • Download URL: code_metrics_tracker-0.1.2.tar.gz
  • Upload date:
  • Size: 15.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for code_metrics_tracker-0.1.2.tar.gz
Algorithm Hash digest
SHA256 430921467679b9e31b5b100c1d1210c481485e1be4aa5f5b75464471e6fbacfc
MD5 32e2a32e1b9be1df07583e7724039331
BLAKE2b-256 e913f1b31feb7ee120ad6f212e5c0afd745dd7d85a5f556312714d26d090caa0

See more details on using hashes here.

File details

Details for the file code_metrics_tracker-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for code_metrics_tracker-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f7ff4a122668e765f63a8db8a5f1c29ad478ed58985aebffb27137e66a0d9f86
MD5 2a4b721a1e81adff3d3c2ae27861c40d
BLAKE2b-256 8d916a5d0befd343eedf3278f8bb0283abecbe529ebbe840cf4d9a726ca9ca78

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