Fail CI when vulture finds new dead code (#889)

* Fail CI when vulture finds new dead code

scripts/check_dead_code.py runs vulture and compares its findings with
scripts/vulture_baseline.txt.  The baseline is keyed by file and name, not
line number, so unrelated edits do not invalidate it.  Class fields,
attributes, test arguments (side-effect fixtures), and alembic revision
names are not reported, because nearly all of them are false positives.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* TEMP: add a dead function to prove the Dead Code check fails

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Revert the temporary dead function

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
lrnselfreliance 2026-10-27 16:10:41 -06:00 • committed by Roland
parent 4365e23327
commit f4cd3b6f77
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
3 changed files with 224 additions and 0 deletions

34
.github/workflows/dead-code.yml vendored Normal file
View file

@ -0,0 +1,34 @@
name: Dead Code
# Same triggers as backend.yml: `pull_request` is unfiltered so pull requests into feature branches
# are checked too, not only those into master.
on:
push:
branches: [master, feature/*]
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
# Fails when vulture finds dead code that is not in scripts/vulture_baseline.txt. vulture only
# parses the source, so WROLPi's requirements are not installed.
vulture:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
# Trixie ships 3.13.
python-version: '3.13'
# Pinned: a new vulture release can report findings the baseline does not know about.
- name: Install vulture
run: pip install vulture==2.16
- name: Check for new dead code
run: python scripts/check_dead_code.py