Skip to content

Commit bba7f6d

Browse files
committed
construct a Rule from NoqaCode instead of the rule name
1 parent d04d40d commit bba7f6d

File tree

1 file changed

+2
-5
lines changed
  • crates/ruff_linter/src/message

1 file changed

+2
-5
lines changed

crates/ruff_linter/src/message/mod.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,8 @@ impl OldDiagnostic {
284284

285285
/// Returns the [`Rule`] corresponding to the diagnostic message.
286286
pub fn to_rule(&self) -> Option<Rule> {
287-
if self.is_syntax_error() {
288-
None
289-
} else {
290-
Some(self.name().parse().expect("Expected a valid rule name"))
291-
}
287+
self.noqa_code
288+
.map(|code| Rule::from_code(&code.to_string()).expect("Expected a valid noqa code"))
292289
}
293290

294291
/// Returns the [`NoqaCode`] corresponding to the diagnostic message.

0 commit comments

Comments
 (0)