Skip to main content

Module co_change

Module co_change 

Source
Expand description

The commit-scoped co-change check (#33): a source file that changed in a git diff must change its colocated test too.

Convention: when a source file is modified (e.g. a function removed from foo.py) or deleted in a commit range, its colocated test — the #15/#18 pairing, foo.pyfoo_test.py, foo.tsfoo.test.ts — must also be in that diff. This catches edits and removals that leave the test silently stale. Added source files are not subjects: brand-new code is the coverage floor’s job, not this one.

stale_sources walks git diff --name-status <base>...HEAD for a Language and returns every changed source file whose colocated test did not co-change. A file listed in the config exempt table (rule co-change) is a deliberate, reason-required omission. Rust has no sibling test file — units are inline #[cfg(test)] in the same .rs — so the rule is Python/TypeScript only (the CLI rejects --language rust).

Functions§

stale_sources
Every source file changed in repo’s <base>...HEAD diff whose colocated test did not also change — the stale-test risks — sorted for deterministic output.