Avoid unnecessary assignments

This commit is contained in:
Amethyst Reese 2025-12-16 18:23:16 -08:00
parent c1101cb04c
commit 9ebae7aa6b
1 changed files with 46 additions and 41 deletions

View File

@ -189,14 +189,15 @@ impl Suppressions {
} }
}; };
let mut diagnostic = context.report_diagnostic( context
.report_diagnostic(
UnusedNOQA { UnusedNOQA {
codes: Some(codes), codes: Some(codes),
kind: UnusedNOQAKind::Suppression, kind: UnusedNOQAKind::Suppression,
}, },
range, range,
); )
diagnostic.set_fix(Fix::safe_edit(edit)); .set_fix(Fix::safe_edit(edit));
} }
} }
@ -206,14 +207,15 @@ impl Suppressions {
.iter() .iter()
.filter(|error| error.kind == ParseErrorKind::MissingCodes) .filter(|error| error.kind == ParseErrorKind::MissingCodes)
{ {
let mut diagnostic = context.report_diagnostic( context
.report_diagnostic(
UnusedNOQA { UnusedNOQA {
codes: Some(UnusedCodes::default()), codes: Some(UnusedCodes::default()),
kind: UnusedNOQAKind::Suppression, kind: UnusedNOQAKind::Suppression,
}, },
error.range, error.range,
); )
diagnostic.set_fix(Fix::safe_edit(delete_comment(error.range, locator))); .set_fix(Fix::safe_edit(delete_comment(error.range, locator)));
} }
} }
@ -226,14 +228,15 @@ impl Suppressions {
for comment in &suppression.comments { for comment in &suppression.comments {
let (range, edit) = let (range, edit) =
Suppressions::delete_code_or_comment(locator, suppression, comment); Suppressions::delete_code_or_comment(locator, suppression, comment);
let mut diagnostic = context.report_diagnostic( context
.report_diagnostic(
InvalidRuleCode { InvalidRuleCode {
rule_code: suppression.code.to_string(), rule_code: suppression.code.to_string(),
kind: InvalidRuleCodeKind::Suppression, kind: InvalidRuleCodeKind::Suppression,
}, },
range, range,
); )
diagnostic.set_fix(Fix::safe_edit(edit)); .set_fix(Fix::safe_edit(edit));
} }
} }
} }
@ -245,23 +248,25 @@ impl Suppressions {
.iter() .iter()
.filter(|error| error.kind != ParseErrorKind::MissingCodes) .filter(|error| error.kind != ParseErrorKind::MissingCodes)
{ {
let mut diagnostic = context.report_diagnostic( context
.report_diagnostic(
InvalidSuppressionComment { InvalidSuppressionComment {
kind: InvalidSuppressionCommentKind::Error(error.kind), kind: InvalidSuppressionCommentKind::Error(error.kind),
}, },
error.range, error.range,
); )
diagnostic.set_fix(Fix::unsafe_edit(delete_comment(error.range, locator))); .set_fix(Fix::unsafe_edit(delete_comment(error.range, locator)));
} }
for invalid in &self.invalid { for invalid in &self.invalid {
let mut diagnostic = context.report_diagnostic( context
.report_diagnostic(
InvalidSuppressionComment { InvalidSuppressionComment {
kind: InvalidSuppressionCommentKind::Invalid(invalid.kind), kind: InvalidSuppressionCommentKind::Invalid(invalid.kind),
}, },
invalid.comment.range, invalid.comment.range,
); )
diagnostic.set_fix(Fix::unsafe_edit(delete_comment( .set_fix(Fix::unsafe_edit(delete_comment(
invalid.comment.range, invalid.comment.range,
locator, locator,
))); )));