mirror of https://github.com/astral-sh/ruff
Avoid unnecessary assignments
This commit is contained in:
parent
c1101cb04c
commit
9ebae7aa6b
|
|
@ -189,14 +189,15 @@ impl Suppressions {
|
|||
}
|
||||
};
|
||||
|
||||
let mut diagnostic = context.report_diagnostic(
|
||||
context
|
||||
.report_diagnostic(
|
||||
UnusedNOQA {
|
||||
codes: Some(codes),
|
||||
kind: UnusedNOQAKind::Suppression,
|
||||
},
|
||||
range,
|
||||
);
|
||||
diagnostic.set_fix(Fix::safe_edit(edit));
|
||||
)
|
||||
.set_fix(Fix::safe_edit(edit));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -206,14 +207,15 @@ impl Suppressions {
|
|||
.iter()
|
||||
.filter(|error| error.kind == ParseErrorKind::MissingCodes)
|
||||
{
|
||||
let mut diagnostic = context.report_diagnostic(
|
||||
context
|
||||
.report_diagnostic(
|
||||
UnusedNOQA {
|
||||
codes: Some(UnusedCodes::default()),
|
||||
kind: UnusedNOQAKind::Suppression,
|
||||
},
|
||||
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 {
|
||||
let (range, edit) =
|
||||
Suppressions::delete_code_or_comment(locator, suppression, comment);
|
||||
let mut diagnostic = context.report_diagnostic(
|
||||
context
|
||||
.report_diagnostic(
|
||||
InvalidRuleCode {
|
||||
rule_code: suppression.code.to_string(),
|
||||
kind: InvalidRuleCodeKind::Suppression,
|
||||
},
|
||||
range,
|
||||
);
|
||||
diagnostic.set_fix(Fix::safe_edit(edit));
|
||||
)
|
||||
.set_fix(Fix::safe_edit(edit));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -245,23 +248,25 @@ impl Suppressions {
|
|||
.iter()
|
||||
.filter(|error| error.kind != ParseErrorKind::MissingCodes)
|
||||
{
|
||||
let mut diagnostic = context.report_diagnostic(
|
||||
context
|
||||
.report_diagnostic(
|
||||
InvalidSuppressionComment {
|
||||
kind: InvalidSuppressionCommentKind::Error(error.kind),
|
||||
},
|
||||
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 {
|
||||
let mut diagnostic = context.report_diagnostic(
|
||||
context
|
||||
.report_diagnostic(
|
||||
InvalidSuppressionComment {
|
||||
kind: InvalidSuppressionCommentKind::Invalid(invalid.kind),
|
||||
},
|
||||
invalid.comment.range,
|
||||
);
|
||||
diagnostic.set_fix(Fix::unsafe_edit(delete_comment(
|
||||
)
|
||||
.set_fix(Fix::unsafe_edit(delete_comment(
|
||||
invalid.comment.range,
|
||||
locator,
|
||||
)));
|
||||
|
|
|
|||
Loading…
Reference in New Issue