lint: clippy rules or_fun_call (#2561)

Co-authored-by: houseme <housemecn@gmail.com>
This commit is contained in:
Tunglies
2026-04-15 19:48:39 -07:00
committed by GitHub
parent 1ffe23e10f
commit 579b124726
32 changed files with 109 additions and 85 deletions
+1 -2
View File
@@ -20,7 +20,6 @@ use rustfs_iam::store::object::ObjectStore;
use rustfs_iam::sys::IamSys;
use rustfs_policy::policy::{Args, action::Action};
use s3s::{S3Result, s3_error};
use std::collections::HashMap;
use std::sync::Arc;
use tracing::debug;
@@ -79,7 +78,7 @@ async fn check_admin_request_auth(
action,
conditions: &conditions,
is_owner: ctx.is_owner,
claims: ctx.cred.claims.as_ref().unwrap_or(&HashMap::new()),
claims: ctx.cred.claims_or_empty(),
deny_only: ctx.deny_only,
bucket,
object,
+1 -1
View File
@@ -419,7 +419,7 @@ fn get_console_config_from_env() -> (bool, u32, u64, String) {
let cors_allowed_origins = std::env::var(rustfs_config::ENV_CONSOLE_CORS_ALLOWED_ORIGINS)
.unwrap_or_else(|_| rustfs_config::DEFAULT_CONSOLE_CORS_ALLOWED_ORIGINS.to_string())
.parse::<String>()
.unwrap_or(rustfs_config::DEFAULT_CONSOLE_CORS_ALLOWED_ORIGINS.to_string());
.unwrap_or_else(|_| rustfs_config::DEFAULT_CONSOLE_CORS_ALLOWED_ORIGINS.to_string());
(rate_limit_enable, rate_limit_rpm, auth_timeout, cors_allowed_origins)
}
+1 -1
View File
@@ -103,7 +103,7 @@ fn parse_set_bucket_quota_request(body: &[u8]) -> Result<SetBucketQuotaRequest,
quota: request
.size
.filter(|quota| *quota > 0)
.or(request.quota.filter(|quota| *quota > 0)),
.or_else(|| request.quota.filter(|quota| *quota > 0)),
quota_type: request.quota_type.unwrap_or_else(default_quota_type),
})
}
+9 -9
View File
@@ -250,7 +250,7 @@ impl Operation for AddServiceAccount {
),
is_owner: owner,
object: "",
claims: cred.claims.as_ref().unwrap_or(&HashMap::new()),
claims: cred.claims_or_empty(),
deny_only: false, // Always require explicit Allow permission
})
.await
@@ -546,7 +546,7 @@ impl Operation for UpdateServiceAccount {
),
is_owner: owner,
object: "",
claims: cred.claims.as_ref().unwrap_or(&HashMap::new()),
claims: cred.claims_or_empty(),
deny_only: false,
})
.await
@@ -662,7 +662,7 @@ impl Operation for InfoServiceAccount {
),
is_owner: owner,
object: "",
claims: cred.claims.as_ref().unwrap_or(&HashMap::new()),
claims: cred.claims_or_empty(),
deny_only: false,
})
.await
@@ -729,7 +729,7 @@ impl Operation for TemporaryAccountInfo {
),
is_owner: owner,
object: "",
claims: cred.claims.as_ref().unwrap_or(&HashMap::new()),
claims: cred.claims_or_empty(),
deny_only: false,
})
.await
@@ -803,7 +803,7 @@ impl Operation for InfoAccessKey {
),
is_owner: owner,
object: "",
claims: cred.claims.as_ref().unwrap_or(&HashMap::new()),
claims: cred.claims_or_empty(),
deny_only: false,
})
.await
@@ -940,7 +940,7 @@ impl Operation for ListServiceAccount {
),
is_owner: owner,
object: "",
claims: cred.claims.as_ref().unwrap_or(&HashMap::new()),
claims: cred.claims_or_empty(),
deny_only: false,
})
.await
@@ -1076,7 +1076,7 @@ impl Operation for ListAccessKeysBulk {
),
is_owner: owner,
object: "",
claims: cred.claims.as_ref().unwrap_or(&HashMap::new()),
claims: cred.claims_or_empty(),
deny_only: false,
})
.await
@@ -1099,7 +1099,7 @@ impl Operation for ListAccessKeysBulk {
),
is_owner: owner,
object: "",
claims: cred.claims.as_ref().unwrap_or(&HashMap::new()),
claims: cred.claims_or_empty(),
deny_only: self_only,
})
.await
@@ -1268,7 +1268,7 @@ impl Operation for DeleteServiceAccount {
),
is_owner: owner,
object: "",
claims: cred.claims.as_ref().unwrap_or(&HashMap::new()),
claims: cred.claims_or_empty(),
deny_only: false,
})
.await
+2 -2
View File
@@ -245,7 +245,7 @@ async fn handle_assume_role(
expiration: Timestamp::from(
new_cred
.expiration
.unwrap_or(OffsetDateTime::now_utc().saturating_add(Duration::seconds(3600))),
.unwrap_or_else(|| OffsetDateTime::now_utc().saturating_add(Duration::seconds(3600))),
),
secret_access_key: new_cred.secret_key,
session_token: new_cred.session_token,
@@ -326,7 +326,7 @@ async fn handle_assume_role_with_web_identity(body: AssumeRoleRequest) -> S3Resu
// Build XML response (AssumeRoleWithWebIdentityResponse)
let expiration = new_cred
.expiration
.unwrap_or(OffsetDateTime::now_utc().saturating_add(Duration::seconds(3600)));
.unwrap_or_else(|| OffsetDateTime::now_utc().saturating_add(Duration::seconds(3600)));
let exp_str = expiration
.format(&time::format_description::well_known::Rfc3339)
.unwrap_or_default();