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)
|
||||
- philipcristiano
|
||||
- Jianchen Zhao (bolu61)
|
||||
- Allan Zhang (allan2)
|
||||
|
||||
## Acknowledgements
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ impl KanidmClient {
|
|||
format!("/v1/sync_account/{}/_attr/sync_credential_portal", id).as_str(),
|
||||
)
|
||||
.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(
|
||||
|
|
|
@ -83,7 +83,7 @@ pub enum CryptoError {
|
|||
impl From<OpenSSLErrorStack> for CryptoError {
|
||||
fn from(ossl_err: OpenSSLErrorStack) -> Self {
|
||||
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"))]
|
||||
let result = CryptoError::OpenSSL(code);
|
||||
|
||||
|
|
|
@ -372,7 +372,7 @@ impl Credential {
|
|||
pub fn try_from_repl_v1(rc: &ReplCredV1) -> Result<(String, Self), OperationError> {
|
||||
match rc {
|
||||
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
|
||||
.iter()
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
//! factor to assert that the user is legitimate. This also contains some
|
||||
//! support code for asynchronous task execution.
|
||||
use std::collections::BTreeMap;
|
||||
pub use std::collections::BTreeSet as Set;
|
||||
use std::convert::TryFrom;
|
||||
use std::fmt;
|
||||
use std::time::Duration;
|
||||
|
@ -1237,7 +1236,6 @@ impl AuthSession {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
pub use std::collections::BTreeSet as Set;
|
||||
use std::str::FromStr;
|
||||
use std::time::Duration;
|
||||
|
||||
|
|
|
@ -372,7 +372,7 @@ impl<'a> IdmServerProxyWriteTransaction<'a> {
|
|||
&[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");
|
||||
OperationError::InvalidState
|
||||
})?;
|
||||
|
@ -485,7 +485,7 @@ impl<'a> IdmServerProxyWriteTransaction<'a> {
|
|||
&[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");
|
||||
OperationError::InvalidState
|
||||
})?;
|
||||
|
@ -2782,7 +2782,7 @@ mod tests {
|
|||
assert!(c_status.passkeys.len() == 1);
|
||||
|
||||
// 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
|
||||
drop(cutxn);
|
||||
|
|
|
@ -251,7 +251,7 @@ impl<'a> IdmServerProxyWriteTransaction<'a> {
|
|||
.get_accesscontrols()
|
||||
.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");
|
||||
OperationError::InvalidState
|
||||
})?;
|
||||
|
@ -382,7 +382,7 @@ impl<'a> IdmServerProxyWriteTransaction<'a> {
|
|||
.get_accesscontrols()
|
||||
.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");
|
||||
OperationError::InvalidState
|
||||
})?;
|
||||
|
@ -2153,7 +2153,7 @@ mod tests {
|
|||
// Should be none as the entry was masked by being recycled.
|
||||
.map(|entries| {
|
||||
assert!(entries.len() == 1);
|
||||
let ent = entries.get(0).unwrap();
|
||||
let ent = entries.first().unwrap();
|
||||
ent.mask_recycled_ts().is_none()
|
||||
})
|
||||
.unwrap_or(false));
|
||||
|
@ -2348,7 +2348,7 @@ mod tests {
|
|||
// Should be none as the entry was masked by being recycled.
|
||||
.map(|entries| {
|
||||
assert!(entries.len() == 1);
|
||||
let ent = entries.get(0).unwrap();
|
||||
let ent = entries.first().unwrap();
|
||||
ent.mask_recycled_ts().is_none()
|
||||
})
|
||||
.unwrap_or(false));
|
||||
|
@ -2432,7 +2432,7 @@ mod tests {
|
|||
// Should be none as the entry was masked by being recycled.
|
||||
.map(|entries| {
|
||||
assert!(entries.len() == 1);
|
||||
let ent = entries.get(0).unwrap();
|
||||
let ent = entries.first().unwrap();
|
||||
ent.mask_recycled_ts().is_none()
|
||||
})
|
||||
.unwrap_or(false));
|
||||
|
@ -2447,7 +2447,7 @@ mod tests {
|
|||
// Should be none as the entry was masked by being recycled.
|
||||
.map(|entries| {
|
||||
assert!(entries.len() == 1);
|
||||
let ent = entries.get(0).unwrap();
|
||||
let ent = entries.first().unwrap();
|
||||
ent.mask_recycled_ts().is_none()
|
||||
})
|
||||
.unwrap_or(false));
|
||||
|
|
|
@ -926,7 +926,7 @@ impl<'a> IdmServerAuthTransaction<'a> {
|
|||
|
||||
pub fn get_origin(&self) -> &Url {
|
||||
#[allow(clippy::unwrap_used)]
|
||||
self.webauthn.get_allowed_origins().get(0).unwrap()
|
||||
self.webauthn.get_allowed_origins().first().unwrap()
|
||||
}
|
||||
|
||||
#[instrument(level = "trace", skip(self))]
|
||||
|
@ -1544,7 +1544,7 @@ impl<'a> IdmServerProxyWriteTransaction<'a> {
|
|||
|
||||
pub fn get_origin(&self) -> &Url {
|
||||
#[allow(clippy::unwrap_used)]
|
||||
self.webauthn.get_allowed_origins().get(0).unwrap()
|
||||
self.webauthn.get_allowed_origins().first().unwrap()
|
||||
}
|
||||
|
||||
fn check_password_quality(
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
use gloo::console;
|
||||
use kanidm_proto::constants::uri::{OAUTH2_AUTHORISE, OAUTH2_AUTHORISE_PERMIT};
|
||||
use kanidm_proto::constants::{APPLICATION_JSON, KOPID};
|
||||
pub use kanidm_proto::oauth2::{
|
||||
AccessTokenRequest, AccessTokenResponse, AuthorisationRequest, AuthorisationResponse,
|
||||
CodeChallengeMethod, ErrorResponse,
|
||||
};
|
||||
pub use kanidm_proto::oauth2::{AuthorisationRequest, AuthorisationResponse};
|
||||
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::{
|
||||
|
|
|
@ -259,7 +259,7 @@ async fn process_auth_state(
|
|||
{
|
||||
#[allow(clippy::expect_used)]
|
||||
allowed
|
||||
.get(0)
|
||||
.first()
|
||||
.expect("can not fail - bounds already checked.")
|
||||
}
|
||||
_ => {
|
||||
|
@ -387,7 +387,7 @@ impl LoginOpt {
|
|||
{
|
||||
#[allow(clippy::expect_used)]
|
||||
mechs
|
||||
.get(0)
|
||||
.first()
|
||||
.expect("can not fail - bounds already checked.")
|
||||
}
|
||||
_ => {
|
||||
|
|
|
@ -19,6 +19,3 @@ extern crate lazy_static;
|
|||
|
||||
#[cfg(target_family = "unix")]
|
||||
mod implementation;
|
||||
|
||||
#[cfg(target_family = "unix")]
|
||||
pub use implementation::*;
|
||||
|
|
Loading…
Reference in a new issue