ruff_db: tweak main diagnostic message

In our existing diagnostics, our message is just the diagnostic
ID, and the message goes to the annotation. In reality, the
diagnostic can have its own message distinct from the optional
messages associated with an annotation.

In order to make the outputs match, we do a small tweak here:
when the main diagnostic message is empty, we drop the colon
after the diagnostic ID.

I expect that we'll want to rejigger this output format more
in the future, but for now this was a very simple change to
preserve the status quo.
This commit is contained in:
Andrew Gallant 2025-03-17 11:13:04 -04:00 committed by Andrew Gallant
parent 602a27c4e3
commit 9291074ba6

View file

@ -128,16 +128,21 @@ impl<'a> ResolvedDiagnostic<'a> {
ResolvedAnnotation::new(path, &input, ann)
})
.collect();
ResolvedDiagnostic {
severity: diag.inner.severity,
let message = if diag.inner.message.is_empty() {
diag.inner.id.to_string()
} else {
// TODO: See the comment on `Renderable::id` for
// a plausible better idea than smushing the ID
// into the diagnostic message.
message: format!(
format!(
"{id}: {message}",
id = diag.inner.id,
message = diag.inner.message
),
)
};
ResolvedDiagnostic {
severity: diag.inner.severity,
message,
annotations,
}
}