Skip to content

Show every finding of a lint in a file that is over its baseline - #30

Merged
alii merged 1 commit into
scarletindustries:masterfrom
robobun:robobun/5c0dd972/baseline-prints-all
Sep 22, 2026
Merged

alii merged 1 commit into
scarletindustries:masterfrom
robobun:robobun/5c0dd972/baseline-prints-all

Conversation

@robobun

@robobun robobun commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Problem

  • mordant-baseline.toml holds a count of allowed findings for each lint and file, not which findings. When a file had more findings than its count, a run hid the first N in file order and printed the rest.
  • So the finding it printed could be an old one. A new finding written above the old ones was hidden, and an old one was printed in its place.
  • Seen on node:fs: call callbacks from the native completion, not a promise reaction oven-sh/bun#43728: the baseline allowed three generic_body_not_generic findings in node_fs.rs, the change added a fourth (UVFSRequest::run_from_js_thread, Windows only), and the CI annotation named readdir_with_entries_recursive_async at node_fs.rs:6446, which is not in that change's diff.

Fix

  • A file that goes over shows every finding of that lint. Each one has the note with the recorded count, as before. One line follows them with both counts and the reason:

    warning: mordant: 4 `generic_body_not_generic` findings in src/runtime/node/node_fs.rs, and the baseline allows 3. The baseline holds a count, not which findings, so all 4 are shown: any of them can be the new one
    
  • A file within its count still prints nothing.

  • over-baseline.txt and the closing line per crate do not change. They count the findings past the recorded count, not the findings shown.

  • In the driver, whether a file is over is known only once the crate is done. weigh no longer decides per finding. Each finding is built at once, kept as an owned DiagInner (the Diag itself borrows the session and is cancelled), and BaselineWriter::check_crate_post prints all of a key's findings or none. They are printed by position, because a lint that reports at the end of the crate has an order of its own.

  • cargo mordant does the same for unused_pub, where it already has every finding at hand. Both use baseline_file::over_message for the line with the counts.

Tests

  • New: a_file_over_the_baseline_shows_every_finding_of_the_lint. It records one discarded_error, then adds a second one above it. Without the change the run prints line 10, the old finding, and not line 6, the new one.
  • Changed: unused_pub_is_held_to_the_baseline now adds the new item above the recorded one and expects both. Without the change it prints demo::old only.
  • cargo fmt --check, cargo test, cargo clippy --all-targets -- -D warnings, and mordant over itself with -D warnings pass.

Checked over oven-sh/bun

  • With bun's baseline as it is, a run over three targets prints nothing about the baseline and writes no over-baseline.txt.
  • With generic_body_not_generic:src/runtime/node/node_fs.rs lowered from 3 to 2, the run prints all three findings in that file (CpSingleTask::create, mkdir_recursive_os_path_impl, readdir_with_entries_recursive_async), then the line with "3 ... findings" and "allows 2", and over-baseline.txt gets bun_runtime 1.

Cost

  • A file with a large count prints all of it when one finding is added. bun records 105 derived_field findings for one file. That is the price of a baseline that counts: it cannot name the new one.

The baseline holds a count for a lint and a file, not which findings.
A run hid the first N findings in the file and printed the rest, so a
new finding written above the old ones was hidden and an old one was
printed in its place. On oven-sh/bun#43728 the baseline allowed three
`generic_body_not_generic` findings in node_fs.rs, the change added a
fourth, and the run named `readdir_with_entries_recursive_async`, which
the change did not touch.

A file that goes over now shows every finding of that lint, each with
the note that names the recorded count, and one line after them with
both counts and the reason: any of the findings can be the new one. A
file within its count still prints nothing.

Whether a file is over is known once the crate is done, so the driver
builds each finding and holds it, as a `DiagInner`, until
`BaselineWriter::check_crate_post`, and prints all of a key's findings
or none. `cargo mordant` does the same for `unused_pub`, where it has
every finding at hand already. What `over-baseline.txt` and the closing
line per crate count is unchanged: the findings past the recorded count.
@alii
alii merged commit 52896c0 into scarletindustries:master Sep 22, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants