Browse Source

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.
pull/7199/head
Taylor Tumlin 2 weeks ago
parent
commit
def93ae78f
  1. 1
      Cargo.toml
  2. 3
      src/api/admin.rs
  3. 3
      src/api/core/organizations.rs
  4. 3
      src/config.rs
  5. 5
      src/db/mod.rs
  6. 6
      src/db/models/cipher.rs
  7. 6
      src/mail.rs

1
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"

3
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"));
}
};

3
src/api/core/organizations.rs

@ -1085,14 +1085,13 @@ 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
}
}
};
let mut new_member = Membership::new(user.uuid.clone(), org_id.clone(), Some(headers.user.email.clone()));

3
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;

5
src/db/mod.rs

@ -271,16 +271,15 @@ impl DbConnType {
#[cfg(not(postgresql))]
err!("`DATABASE_URL` is a PostgreSQL URL, but the 'postgresql' feature is not enabled")
}
//Sqlite
} else {
// 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 {
let init_stmts = CONFIG.database_conn_init();

6
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
}

6
src/mail.rs

@ -664,12 +664,11 @@ 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}"));
}
}
}
} else {
match smtp_transport().send(email).await {
Ok(_) => Ok(()),
@ -695,13 +694,12 @@ 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}"));
}
}
}
}
}
async fn send_email(address: &str, subject: &str, body_html: String, body_text: String) -> EmptyResult {

Loading…
Cancel
Save