mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 10:49:50 +00:00
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:
parent
602a27c4e3
commit
9291074ba6
1 changed files with 9 additions and 4 deletions
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue