clippy: is_some/none/ok/err/empty
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
@ -72,7 +72,7 @@ fn extract_acl_node_data(
|
||||
}
|
||||
}
|
||||
for (group, roles) in &node.groups {
|
||||
if let Some(_) = token_user {
|
||||
if token_user.is_some() {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -210,7 +210,7 @@ pub fn update_acl(
|
||||
|
||||
let top_level_privs = user_info.lookup_privs(¤t_auth_id, &["access", "acl"]);
|
||||
if top_level_privs & PRIV_PERMISSIONS_MODIFY == 0 {
|
||||
if let Some(_) = group {
|
||||
if group.is_some() {
|
||||
bail!("Unprivileged users are not allowed to create group ACL item.");
|
||||
}
|
||||
|
||||
|
@ -230,7 +230,7 @@ pub fn create_user(
|
||||
|
||||
let (mut config, _digest) = user::config()?;
|
||||
|
||||
if let Some(_) = config.sections.get(user.userid.as_str()) {
|
||||
if config.sections.get(user.userid.as_str()).is_some() {
|
||||
bail!("user '{}' already exists.", user.userid);
|
||||
}
|
||||
|
||||
@ -595,7 +595,7 @@ pub fn generate_token(
|
||||
let tokenid = Authid::from((userid.clone(), Some(tokenname.clone())));
|
||||
let tokenid_string = tokenid.to_string();
|
||||
|
||||
if let Some(_) = config.sections.get(&tokenid_string) {
|
||||
if config.sections.get(&tokenid_string).is_some() {
|
||||
bail!("token '{}' for user '{}' already exists.", tokenname.as_str(), userid);
|
||||
}
|
||||
|
||||
|
@ -711,7 +711,7 @@ pub fn verify(
|
||||
|
||||
verify_all_backups(datastore, worker.clone(), worker.upid(), owner, None)?
|
||||
};
|
||||
if failed_dirs.len() > 0 {
|
||||
if !failed_dirs.is_empty() {
|
||||
worker.log("Failed to verify the following snapshots/groups:");
|
||||
for dir in failed_dirs {
|
||||
worker.log(format!("\t{}", dir));
|
||||
@ -1341,7 +1341,7 @@ fn catalog(
|
||||
|
||||
if filepath != "root" {
|
||||
components = base64::decode(filepath)?;
|
||||
if components.len() > 0 && components[0] == '/' as u8 {
|
||||
if !components.is_empty() && components[0] == b'/' {
|
||||
components.remove(0);
|
||||
}
|
||||
for component in components.split(|c| *c == '/' as u8) {
|
||||
@ -1487,7 +1487,7 @@ fn pxar_file_download(
|
||||
check_priv_or_backup_owner(&datastore, backup_dir.group(), &auth_id, PRIV_DATASTORE_READ)?;
|
||||
|
||||
let mut components = base64::decode(&filepath)?;
|
||||
if components.len() > 0 && components[0] == '/' as u8 {
|
||||
if !components.is_empty() && components[0] == b'/' {
|
||||
components.remove(0);
|
||||
}
|
||||
|
||||
|
@ -465,7 +465,7 @@ impl BackupEnvironment {
|
||||
state.ensure_unfinished()?;
|
||||
|
||||
// test if all writer are correctly closed
|
||||
if state.dynamic_writers.len() != 0 || state.fixed_writers.len() != 0 {
|
||||
if !state.dynamic_writers.is_empty() || !state.fixed_writers.is_empty() {
|
||||
bail!("found open index writer - unable to finish backup");
|
||||
}
|
||||
|
||||
|
@ -124,7 +124,7 @@ pub fn create_datastore(param: Value) -> Result<(), Error> {
|
||||
|
||||
let (mut config, _digest) = datastore::config()?;
|
||||
|
||||
if let Some(_) = config.sections.get(&datastore.name) {
|
||||
if config.sections.get(&datastore.name).is_some() {
|
||||
bail!("datastore '{}' already exists.", datastore.name);
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ pub fn create_remote(password: String, param: Value) -> Result<(), Error> {
|
||||
|
||||
let (mut config, _digest) = remote::config()?;
|
||||
|
||||
if let Some(_) = config.sections.get(&remote.name) {
|
||||
if config.sections.get(&remote.name).is_some() {
|
||||
bail!("remote '{}' already exists.", remote.name);
|
||||
}
|
||||
|
||||
|
@ -161,7 +161,7 @@ pub fn create_sync_job(
|
||||
|
||||
let (mut config, _digest) = sync::config()?;
|
||||
|
||||
if let Some(_) = config.sections.get(&sync_job.id) {
|
||||
if config.sections.get(&sync_job.id).is_some() {
|
||||
bail!("job '{}' already exists.", sync_job.id);
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ pub fn create_verification_job(
|
||||
|
||||
let (mut config, _digest) = verify::config()?;
|
||||
|
||||
if let Some(_) = config.sections.get(&verification_job.id) {
|
||||
if config.sections.get(&verification_job.id).is_some() {
|
||||
bail!("job '{}' already exists.", verification_job.id);
|
||||
}
|
||||
|
||||
|
@ -196,7 +196,7 @@ fn apt_get_changelog(
|
||||
}
|
||||
}, Some(&name));
|
||||
|
||||
if pkg_info.len() == 0 {
|
||||
if pkg_info.is_empty() {
|
||||
bail!("Package '{}' not found", name);
|
||||
}
|
||||
|
||||
|
@ -513,7 +513,7 @@ pub fn list_tasks(
|
||||
.collect();
|
||||
|
||||
let mut count = result.len() + start as usize;
|
||||
if result.len() > 0 && result.len() >= limit { // we have a 'virtual' entry as long as we have any new
|
||||
if !result.is_empty() && result.len() >= limit { // we have a 'virtual' entry as long as we have any new
|
||||
count += 1;
|
||||
}
|
||||
|
||||
|
@ -747,11 +747,9 @@ pub fn update_inventory(
|
||||
|
||||
let label_text = label_text.to_string();
|
||||
|
||||
if !read_all_labels.unwrap_or(false) {
|
||||
if let Some(_) = inventory.find_media_by_label_text(&label_text) {
|
||||
worker.log(format!("media '{}' already inventoried", label_text));
|
||||
continue;
|
||||
}
|
||||
if !read_all_labels.unwrap_or(false) && inventory.find_media_by_label_text(&label_text).is_some() {
|
||||
worker.log(format!("media '{}' already inventoried", label_text));
|
||||
continue;
|
||||
}
|
||||
|
||||
if let Err(err) = changer.load_media(&label_text) {
|
||||
|
@ -1077,7 +1077,7 @@ fn test_cert_fingerprint_schema() -> Result<(), anyhow::Error> {
|
||||
];
|
||||
|
||||
for fingerprint in invalid_fingerprints.iter() {
|
||||
if let Ok(_) = parse_simple_value(fingerprint, &schema) {
|
||||
if parse_simple_value(fingerprint, &schema).is_ok() {
|
||||
bail!("test fingerprint '{}' failed - got Ok() while exception an error.", fingerprint);
|
||||
}
|
||||
}
|
||||
@ -1118,7 +1118,7 @@ fn test_proxmox_user_id_schema() -> Result<(), anyhow::Error> {
|
||||
];
|
||||
|
||||
for name in invalid_user_ids.iter() {
|
||||
if let Ok(_) = parse_simple_value(name, &Userid::API_SCHEMA) {
|
||||
if parse_simple_value(name, &Userid::API_SCHEMA).is_ok() {
|
||||
bail!("test userid '{}' failed - got Ok() while exception an error.", name);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user