Metadata-Version: 2.4
Name: gh-repo-auditor
Version: 1.0.0
Summary: Async CLI that audits Python repositories on GitHub for engineering quality and explains every finding.
Project-URL: Homepage, https://github.com/david-oliveira-dev/repo-auditor
Project-URL: Repository, https://github.com/david-oliveira-dev/repo-auditor
Project-URL: Changelog, https://github.com/david-oliveira-dev/repo-auditor/blob/main/CHANGELOG.md
Author-email: David Oliveira <davidoliveira.devbr@gmail.com>
License: MIT License
        
        Copyright (c) 2026 David Oliveira
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: asyncio,cli,code-quality,devtools,github-api,httpx,open-source,python
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Typing :: Typed
Requires-Python: >=3.11
Requires-Dist: httpx>=0.27
Requires-Dist: pydantic>=2.7
Requires-Dist: rich>=13.7
Requires-Dist: typer>=0.12
Description-Content-Type: text/markdown

# repo-auditor

Async CLI that audits Python repositories on GitHub for engineering quality — tests, CI,
typing, packaging, docs and security — and explains every finding.

## Problem

Judging whether a Python repository is well engineered is manual and inconsistent.
Everyone looks at the same things — is there a README? are there tests? is CI running? is
the package installable? is a secret committed? — but without explicit criteria the
verdict changes with who is looking and on which day.

Existing badges and services hand back a number without saying how they reached it, which
makes the number useless for acting on. Here, **a score without a justification is a
bug**: the report is a list of findings, each with the evidence behind it and a concrete
recommendation. The number is only a summary of that list. The exact method is public in
[`docs/scoring.md`](docs/scoring.md).

## Features

- Audit a single repository or every public repository of a user
- Eight dimensions: security, documentation, testing, CI/CD, static quality, packaging,
  activity and community
- Every finding carries evidence and, when not OK, an actionable recommendation
- Bounded concurrency, proactive rate-limit handling, retry with exponential backoff
- Local SQLite cache with TTL and conditional (ETag) revalidation — a warm cache is nearly
  free
- Text, JSON and Markdown output; severity-based exit codes for CI use
- Never executes the audited repository's code; a detected secret is reported by file and
  type, never by value

## Requirements

- Python 3.11+
- Optionally a `GITHUB_TOKEN` — without one the GitHub API allows 60 requests/hour instead
  of 5000, which caps a single run at roughly 14 repositories and prints a warning

## Installation

```bash
uv tool install gh-repo-auditor      # or: pipx install gh-repo-auditor
repo-auditor --help
```

The distribution is published as **`gh-repo-auditor`**, but the command it installs is
`repo-auditor`. The prefix exists because PyPI rejects `repo-auditor` as too similar to the
unrelated project [`RepoAuditor`](https://pypi.org/project/RepoAuditor/); it also states
what is audited — GitHub repositories.

For local development:

```bash
uv sync
uv run repo-auditor --help
```

## Usage

```bash
export GITHUB_TOKEN=...            # optional but recommended

repo-auditor audit psf/requests            # audit one repository
repo-auditor audit-user octocat            # audit all of a user's public repos
repo-auditor compare psf/requests urllib3/urllib3
repo-auditor audit psf/requests --json     # stable JSON (see docs)
repo-auditor audit psf/requests --markdown --output report.md
repo-auditor rules                         # show active dimensions and weights
repo-auditor cache clear
```

Real output, auditing this author's own `ubuntu-doctor` (the tool applied to its own
portfolio):

```text
david-oliveira-dev/ubuntu-doctor  score 92.5  INFO
  [INFO] activity.has_release: no published release was found
          → Tag a release so users can depend on a specific version.
  [INFO] community.security_policy: no SECURITY.md was found
          → Add a SECURITY.md describing how to report vulnerabilities.
  [OK] security.no_secret_patterns: no content matching a known secret pattern was found
  [OK] documentation.readme_substance: README has 6736 characters and 18 headings
  [OK] testing.suite_present: found 18 test file(s), e.g. tests/integration/test_cli.py
  [OK] ci.runs_lint_and_tests: a workflow runs both linting and tests
  [OK] packaging.src_layout: the package uses a src/ layout
  ...
```

### Exit codes

| Code | Meaning |
| --- | --- |
| 0 | clean — no critical finding |
| 1 | a critical finding (e.g. a committed secret) |
| 2 | usage error (bad reference, repository not found) |
| 3 | API/network error |

This makes `repo-auditor` usable as a CI gate: fail the build if a critical finding
appears.

### JSON contract

`--json` emits a versioned, stable schema (`schema_version`). It is the tool's public
contract — field names and nesting change only with a version bump. See
[`docs/scoring.md`](docs/scoring.md) for what each field means.

## Configuration

| Variable | Required | Purpose |
|---|---|---|
| `GITHUB_TOKEN` | No | Raises the API limit from 60 to 5000 requests/hour |
| `XDG_CACHE_HOME` | No | Overrides where the SQLite cache is stored |

The token is read **only** from the environment. It is never accepted as a command-line
argument, never logged, and never written to the cache. See `.env.example`.

## Testing

```bash
make check      # ruff + mypy (strict) + pytest with coverage
```

Every test runs offline. HTTP is exercised with `respx` against sanitised fixtures of real
API responses; rules are exercised against hand-built snapshots. Minimum coverage: 85%.

## Design decisions

- [`docs/architecture.md`](docs/architecture.md) — the layers and the collect/evaluate
  boundary, with a diagram
- [`docs/scoring.md`](docs/scoring.md) — the public scoring method
- [`docs/api-budget.md`](docs/api-budget.md) — measured API limits, the endpoints used,
  and the cost of an audit
- Architecture decision records in [`docs/adr/`](docs/adr/):
  [snapshot separates collection from evaluation](docs/adr/0001-snapshot-separates-collection-from-evaluation.md),
  [UNKNOWN never penalizes](docs/adr/0002-unknown-never-penalizes.md),
  [SQLite cache over an external service](docs/adr/0003-sqlite-cache-over-external-service.md)

## Limitations

Stated up front, because a quality tool that overstates its reach is its own
counter-example:

- Does not analyse source code — no AST, no complexity metrics
- Does not run the audited repository's tests, and never executes its code
- GitHub only; Python repositories only
- Community and activity signals are heuristics, not measurements
- Secret detection reports a *pattern compatible with a secret*, never a certainty — and
  never prints the value it matched

## Roadmap

v1.1 adds audit history over time; v1.2 user-defined rules; v2.0 would require abstracting
the provider layer to support GitLab.

## Contributing

Issues and pull requests are welcome. Please read the PR template first.

## License

MIT — see [LICENSE](LICENSE).

## Contact

David Oliveira — davidoliveira.devbr@gmail.com
