Skip to content

Commit

Permalink
Update crates/ruff_cli/src/commands/rule.rs
Browse files Browse the repository at this point in the history
Co-authored-by: Micha Reiser <[email protected]>
  • Loading branch information
akx and MichaReiser authored Jun 29, 2023
1 parent 3883d60 commit b787d23
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions crates/ruff_cli/src/commands/rule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,20 @@ struct Explanation<'a> {
explanation: Option<&'a str>,
}

fn rule_to_explanation(rule: &Rule) -> Explanation<'_> {
let code = rule.noqa_code().to_string();
let (linter, _) = Linter::parse_code(&code).unwrap();
let autofix = rule.autofixable().to_string();
Explanation {
name: rule.as_ref(),
code,
linter: linter.name(),
summary: rule.message_formats()[0],
message_formats: rule.message_formats(),
autofix,
explanation: rule.explanation(),
impl<'a> Explanation<'a> {
fn from_rule(rule: &'a Rule) -> Self {
let code = rule.noqa_code().to_string();
let (linter, _) = Linter::parse_code(&code).unwrap();
let autofix = rule.autofixable().to_string();
Self {
name: rule.as_ref(),
code,
linter: linter.name(),
summary: rule.message_formats()[0],
message_formats: rule.message_formats(),
autofix,
explanation: rule.explanation(),
}
}
}

Expand Down

0 comments on commit b787d23

Please sign in to comment.