diff --git a/crates/ruff_cli/src/lib.rs b/crates/ruff_cli/src/lib.rs index a44ff3edb00920..2f8f3534ff3659 100644 --- a/crates/ruff_cli/src/lib.rs +++ b/crates/ruff_cli/src/lib.rs @@ -280,17 +280,27 @@ fn check(args: CheckArgs, log_level: LogLevel) -> Result { } if !cli.exit_zero { - if cli.diff || fix_only { + if cli.diff { if !diagnostics.fixed.is_empty() { return Ok(ExitStatus::Failure); } - } else if cli.exit_non_zero_on_fix { - if !diagnostics.fixed.is_empty() || !diagnostics.messages.is_empty() { - return Ok(ExitStatus::Failure); + } else if fix_only { + if cli.exit_non_zero_on_fix { + if !diagnostics.fixed.is_empty() { + return Ok(ExitStatus::Failure); + } + } else { + return Ok(ExitStatus::Success); } } else { - if !diagnostics.messages.is_empty() { - return Ok(ExitStatus::Failure); + if cli.exit_non_zero_on_fix { + if !diagnostics.fixed.is_empty() || !diagnostics.messages.is_empty() { + return Ok(ExitStatus::Failure); + } + } else { + if !diagnostics.messages.is_empty() { + return Ok(ExitStatus::Failure); + } } } }