diff --git a/kanidm_tools/src/cli/badlist.rs b/kanidm_tools/src/cli/badlist.rs index 7fb083741..505d8e61d 100644 --- a/kanidm_tools/src/cli/badlist.rs +++ b/kanidm_tools/src/cli/badlist.rs @@ -103,8 +103,7 @@ impl PwBadlistOpt { let filt_pwset: Vec<_> = results .into_iter() - .map(|res| res.expect("Thread join failure")) - .flatten() + .flat_map(|res| res.expect("Thread join failure")) .collect(); info!( diff --git a/kanidmd/lib-macros/src/entry.rs b/kanidmd/lib-macros/src/entry.rs index ca779814c..53a1448ea 100644 --- a/kanidmd/lib-macros/src/entry.rs +++ b/kanidmd/lib-macros/src/entry.rs @@ -16,7 +16,7 @@ pub(crate) fn qs_test(_args: &TokenStream, item: TokenStream, with_init: bool) - if let Some(attr) = input.attrs.iter().find(|attr| attr.path.is_ident("test")) { let msg = "second test attribute is supplied"; - return token_stream_with_error(item, syn::Error::new_spanned(&attr, msg)); + return token_stream_with_error(item, syn::Error::new_spanned(attr, msg)); }; if input.sig.asyncness.is_none() { @@ -106,7 +106,7 @@ pub(crate) fn idm_test(_args: &TokenStream, item: TokenStream) -> TokenStream { if let Some(attr) = input.attrs.iter().find(|attr| attr.path.is_ident("test")) { let msg = "second test attribute is supplied"; - return token_stream_with_error(item, syn::Error::new_spanned(&attr, msg)); + return token_stream_with_error(item, syn::Error::new_spanned(attr, msg)); }; if input.sig.asyncness.is_none() { diff --git a/kanidmd/lib/build.rs b/kanidmd/lib/build.rs index 092aa709f..54b626248 100644 --- a/kanidmd/lib/build.rs +++ b/kanidmd/lib/build.rs @@ -6,7 +6,7 @@ fn main() { if let Ok(v) = env::var("DEP_OPENSSL_VERSION_NUMBER") { let version = u64::from_str_radix(&v, 16).unwrap(); - if version >= 0x3_00_00_00_0 { + if version >= 0x3000_0000 { println!("cargo:rustc-cfg=openssl3"); } } diff --git a/kanidmd/lib/src/be/idl_sqlite.rs b/kanidmd/lib/src/be/idl_sqlite.rs index 6ef359d0a..dfc2b7189 100644 --- a/kanidmd/lib/src/be/idl_sqlite.rs +++ b/kanidmd/lib/src/be/idl_sqlite.rs @@ -999,7 +999,7 @@ impl IdlSqliteWriteTransaction { idx_table_list.iter().try_for_each(|idx_table| { trace!(table = ?idx_table, "removing idx_table"); self.conn - .prepare(&format!("DROP TABLE {}.{}", "main", idx_table).as_str()) + .prepare(format!("DROP TABLE {}.{}", "main", idx_table).as_str()) .and_then(|mut stmt| stmt.execute([]).map(|_| ())) .map_err(sqlite_error) }) @@ -1373,7 +1373,7 @@ impl IdlSqlite { })?; vconn - .pragma_update(None, "journal_mode", &"DELETE") + .pragma_update(None, "journal_mode", "DELETE") .map_err(|e| { admin_error!(?e, "rusqlite journal_mode update error"); OperationError::SqliteError @@ -1388,7 +1388,7 @@ impl IdlSqlite { Connection::open_with_flags(cfg.path.as_str(), flags).map_err(sqlite_error)?; vconn - .pragma_update(None, "page_size", &(cfg.fstype as u32)) + .pragma_update(None, "page_size", cfg.fstype as u32) .map_err(|e| { admin_error!(?e, "rusqlite page_size update error"); OperationError::SqliteError @@ -1400,7 +1400,7 @@ impl IdlSqlite { })?; vconn - .pragma_update(None, "journal_mode", &"WAL") + .pragma_update(None, "journal_mode", "WAL") .map_err(|e| { admin_error!(?e, "rusqlite journal_mode update error"); OperationError::SqliteError diff --git a/kanidmd/lib/src/idm/oauth2.rs b/kanidmd/lib/src/idm/oauth2.rs index 3e8d0a411..98795ab74 100644 --- a/kanidmd/lib/src/idm/oauth2.rs +++ b/kanidmd/lib/src/idm/oauth2.rs @@ -465,7 +465,8 @@ impl Oauth2ResourceServersReadTransaction { // let o2rs = self.inner.rs_set.get(&auth_req.client_id).ok_or_else(|| { admin_warn!( - "Invalid oauth2 client_id (have you configured the oauth2 resource server?)" + "Invalid oauth2 client_id ({}) Have you configured the oauth2 resource server?", + &auth_req.client_id ); Oauth2Error::InvalidClientId })?; @@ -474,7 +475,9 @@ impl Oauth2ResourceServersReadTransaction { if auth_req.redirect_uri.origin() != o2rs.origin { admin_warn!( origin = ?o2rs.origin, - "Invalid oauth2 redirect_uri (must be related to origin of) - got {:?}", auth_req.redirect_uri.origin() + "Invalid oauth2 redirect_uri (must be related to origin {:?}) - got {:?}", + o2rs.origin, + auth_req.redirect_uri.origin() ); return Err(Oauth2Error::InvalidOrigin); } diff --git a/kanidmd/lib/src/idm/server.rs b/kanidmd/lib/src/idm/server.rs index cd89e71ea..859e22b59 100644 --- a/kanidmd/lib/src/idm/server.rs +++ b/kanidmd/lib/src/idm/server.rs @@ -1577,6 +1577,7 @@ impl<'a> IdmServerTransaction<'a> for IdmServerProxyWriteTransaction<'a> { impl<'a> IdmServerProxyWriteTransaction<'a> { pub fn get_origin(&self) -> &Url { + #[allow(clippy::unwrap_used)] self.webauthn.get_allowed_origins().get(0).unwrap() } @@ -2131,8 +2132,7 @@ impl<'a> IdmServerProxyWriteTransaction<'a> { let mlist: Vec<_> = sessions .iter() - .map(|item| item.iter()) - .flatten() + .flat_map(|item| item.iter()) .filter_map(|(k, v)| { // We only check if an expiry is present v.expiry.and_then(|exp| { diff --git a/kanidmd/lib/src/idm/serviceaccount.rs b/kanidmd/lib/src/idm/serviceaccount.rs index 14369fe0b..8e21f156f 100644 --- a/kanidmd/lib/src/idm/serviceaccount.rs +++ b/kanidmd/lib/src/idm/serviceaccount.rs @@ -205,10 +205,7 @@ impl<'a> IdmServerProxyWriteTransaction<'a> { let issued_at = time::OffsetDateTime::unix_epoch() + ct; // Normalise to UTC incase it was provided as something else. - let expiry = gte - .expiry - .clone() - .map(|odt| odt.to_offset(time::UtcOffset::UTC)); + let expiry = gte.expiry.map(|odt| odt.to_offset(time::UtcOffset::UTC)); let purpose = if gte.read_write { ApiTokenPurpose::ReadWrite diff --git a/kanidmd/lib/src/plugins/dyngroup.rs b/kanidmd/lib/src/plugins/dyngroup.rs index 5d0633f88..2beec6768 100644 --- a/kanidmd/lib/src/plugins/dyngroup.rs +++ b/kanidmd/lib/src/plugins/dyngroup.rs @@ -15,6 +15,7 @@ pub struct DynGroupCache { pub struct DynGroup; impl DynGroup { + #[allow(clippy::too_many_arguments)] fn apply_dyngroup_change( qs: &QueryServerWriteTransaction, ident: &Identity, @@ -35,7 +36,7 @@ impl DynGroup { // Search all the new groups first. let filt = filter!(FC::Or( n_dyn_groups - .into_iter() + .iter() .map(|e| f_eq("uuid", PartialValue::new_uuid(e.get_uuid()))) .collect() )); diff --git a/kanidmd/lib/src/testkit.rs b/kanidmd/lib/src/testkit.rs index 00a7607b6..73b947f3b 100644 --- a/kanidmd/lib/src/testkit.rs +++ b/kanidmd/lib/src/testkit.rs @@ -4,8 +4,9 @@ use crate::schema::Schema; #[allow(unused_imports)] use crate::utils::duration_from_epoch_now; +#[allow(clippy::expect_used)] pub async fn setup_test() -> QueryServer { - let _ = sketching::test_init(); + sketching::test_init(); // Create an in memory BE let schema_outer = Schema::new().expect("Failed to init schema"); @@ -15,17 +16,16 @@ pub async fn setup_test() -> QueryServer { }; let be = Backend::new(BackendConfig::new_test(), idxmeta, false).expect("Failed to init BE"); - let qs = QueryServer::new(be, schema_outer, "example.com".to_string()); // Init is called via the proc macro - qs + QueryServer::new(be, schema_outer, "example.com".to_string()) } +#[allow(clippy::expect_used)] pub async fn setup_idm_test() -> (IdmServer, IdmServerDelayed) { let qs = setup_test().await; qs.initialise_helper(duration_from_epoch_now()) .await .expect("init failed!"); - IdmServer::new(qs, "https://idm.example.com").expect("Failed to setup idms") } diff --git a/kanidmd/lib/src/value.rs b/kanidmd/lib/src/value.rs index 10fac2bc7..34101fb93 100644 --- a/kanidmd/lib/src/value.rs +++ b/kanidmd/lib/src/value.rs @@ -735,6 +735,7 @@ impl PartialValue { } } + #[allow(clippy::unimplemented)] pub fn get_idx_sub_key(&self) -> String { unimplemented!(); } diff --git a/kanidmd/lib/src/valueset/mod.rs b/kanidmd/lib/src/valueset/mod.rs index 97407d2ca..636107a17 100644 --- a/kanidmd/lib/src/valueset/mod.rs +++ b/kanidmd/lib/src/valueset/mod.rs @@ -647,7 +647,7 @@ pub fn from_db_valueset_v2(dbvs: DbValueSetV2) -> Result ValueSetJwsKeyEs256::from_dbvs2(&set), DbValueSetV2::JwsKeyRs256(set) => ValueSetJwsKeyEs256::from_dbvs2(&set), DbValueSetV2::PhoneNumber(_, _) | DbValueSetV2::TrustedDeviceEnrollment(_) => { - unimplemented!() + todo!() } } } diff --git a/kanidmd/testkit-macros/src/entry.rs b/kanidmd/testkit-macros/src/entry.rs index d1d90e256..e17dd8e8f 100644 --- a/kanidmd/testkit-macros/src/entry.rs +++ b/kanidmd/testkit-macros/src/entry.rs @@ -76,7 +76,7 @@ pub(crate) fn test(_args: &TokenStream, item: TokenStream) -> TokenStream { if let Some(attr) = input.attrs.iter().find(|attr| attr.path.is_ident("test")) { let msg = "second test attribute is supplied"; - return token_stream_with_error(item, syn::Error::new_spanned(&attr, msg)); + return token_stream_with_error(item, syn::Error::new_spanned(attr, msg)); }; if input.sig.asyncness.is_none() { diff --git a/kanidmd_web_ui/src/components/change_unix_password.rs b/kanidmd_web_ui/src/components/change_unix_password.rs index 9f9f68978..025fbc07d 100644 --- a/kanidmd_web_ui/src/components/change_unix_password.rs +++ b/kanidmd_web_ui/src/components/change_unix_password.rs @@ -288,7 +288,7 @@ impl ChangeUnixPassword { let headers = resp.headers(); let kopid = headers.get("x-kanidm-opid").ok().flatten(); let text = JsFuture::from(resp.text()?).await?; - let emsg = text.as_string().unwrap_or_else(|| "".to_string()); + let emsg = text.as_string().unwrap_or_default(); Ok(Msg::Error { emsg, kopid }) } } diff --git a/kanidmd_web_ui/src/credential/delete.rs b/kanidmd_web_ui/src/credential/delete.rs index fc5d07fd5..327356c5a 100644 --- a/kanidmd_web_ui/src/credential/delete.rs +++ b/kanidmd_web_ui/src/credential/delete.rs @@ -78,7 +78,7 @@ impl DeleteApp { Ok(Msg::Success) } else { let text = JsFuture::from(resp.text()?).await?; - let emsg = text.as_string().unwrap_or_else(|| "".to_string()); + let emsg = text.as_string().unwrap_or_default(); Ok(Msg::Error { emsg, kopid }) } } diff --git a/kanidmd_web_ui/src/credential/passkey.rs b/kanidmd_web_ui/src/credential/passkey.rs index f87908c31..8f02c37ca 100644 --- a/kanidmd_web_ui/src/credential/passkey.rs +++ b/kanidmd_web_ui/src/credential/passkey.rs @@ -104,7 +104,7 @@ impl PasskeyModalApp { }) } else { let text = JsFuture::from(resp.text()?).await?; - let emsg = text.as_string().unwrap_or_else(|| "".to_string()); + let emsg = text.as_string().unwrap_or_default(); Ok(Msg::Error { emsg, kopid }) } } diff --git a/kanidmd_web_ui/src/credential/passkeyremove.rs b/kanidmd_web_ui/src/credential/passkeyremove.rs index 292e418b6..dbf6a31fa 100644 --- a/kanidmd_web_ui/src/credential/passkeyremove.rs +++ b/kanidmd_web_ui/src/credential/passkeyremove.rs @@ -113,7 +113,7 @@ impl PasskeyRemoveModalApp { }) } else { let text = JsFuture::from(resp.text()?).await?; - let emsg = text.as_string().unwrap_or_else(|| "".to_string()); + let emsg = text.as_string().unwrap_or_default(); Ok(Msg::Error { emsg, kopid }) } } diff --git a/kanidmd_web_ui/src/credential/pwmodal.rs b/kanidmd_web_ui/src/credential/pwmodal.rs index 5aaa808b7..e17f69939 100644 --- a/kanidmd_web_ui/src/credential/pwmodal.rs +++ b/kanidmd_web_ui/src/credential/pwmodal.rs @@ -103,7 +103,7 @@ impl PwModalApp { } else { let kopid = headers.get("x-kanidm-opid").ok().flatten(); let text = JsFuture::from(resp.text()?).await?; - let emsg = text.as_string().unwrap_or_else(|| "".to_string()); + let emsg = text.as_string().unwrap_or_default(); Ok(Msg::Error { emsg, kopid }) } } diff --git a/kanidmd_web_ui/src/credential/reset.rs b/kanidmd_web_ui/src/credential/reset.rs index 58f742aff..5e3bb4ff8 100644 --- a/kanidmd_web_ui/src/credential/reset.rs +++ b/kanidmd_web_ui/src/credential/reset.rs @@ -563,7 +563,7 @@ impl CredentialResetApp { } else { let kopid = headers.get("x-kanidm-opid").ok().flatten(); let text = JsFuture::from(resp.text()?).await?; - let emsg = text.as_string().unwrap_or_else(|| "".to_string()); + let emsg = text.as_string().unwrap_or_default(); Ok(Msg::Error { emsg, kopid }) } } @@ -596,7 +596,7 @@ impl CredentialResetApp { } else { let kopid = headers.get("x-kanidm-opid").ok().flatten(); let text = JsFuture::from(resp.text()?).await?; - let emsg = text.as_string().unwrap_or_else(|| "".to_string()); + let emsg = text.as_string().unwrap_or_default(); Ok(Msg::Error { emsg, kopid }) } } diff --git a/kanidmd_web_ui/src/credential/totpmodal.rs b/kanidmd_web_ui/src/credential/totpmodal.rs index 3616ea04c..bba3c7062 100644 --- a/kanidmd_web_ui/src/credential/totpmodal.rs +++ b/kanidmd_web_ui/src/credential/totpmodal.rs @@ -113,7 +113,7 @@ impl TotpModalApp { }) } else { let text = JsFuture::from(resp.text()?).await?; - let emsg = text.as_string().unwrap_or_else(|| "".to_string()); + let emsg = text.as_string().unwrap_or_default(); Ok(Msg::Error { emsg, kopid }) } } diff --git a/kanidmd_web_ui/src/login.rs b/kanidmd_web_ui/src/login.rs index c5f195c95..ce33958ce 100644 --- a/kanidmd_web_ui/src/login.rs +++ b/kanidmd_web_ui/src/login.rs @@ -132,7 +132,7 @@ impl LoginApp { } else { let kopid = headers.get("x-kanidm-opid").ok().flatten(); let text = JsFuture::from(resp.text()?).await?; - let emsg = text.as_string().unwrap_or_else(|| "".to_string()); + let emsg = text.as_string().unwrap_or_default(); Ok(LoginAppMsg::Error { emsg, kopid }) } } diff --git a/kanidmd_web_ui/src/manager.rs b/kanidmd_web_ui/src/manager.rs index 2adeeb228..76a036160 100644 --- a/kanidmd_web_ui/src/manager.rs +++ b/kanidmd_web_ui/src/manager.rs @@ -52,10 +52,15 @@ fn switch(route: &Route) -> Html { #[cfg(debug)] console::debug!("manager::switch"); match route { + #[allow(clippy::let_unit_value)] Route::Landing => html! { }, + #[allow(clippy::let_unit_value)] Route::Login => html! { }, + #[allow(clippy::let_unit_value)] Route::Oauth2 => html! { }, + #[allow(clippy::let_unit_value)] Route::Views => html! { }, + #[allow(clippy::let_unit_value)] Route::CredentialReset => html! { }, Route::NotFound => { add_body_form_classes!(); diff --git a/kanidmd_web_ui/src/oauth2.rs b/kanidmd_web_ui/src/oauth2.rs index d01181692..a81ef2dfa 100644 --- a/kanidmd_web_ui/src/oauth2.rs +++ b/kanidmd_web_ui/src/oauth2.rs @@ -92,7 +92,7 @@ impl Oauth2App { let headers = resp.headers(); let kopid = headers.get("x-kanidm-opid").ok().flatten(); let text = JsFuture::from(resp.text()?).await?; - let emsg = text.as_string().unwrap_or_else(|| "".to_string()); + let emsg = text.as_string().unwrap_or_default(); // let jsval_json = JsFuture::from(resp.json()?).await?; Ok(Oauth2Msg::Error { emsg, kopid }) } @@ -158,7 +158,7 @@ impl Oauth2App { Ok(Oauth2Msg::AccessDenied { kopid }) } else { let text = JsFuture::from(resp.text()?).await?; - let emsg = text.as_string().unwrap_or_else(|| "".to_string()); + let emsg = text.as_string().unwrap_or_default(); Ok(Oauth2Msg::Error { emsg, kopid }) } } diff --git a/kanidmd_web_ui/src/views/mod.rs b/kanidmd_web_ui/src/views/mod.rs index 1f33b5040..0e3661334 100644 --- a/kanidmd_web_ui/src/views/mod.rs +++ b/kanidmd_web_ui/src/views/mod.rs @@ -320,6 +320,7 @@ impl ViewsApp { ViewRoute::Admin => html!{ render={ Switch::render(admin_routes) } /> }, + #[allow(clippy::let_unit_value)] ViewRoute::Apps => html! { }, ViewRoute::Profile => html! { }, ViewRoute::Security => html! { }, @@ -359,7 +360,7 @@ impl ViewsApp { let headers = resp.headers(); let kopid = headers.get("x-kanidm-opid").ok().flatten(); let text = JsFuture::from(resp.text()?).await?; - let emsg = text.as_string().unwrap_or_else(|| "".to_string()); + let emsg = text.as_string().unwrap_or_default(); Ok(ViewsMsg::Error { emsg, kopid }) } } @@ -396,7 +397,7 @@ impl ViewsApp { let headers = resp.headers(); let kopid = headers.get("x-kanidm-opid").ok().flatten(); let text = JsFuture::from(resp.text()?).await?; - let emsg = text.as_string().unwrap_or_else(|| "".to_string()); + let emsg = text.as_string().unwrap_or_default(); Ok(ViewsMsg::Error { emsg, kopid }) } } @@ -425,7 +426,7 @@ impl ViewsApp { let headers = resp.headers(); let kopid = headers.get("x-kanidm-opid").ok().flatten(); let text = JsFuture::from(resp.text()?).await?; - let emsg = text.as_string().unwrap_or_else(|| "".to_string()); + let emsg = text.as_string().unwrap_or_default(); Ok(ViewsMsg::Error { emsg, kopid }) } } diff --git a/kanidmd_web_ui/src/views/profile.rs b/kanidmd_web_ui/src/views/profile.rs index 420005236..ac3af991b 100644 --- a/kanidmd_web_ui/src/views/profile.rs +++ b/kanidmd_web_ui/src/views/profile.rs @@ -24,7 +24,7 @@ impl TryFrom for Profile { type Error = String; fn try_from(entry: Entry) -> Result { - console::error!("Entry Dump", format!("{:?}", entry).to_string()); + console::error!("Entry Dump", format!("{:?}", entry)); let uuid = entry .attrs @@ -152,7 +152,7 @@ impl Component for ProfileApp { } } - State::Ready(profile) => self.view_profile(ctx, &profile), + State::Ready(profile) => self.view_profile(ctx, profile), State::Error { emsg, kopid } => self.do_alert_error( "An error has occured 😔 ", Some( @@ -313,7 +313,7 @@ impl ProfileApp { let headers = resp.headers(); let kopid = headers.get("x-kanidm-opid").ok().flatten(); let text = JsFuture::from(resp.text()?).await?; - let emsg = text.as_string().unwrap_or_else(|| "".to_string()); + let emsg = text.as_string().unwrap_or_default(); Ok(Msg::Error { emsg, kopid }) } } diff --git a/kanidmd_web_ui/src/views/security.rs b/kanidmd_web_ui/src/views/security.rs index 867c7b50e..9f99affb4 100644 --- a/kanidmd_web_ui/src/views/security.rs +++ b/kanidmd_web_ui/src/views/security.rs @@ -198,7 +198,7 @@ impl SecurityApp { let headers = resp.headers(); let kopid = headers.get("x-kanidm-opid").ok().flatten(); let text = JsFuture::from(resp.text()?).await?; - let emsg = text.as_string().unwrap_or_else(|| "".to_string()); + let emsg = text.as_string().unwrap_or_default(); // let jsval_json = JsFuture::from(resp.json()?).await?; Ok(Msg::Error { emsg, kopid }) } diff --git a/orca/src/main.rs b/orca/src/main.rs index 890411d97..db291551d 100644 --- a/orca/src/main.rs +++ b/orca/src/main.rs @@ -63,6 +63,7 @@ impl TargetServerBuilder { } } +#[allow(clippy::large_enum_variant)] pub enum TargetServer { Kanidm(KaniHttpServer), KanidmLdap(Box),