mirror of
https://github.com/kanidm/kanidm.git
synced 2025-02-23 12:37:00 +01:00
Remove unused imports and clippy lint (#2276)
* Fix unused import errors * Apply clippy get_first lint * Add contributor --------- Co-authored-by: James Hodgkinson <james@terminaloutcomes.com>
This commit is contained in:
parent
c3c0b5f459
commit
dbf476fe5e
|
@ -32,6 +32,7 @@
|
||||||
- Samuel Cabrero (scabrero)
|
- Samuel Cabrero (scabrero)
|
||||||
- philipcristiano
|
- philipcristiano
|
||||||
- Jianchen Zhao (bolu61)
|
- Jianchen Zhao (bolu61)
|
||||||
|
- Allan Zhang (allan2)
|
||||||
|
|
||||||
## Acknowledgements
|
## Acknowledgements
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ impl KanidmClient {
|
||||||
format!("/v1/sync_account/{}/_attr/sync_credential_portal", id).as_str(),
|
format!("/v1/sync_account/{}/_attr/sync_credential_portal", id).as_str(),
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map(|values: Vec<Url>| values.get(0).cloned())
|
.map(|values: Vec<Url>| values.first().cloned())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn idm_sync_account_set_yield_attributes(
|
pub async fn idm_sync_account_set_yield_attributes(
|
||||||
|
|
|
@ -83,7 +83,7 @@ pub enum CryptoError {
|
||||||
impl From<OpenSSLErrorStack> for CryptoError {
|
impl From<OpenSSLErrorStack> for CryptoError {
|
||||||
fn from(ossl_err: OpenSSLErrorStack) -> Self {
|
fn from(ossl_err: OpenSSLErrorStack) -> Self {
|
||||||
error!(?ossl_err);
|
error!(?ossl_err);
|
||||||
let code = ossl_err.errors().get(0).map(|e| e.code()).unwrap_or(0);
|
let code = ossl_err.errors().first().map(|e| e.code()).unwrap_or(0);
|
||||||
#[cfg(not(target_family = "windows"))]
|
#[cfg(not(target_family = "windows"))]
|
||||||
let result = CryptoError::OpenSSL(code);
|
let result = CryptoError::OpenSSL(code);
|
||||||
|
|
||||||
|
|
|
@ -372,7 +372,7 @@ impl Credential {
|
||||||
pub fn try_from_repl_v1(rc: &ReplCredV1) -> Result<(String, Self), OperationError> {
|
pub fn try_from_repl_v1(rc: &ReplCredV1) -> Result<(String, Self), OperationError> {
|
||||||
match rc {
|
match rc {
|
||||||
ReplCredV1::TmpWn { tag, set } => {
|
ReplCredV1::TmpWn { tag, set } => {
|
||||||
let m_uuid: Option<Uuid> = set.get(0).map(|v| v.uuid);
|
let m_uuid: Option<Uuid> = set.first().map(|v| v.uuid);
|
||||||
|
|
||||||
let v_webauthn = set
|
let v_webauthn = set
|
||||||
.iter()
|
.iter()
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
//! factor to assert that the user is legitimate. This also contains some
|
//! factor to assert that the user is legitimate. This also contains some
|
||||||
//! support code for asynchronous task execution.
|
//! support code for asynchronous task execution.
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
pub use std::collections::BTreeSet as Set;
|
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
@ -1237,7 +1236,6 @@ impl AuthSession {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
pub use std::collections::BTreeSet as Set;
|
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
|
|
|
@ -372,7 +372,7 @@ impl<'a> IdmServerProxyWriteTransaction<'a> {
|
||||||
&[entry],
|
&[entry],
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let eperm = effective_perms.get(0).ok_or_else(|| {
|
let eperm = effective_perms.first().ok_or_else(|| {
|
||||||
error!("Effective Permission check returned no results");
|
error!("Effective Permission check returned no results");
|
||||||
OperationError::InvalidState
|
OperationError::InvalidState
|
||||||
})?;
|
})?;
|
||||||
|
@ -485,7 +485,7 @@ impl<'a> IdmServerProxyWriteTransaction<'a> {
|
||||||
&[entry],
|
&[entry],
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let eperm = effective_perms.get(0).ok_or_else(|| {
|
let eperm = effective_perms.first().ok_or_else(|| {
|
||||||
admin_error!("Effective Permission check returned no results");
|
admin_error!("Effective Permission check returned no results");
|
||||||
OperationError::InvalidState
|
OperationError::InvalidState
|
||||||
})?;
|
})?;
|
||||||
|
@ -2782,7 +2782,7 @@ mod tests {
|
||||||
assert!(c_status.passkeys.len() == 1);
|
assert!(c_status.passkeys.len() == 1);
|
||||||
|
|
||||||
// Get the UUID of the passkey here.
|
// Get the UUID of the passkey here.
|
||||||
let pk_uuid = c_status.passkeys.get(0).map(|pkd| pkd.uuid).unwrap();
|
let pk_uuid = c_status.passkeys.first().map(|pkd| pkd.uuid).unwrap();
|
||||||
|
|
||||||
// Commit
|
// Commit
|
||||||
drop(cutxn);
|
drop(cutxn);
|
||||||
|
|
|
@ -251,7 +251,7 @@ impl<'a> IdmServerProxyWriteTransaction<'a> {
|
||||||
.get_accesscontrols()
|
.get_accesscontrols()
|
||||||
.effective_permission_check(&sfe.ident, Some(BTreeSet::default()), &[entry])?;
|
.effective_permission_check(&sfe.ident, Some(BTreeSet::default()), &[entry])?;
|
||||||
|
|
||||||
let eperm = effective_perms.get(0).ok_or_else(|| {
|
let eperm = effective_perms.first().ok_or_else(|| {
|
||||||
admin_error!("Effective Permission check returned no results");
|
admin_error!("Effective Permission check returned no results");
|
||||||
OperationError::InvalidState
|
OperationError::InvalidState
|
||||||
})?;
|
})?;
|
||||||
|
@ -382,7 +382,7 @@ impl<'a> IdmServerProxyWriteTransaction<'a> {
|
||||||
.get_accesscontrols()
|
.get_accesscontrols()
|
||||||
.effective_permission_check(&ste.ident, Some(BTreeSet::default()), &[entry])?;
|
.effective_permission_check(&ste.ident, Some(BTreeSet::default()), &[entry])?;
|
||||||
|
|
||||||
let eperm = effective_perms.get(0).ok_or_else(|| {
|
let eperm = effective_perms.first().ok_or_else(|| {
|
||||||
admin_error!("Effective Permission check returned no results");
|
admin_error!("Effective Permission check returned no results");
|
||||||
OperationError::InvalidState
|
OperationError::InvalidState
|
||||||
})?;
|
})?;
|
||||||
|
@ -2153,7 +2153,7 @@ mod tests {
|
||||||
// Should be none as the entry was masked by being recycled.
|
// Should be none as the entry was masked by being recycled.
|
||||||
.map(|entries| {
|
.map(|entries| {
|
||||||
assert!(entries.len() == 1);
|
assert!(entries.len() == 1);
|
||||||
let ent = entries.get(0).unwrap();
|
let ent = entries.first().unwrap();
|
||||||
ent.mask_recycled_ts().is_none()
|
ent.mask_recycled_ts().is_none()
|
||||||
})
|
})
|
||||||
.unwrap_or(false));
|
.unwrap_or(false));
|
||||||
|
@ -2348,7 +2348,7 @@ mod tests {
|
||||||
// Should be none as the entry was masked by being recycled.
|
// Should be none as the entry was masked by being recycled.
|
||||||
.map(|entries| {
|
.map(|entries| {
|
||||||
assert!(entries.len() == 1);
|
assert!(entries.len() == 1);
|
||||||
let ent = entries.get(0).unwrap();
|
let ent = entries.first().unwrap();
|
||||||
ent.mask_recycled_ts().is_none()
|
ent.mask_recycled_ts().is_none()
|
||||||
})
|
})
|
||||||
.unwrap_or(false));
|
.unwrap_or(false));
|
||||||
|
@ -2432,7 +2432,7 @@ mod tests {
|
||||||
// Should be none as the entry was masked by being recycled.
|
// Should be none as the entry was masked by being recycled.
|
||||||
.map(|entries| {
|
.map(|entries| {
|
||||||
assert!(entries.len() == 1);
|
assert!(entries.len() == 1);
|
||||||
let ent = entries.get(0).unwrap();
|
let ent = entries.first().unwrap();
|
||||||
ent.mask_recycled_ts().is_none()
|
ent.mask_recycled_ts().is_none()
|
||||||
})
|
})
|
||||||
.unwrap_or(false));
|
.unwrap_or(false));
|
||||||
|
@ -2447,7 +2447,7 @@ mod tests {
|
||||||
// Should be none as the entry was masked by being recycled.
|
// Should be none as the entry was masked by being recycled.
|
||||||
.map(|entries| {
|
.map(|entries| {
|
||||||
assert!(entries.len() == 1);
|
assert!(entries.len() == 1);
|
||||||
let ent = entries.get(0).unwrap();
|
let ent = entries.first().unwrap();
|
||||||
ent.mask_recycled_ts().is_none()
|
ent.mask_recycled_ts().is_none()
|
||||||
})
|
})
|
||||||
.unwrap_or(false));
|
.unwrap_or(false));
|
||||||
|
|
|
@ -926,7 +926,7 @@ impl<'a> IdmServerAuthTransaction<'a> {
|
||||||
|
|
||||||
pub fn get_origin(&self) -> &Url {
|
pub fn get_origin(&self) -> &Url {
|
||||||
#[allow(clippy::unwrap_used)]
|
#[allow(clippy::unwrap_used)]
|
||||||
self.webauthn.get_allowed_origins().get(0).unwrap()
|
self.webauthn.get_allowed_origins().first().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(level = "trace", skip(self))]
|
#[instrument(level = "trace", skip(self))]
|
||||||
|
@ -1544,7 +1544,7 @@ impl<'a> IdmServerProxyWriteTransaction<'a> {
|
||||||
|
|
||||||
pub fn get_origin(&self) -> &Url {
|
pub fn get_origin(&self) -> &Url {
|
||||||
#[allow(clippy::unwrap_used)]
|
#[allow(clippy::unwrap_used)]
|
||||||
self.webauthn.get_allowed_origins().get(0).unwrap()
|
self.webauthn.get_allowed_origins().first().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_password_quality(
|
fn check_password_quality(
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
use gloo::console;
|
use gloo::console;
|
||||||
use kanidm_proto::constants::uri::{OAUTH2_AUTHORISE, OAUTH2_AUTHORISE_PERMIT};
|
use kanidm_proto::constants::uri::{OAUTH2_AUTHORISE, OAUTH2_AUTHORISE_PERMIT};
|
||||||
use kanidm_proto::constants::{APPLICATION_JSON, KOPID};
|
use kanidm_proto::constants::{APPLICATION_JSON, KOPID};
|
||||||
pub use kanidm_proto::oauth2::{
|
pub use kanidm_proto::oauth2::{AuthorisationRequest, AuthorisationResponse};
|
||||||
AccessTokenRequest, AccessTokenResponse, AuthorisationRequest, AuthorisationResponse,
|
|
||||||
CodeChallengeMethod, ErrorResponse,
|
|
||||||
};
|
|
||||||
use kanidmd_web_ui_shared::constants::{CONTENT_TYPE, CSS_ALERT_DANGER, URL_OAUTH2};
|
use kanidmd_web_ui_shared::constants::{CONTENT_TYPE, CSS_ALERT_DANGER, URL_OAUTH2};
|
||||||
use kanidmd_web_ui_shared::utils::{do_alert_error, do_footer, window};
|
use kanidmd_web_ui_shared::utils::{do_alert_error, do_footer, window};
|
||||||
use kanidmd_web_ui_shared::{
|
use kanidmd_web_ui_shared::{
|
||||||
|
|
|
@ -259,7 +259,7 @@ async fn process_auth_state(
|
||||||
{
|
{
|
||||||
#[allow(clippy::expect_used)]
|
#[allow(clippy::expect_used)]
|
||||||
allowed
|
allowed
|
||||||
.get(0)
|
.first()
|
||||||
.expect("can not fail - bounds already checked.")
|
.expect("can not fail - bounds already checked.")
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
|
@ -387,7 +387,7 @@ impl LoginOpt {
|
||||||
{
|
{
|
||||||
#[allow(clippy::expect_used)]
|
#[allow(clippy::expect_used)]
|
||||||
mechs
|
mechs
|
||||||
.get(0)
|
.first()
|
||||||
.expect("can not fail - bounds already checked.")
|
.expect("can not fail - bounds already checked.")
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
|
|
|
@ -19,6 +19,3 @@ extern crate lazy_static;
|
||||||
|
|
||||||
#[cfg(target_family = "unix")]
|
#[cfg(target_family = "unix")]
|
||||||
mod implementation;
|
mod implementation;
|
||||||
|
|
||||||
#[cfg(target_family = "unix")]
|
|
||||||
pub use implementation::*;
|
|
||||||
|
|
Loading…
Reference in a new issue