Ci/dejadoc duplicate doctests #5216
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.42 · 233 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.326
Shallow Review Depth
shallow_review_depth
0.289
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #5216"
general
weight: 0.35
weiznich
Duplicated doctests slip in either through tiredness, a doc pasted from its neighbour and half-adapted, or an LLM regurgitating an existing doctest when writing a new one.
For instance, I nearly missed a duplicated doctest while reviewing #5198, where the
LikeAnyandILikeAnystruct docs repeated examples that the method doctests already run. Both copies compile and pass CI, rustdoc just runs the same test twice, so nothing else would flag them.Since these kind of thing can be detected statically, I decided to write
cargo-dejadoc, a well tested crate + GitHub Action.It parses the code statically and canonicalizes every doctest rustdoc would run, reports clones, and ships as a GitHub Action that comments on the copies to remove, each linked to the copy that survives with a removal suggestion. The check, not requiring the code to actually build, is fairly fast, locally takes for diesel
0.4s.In its default mode, which is how I propose to configure it, it reports only duplicates a pull request introduces (all existing duplicates in diesel have now been taken care of).
In fact, I ran a scan of current main and unexpectedly found 8 duplicated groups, 13 redundant copies out of 536 doctests.
The worst offenders are the doctests under
jsonb_group_arraycalljson_group_arrayinstead, so the JSONB aggregate currently has no doctest coverage at all. I fixed these and the other mentioned cases in #5213, #5214, and #5215In this PR, the
`rust,dejadocnotation is to denote duplicated tests which we expect to appear as duplicates.The workflow runs on
pull_request_targetrather thanpull_requestbecause fork PRs get a read-only token and the action review comments would not post, it checks out the pull request head withpersist-credentials: false.