From def93ae78f0605a884cbb5db992032b5d0c4b290 Mon Sep 17 00:00:00 2001 From: Taylor Tumlin <146587581+taylortumlin@users.noreply.github.com> Date: Fri, 8 May 2026 15:26:15 -0400 Subject: [PATCH] Add redundant_else clippy lint Removes 8 redundant else blocks where the preceding if arm always diverges, and adds the lint to the workspace deny list to prevent regressions. --- Cargo.toml | 1 + src/api/admin.rs | 3 +-- src/api/core/organizations.rs | 11 +++++------ src/config.rs | 3 +-- src/db/mod.rs | 15 +++++++-------- src/db/models/cipher.rs | 6 ++---- src/mail.rs | 10 ++++------ 7 files changed, 21 insertions(+), 28 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e7fd5ade..fee833a9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -325,6 +325,7 @@ needless_continue = "deny" needless_lifetimes = "deny" option_option = "deny" redundant_clone = "deny" +redundant_else = "deny" ref_option = "deny" string_add_assign = "deny" unnecessary_join = "deny" diff --git a/src/api/admin.rs b/src/api/admin.rs index 02c976cc..e5e02e2a 100644 --- a/src/api/admin.rs +++ b/src/api/admin.rs @@ -851,9 +851,8 @@ impl<'r> FromRequest<'r> for AdminToken { // Else, return a 401 failure, which will be caught if requested_page.is_empty() { return Outcome::Forward(Status::Unauthorized); - } else { - return Outcome::Error((Status::Unauthorized, "Unauthorized")); } + return Outcome::Error((Status::Unauthorized, "Unauthorized")); } }; diff --git a/src/api/core/organizations.rs b/src/api/core/organizations.rs index 31311a65..6eea3a22 100644 --- a/src/api/core/organizations.rs +++ b/src/api/core/organizations.rs @@ -1085,13 +1085,12 @@ async fn send_invite( Some(user) => { if Membership::find_by_user_and_org(&user.uuid, &org_id, &conn).await.is_some() { err!(format!("User already in organization: {email}")) - } else { - // automatically accept existing users if mail is disabled - if !CONFIG.mail_enabled() && !user.password_hash.is_empty() { - member_status = MembershipStatus::Accepted as i32; - } - user } + // automatically accept existing users if mail is disabled + if !CONFIG.mail_enabled() && !user.password_hash.is_empty() { + member_status = MembershipStatus::Accepted as i32; + } + user } }; diff --git a/src/config.rs b/src/config.rs index ae995f69..e2889b5e 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1037,9 +1037,8 @@ fn validate_config(cfg: &ConfigItems, on_update: bool) -> Result<(), Error> { Supported flags: {:?}\n", invalid_flags, SUPPORTED_FEATURE_FLAGS); if on_update { err!(feature_flags_error); - } else { - println!("[WARNING] {feature_flags_error}"); } + println!("[WARNING] {feature_flags_error}"); } const MAX_FILESIZE_KB: i64 = i64::MAX >> 10; diff --git a/src/db/mod.rs b/src/db/mod.rs index d2ed9479..7d7af747 100644 --- a/src/db/mod.rs +++ b/src/db/mod.rs @@ -271,15 +271,14 @@ impl DbConnType { #[cfg(not(postgresql))] err!("`DATABASE_URL` is a PostgreSQL URL, but the 'postgresql' feature is not enabled") - - //Sqlite - } else { - #[cfg(sqlite)] - return Ok(DbConnType::Sqlite); - - #[cfg(not(sqlite))] - err!("`DATABASE_URL` looks like a SQLite URL, but 'sqlite' feature is not enabled") } + + // Sqlite + #[cfg(sqlite)] + return Ok(DbConnType::Sqlite); + + #[cfg(not(sqlite))] + err!("`DATABASE_URL` looks like a SQLite URL, but 'sqlite' feature is not enabled") } pub fn get_init_stmts(&self) -> String { diff --git a/src/db/models/cipher.rs b/src/db/models/cipher.rs index db906179..a911e5bb 100644 --- a/src/db/models/cipher.rs +++ b/src/db/models/cipher.rs @@ -124,9 +124,8 @@ impl Cipher { "object": "error" }); err_json!(err_json, "Import validation errors") - } else { - Ok(()) } + Ok(()) } } @@ -584,9 +583,8 @@ impl Cipher { if let Some(ref org_uuid) = self.organization_uuid { if let Some(cipher_sync_data) = cipher_sync_data { return cipher_sync_data.user_group_full_access_for_organizations.contains(org_uuid); - } else { - return Group::is_in_full_access_group(user_uuid, org_uuid, conn).await; } + return Group::is_in_full_access_group(user_uuid, org_uuid, conn).await; } false } diff --git a/src/mail.rs b/src/mail.rs index cdbd269a..fb0b1d97 100644 --- a/src/mail.rs +++ b/src/mail.rs @@ -664,10 +664,9 @@ async fn send_with_selected_transport(email: Message) -> EmptyResult { } else if e.is_response() { debug!("Sendmail response error: {e:?}"); err!(format!("Sendmail response error: {e}")); - } else { - debug!("Sendmail error: {e:?}"); - err!(format!("Sendmail error: {e}")); } + debug!("Sendmail error: {e:?}"); + err!(format!("Sendmail error: {e}")); } } } else { @@ -695,10 +694,9 @@ async fn send_with_selected_transport(email: Message) -> EmptyResult { } else if e.is_tls() { debug!("SMTP encryption error: {e:#?}"); err!(format!("SMTP encryption error: {e}")); - } else { - debug!("SMTP error: {e:#?}"); - err!(format!("SMTP error: {e}")); } + debug!("SMTP error: {e:#?}"); + err!(format!("SMTP error: {e}")); } } }