CODEOWNERS Coverage Analyzer
Check changed paths against base-branch CODEOWNERS rules, measure direct and fallback coverage, and surface review gaps before merge.| Changed path | Group | Outcome | Owners | Winning rule | Review note | Copy |
|---|---|---|---|---|---|---|
| {{ row.path }} | {{ row.group }} | {{ outcomeLabel(row.outcome) }} | {{ row.owners }} | {{ row.rule }} | {{ row.note }} |
| Priority | Finding | Evidence | Suggested next step | Copy |
|---|---|---|---|---|
| {{ row.priority }} | {{ row.finding }} | {{ row.evidence }} | {{ row.next_step }} |
| Line | Pattern | Owners | Rule state | Winning matches | Copy |
|---|---|---|---|---|---|
| {{ row.line }} | {{ row.pattern }} | {{ row.owners }} | {{ ruleStateLabel(row.state) }} | {{ row.match_count }} |
Ownership coverage can reach 100% while still routing a sensitive change to the wrong reviewers. A catch-all rule assigns an owner to every path, but it says nothing about whether database migrations, infrastructure, or the ownership policy itself have focused maintainers. Useful coverage distinguishes a specific match from a fallback and keeps policy defects visible beside the percentage.
A CODEOWNERS file maps repository paths to users or teams. For a pull request, the relevant policy comes from the base branch, which is the branch receiving the proposed change. On GitHub, the supported locations are .github/CODEOWNERS, CODEOWNERS at the repository root, and docs/CODEOWNERS; the first file found in that order is used.
Order inside the file matters as much as location. When several usable rules match a changed path, the last match wins. A later scoped rule can replace a broad default, while a later entry with no owner can deliberately or accidentally clear the earlier assignment. Matching is case-sensitive, and some familiar .gitignore features, including negation and bracket ranges, are not supported in CODEOWNERS.
- Specific ownership means a non-catch-all rule with at least one owner wins.
- Fallback ownership means the catch-all rule supplies the owner.
- Ownerless override means the winning rule names no owner.
- Missing ownership means no usable rule matches the path.
Protected paths deserve stricter treatment because fallback review can hide responsibility gaps. Changes to CODEOWNERS may also need a specific owner so the policy cannot silently review itself through a broad wildcard. Ignored paths affect the denominator and should be limited to files that genuinely belong outside the review, such as generated or vendored output.
Coverage remains a pre-merge diagnostic. It cannot prove that an owner exists, has the required access, will be requested by the repository host, or satisfies branch-protection rules. Confirm every blocking or surprising result in the pull request's native review interface.
How to Use This Tool:
Use the base-branch policy and the exact changed-path set from the same pull-request comparison.
- Paste the base branch's CODEOWNERS file or load one CODEOWNERS or TXT file up to 3 MiB. Correct reported invalid rules before accepting the result.
- Paste Changed files as plain paths or common Git status, rename, copy, or numeric diff rows. Duplicate paths count once and rename or copy records use the destination path.
- Set a coverage target from 0% to 100%, list protected path prefixes, and enable CODEOWNERS self-owner when policy changes require a focused reviewer. Exclude paths only when they are intentionally outside the review because ignored patterns change the denominator.
- Review the path ledger and remediation queue even when the headline percentage meets its target. The owner gate clears only when the target is met and no blocking finding remains.
Interpreting Results:
Coverage counts both specific and catch-all owner-bearing matches. Direct coverage counts only specific matches, so the gap between them reveals reliance on fallback ownership. Neither percentage should hide an invalid rule, ownerless override, protected catch-all, self-owner gap, or truncated path set.
- Gate clear requires coverage greater than or equal to the target and zero blocking findings.
- A protected path on the catch-all still contributes to ordinary coverage but creates a blocker.
- An ownerless winning rule and a path with no match both fail to contribute to coverage.
- Ignored files are excluded before the denominator is formed; review them separately to prevent an artificially high percentage.
- A repository-host result that differs from the ledger takes precedence. Check file location, base branch, case, rule syntax, and owner eligibility.
Technical Details:
Coverage analysis is a deterministic path lookup followed by percentage and gate rules. Changed paths are normalized to forward slashes, filtered, deduplicated, and capped before matching. Every checked path receives the outcome of its last matching usable rule.
Rule Core
| Rule | Exact behavior |
|---|---|
| Comments | Blank lines and lines beginning with # are skipped. A whitespace-delimited # starts an inline comment. |
| Unsupported syntax | Negation, bracket ranges, and an escaped initial # are reported as invalid and omitted from matching. |
| Wildcards | * matches within a path segment, ? matches one non-slash character, and ** can span directories. |
| Precedence | Rules are evaluated in file order and the last usable matching rule wins. |
| Changed paths | Common status and numeric-diff prefixes are removed. Rename and copy records use the destination path; duplicates are counted once. |
| Protected paths | A protected prefix or wildcard that wins only the catch-all creates a blocking finding even though an owner is present. |
| Self-owner check | When enabled and a supported CODEOWNERS path is changed, a specific non-catch-all owner must win. |
Formula Core
Ordinary coverage uses every checked path whose winning rule names an owner. Direct coverage uses only paths with a specific owner-bearing winner.
The shortfall is the greater of zero and target minus coverage, measured in percentage points. Percentages are retained at calculation precision and displayed to one decimal place in review evidence.
Gate and input boundaries
The gate passes only when C is greater than or equal to the target and the blocking count is zero. Blocking findings include every missing-owner path, ownerless winner, protected catch-all path, invalid rule, and path beyond the 5,000-path limit, plus one finding when the enabled self-owner check fails. The CODEOWNERS text is limited to 3 MiB and changed-path input to 2 MiB.
Accuracy and Privacy Notes:
Both text sources are processed in the current browser and are not uploaded. The bounded matcher covers the documented core patterns used by this review, but the repository host remains authoritative for exact CODEOWNERS behavior, file selection, owner validity, team visibility, permissions, review requests, and branch protection. Compare any disputed path directly on the base branch before changing policy or approving a merge.
References:
- About code owners, GitHub Docs.
- Git diff format, Git Documentation.
- How to review changes against a base branch with Codex, Simplified Guide.