Skip to main content

scopio

Code metrics auditor with SQLite history, diffs and quality gates.

PyPI version Python versions License: MIT

Features

  • Audits code metrics (lines, complexity, warnings, languages) across multiple projects.
  • Stores audit history in SQLite with diffs and quality gates.
  • Ingests external linter reports (Ruff, ESLint, Clippy, SARIF) — see Ingestion Cookbook.
  • Exports results as JSON, CSV and Markdown.
  • Compares audits and detects regressions for CI (--fail-on-regression).

Install

pip install scopio

Requirements

  • Python >= 3.11
  • lizard >= 1.24.0 (required for CSV parsing mode)
  • scc >= 3.3.0 (optional, used for language/line counting) — the boyter/scc code counter, not the unrelated PyPI scc package:
    # Download a binary from https://github.com/boyter/scc/releases, or:
    go install github.com/boyter/scc/v3@latest
    
  • git (optional, used for metadata)

Quick Start

scopio --config scopio.toml run

All output artifacts (database, JSON, CSV, Markdown) are stored in the .scopio/ directory by default. Use --output-dir to override.

If scc or lizard versions differ from the expected range, a non-blocking tool_version_diverge warning is emitted in the logs.

Usage

Run audit

scopio --config scopio.toml run
scopio --config scopio.toml run --verbose
scopio --config scopio.toml run --incremental

Report history

scopio report --project my-project --limit 10

Diff between audits

scopio diff --project my-project

Diff report with file-level detail

scopio diff-report --project my-project --files --threshold-ccn 6

CI integration

scopio ci --project my-project --fail-on-regression

Clean old audits

scopio clean --keep 50

Archive old data

scopio archive --older-than 2026-01-01 --format csv

Initialize config

scopio init

Configuration

[discovery]
ignore_hidden = true
projects = ["my-project"]

[filters]
global_dirs = ["node_modules", "target", "dist", "build"]
minified_files = ["*.min.js", "*.min.css"]
ignored_langs = ["JSON", "Markdown", "TOML"]

[quality_gates]
max_ccn = 10.0            # average CCN per function
max_function_ccn = 15.0   # worst function complexity (disabled if omitted)
max_warnings = 10
max_ccn_trend_increase = 0.2
trend_sensitive_projects = []

[quality_gates.per_project]
# "my-project" = { max_ccn = 12.0, max_warnings = 15, max_function_ccn = 20.0 }

[quality_gates.per_language]
# Python = { max_ccn = 12.0, max_warnings = 20 }

[ci]
max_loc_trend_increase = 0.0  # fail if LOC grows above this ratio (0.0 = any growth)

Audit behavior

  • Each audit run creates/updates a single row per (project, branch, commit_hash).
  • Same commit, same branch: metrics are upserted (updated) and runs_count is incremented. This avoids data staleness when re-running on the same commit (e.g. after changing .scopio.toml filters).
  • Different commit: a new row is created with runs_count = 1.
  • The runs_count field is exposed in report, CSV, JSON and Markdown exports.
  • Diff and CI comparisons compare the previous audit against the current one by default (use --base first to compare against the very first audit).
  • Quality gates use the current audit's values; the trend gate compares against the previous historical audit.

What the numbers mean

  • LOC: source lines of code counted by scc.
  • NLOC: logical lines of code counted by lizard. LOC and NLOC are intentionally different metrics (different counting methodologies).
  • CCN (avg): cyclomatic complexity averaged over all functions. Averages hide outliers.
  • ccn_max / max_function_ccn: cyclomatic complexity of the worst single function — this is what the per-function quality gate checks.
  • warnings: currently always 0 — the lizard --csv format does not emit warnings. Language-specific warning adapters (clippy, eslint, ruff) are planned.
  • file_metrics: stored per-function in the database; the granular diff-report aggregates them per file (NLOC sum, CCN max).

GitHub Actions

name: Scopio
on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  scopio:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Install uv
        uses: astral-sh/setup-uv@v10.0.1
        with:
          enable-cache: true
          cache-dependency-glob: "uv.lock"
      - name: Install Python
        run: uv python install 3.11
      - name: Install scopio
        run: pip install scopio
      - name: Run scopio
        run: scopio ci --project my-project --fail-on-regression

Development

This project uses uv as the Python toolchain.

See CONTRIBUTING.md for the commit convention and release workflow.

Architecture and scope decisions are recorded in docs/DECISIONS.md.

# Sync dependencies and create a virtual environment
uv sync

# Run tests
uv run pytest

# Run a lint check
uv run ruff check

# Run scopio locally
uv run scopio --help

Semantic Versioning

This project adheres to Semantic Versioning.

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scopio-0.6.0.tar.gz (131.5 kB view details)

Uploaded Source

Built Distribution

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

scopio-0.6.0-py3-none-any.whl (30.7 kB view details)

Uploaded Python 3

File details

Details for the file scopio-0.6.0.tar.gz.

File metadata

  • Download URL: scopio-0.6.0.tar.gz
  • Upload date:
  • Size: 131.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for scopio-0.6.0.tar.gz
Algorithm Hash digest
SHA256 9d41237f045cf9b41cce76d86c2c3c79eb416e99f64e0fcabddcfdeecc4fcf3b
MD5 6a5cb94991895ec5314d10f1fb5b0931
BLAKE2b-256 eed220bff78af459a148cc57b18b1595e4ca93a8076dac5fa76c9bb36263b710

See more details on using hashes here.

Provenance

The following attestation bundles were made for scopio-0.6.0.tar.gz:

Publisher: publish.yml on ImGabe/scopio

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

File details

Details for the file scopio-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: scopio-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 30.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for scopio-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 66af77b2c0961133f246228eec97b81b3db4e1f0db0d864814834c15ced4c385
MD5 d5782402327b25b9edd7ee5a0afaae38
BLAKE2b-256 504fe6239509a37933a93a98f1929758c886b7bfcdbdadeaefed0e57a2a9ccb4

See more details on using hashes here.

Provenance

The following attestation bundles were made for scopio-0.6.0-py3-none-any.whl:

Publisher: publish.yml on ImGabe/scopio

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

Release history Release notifications | RSS feed

0.7.0

2 files

This release

0.6.0 This release

2 files

0.5.0

2 files

0.3.0

2 files

0.2.2

2 files

0.1.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page