Skip to content

Commit

Permalink
Check the more performant option first
Browse files Browse the repository at this point in the history
  • Loading branch information
zanieb committed Oct 10, 2023
1 parent afc6bcd commit aa70071
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions crates/ruff_linter/src/linter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,15 +264,15 @@ pub fn check_path(
if !settings.extend_safe_fixes.is_empty() || !settings.extend_unsafe_fixes.is_empty() {
for diagnostic in &mut diagnostics {
if let Some(fix) = diagnostic.fix.take() {
// Check unsafe before safe so if someone puts a rule in both we are conservative
if settings
.extend_unsafe_fixes
.contains(diagnostic.kind.rule())
&& fix.applicability().is_safe()
// Enforce demotions over promotions so if someone puts a rule in both we are conservative
if fix.applicability().is_safe()
&& settings
.extend_unsafe_fixes
.contains(diagnostic.kind.rule())
{
diagnostic.set_fix(fix.with_applicability(Applicability::Unsafe));
} else if settings.extend_safe_fixes.contains(diagnostic.kind.rule())
&& fix.applicability().is_unsafe()
} else if fix.applicability().is_unsafe()
&& settings.extend_safe_fixes.contains(diagnostic.kind.rule())
{
diagnostic.set_fix(fix.with_applicability(Applicability::Safe));
} else {
Expand Down

0 comments on commit aa70071

Please sign in to comment.