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
|
||||||
UnusedNOQA {
|
.report_diagnostic(
|
||||||
codes: Some(codes),
|
UnusedNOQA {
|
||||||
kind: UnusedNOQAKind::Suppression,
|
codes: Some(codes),
|
||||||
},
|
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
|
||||||
UnusedNOQA {
|
.report_diagnostic(
|
||||||
codes: Some(UnusedCodes::default()),
|
UnusedNOQA {
|
||||||
kind: UnusedNOQAKind::Suppression,
|
codes: Some(UnusedCodes::default()),
|
||||||
},
|
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
|
||||||
InvalidRuleCode {
|
.report_diagnostic(
|
||||||
rule_code: suppression.code.to_string(),
|
InvalidRuleCode {
|
||||||
kind: InvalidRuleCodeKind::Suppression,
|
rule_code: suppression.code.to_string(),
|
||||||
},
|
kind: InvalidRuleCodeKind::Suppression,
|
||||||
range,
|
},
|
||||||
);
|
range,
|
||||||
diagnostic.set_fix(Fix::safe_edit(edit));
|
)
|
||||||
|
.set_fix(Fix::safe_edit(edit));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -245,26 +248,28 @@ impl Suppressions {
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|error| error.kind != ParseErrorKind::MissingCodes)
|
.filter(|error| error.kind != ParseErrorKind::MissingCodes)
|
||||||
{
|
{
|
||||||
let mut diagnostic = context.report_diagnostic(
|
context
|
||||||
InvalidSuppressionComment {
|
.report_diagnostic(
|
||||||
kind: InvalidSuppressionCommentKind::Error(error.kind),
|
InvalidSuppressionComment {
|
||||||
},
|
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
|
||||||
InvalidSuppressionComment {
|
.report_diagnostic(
|
||||||
kind: InvalidSuppressionCommentKind::Invalid(invalid.kind),
|
InvalidSuppressionComment {
|
||||||
},
|
kind: InvalidSuppressionCommentKind::Invalid(invalid.kind),
|
||||||
invalid.comment.range,
|
},
|
||||||
);
|
invalid.comment.range,
|
||||||
diagnostic.set_fix(Fix::unsafe_edit(delete_comment(
|
)
|
||||||
invalid.comment.range,
|
.set_fix(Fix::unsafe_edit(delete_comment(
|
||||||
locator,
|
invalid.comment.range,
|
||||||
)));
|
locator,
|
||||||
|
)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue