Module clippy_report

Module clippy_report 

Source
Expand description

cargo xtask ci clippy-report — deduplicate clippy JSON artifacts and report via reviewdog.

§How it fits into CI

The clippy matrix job runs cargo xtask clippy --save-json <file> for every feature label on ubuntu-latest, uploading each file as a GitHub Actions artifact. After the matrix completes, the clippy-report job downloads all artifacts into a single directory and calls:

cargo xtask ci clippy-report --artifacts-dir <dir>

This command reads every .json file in the directory, deduplicates diagnostics across feature labels, and pipes the unique set through reviewdog once — so each warning appears as exactly one PR review comment regardless of how many feature combinations triggered it.

§Deduplication key

Two diagnostics are considered identical when they share the same (file_name, line_start, message) triple taken from the primary span of the clippy JSON message. Only diagnostic messages (compiler-message with spans) are included; non-diagnostic JSON (build artifacts, build-finished, etc.) is filtered out.

§Reviewdog

Uses the github-pr-review reporter. Requires:

  • reviewdog on PATH
  • REVIEWDOG_GITHUB_API_TOKEN set to a token with pull-requests: write

Structs§

ClippyReportArgs
Arguments for cargo xtask ci clippy-report.

Enums§

DiagnosticKey 🔒
A key that uniquely identifies a clippy diagnostic for deduplication.

Functions§

collect_unique_lines 🔒
Collects all JSON lines from every .json file in dir, returning only the unique ones (deduplicated by primary span + message text).
diagnostic_key 🔒
Extracts a DiagnosticKey from a raw clippy JSON line.
find_primary_span 🔒
Extracts a primary span from clippy JSON diagnostic message.
json_files 🔒
Returns sorted paths of every .json file directly inside dir.
json_to_short 🔒
Converts a clippy JSON line to short format for reviewdog.
pipe_to_reviewdog 🔒
Spawns reviewdog with the github-pr-review reporter and writes lines to its stdin.
run
Reads all .json files in artifacts_dir, deduplicates diagnostics, and pipes the unique set through reviewdog using the github-pr-review reporter.