Skip to content

Commit 28477f0

Browse files
committed
message -> diagnostic
1 parent 3718c62 commit 28477f0

File tree

1 file changed

+20
-19
lines changed
  • crates/ruff_db/src/diagnostic/render

1 file changed

+20
-19
lines changed

crates/ruff_db/src/diagnostic/render/junit.rs

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,29 +32,30 @@ impl<'a> JunitRenderer<'a> {
3232
test_suite.add_test_case(case);
3333
report.add_test_suite(test_suite);
3434
} else {
35-
for (filename, messages) in group_diagnostics_by_filename(diagnostics, self.resolver) {
35+
for (filename, diagnostics) in group_diagnostics_by_filename(diagnostics, self.resolver)
36+
{
3637
let mut test_suite = TestSuite::new(filename);
3738
test_suite
3839
.extra
3940
.insert(XmlString::new("package"), XmlString::new("org.ruff"));
4041

41-
for message in messages {
42-
let MessageWithLocation {
43-
message,
42+
for diagnostic in diagnostics {
43+
let DiagnosticWithLocation {
44+
diagnostic,
4445
start_location: location,
45-
} = message;
46+
} = diagnostic;
4647
let mut status = TestCaseStatus::non_success(NonSuccessKind::Failure);
47-
status.set_message(message.body());
48+
status.set_message(diagnostic.body());
4849

4950
status.set_description(format!(
5051
"line {row}, col {col}, {body}",
5152
row = location.line,
5253
col = location.column,
53-
body = message.body()
54+
body = diagnostic.body()
5455
));
55-
let code = message
56+
let code = diagnostic
5657
.secondary_code()
57-
.map_or_else(|| message.name(), SecondaryCode::as_str);
58+
.map_or_else(|| diagnostic.name(), SecondaryCode::as_str);
5859
let mut case = TestCase::new(format!("org.ruff.{code}"), status);
5960
let file_path = Path::new(filename);
6061
let file_stem = file_path.file_stem().unwrap().to_str().unwrap();
@@ -92,24 +93,24 @@ impl<'a> JunitRenderer<'a> {
9293
// TODO(brent) this and `group_diagnostics_by_filename` are also used by the `grouped` output
9394
// format. I think they'd make more sense in that file, but I started here first. I'll move them to
9495
// that module when adding the `grouped` output format.
95-
struct MessageWithLocation<'a> {
96-
message: &'a Diagnostic,
96+
struct DiagnosticWithLocation<'a> {
97+
diagnostic: &'a Diagnostic,
9798
start_location: LineColumn,
9899
}
99100

100-
impl Deref for MessageWithLocation<'_> {
101+
impl Deref for DiagnosticWithLocation<'_> {
101102
type Target = Diagnostic;
102103

103104
fn deref(&self) -> &Self::Target {
104-
self.message
105+
self.diagnostic
105106
}
106107
}
107108

108109
fn group_diagnostics_by_filename<'a>(
109110
diagnostics: &'a [Diagnostic],
110111
resolver: &'a dyn FileResolver,
111-
) -> BTreeMap<&'a str, Vec<MessageWithLocation<'a>>> {
112-
let mut grouped_messages = BTreeMap::default();
112+
) -> BTreeMap<&'a str, Vec<DiagnosticWithLocation<'a>>> {
113+
let mut grouped_diagnostics = BTreeMap::default();
113114
for diagnostic in diagnostics {
114115
let (filename, start_location) = diagnostic
115116
.primary_span_ref()
@@ -128,15 +129,15 @@ fn group_diagnostics_by_filename<'a>(
128129
})
129130
.unwrap_or_default();
130131

131-
grouped_messages
132+
grouped_diagnostics
132133
.entry(filename)
133134
.or_insert_with(Vec::new)
134-
.push(MessageWithLocation {
135-
message: diagnostic,
135+
.push(DiagnosticWithLocation {
136+
diagnostic,
136137
start_location: start_location.unwrap_or_default(),
137138
});
138139
}
139-
grouped_messages
140+
grouped_diagnostics
140141
}
141142

142143
#[cfg(test)]

0 commit comments

Comments
 (0)