Skip to content

Commit a120610

Browse files
committed
unify diagnostic handling in wasm
1 parent 022107c commit a120610

File tree

1 file changed

+17
-30
lines changed

1 file changed

+17
-30
lines changed

crates/ruff_wasm/src/lib.rs

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -207,36 +207,23 @@ impl Workspace {
207207

208208
let messages: Vec<ExpandedMessage> = messages
209209
.into_iter()
210-
.map(|msg| {
211-
let message = msg.body().to_string();
212-
let range = msg.range();
213-
match msg.to_noqa_code() {
214-
Some(code) => ExpandedMessage {
215-
code: Some(code.to_string()),
216-
message,
217-
start_location: source_code.line_column(range.start()).into(),
218-
end_location: source_code.line_column(range.end()).into(),
219-
fix: msg.fix().map(|fix| ExpandedFix {
220-
message: msg.suggestion().map(ToString::to_string),
221-
edits: fix
222-
.edits()
223-
.iter()
224-
.map(|edit| ExpandedEdit {
225-
location: source_code.line_column(edit.start()).into(),
226-
end_location: source_code.line_column(edit.end()).into(),
227-
content: edit.content().map(ToString::to_string),
228-
})
229-
.collect(),
230-
}),
231-
},
232-
None => ExpandedMessage {
233-
code: None,
234-
message,
235-
start_location: source_code.line_column(range.start()).into(),
236-
end_location: source_code.line_column(range.end()).into(),
237-
fix: None,
238-
},
239-
}
210+
.map(|msg| ExpandedMessage {
211+
code: msg.to_noqa_code().map(|code| code.to_string()),
212+
message: msg.body().to_string(),
213+
start_location: source_code.line_column(msg.start()).into(),
214+
end_location: source_code.line_column(msg.end()).into(),
215+
fix: msg.fix().map(|fix| ExpandedFix {
216+
message: msg.suggestion().map(ToString::to_string),
217+
edits: fix
218+
.edits()
219+
.iter()
220+
.map(|edit| ExpandedEdit {
221+
location: source_code.line_column(edit.start()).into(),
222+
end_location: source_code.line_column(edit.end()).into(),
223+
content: edit.content().map(ToString::to_string),
224+
})
225+
.collect(),
226+
}),
240227
})
241228
.collect();
242229

0 commit comments

Comments
 (0)