Test coverage
A test run that ran before the review wrote an lcov tracefile: for each file, which lines a test ran and how often. --lcov hands that file to a review, and the profiles that read test coverage learn, for each line the change adds, whether a test ran it. The built-in best-practices profile reads it, and so does any profile of your own that sets testCoverage: true. This page says what quorum reads, the flag, the four states a line can have, what the finder and which voters receive and why, what a person sees, and what a coverage report can never tell.
What quorum reads, and never runs
- Files only. Quorum reads the tracefile a flag names and never runs a test, a coverage tool or a build. The test job is the CI's, and it runs before the review.
- As data, never as configuration. The change's own tests write the file, so it is text the change can influence. It is read through the bounded reader, as a regular file and never through a link, at most 16 MiB, and no word of it reaches a model: what a profile is sent of it is code's own words and the diff's file names, never a test name, a path the diff does not name or a line of the file: What the finder and the voters receive.
- A report adds facts, never removes a finding. No finding is dropped on a report's word, and no verdict, confidence or exit code is decided by one: the panel weighs a state as it weighs the diff.
- Nothing local is written out. No result, event, line or detail holds the tracefile's path, a file name it lists or its text, only counts, a hash and code words.
- A review that names no tracefile sends what it always sent: no new block, no new line and no new gap. Its result differs only in that a profile that reads test coverage,
best-practicesamong them, recordstestCoverage: noneinmeta.profilesandtestCoverage: truein its settings record and in the entry of each lens flagged to receive the line, in every review.
The flag and its error
quorum --range "$BASE...$HEAD" --profile best-practices --lcov coverage/lcov.info--lcov <path>names one tracefile, relative to the working directory unless absolute. It takes the path alone: a coverage report feeds every profile that reads test coverage, so there is no<profile>=, and a value that starts with an id and=is a path like any other.- It repeats, and the tracefiles are merged: a test run split into jobs, each with its own tracefile, is read as one. The merge is line by line, the strongest state of a line winning (The states). Each file is a report of its own, counted in the 16 reports a review reads at most with
--sarifand--sonarqube, read after them, so its place inmeta.context.reports, and its number from 1 in the lines, follow the scanner reports'. --scan-root <dir>places the absolute paths of a tracefile as it places a scanner report's: The paths. A tracefile written by a runner that checked the repository out to its default directory needs none.- A CI job writes the tracefile. The scan job of the recipe runs the tests with an lcov reporter, with no secret, and hands the file to the review job that holds the key: A workflow with a scan job.
quorum mcpdefines none: an agent's review reads the changes it names, and a test run is the CLI's.
| Error | When | Exit |
|---|---|---|
Error: --lcov: must name a file | An empty path, --lcov '' | 2, with the usage, before any config |
Error: --lcov: takes at most 16 reports in all | A seventeenth report, named at the flag of the seventeenth | 2, with the usage |
Error: --lcov: no profile that runs reads test coverage, as best-practices does | A tracefile while no profile that runs reads test coverage, security alone for one | 2, no usage, after the config loads and before any git |
Error: --print-config: reads no report, so it takes no --sarif, --sonarqube, --lcov or --scan-root | --lcov with --print-config, which reads no diff | 2, with the usage |
The third is the fix to read: a tracefile no profile reads would be dropped silently, so the run says so before any model is called. Add --profile best-practices, or set testCoverage: true on a profile of your config (Turning it on and off). No message repeats a path or a value given. A tracefile that is missing, a link, over 16 MiB or no lcov text is never an exit 2: it is a gap of each profile that reads test coverage (The gaps).
Reading a tracefile
The format is lcov's line text: a file's record opens at SF:<path> and closes at end_of_record, and holds the rows quorum reads and the rows it reads past.
DA:<line>,<count>[,<checksum>]gives a line's hits. The checksum is never read.BRDA:<line>,<block>,<branch>,<taken>gives a branch of a line, taken that many times,-for a branch that was never evaluated. A branch taken0times or-is missed, and marks its line as having a missed branch, whichever of the line's rows comes first in the record.- Every other row (
TN,FN,FNDA,LF,LH,BRF,BRH) is read past. Vitest's and Bun's tracefiles are the shapes the reader is tested against, and any tool that writes these rows is read the same way. - A record is read alone. One with a row quorum cannot read (a line or a count that is no whole number of 0 or more, a row with another number of fields), one never closed, and a
DA,BRDAorend_of_recordrow outside any record cost that record, counted as unreadable, and no other. A text with noSFrow is no tracefile. - A record's path is placed by the path rules of a scanner report, compared with the diff's own paths and never opened. A record whose path cannot be placed in the repository (an absolute path outside the scan root, a path with a
..segment) is counted as unmapped, and its rows are not read. - A file or a line listed twice is read as it is listed, and the merge takes the strongest state of each line.
A tracefile that has records it could not read or place is read in part, and says so: The gaps. A tracefile states no commit, so none is checked: run the tests on the commit under review, and for --local or --staged, on the working tree as it is reviewed.
The states
A changed line is a line the change adds, in the new file, as the diff the review reads has it; a file with no added row is in no block and no count. Each changed line has one of four states, from what the merged tracefiles say of it:
| State | What the report says | The words |
|---|---|---|
covered | It lists the line with hits above 0, and no branch on it was missed | covered |
partial | It lists the line with hits above 0, and a branch on it was taken 0 times or never evaluated | a missed branch |
zero | It lists the line with 0 hits | zero hits |
not-measured | It lists no hit for the line, or has no record of its file | not measured |
The records merge line by line, within a tracefile and across tracefiles, each line taking the strongest state any record gives it: covered, then partial, then zero, and not-measured only for a line no record lists. A line listed with hits in one job and with none in another is covered: the tests of the one that ran it ran it.
What the finder and the voters receive
When the review read a tracefile, each profile that reads test coverage is sent the state of the changed lines, in two places, and in the second only the lens that asks for it.
- The finder (the research request) is sent a block,
tests, after the diff and the rules and before the guidelines: one line for each file of the request's own part of the diff that has a changed line, in the diff's order,src/a.js: zero hits 12-15, 20; missed branch 16; not measured 22-24; covered 10-11(a state with no line left out), orsrc/b.js: not in the coverage report, thenand <n> more fileswhen the block's budget ends first. The budget is a quarter of the lesser ofpartTokensand the room a request with no block leaves, a quarter ofpartTokensfor a provider that states no room, so no part's request outgrows its model's window. The data notice describes it aswhich changed lines the project's tests ran, read by code from a coverage report: covered, zero hits, a missed branch, or not measured, by file and line range. A line not measured is no proof that no test runs it. - One lens is sent the cited file's line of that block, at most 1,024 bytes, in its vote. In
best-practicesit is theabsentlens alone, whose question asks whether the required piece is really missing: a line the block shows as covered is evidence that a test ran it, and refutes the claim that no test does. Theaskedlens, which judges whether the rule fits the code, and theintroducedlens, which judges whether the code is new, have no use for it, and receive nothing new. - Each finding of such a profile carries the state of the line it stands on,
testCoveragein its verdict, and the report says it:test coverage: zero hits. The state is a fact for a reader, and it is the one fact the panel never decides on: no finding is dropped, kept or ranked for it.
Why one lens, where every voter of the profile could be sent it: a text sent to every voter lowered kept recall in an ablation of 0.13, from 60% to 40%, the voters rejecting true findings. The coverage line is evidence for one refutation angle, and a voter that judges something else gains only a reason to doubt. So the line goes to the lens that asks for it, and each of the others votes on what it always did: Test coverage in a lens.
A profile that reads none, security, code-review and performance among them, is sent nothing of a tracefile, even in a review that reads one beside a profile that does: its requests, its findings and its record are as they were.
What a person sees
- The log, once for each tracefile, after the scanner reports' lines:
context: report 1 lcov: 3 of 4 changed file(s) measured; 9 changed line(s) with zero hits, 1 with a missed branch, 6 not measured, 40 covered, then; read in partfor a tracefile read in part. A tracefile that could not be read iscontext: report 2 lcov: could not be read. The text report'sreports:lines and the Markdown summary's list of the reports read say the same: Progress lines, The summary. - Each finding of a profile that reads test coverage, in the text report, the Markdown, the summary and the JSON:
test coverage: zero hits,a missed branch,coveredornot measured, so it rests on the diff alone. --print-config, under a profile that reads test coverage, the lenses that are sent the line:testCoverage: { lenses: [absent] }forbest-practices, and nothing undersecurity: Printing the resolved config.- The result records the tracefile's hash and counts in
meta.context.reports, with the statusread,partialorunreadable, andmeta.profiles.<id>.testCoverage,readornone: A coverage report's record.
Turning it on and off
testCoverage is a boolean of a profile and of a lens, false when unset. A profile that sets it reads test coverage; a lens that sets it is sent the cited file's line, when its profile reads it.
profiles:
best-practices: {}
quiet:
extends: best-practices
testCoverage: false
team-practices:
extends: best-practices
lenses:
- id: asked
question: Does the cited rule's text really ask for what the finding says is missing?
- id: absent
question: Is the required piece really missing? A line the test-coverage block shows as covered refutes the claim.
testCoverage: true
- id: introduced
question: Is the gap in code this change adds or alters, rather than in code it leaves as it was?- A profile that extends
best-practicesinherits both: it reads test coverage and itsabsentlens is sent the line.testCoverage: falseturns the reading off, and the flagabsentcarries with it. - A lens that sets it on a profile that reads none takes nothing, and the run warns of it:
<id>.lenses.<index>.testCoverage: has no effect while the profile reads no test coverage. - A profile of your own that sets
testCoverage: true, with lenses that set it or none, is read the same way. With no lens that asks, it is sent the block and its findings carry their state, and no voter receives the line. - The bench holds neither setting in a configuration's fingerprint while no case carries a report: The fingerprint.
The gaps
A tracefile that is not read whole is a gap of each profile that reads test coverage, in fixed words that name the report by its place and never by a file name, as a scanner report's are:
| Reason | When | The detail |
|---|---|---|
report-unreadable | Nothing of it was used | report <n> (lcov) could not be read: <why> |
report-partial | Part of it was not read or not placed | report <n> (lcov) was read in part: <why> |
- Unreadable, by cause:
the file does not exist,the file cannot be read,it is a symbolic link or no regular file, which quorum does not read,it is over 16 MiBandit is no lcov tracefile, which a file that is no UTF-8 text is too. - In part, by cause:
<u> file record(s) could not be readand<m> file record(s) name a path quorum could not place in the repository. - No flag lifts one. A gating profile's gap exits
4and an advisory profile's, asbest-practices' is, is reported and exits nothing: Exit codes. The summary says the fix,check the report's path, and that the scan job wrote it for the reviewed commitfor an unreadable one andsee the gap in the reportfor a partial one. A profile whose tracefile could not be used is sent no block, and its findings carry no state: they rest on the diff alone.
What a coverage report cannot say
- Covered means a test ran the line, not that a test checks it. A test that calls a function and asserts nothing covers every line it runs. A
coveredline refutes the claim that no test runs it and never the claim that no test checks it, so theabsentlens is asked to weigh a state, never to take it as proof, and a finding'scoveredis a fact to read, not a reason it is wrong. - Not measured is no proof that no test runs a line. A tracefile lists the files its tool instrumented and the lines it could measure: a generated file, a file no test imports, a line the tool does not count, a tracefile of another package or a path quorum could not place are all
not measured. The data notice says so to the model, and the report saysso it rests on the diff alone. - The change writes the file. The tests that wrote it run the change's own code, and a change can make a test run a line without checking it, or write a tracefile of its own. So a state is evidence the panel weighs, one voter's, and the only decision code makes of it is none: no finding is dropped, kept or ranked on a state, and no exit code follows one: Threat model.
- The change can edit what the tests measure. A change to a coverage tool's config (
.nycrc*,.c8rc*,.coveragerc,codecov.yml) or to a CI workflow, while the review reads a tracefile, raises an advisoryscanner-config-editedflag, a hint for a person that changes no state, verdict or exit code: Suppressions. - A tracefile of another commit says nothing of this change. It states none, so quorum cannot check it: the test job must run on the commit the review is of.
Next
Related code — the code of the repository outside the diff that a finding's cited row names, read at a commit quorum resolves: what is read and why it is off by default, the files never read, the bounds, and what it cannot do.
