| name | brokk-untested-paths |
| description | Use when asked to find untested code, missing test coverage, or pathways with no tests in a codebase - maps source files and functions against test files to surface gaps |
brokk-untested-paths
Overview
Find code paths with no test coverage by cross-referencing source files against test files, detecting test framework conventions, checking for coverage reports, and identifying critical functions that appear nowhere in the test suite.
Prerequisites
rg --version 2>/dev/null || echo "rg MISSING"
Step 1 — Detect Test Framework & Convention
rg --files | rg -i "(test|spec)\.(py|js|ts|java|go|rb|cs|php|rs)"
rg --files | rg -i "(test|spec)s?/"
rg --files | rg "_test\.(go|py|rs)$"
| Language | Test file pattern | Framework markers |
|---|
| Python | test_*.py, *_test.py | import pytest, import unittest, def test_ |
| JS/TS | *.test.ts, *.spec.ts | describe(, it(, test(, expect( |
| Java | *Test.java, *Tests.java | @Test, import org.junit |
| Go | *_test.go | func Test, func Benchmark |
| Ruby | *_spec.rb, test_*.rb | describe, it, expect |
| C# | *Tests.cs, *Test.cs | [Test], [Fact], [TestMethod] |
| Rust | same file, #[cfg(test)] | #[test] |
| PHP | *Test.php | extends TestCase |
Note the conventions found. This shapes Step 3.
Step 2 — Check for Existing Coverage Reports
Before doing manual analysis, look for pre-generated coverage data:
rg --files | rg -i "(coverage|lcov|\.coverage|htmlcov|coverage\.xml|clover\.xml|jacoco)"
If a coverage report exists, read it and extract:
- Overall line/branch coverage %
- Files with 0% coverage
- Files with <50% coverage
Report these directly — they are the answer. Still do Step 3 to find structurally untested paths the report may miss.
Step 3 — Map Source Files to Test Files
Build two lists:
Source files (exclude test dirs, vendor, node_modules, generated):
rg --files --glob "!*test*" --glob "!*spec*" --glob "!vendor/*" \
--glob "!node_modules/*" --glob "!dist/*" --glob "!build/*" \
| rg "\.(py|js|ts|java|go|rb|cs|php|rs)$"
Test files:
rg --files | rg -i "(test|spec)\.(py|js|ts|java|go|rb|cs|php|rs)|_test\.(go|py|rs)"
For each source file src/foo/bar.py, check whether a matching test file exists:
tests/foo/test_bar.py ✓
tests/foo/bar_test.py ✓
- No match ✗ → untested file
List all source files with no corresponding test file. These are candidates — confirm below.
Step 4 — Find Untested Functions
For each file flagged in Step 3, list its public functions/methods:
rg -n "^def [^_]|^ def [^_]" src/foo/bar.py
rg -n "^export (async )?function|^export (const|let) \w+ = " src/foo/bar.ts
rg -n "public \w+ \w+\(" src/Foo.java
rg -n "^func [A-Z]" foo.go
rg -n "^\s*def [^_]" foo.rb
Then check whether each function name appears anywhere in the test suite:
rg -l "function_name" tests/
If the function name does not appear in any test file → untested function.
Step 5 — Identify High-Risk Untested Paths
Not all untested code is equal. Flag as critical if the untested code:
- Is in files touched by recent commits:
git log --oneline -30 -- <file>
- Handles auth, payments, data mutation, file I/O, external APIs
- Contains error handling (
except, catch, rescue) — edge cases are rarely tested
- Is in a file with no test at all (not just low coverage)
git log --since="90 days ago" --name-only --format="" | sort -u \
| rg "\.(py|js|ts|java|go)$" > recently_changed.txt
Output Format
## Untested Paths Report
### Coverage Summary (if report found)
- Overall: 34% line coverage
- Files with 0% coverage: 12
- Files with <50% coverage: 28
### Source Files With No Test File
| File | Public Functions | Recently Changed |
|------|-----------------|-----------------|
| src/auth/token.py | 6 | yes (14 days ago) |
| src/billing/invoice.py | 4 | no |
### Untested Functions (in partially-tested files)
| Function | File | Risk |
|----------|------|------|
| validate_payment() | src/billing/payment.py:88 | HIGH — handles money |
| refresh_token() | src/auth/token.py:42 | HIGH — auth path |
### Test Framework Detected
- pytest (Python)
- jest (JS)
### Coverage Tool Detected
- .coverage found — run `coverage html` to view report
Windows Notes
rg --files and rg -l work natively
- Replace shell pipeline
sort -u | rg with: collect rg output, deduplicate manually
git log works natively on Windows with Git for Windows
Common Mistakes
| Mistake | Fix |
|---|
| Reporting private/internal functions as untested | Focus on public API surface first |
| Missing test files in non-standard locations | Search broadly with rg --files | rg -i test |
| Assuming no test file = no tests | Some projects co-locate tests; check for #[test] or describe( blocks in source |
| Ignoring coverage reports that already exist | Always check for existing reports first (Step 2) |