From fce3d603dc0cb94ee782b6c8be61cc37b4997669 Mon Sep 17 00:00:00 2001 From: Tommy Volk Date: Wed, 20 Aug 2025 08:30:19 -0500 Subject: [PATCH 01/24] chore: enable clippy nursery and pedantic rules --- harbor-client/src/lib.rs | 38 ++++++++++++++++++++++++++++++++++ harbor-ui/src/main.rs | 44 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) diff --git a/harbor-client/src/lib.rs b/harbor-client/src/lib.rs index fbb0e353..dfd9b6d5 100644 --- a/harbor-client/src/lib.rs +++ b/harbor-client/src/lib.rs @@ -1,3 +1,41 @@ +#![warn(clippy::nursery, clippy::pedantic)] +#![allow( + clippy::cast_lossless, + clippy::cast_possible_wrap, + clippy::cast_sign_loss, + clippy::default_trait_access, + clippy::derive_partial_eq_without_eq, + clippy::doc_markdown, + clippy::explicit_iter_loop, + clippy::future_not_send, + clippy::ignored_unit_patterns, + clippy::items_after_statements, + clippy::large_futures, + clippy::match_same_arms, + clippy::match_wildcard_for_single_variants, + clippy::missing_const_for_fn, + clippy::missing_errors_doc, + clippy::missing_panics_doc, + clippy::must_use_candidate, + clippy::needless_pass_by_value, + clippy::option_if_let_else, + clippy::or_fun_call, + clippy::redundant_clone, + clippy::redundant_closure_for_method_calls, + clippy::redundant_pub_crate, + clippy::semicolon_if_nothing_returned, + clippy::significant_drop_in_scrutinee, + clippy::significant_drop_tightening, + clippy::similar_names, + clippy::single_char_pattern, + clippy::single_match_else, + clippy::too_many_lines, + clippy::uninlined_format_args, + clippy::unnecessary_wraps, + clippy::unused_async, + clippy::use_self +)] + use crate::cashu_client::{ TorMintConnector, spawn_lightning_payment_thread, spawn_lightning_receive_thread, }; diff --git a/harbor-ui/src/main.rs b/harbor-ui/src/main.rs index 370a1ab9..26aa138d 100644 --- a/harbor-ui/src/main.rs +++ b/harbor-ui/src/main.rs @@ -1,3 +1,47 @@ +#![warn(clippy::nursery, clippy::pedantic)] +#![allow( + clippy::cast_lossless, + clippy::cast_possible_truncation, + clippy::cast_possible_wrap, + clippy::cast_precision_loss, + clippy::cast_sign_loss, + clippy::cognitive_complexity, + clippy::derive_partial_eq_without_eq, + clippy::doc_markdown, + clippy::if_not_else, + clippy::ignored_unit_patterns, + clippy::implicit_clone, + clippy::large_futures, + clippy::manual_let_else, + clippy::manual_string_new, + clippy::map_unwrap_or, + clippy::match_bool, + clippy::match_same_arms, + clippy::match_wildcard_for_single_variants, + clippy::missing_const_for_fn, + clippy::missing_errors_doc, + clippy::missing_panics_doc, + clippy::must_use_candidate, + clippy::needless_collect, + clippy::needless_pass_by_ref_mut, + clippy::needless_pass_by_value, + clippy::option_if_let_else, + clippy::or_fun_call, + clippy::redundant_clone, + clippy::redundant_closure_for_method_calls, + clippy::redundant_else, + clippy::ref_option, + clippy::return_self_not_must_use, + clippy::semicolon_if_nothing_returned, + clippy::single_match_else, + clippy::struct_excessive_bools, + clippy::suboptimal_flops, + clippy::too_many_lines, + clippy::uninlined_format_args, + clippy::unreadable_literal, + clippy::unused_self, + clippy::use_self +)] #![windows_subsystem = "windows"] use crate::bridge::run_core; From 7207e3882eca082292ad6e1c5d274d972c1b5dcc Mon Sep 17 00:00:00 2001 From: Tommy Volk Date: Mon, 25 Aug 2025 15:46:46 -0500 Subject: [PATCH 02/24] chore: enforce clippy cast_lossless rule --- harbor-client/src/db_models/profile.rs | 4 ++-- harbor-client/src/lib.rs | 1 - harbor-ui/src/components/spinner.rs | 2 +- harbor-ui/src/main.rs | 1 - 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/harbor-client/src/db_models/profile.rs b/harbor-client/src/db_models/profile.rs index 5782b3c1..8870109c 100644 --- a/harbor-client/src/db_models/profile.rs +++ b/harbor-client/src/db_models/profile.rs @@ -29,7 +29,7 @@ impl Profile { enabled ); diesel::update(profile::table) - .set(profile::onchain_receive_enabled.eq(enabled as i32)) + .set(profile::onchain_receive_enabled.eq(i32::from(enabled))) .execute(conn)?; log::debug!("Successfully updated on-chain receive enabled setting in database"); Ok(()) @@ -42,7 +42,7 @@ impl Profile { pub fn set_tor_enabled(conn: &mut SqliteConnection, enabled: bool) -> anyhow::Result<()> { log::debug!("Updating Tor enabled setting in database to: {}", enabled); diesel::update(profile::table) - .set(profile::tor_enabled.eq(enabled as i32)) + .set(profile::tor_enabled.eq(i32::from(enabled))) .execute(conn)?; log::debug!("Successfully updated Tor enabled setting in database"); Ok(()) diff --git a/harbor-client/src/lib.rs b/harbor-client/src/lib.rs index dfd9b6d5..4fd08c5a 100644 --- a/harbor-client/src/lib.rs +++ b/harbor-client/src/lib.rs @@ -1,6 +1,5 @@ #![warn(clippy::nursery, clippy::pedantic)] #![allow( - clippy::cast_lossless, clippy::cast_possible_wrap, clippy::cast_sign_loss, clippy::default_trait_access, diff --git a/harbor-ui/src/components/spinner.rs b/harbor-ui/src/components/spinner.rs index e4718f89..668019b3 100644 --- a/harbor-ui/src/components/spinner.rs +++ b/harbor-ui/src/components/spinner.rs @@ -148,7 +148,7 @@ impl Animation { start: now, progress: 0.0, rotation: rotation.wrapping_add(BASE_ROTATION_SPEED.wrapping_add( - (f64::from(WRAP_ANGLE / (2.0 * Radians::PI)) * u32::MAX as f64) as u32, + (f64::from(WRAP_ANGLE / (2.0 * Radians::PI)) * f64::from(u32::MAX)) as u32, )), last: now, }, diff --git a/harbor-ui/src/main.rs b/harbor-ui/src/main.rs index 26aa138d..781059b4 100644 --- a/harbor-ui/src/main.rs +++ b/harbor-ui/src/main.rs @@ -1,6 +1,5 @@ #![warn(clippy::nursery, clippy::pedantic)] #![allow( - clippy::cast_lossless, clippy::cast_possible_truncation, clippy::cast_possible_wrap, clippy::cast_precision_loss, From e2322fd20c3711b3d3ecd7d73e0598f4b9baf822 Mon Sep 17 00:00:00 2001 From: Tommy Volk Date: Mon, 25 Aug 2025 16:05:24 -0500 Subject: [PATCH 03/24] chore: enforce clippy doc_markdown rule --- harbor-client/src/http.rs | 8 ++++---- harbor-client/src/lib.rs | 1 - harbor-ui/src/bridge.rs | 2 +- harbor-ui/src/main.rs | 1 - 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/harbor-client/src/http.rs b/harbor-client/src/http.rs index ffea747e..3a24aa96 100644 --- a/harbor-client/src/http.rs +++ b/harbor-client/src/http.rs @@ -50,7 +50,7 @@ const MAX_RESPONSE_SIZE: usize = 10 * 1024 * 1024; // 10MB limit /// /// This is the standard way to make HTTPS requests. It: /// - Uses a connection pool for better performance -/// - Handles redirects automatically (up to MAX_REDIRECTS) +/// - Handles redirects automatically (up to `MAX_REDIRECTS`) /// - Enforces a response size limit /// - Returns deserialized JSON pub(crate) async fn make_get_request_direct(url: &str) -> anyhow::Result @@ -75,7 +75,7 @@ async fn check_cancel(cancel_handle: Arc) { /// - Enforcing HTTPS-only connections /// - Using fresh circuits for each request /// -/// The request can be cancelled at any time using the cancel_handle. +/// The request can be cancelled at any time using the `cancel_handle`. /// /// Note: This is slower than direct requests due to Tor routing. pub async fn make_get_request_tor(url: &str, cancel_handle: Arc) -> anyhow::Result @@ -93,7 +93,7 @@ where /// - Enforcing HTTPS-only connections /// - Using fresh circuits for each request /// -/// The request can be cancelled at any time using the cancel_handle. +/// The request can be cancelled at any time using the `cancel_handle`. /// /// Note: This is slower than direct requests due to Tor routing. pub(crate) async fn make_tor_request( @@ -450,7 +450,7 @@ where handle_response(response, 0, None).await } -/// Use what Chrome puts for User Agent for better privacy, copied from: https://www.whatismybrowser.com/guides/the-latest-user-agent/chrome +/// Use what Chrome puts for User Agent for better privacy, copied from: `https://www.whatismybrowser.com/guides/the-latest-user-agent/chrome` const USER_AGENT: &str = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36"; /// Build a GET request with common headers diff --git a/harbor-client/src/lib.rs b/harbor-client/src/lib.rs index 4fd08c5a..96e2a78d 100644 --- a/harbor-client/src/lib.rs +++ b/harbor-client/src/lib.rs @@ -4,7 +4,6 @@ clippy::cast_sign_loss, clippy::default_trait_access, clippy::derive_partial_eq_without_eq, - clippy::doc_markdown, clippy::explicit_iter_loop, clippy::future_not_send, clippy::ignored_unit_patterns, diff --git a/harbor-ui/src/bridge.rs b/harbor-ui/src/bridge.rs index 8b774118..d1f59f75 100644 --- a/harbor-ui/src/bridge.rs +++ b/harbor-ui/src/bridge.rs @@ -74,7 +74,7 @@ pub fn create_handles() -> (UIHandle, CoreHandle) { (ui_handle, core_handle) } -/// Common setup function for creating a HarborCore instance +/// Common setup function for creating a `HarborCore` instance async fn setup_harbor_core( data_dir: PathBuf, db_path: &str, diff --git a/harbor-ui/src/main.rs b/harbor-ui/src/main.rs index 781059b4..2fb1fb7e 100644 --- a/harbor-ui/src/main.rs +++ b/harbor-ui/src/main.rs @@ -6,7 +6,6 @@ clippy::cast_sign_loss, clippy::cognitive_complexity, clippy::derive_partial_eq_without_eq, - clippy::doc_markdown, clippy::if_not_else, clippy::ignored_unit_patterns, clippy::implicit_clone, From 25abd237a4360967056d2fb127b6d15ec58fbc1f Mon Sep 17 00:00:00 2001 From: Tommy Volk Date: Mon, 25 Aug 2025 21:50:49 -0500 Subject: [PATCH 04/24] chore: enforce clippy explicit_iter_loop rule --- harbor-client/src/fedimint_client.rs | 2 +- harbor-client/src/lib.rs | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/harbor-client/src/fedimint_client.rs b/harbor-client/src/fedimint_client.rs index 6b91a0f8..dd0c3f66 100644 --- a/harbor-client/src/fedimint_client.rs +++ b/harbor-client/src/fedimint_client.rs @@ -294,7 +294,7 @@ pub(crate) async fn select_gateway(client: &ClientHandleArc) -> Option = None; - for gateway in gateways.iter() { + for gateway in &gateways { // first try to find a vetted gateway if gateway.vetted { // if we can select the gateway, return it diff --git a/harbor-client/src/lib.rs b/harbor-client/src/lib.rs index 96e2a78d..630d33cd 100644 --- a/harbor-client/src/lib.rs +++ b/harbor-client/src/lib.rs @@ -4,7 +4,6 @@ clippy::cast_sign_loss, clippy::default_trait_access, clippy::derive_partial_eq_without_eq, - clippy::explicit_iter_loop, clippy::future_not_send, clippy::ignored_unit_patterns, clippy::items_after_statements, From 58cc3bf2d5f9bd8bc1c875c9df13db8c4e1be170 Mon Sep 17 00:00:00 2001 From: Tommy Volk Date: Mon, 25 Aug 2025 22:00:07 -0500 Subject: [PATCH 05/24] chore: enforce clippy future_not_send rule --- harbor-client/src/cashu_client.rs | 4 ++-- harbor-client/src/lib.rs | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/harbor-client/src/cashu_client.rs b/harbor-client/src/cashu_client.rs index bed6b97a..101d87ab 100644 --- a/harbor-client/src/cashu_client.rs +++ b/harbor-client/src/cashu_client.rs @@ -51,10 +51,10 @@ impl TorMintConnector { } #[inline] - async fn http_post( + async fn http_post( &self, url: Url, - payload: &P, + payload: P, ) -> Result { let res: R = make_tor_request(url.as_str(), Some(payload), self.cancel_handle.clone()) .await diff --git a/harbor-client/src/lib.rs b/harbor-client/src/lib.rs index 630d33cd..e4b086dc 100644 --- a/harbor-client/src/lib.rs +++ b/harbor-client/src/lib.rs @@ -4,7 +4,6 @@ clippy::cast_sign_loss, clippy::default_trait_access, clippy::derive_partial_eq_without_eq, - clippy::future_not_send, clippy::ignored_unit_patterns, clippy::items_after_statements, clippy::large_futures, From dd3490ae68ff89eb0d197cca4fd82341a0b93f22 Mon Sep 17 00:00:00 2001 From: Tommy Volk Date: Mon, 25 Aug 2025 22:05:39 -0500 Subject: [PATCH 06/24] chore: enforce clippy if_not_else rule --- harbor-ui/src/components/sidebar.rs | 6 +++--- harbor-ui/src/main.rs | 14 ++++++-------- harbor-ui/src/routes/home.rs | 12 ++++++------ 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/harbor-ui/src/components/sidebar.rs b/harbor-ui/src/components/sidebar.rs index cd53e4ce..3aed4856 100644 --- a/harbor-ui/src/components/sidebar.rs +++ b/harbor-ui/src/components/sidebar.rs @@ -64,10 +64,10 @@ pub fn sidebar(harbor: &HarborWallet) -> Element { Position::Right, harbor.show_add_a_mint_cta ), - if !transfer_disabled { - transfer_button.on_press(Message::Navigate(Route::Transfer)) - } else { + if transfer_disabled { transfer_button + } else { + transfer_button.on_press(Message::Navigate(Route::Transfer)) }, sidebar_button( "History", diff --git a/harbor-ui/src/main.rs b/harbor-ui/src/main.rs index 2fb1fb7e..508bb831 100644 --- a/harbor-ui/src/main.rs +++ b/harbor-ui/src/main.rs @@ -6,7 +6,6 @@ clippy::cast_sign_loss, clippy::cognitive_complexity, clippy::derive_partial_eq_without_eq, - clippy::if_not_else, clippy::ignored_unit_patterns, clippy::implicit_clone, clippy::large_futures, @@ -1058,14 +1057,14 @@ impl HarborWallet { self.clear_send_state(); } // Toast success - if params != SendSuccessMsg::Transfer { + if params == SendSuccessMsg::Transfer { + Task::none() + } else { Task::done(Message::AddToast(Toast { title: "Payment sent".to_string(), body: None, status: ToastStatus::Good, })) - } else { - Task::none() } } CoreUIMsg::SendFailure(reason) => { @@ -1096,16 +1095,15 @@ impl HarborWallet { self.active_route = Route::History; self.clear_transfer_state(); } - if params != ReceiveSuccessMsg::Transfer { - // Toast success + if params == ReceiveSuccessMsg::Transfer { Task::done(Message::AddToast(Toast { - title: "Payment received".to_string(), + title: "Transfer complete".to_string(), body: None, status: ToastStatus::Good, })) } else { Task::done(Message::AddToast(Toast { - title: "Transfer complete".to_string(), + title: "Payment received".to_string(), body: None, status: ToastStatus::Good, })) diff --git a/harbor-ui/src/routes/home.rs b/harbor-ui/src/routes/home.rs index 6d79536c..632868be 100644 --- a/harbor-ui/src/routes/home.rs +++ b/harbor-ui/src/routes/home.rs @@ -18,15 +18,15 @@ pub fn home(harbor: &HarborWallet) -> Element { let receive_button = h_button("Deposit", SvgIcon::DownLeft, false); let buttons = row![ - if !send_disabled { - send_button.on_press(Message::Navigate(Route::Send)) - } else { + if send_disabled { send_button - }, - if !receive_disabled { - receive_button.on_press(Message::Navigate(Route::Receive)) } else { + send_button.on_press(Message::Navigate(Route::Send)) + }, + if receive_disabled { receive_button + } else { + receive_button.on_press(Message::Navigate(Route::Receive)) } ] .spacing(32); From 53212e708bcee03334a85009d9c843b31899631a Mon Sep 17 00:00:00 2001 From: Tommy Volk Date: Mon, 25 Aug 2025 22:09:32 -0500 Subject: [PATCH 07/24] chore: enforce clippy ignored_unit_patterns rule --- harbor-client/src/fedimint_client.rs | 6 +++--- harbor-client/src/http.rs | 10 +++++----- harbor-client/src/lib.rs | 1 - harbor-client/src/lightning_address.rs | 2 +- harbor-ui/src/bridge.rs | 12 ++++++------ harbor-ui/src/keyring.rs | 2 +- harbor-ui/src/main.rs | 3 +-- 7 files changed, 17 insertions(+), 19 deletions(-) diff --git a/harbor-client/src/fedimint_client.rs b/harbor-client/src/fedimint_client.rs index dd0c3f66..fcde57c2 100644 --- a/harbor-client/src/fedimint_client.rs +++ b/harbor-client/src/fedimint_client.rs @@ -170,7 +170,7 @@ impl FedimintClient { ) .await; match client.wait_for_all_recoveries().await { - Ok(_) => { + Ok(()) => { info!("Federation successfully recovered"); HarborCore::send_msg( &mut sender, @@ -240,7 +240,7 @@ impl FedimintClient { let start = Instant::now(); match client.backup_to_federation(Metadata::empty()).await { Err(e) => error!("Could not create backup to federation: {e}"), - Ok(_) => info!("Successfully created backup to federation"), + Ok(()) => info!("Successfully created backup to federation"), } info!("Creating backup took: {}ms", start.elapsed().as_millis()); @@ -255,7 +255,7 @@ impl FedimintClient { .expect("must have ln module"); match lightning_module.update_gateway_cache().await { - Ok(_) => { + Ok(()) => { trace!("Updated lightning gateway cache"); } Err(e) => { diff --git a/harbor-client/src/http.rs b/harbor-client/src/http.rs index 3a24aa96..740e9254 100644 --- a/harbor-client/src/http.rs +++ b/harbor-client/src/http.rs @@ -123,14 +123,14 @@ where // Use select! to handle cancellation during bootstrap let bootstrap_result = tokio::select! { biased; // Check cancellation first - _ = check_cancel(cancel_handle.clone()) => { + () = check_cancel(cancel_handle.clone()) => { return Err(anyhow!("Request cancelled during bootstrap")); } result = tokio::time::timeout(bootstrap_timeout, tor_client.bootstrap()) => result, }; match bootstrap_result { - Ok(Ok(_)) => log::debug!("Successfully bootstrapped Tor client"), + Ok(Ok(())) => log::debug!("Successfully bootstrapped Tor client"), Ok(Err(e)) => return Err(anyhow!("Failed to bootstrap Tor client: {:?}", e)), Err(_) => { return Err(anyhow!( @@ -173,7 +173,7 @@ where // Use select! to handle cancellation during onion connection let stream_result = tokio::select! { biased; - _ = check_cancel(cancel_handle.clone()) => { + () = check_cancel(cancel_handle.clone()) => { return Err(anyhow!("Request cancelled during onion connection")); } result = tokio::time::timeout( @@ -199,7 +199,7 @@ where // Use select! to handle cancellation during regular connection let stream_result = tokio::select! { biased; - _ = check_cancel(cancel_handle.clone()) => { + () = check_cancel(cancel_handle.clone()) => { return Err(anyhow!("Request cancelled during connection")); } result = tokio::time::timeout(connect_timeout, tor_client.connect(tor_addr)) => result, @@ -239,7 +239,7 @@ where // Use select! to handle cancellation during TLS handshake let tls_result = tokio::select! { biased; - _ = check_cancel(cancel_handle.clone()) => { + () = check_cancel(cancel_handle.clone()) => { return Err(anyhow!("Request cancelled during TLS handshake")); } result = tokio::time::timeout(tls_timeout, connector.connect(server_name, stream)) => result, diff --git a/harbor-client/src/lib.rs b/harbor-client/src/lib.rs index e4b086dc..89351955 100644 --- a/harbor-client/src/lib.rs +++ b/harbor-client/src/lib.rs @@ -4,7 +4,6 @@ clippy::cast_sign_loss, clippy::default_trait_access, clippy::derive_partial_eq_without_eq, - clippy::ignored_unit_patterns, clippy::items_after_statements, clippy::large_futures, clippy::match_same_arms, diff --git a/harbor-client/src/lightning_address.rs b/harbor-client/src/lightning_address.rs index 91000abf..c209a617 100644 --- a/harbor-client/src/lightning_address.rs +++ b/harbor-client/src/lightning_address.rs @@ -128,7 +128,7 @@ mod tests { // Test with Tor, but don't fail the whole test if Tor fails log::debug!("Starting Tor test"); match try_with_tor_mode(&ln_address, true).await { - Ok(_) => { + Ok(()) => { log::debug!("Tor test completed successfully"); } Err(e) => { diff --git a/harbor-ui/src/bridge.rs b/harbor-ui/src/bridge.rs index d1f59f75..aeeaf30a 100644 --- a/harbor-ui/src/bridge.rs +++ b/harbor-ui/src/bridge.rs @@ -654,7 +654,7 @@ async fn process_core(core_handle: &mut CoreHandle, core: &HarborCore) { core.msg(msg.id, CoreUIMsg::AddMintFailed(e.to_string())) .await; } - Ok(_) => { + Ok(()) => { if let Ok(new_federation_list) = core.get_mint_items().await { core.msg( msg.id, @@ -679,7 +679,7 @@ async fn process_core(core_handle: &mut CoreHandle, core: &HarborCore) { core.msg(msg.id, CoreUIMsg::AddMintFailed(e.to_string())) .await; } - Ok(_) => { + Ok(()) => { if let Ok(new_federation_list) = core.get_mint_items().await { core.msg(msg.id, CoreUIMsg::MintListUpdated(new_federation_list)) .await; @@ -713,7 +713,7 @@ async fn process_core(core_handle: &mut CoreHandle, core: &HarborCore) { ) .await; } - Ok(_) => { + Ok(()) => { log::info!("Removed federation: {id}"); if let Ok(new_federation_list) = core.get_mint_items().await { @@ -737,7 +737,7 @@ async fn process_core(core_handle: &mut CoreHandle, core: &HarborCore) { ) .await; } - Ok(_) => { + Ok(()) => { log::info!("Removed cashu mint: {url}"); if let Ok(new_federation_list) = core.get_mint_items().await { @@ -764,7 +764,7 @@ async fn process_core(core_handle: &mut CoreHandle, core: &HarborCore) { core.msg(msg.id, CoreUIMsg::AddMintFailed(e.to_string())) .await; } - Ok(_) => { + Ok(()) => { if let Ok(new_federation_list) = core.get_mint_items().await { core.msg( @@ -786,7 +786,7 @@ async fn process_core(core_handle: &mut CoreHandle, core: &HarborCore) { core.msg(msg.id, CoreUIMsg::AddMintFailed(e.to_string())) .await; } - Ok(_) => { + Ok(()) => { if let Ok(new_list) = core.get_mint_items().await { core.msg(msg.id, CoreUIMsg::MintListUpdated(new_list)) .await; diff --git a/harbor-ui/src/keyring.rs b/harbor-ui/src/keyring.rs index 1a775f6f..568ac7e9 100644 --- a/harbor-ui/src/keyring.rs +++ b/harbor-ui/src/keyring.rs @@ -28,7 +28,7 @@ pub async fn save_to_keyring(password: &str) { set_global_service_name(KEYRING_SERVICE); match KeyringEntry::try_new(KEYRING_USERNAME) { Ok(entry) => match entry.set_secret(password).await { - Ok(_) => { + Ok(()) => { info!("Successfully saved password to keyring"); } Err(e) => { diff --git a/harbor-ui/src/main.rs b/harbor-ui/src/main.rs index 508bb831..672429eb 100644 --- a/harbor-ui/src/main.rs +++ b/harbor-ui/src/main.rs @@ -6,7 +6,6 @@ clippy::cast_sign_loss, clippy::cognitive_complexity, clippy::derive_partial_eq_without_eq, - clippy::ignored_unit_patterns, clippy::implicit_clone, clippy::large_futures, clippy::manual_let_else, @@ -409,7 +408,7 @@ impl HarborWallet { Self::with_ui_handle(self.ui_handle.clone(), move |h| async move { h.send_msg(id, msg).await }), - |_| Message::Noop, + |()| Message::Noop, ); (id, task) } From 5834451748717df58ea5dc482d3a3cde222781f7 Mon Sep 17 00:00:00 2001 From: Tommy Volk Date: Mon, 25 Aug 2025 22:12:31 -0500 Subject: [PATCH 08/24] chore: enforce clippy implicit_clone rule --- harbor-ui/src/bridge.rs | 12 +++--------- harbor-ui/src/main.rs | 1 - 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/harbor-ui/src/bridge.rs b/harbor-ui/src/bridge.rs index aeeaf30a..b24883cb 100644 --- a/harbor-ui/src/bridge.rs +++ b/harbor-ui/src/bridge.rs @@ -389,14 +389,8 @@ pub fn run_core() -> impl Stream { // Save password to keyring when successfully unlocked save_to_keyring(&password).await; - match setup_harbor_core( - path.to_path_buf(), - &db_path, - &password, - network, - &mut tx, - ) - .await + match setup_harbor_core(path.clone(), &db_path, &password, network, &mut tx) + .await { Some(core) => { tx.send(Message::core_msg(id, CoreUIMsg::UnlockSuccess)) @@ -469,7 +463,7 @@ pub fn run_core() -> impl Stream { let core = HarborCore::new( network, db.generate_mnemonic(seed).expect("should generate words"), - path.to_path_buf(), + path.clone(), core_tx, Arc::new(RwLock::new(HashMap::new())), Arc::new(RwLock::new(HashMap::new())), diff --git a/harbor-ui/src/main.rs b/harbor-ui/src/main.rs index 672429eb..63af4308 100644 --- a/harbor-ui/src/main.rs +++ b/harbor-ui/src/main.rs @@ -6,7 +6,6 @@ clippy::cast_sign_loss, clippy::cognitive_complexity, clippy::derive_partial_eq_without_eq, - clippy::implicit_clone, clippy::large_futures, clippy::manual_let_else, clippy::manual_string_new, From 278f9966f063c63153521c492d7ac1e16109ac5d Mon Sep 17 00:00:00 2001 From: Tommy Volk Date: Mon, 25 Aug 2025 22:15:36 -0500 Subject: [PATCH 09/24] chore: enforce clippy items_after_statements rule --- harbor-client/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/harbor-client/src/lib.rs b/harbor-client/src/lib.rs index 89351955..50fbd562 100644 --- a/harbor-client/src/lib.rs +++ b/harbor-client/src/lib.rs @@ -4,7 +4,6 @@ clippy::cast_sign_loss, clippy::default_trait_access, clippy::derive_partial_eq_without_eq, - clippy::items_after_statements, clippy::large_futures, clippy::match_same_arms, clippy::match_wildcard_for_single_variants, @@ -847,6 +846,8 @@ impl HarborCore { msg_id: Uuid, amount: Amount, ) -> anyhow::Result<(Bolt11Invoice, OperationId)> { + const DEFAULT_EXPIRY_TIME_SECS: u32 = 86400; + let enable_lnv2 = cfg!(feature = "lnv2"); if !enable_lnv2 { return Err(anyhow::anyhow!("LNv2 is not enabled")); @@ -855,7 +856,6 @@ impl HarborCore { log::info!("Trying to pay receive {amount} with LNv2..."); let lnv2_module = client.get_first_module::()?; - const DEFAULT_EXPIRY_TIME_SECS: u32 = 86400; self.status_update(msg_id, "Generating invoice").await; let receive = lnv2_module .receive( From a143a1b99ebb6b937dbd6a6dc286625c44d18bba Mon Sep 17 00:00:00 2001 From: Tommy Volk Date: Mon, 25 Aug 2025 22:23:02 -0500 Subject: [PATCH 10/24] chore: enforce clippy manual_string_new rule --- harbor-ui/src/components/input.rs | 2 +- harbor-ui/src/main.rs | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/harbor-ui/src/components/input.rs b/harbor-ui/src/components/input.rs index d0fb1407..5124d09c 100644 --- a/harbor-ui/src/components/input.rs +++ b/harbor-ui/src/components/input.rs @@ -114,7 +114,7 @@ pub fn h_input(args: InputArgs<'_>) -> Element { // If the value is already 0, typing 1 turns it into 10 // Which is annoying, so we'll just clear it if num == 0 { - "".to_string() + String::new() } else { num.to_string() } diff --git a/harbor-ui/src/main.rs b/harbor-ui/src/main.rs index 63af4308..c9b8a4de 100644 --- a/harbor-ui/src/main.rs +++ b/harbor-ui/src/main.rs @@ -8,7 +8,6 @@ clippy::derive_partial_eq_without_eq, clippy::large_futures, clippy::manual_let_else, - clippy::manual_string_new, clippy::map_unwrap_or, clippy::match_bool, clippy::match_same_arms, @@ -523,7 +522,7 @@ impl HarborWallet { if let Some(amt) = msats { self.send_amount_input_str = (amt / 1_000).to_string(); } else { - self.send_amount_input_str = String::from(""); + self.send_amount_input_str = String::new(); } self.send_dest_input_str = input; Task::none() From 2870090d17a5e8615bde3ee7bab0eac0384334b5 Mon Sep 17 00:00:00 2001 From: Tommy Volk Date: Mon, 25 Aug 2025 22:26:04 -0500 Subject: [PATCH 11/24] chore: enforce clippy map_unwrap_or rule --- harbor-ui/src/main.rs | 1 - harbor-ui/src/routes/history.rs | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/harbor-ui/src/main.rs b/harbor-ui/src/main.rs index c9b8a4de..3334da0a 100644 --- a/harbor-ui/src/main.rs +++ b/harbor-ui/src/main.rs @@ -8,7 +8,6 @@ clippy::derive_partial_eq_without_eq, clippy::large_futures, clippy::manual_let_else, - clippy::map_unwrap_or, clippy::match_bool, clippy::match_same_arms, clippy::match_wildcard_for_single_variants, diff --git a/harbor-ui/src/routes/history.rs b/harbor-ui/src/routes/history.rs index 06d5fd23..57344355 100644 --- a/harbor-ui/src/routes/history.rs +++ b/harbor-ui/src/routes/history.rs @@ -17,8 +17,7 @@ pub fn history(harbor: &HarborWallet) -> Element { let is_selected = harbor .selected_transaction .as_ref() - .map(|selected| selected == item) - .unwrap_or(false); + .is_some_and(|selected| selected == item); column .push(h_transaction_item(item, is_selected)) .push(hr()) From 6cce7ca93c339fd77c0bdac1998bff223ebeb65b Mon Sep 17 00:00:00 2001 From: Tommy Volk Date: Mon, 25 Aug 2025 22:32:46 -0500 Subject: [PATCH 12/24] chore: enforce clippy match_bool rule --- harbor-ui/src/components/util.rs | 29 ++++++++++------------------- harbor-ui/src/main.rs | 1 - 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/harbor-ui/src/components/util.rs b/harbor-ui/src/components/util.rs index 35732cfb..60e10f6f 100644 --- a/harbor-ui/src/components/util.rs +++ b/harbor-ui/src/components/util.rs @@ -61,25 +61,16 @@ pub fn format_amount(amount: u64) -> String { } pub fn truncate_text(input: &str, max_len: usize, center: bool) -> String { - match center { + if input.len() <= max_len { + input.to_string() + } else if center { // center the elllipses around middle of the string - true => { - if input.len() > max_len { - format!( - "{}...{}", - &input[..(max_len / 2)], - &input[(input.len() - max_len / 2)..] - ) - } else { - input.to_string() - } - } - false => { - if input.len() > max_len { - format!("{}...", &input[input.len() - max_len..]) - } else { - input.to_string() - } - } + format!( + "{}...{}", + &input[..(max_len / 2)], + &input[(input.len() - max_len / 2)..] + ) + } else { + format!("{}...", &input[input.len() - max_len..]) } } diff --git a/harbor-ui/src/main.rs b/harbor-ui/src/main.rs index 3334da0a..6220ba23 100644 --- a/harbor-ui/src/main.rs +++ b/harbor-ui/src/main.rs @@ -8,7 +8,6 @@ clippy::derive_partial_eq_without_eq, clippy::large_futures, clippy::manual_let_else, - clippy::match_bool, clippy::match_same_arms, clippy::match_wildcard_for_single_variants, clippy::missing_const_for_fn, From 7ad0bc9c621a02d5b33071fef79a88cbc1690338 Mon Sep 17 00:00:00 2001 From: Tommy Volk Date: Mon, 25 Aug 2025 22:41:04 -0500 Subject: [PATCH 13/24] chore: enforce clippy match_wildcard_for_single_variants rule --- harbor-client/src/lib.rs | 5 ++--- harbor-ui/src/components/styles.rs | 2 +- harbor-ui/src/main.rs | 3 +-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/harbor-client/src/lib.rs b/harbor-client/src/lib.rs index 50fbd562..8153573c 100644 --- a/harbor-client/src/lib.rs +++ b/harbor-client/src/lib.rs @@ -6,7 +6,6 @@ clippy::derive_partial_eq_without_eq, clippy::large_futures, clippy::match_same_arms, - clippy::match_wildcard_for_single_variants, clippy::missing_const_for_fn, clippy::missing_errors_doc, clippy::missing_panics_doc, @@ -123,14 +122,14 @@ impl MintIdentifier { pub fn federation_id(&self) -> Option { match self { MintIdentifier::Fedimint(id) => Some(*id), - _ => None, + MintIdentifier::Cashu(_) => None, } } pub fn mint_url(&self) -> Option { match self { MintIdentifier::Cashu(url) => Some(url.clone()), - _ => None, + MintIdentifier::Fedimint(_) => None, } } } diff --git a/harbor-ui/src/components/styles.rs b/harbor-ui/src/components/styles.rs index 2181d779..f2457929 100644 --- a/harbor-ui/src/components/styles.rs +++ b/harbor-ui/src/components/styles.rs @@ -89,7 +89,7 @@ pub fn pick_list_style(theme: &Theme, status: pick_list::Status) -> pick_list::S let background = match status { pick_list::Status::Hovered => lighten(theme.palette().background, 0.05), pick_list::Status::Opened { .. } => darken(Color::BLACK, 0.1), - _ => theme.palette().background, + pick_list::Status::Active => theme.palette().background, }; pick_list::Style { diff --git a/harbor-ui/src/main.rs b/harbor-ui/src/main.rs index 6220ba23..1ff2d4d6 100644 --- a/harbor-ui/src/main.rs +++ b/harbor-ui/src/main.rs @@ -9,7 +9,6 @@ clippy::large_futures, clippy::manual_let_else, clippy::match_same_arms, - clippy::match_wildcard_for_single_variants, clippy::missing_const_for_fn, clippy::missing_errors_doc, clippy::missing_panics_doc, @@ -625,7 +624,7 @@ impl HarborWallet { Message::Noop => Task::none(), Message::Send(invoice_str) => match self.send_status { SendStatus::Sending => Task::none(), - _ => { + SendStatus::Idle => { self.send_failure_reason = None; let mint = match self.active_mint.clone() { Some(f) => f, From b3543fb54a3aedcd8cb728d50cc7cd6a5fd5f79c Mon Sep 17 00:00:00 2001 From: Tommy Volk Date: Mon, 25 Aug 2025 22:44:46 -0500 Subject: [PATCH 14/24] chore: enforce clippy needless_collect rule --- harbor-ui/src/main.rs | 1 - harbor-ui/src/routes/settings.rs | 6 ++---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/harbor-ui/src/main.rs b/harbor-ui/src/main.rs index 1ff2d4d6..3957f892 100644 --- a/harbor-ui/src/main.rs +++ b/harbor-ui/src/main.rs @@ -13,7 +13,6 @@ clippy::missing_errors_doc, clippy::missing_panics_doc, clippy::must_use_candidate, - clippy::needless_collect, clippy::needless_pass_by_ref_mut, clippy::needless_pass_by_value, clippy::option_if_let_else, diff --git a/harbor-ui/src/routes/settings.rs b/harbor-ui/src/routes/settings.rs index fea38ef9..e9f30eb0 100644 --- a/harbor-ui/src/routes/settings.rs +++ b/harbor-ui/src/routes/settings.rs @@ -121,8 +121,7 @@ pub fn render_seed_words(seed_words: &str) -> Element<'static, Message> { .iter() .take(6) .enumerate() - .map(|(i, word)| text(format!("{}. {}", i + 1, word)).into()) - .collect::>>(), + .map(|(i, word)| text(format!("{}. {}", i + 1, word)).into()), ) .spacing(10); @@ -133,8 +132,7 @@ pub fn render_seed_words(seed_words: &str) -> Element<'static, Message> { .skip(6) .take(6) .enumerate() - .map(|(i, word)| text(format!("{}. {}", i + 7, word)).into()) - .collect::>>(), + .map(|(i, word)| text(format!("{}. {}", i + 7, word)).into()), ) .spacing(10); From 94abcb2689bbfb4d83895c33f9050d6e0dac8ece Mon Sep 17 00:00:00 2001 From: Tommy Volk Date: Mon, 25 Aug 2025 22:50:27 -0500 Subject: [PATCH 15/24] chore: enforce clippy needless_pass_by_ref_mut rule --- harbor-ui/src/bridge.rs | 6 ++---- harbor-ui/src/main.rs | 1 - 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/harbor-ui/src/bridge.rs b/harbor-ui/src/bridge.rs index b24883cb..91d6354c 100644 --- a/harbor-ui/src/bridge.rs +++ b/harbor-ui/src/bridge.rs @@ -80,7 +80,7 @@ async fn setup_harbor_core( db_path: &str, password: &str, network: Network, - tx: &mut Sender, + tx: &Sender, ) -> Option { // Setup core message channel let (core_tx, mut core_rx) = iced::futures::channel::mpsc::channel::(128); @@ -389,9 +389,7 @@ pub fn run_core() -> impl Stream { // Save password to keyring when successfully unlocked save_to_keyring(&password).await; - match setup_harbor_core(path.clone(), &db_path, &password, network, &mut tx) - .await - { + match setup_harbor_core(path.clone(), &db_path, &password, network, &tx).await { Some(core) => { tx.send(Message::core_msg(id, CoreUIMsg::UnlockSuccess)) .await diff --git a/harbor-ui/src/main.rs b/harbor-ui/src/main.rs index 3957f892..cc2282dc 100644 --- a/harbor-ui/src/main.rs +++ b/harbor-ui/src/main.rs @@ -13,7 +13,6 @@ clippy::missing_errors_doc, clippy::missing_panics_doc, clippy::must_use_candidate, - clippy::needless_pass_by_ref_mut, clippy::needless_pass_by_value, clippy::option_if_let_else, clippy::or_fun_call, From 8608e36cbefed96c918cce912492d1040f877150 Mon Sep 17 00:00:00 2001 From: Tommy Volk Date: Mon, 25 Aug 2025 22:59:25 -0500 Subject: [PATCH 16/24] chore: simplify SQLConnection::get_profile --- harbor-client/src/db.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/harbor-client/src/db.rs b/harbor-client/src/db.rs index 62314809..b459b1a1 100644 --- a/harbor-client/src/db.rs +++ b/harbor-client/src/db.rs @@ -236,10 +236,7 @@ impl DBConnection for SQLConnection { fn get_profile(&self) -> anyhow::Result> { let conn = &mut self.db.get()?; - match Profile::get_first(conn)? { - Some(p) => Ok(Some(p)), - None => Ok(None), - } + Profile::get_first(conn) } fn insert_new_profile(&self, new_profile: NewProfile) -> anyhow::Result { From 20a9f4d07c922cb64bf3d0acfcef7c913d6e60e9 Mon Sep 17 00:00:00 2001 From: Tommy Volk Date: Mon, 25 Aug 2025 23:22:06 -0500 Subject: [PATCH 17/24] chore: enforce clippy redundant_clone rule --- harbor-client/src/lib.rs | 1 - harbor-client/src/metadata.rs | 5 ++-- harbor-ui/src/components/button.rs | 2 +- harbor-ui/src/components/mini_copy.rs | 2 +- .../src/components/transaction_details.rs | 2 +- harbor-ui/src/main.rs | 25 +++++++------------ harbor-ui/src/routes/restore.rs | 2 +- harbor-ui/src/routes/welcome.rs | 2 +- 8 files changed, 16 insertions(+), 25 deletions(-) diff --git a/harbor-client/src/lib.rs b/harbor-client/src/lib.rs index 8153573c..be07e90d 100644 --- a/harbor-client/src/lib.rs +++ b/harbor-client/src/lib.rs @@ -13,7 +13,6 @@ clippy::needless_pass_by_value, clippy::option_if_let_else, clippy::or_fun_call, - clippy::redundant_clone, clippy::redundant_closure_for_method_calls, clippy::redundant_pub_crate, clippy::semicolon_if_nothing_returned, diff --git a/harbor-client/src/metadata.rs b/harbor-client/src/metadata.rs index 3789b131..e993bc5c 100644 --- a/harbor-client/src/metadata.rs +++ b/harbor-client/src/metadata.rs @@ -148,7 +148,7 @@ pub(crate) async fn get_federation_metadata( FederationMeta { meta_external_url, // Already set... federation_name: merge_values( - data.get_meta("federation_name").clone(), + data.get_meta("federation_name"), config.as_ref().and_then(|c| c.federation_name.clone()), ), federation_expiry_timestamp: merge_values( @@ -175,8 +175,7 @@ pub(crate) async fn get_federation_metadata( config.as_ref().and_then(|c| c.popup_end_timestamp.clone()), ), popup_countdown_message: merge_values( - data.get_meta("popup_countdown_message") - .map(|v| v.to_string()), + data.get_meta("popup_countdown_message"), config .as_ref() .and_then(|c| c.popup_countdown_message.clone()), diff --git a/harbor-ui/src/components/button.rs b/harbor-ui/src/components/button.rs index 997d0305..117b6aac 100644 --- a/harbor-ui/src/components/button.rs +++ b/harbor-ui/src/components/button.rs @@ -175,7 +175,7 @@ pub fn sidebar_button( pub fn text_link(text_str: String, url: String) -> Element<'static, Message> { let svg = map_icon(SvgIcon::ExternalLink, 16., 16.); let text = rich_text([span(text_str).link(url).underline(true).color(link())]) - .on_link_click(|url: String| Message::UrlClicked(url.to_string())); + .on_link_click(|url: String| Message::UrlClicked(url)); row![svg, text] .align_y(iced::Alignment::Center) diff --git a/harbor-ui/src/components/mini_copy.rs b/harbor-ui/src/components/mini_copy.rs index 6a7719bd..48984803 100644 --- a/harbor-ui/src/components/mini_copy.rs +++ b/harbor-ui/src/components/mini_copy.rs @@ -14,7 +14,7 @@ pub fn mini_copy(text: String) -> Button<'static, Message, Theme> { let icon = map_icon(SvgIcon::Copy, 24., 24.); Button::new(icon) - .on_press(Message::CopyToClipboard(text.to_string())) + .on_press(Message::CopyToClipboard(text)) .style(|theme: &Theme, status| { let border = Border { color: Color::WHITE, diff --git a/harbor-ui/src/components/transaction_details.rs b/harbor-ui/src/components/transaction_details.rs index 82f9e6ef..0cba3122 100644 --- a/harbor-ui/src/components/transaction_details.rs +++ b/harbor-ui/src/components/transaction_details.rs @@ -64,7 +64,7 @@ pub fn h_transaction_details<'a>( let mint_section = column![ text(mint_label).size(16).style(subtitle), - row![mint_icon, text(mint.name.clone()).size(16)] + row![mint_icon, text(mint.name).size(16)] .align_y(Alignment::Center) .spacing(8) ] diff --git a/harbor-ui/src/main.rs b/harbor-ui/src/main.rs index cc2282dc..5264e468 100644 --- a/harbor-ui/src/main.rs +++ b/harbor-ui/src/main.rs @@ -16,7 +16,6 @@ clippy::needless_pass_by_value, clippy::option_if_let_else, clippy::or_fun_call, - clippy::redundant_clone, clippy::redundant_closure_for_method_calls, clippy::redundant_else, clippy::ref_option, @@ -590,7 +589,7 @@ impl HarborWallet { if self.transfer_to_federation_selection == self.transfer_from_federation_selection { let fed = self.next_federation(&s); - self.transfer_to_federation_selection = Some(fed.name.clone()); + self.transfer_to_federation_selection = Some(fed.name); } Task::none() } @@ -600,7 +599,7 @@ impl HarborWallet { if self.transfer_from_federation_selection == self.transfer_to_federation_selection { let fed = self.next_federation(&s); - self.transfer_from_federation_selection = Some(fed.name.clone()); + self.transfer_from_federation_selection = Some(fed.name); } Task::none() } @@ -1067,7 +1066,7 @@ impl HarborWallet { } Task::done(Message::AddToast(Toast { title: "Failed to send".to_string(), - body: Some(reason.clone()), + body: Some(reason), status: ToastStatus::Bad, })) } @@ -1110,7 +1109,7 @@ impl HarborWallet { } Task::done(Message::AddToast(Toast { title: "Failed to receive".to_string(), - body: Some(reason.clone()), + body: Some(reason), status: ToastStatus::Bad, })) } @@ -1121,7 +1120,7 @@ impl HarborWallet { error!("Transfer failed: {reason}"); Task::done(Message::AddToast(Toast { title: "Failed to transfer".to_string(), - body: Some(reason.clone()), + body: Some(reason), status: ToastStatus::Bad, })) } @@ -1160,20 +1159,18 @@ impl HarborWallet { Task::none() } CoreUIMsg::AddMintFailed(reason) => { - let reason = reason.clone(); self.clear_add_federation_state(); Task::done(Message::AddToast(Toast { title: "Failed to join mint".to_string(), - body: Some(reason.clone()), + body: Some(reason), status: ToastStatus::Bad, })) } CoreUIMsg::RemoveFederationFailed(reason) => { - let reason = reason.clone(); self.clear_add_federation_state(); Task::done(Message::AddToast(Toast { title: "Failed to remove mint".to_string(), - body: Some(reason.clone()), + body: Some(reason), status: ToastStatus::Bad, })) } @@ -1362,12 +1359,8 @@ impl HarborWallet { operation_id, } => { if let Some(id) = operation_id { - self.operation_status.insert( - id, - OperationStatus { - message: message.clone(), - }, - ); + self.operation_status + .insert(id, OperationStatus { message }); } Task::none() } diff --git a/harbor-ui/src/routes/restore.rs b/harbor-ui/src/routes/restore.rs index b506975d..45536b54 100644 --- a/harbor-ui/src/routes/restore.rs +++ b/harbor-ui/src/routes/restore.rs @@ -76,7 +76,7 @@ pub fn restore(harbor: &HarborWallet) -> Element { SvgIcon::Restart, harbor.unlock_status == UnlockStatus::Unlocking, ) - .on_press_maybe(action.clone()) + .on_press_maybe(action) .width(Length::Fill); column![ diff --git a/harbor-ui/src/routes/welcome.rs b/harbor-ui/src/routes/welcome.rs index 77374bce..d4a9b668 100644 --- a/harbor-ui/src/routes/welcome.rs +++ b/harbor-ui/src/routes/welcome.rs @@ -69,7 +69,7 @@ pub fn welcome(harbor: &HarborWallet) -> Element { label: "Password", value: &harbor.password_input_str, on_input: Message::PasswordInputChanged, - on_submit: action.clone(), + on_submit: action, disabled: harbor.unlock_status == UnlockStatus::Unlocking, secure: true, id: Some("password_init_input"), From a746990188cf487192f30686b2d865eb6d5a0e6d Mon Sep 17 00:00:00 2001 From: Tommy Volk Date: Mon, 25 Aug 2025 23:39:12 -0500 Subject: [PATCH 18/24] chore: enforce clippy redundant_pub_crate rule --- harbor-client/src/http.rs | 4 ++-- harbor-client/src/lib.rs | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/harbor-client/src/http.rs b/harbor-client/src/http.rs index 740e9254..251a9f38 100644 --- a/harbor-client/src/http.rs +++ b/harbor-client/src/http.rs @@ -53,7 +53,7 @@ const MAX_RESPONSE_SIZE: usize = 10 * 1024 * 1024; // 10MB limit /// - Handles redirects automatically (up to `MAX_REDIRECTS`) /// - Enforces a response size limit /// - Returns deserialized JSON -pub(crate) async fn make_get_request_direct(url: &str) -> anyhow::Result +pub async fn make_get_request_direct(url: &str) -> anyhow::Result where T: DeserializeOwned + Send + 'static, { @@ -96,7 +96,7 @@ where /// The request can be cancelled at any time using the `cancel_handle`. /// /// Note: This is slower than direct requests due to Tor routing. -pub(crate) async fn make_tor_request( +pub async fn make_tor_request( url: &str, payload: Option

, cancel_handle: Arc, diff --git a/harbor-client/src/lib.rs b/harbor-client/src/lib.rs index be07e90d..8a983333 100644 --- a/harbor-client/src/lib.rs +++ b/harbor-client/src/lib.rs @@ -14,7 +14,6 @@ clippy::option_if_let_else, clippy::or_fun_call, clippy::redundant_closure_for_method_calls, - clippy::redundant_pub_crate, clippy::semicolon_if_nothing_returned, clippy::significant_drop_in_scrutinee, clippy::significant_drop_tightening, From 46aa0d0f44e7f7a41727ee1d625a43e1a68f792c Mon Sep 17 00:00:00 2001 From: Tommy Volk Date: Mon, 25 Aug 2025 23:46:28 -0500 Subject: [PATCH 19/24] chore: enforce clippy semicolon_if_nothing_returned rule --- harbor-client/src/lib.rs | 21 ++++++++++----------- harbor-ui/src/bridge.rs | 2 +- harbor-ui/src/main.rs | 3 +-- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/harbor-client/src/lib.rs b/harbor-client/src/lib.rs index 8a983333..3e1312b9 100644 --- a/harbor-client/src/lib.rs +++ b/harbor-client/src/lib.rs @@ -14,7 +14,6 @@ clippy::option_if_let_else, clippy::or_fun_call, clippy::redundant_closure_for_method_calls, - clippy::semicolon_if_nothing_returned, clippy::significant_drop_in_scrutinee, clippy::significant_drop_tightening, clippy::similar_names, @@ -366,10 +365,10 @@ impl HarborCore { ) .await; } else { - storage.mark_ln_receive_as_failed(item.operation_id)? + storage.mark_ln_receive_as_failed(item.operation_id)?; } } else { - storage.mark_ln_receive_as_failed(item.operation_id)? + storage.mark_ln_receive_as_failed(item.operation_id)?; } } MintIdentifier::Cashu(mint_url) => { @@ -386,10 +385,10 @@ impl HarborCore { false, ); } else { - storage.mark_ln_receive_as_failed(item.operation_id)? + storage.mark_ln_receive_as_failed(item.operation_id)?; } } else { - storage.mark_ln_receive_as_failed(item.operation_id)? + storage.mark_ln_receive_as_failed(item.operation_id)?; } } } @@ -430,10 +429,10 @@ impl HarborCore { ) .await; } else { - storage.mark_lightning_payment_as_failed(item.operation_id)? + storage.mark_lightning_payment_as_failed(item.operation_id)?; } } else { - storage.mark_lightning_payment_as_failed(item.operation_id)? + storage.mark_lightning_payment_as_failed(item.operation_id)?; } } MintIdentifier::Cashu(mint_url) => { @@ -450,10 +449,10 @@ impl HarborCore { false, ); } else { - storage.mark_lightning_payment_as_failed(item.operation_id)? + storage.mark_lightning_payment_as_failed(item.operation_id)?; } } else { - storage.mark_lightning_payment_as_failed(item.operation_id)? + storage.mark_lightning_payment_as_failed(item.operation_id)?; } } } @@ -477,13 +476,13 @@ impl HarborCore { // Initial setup messages that don't have an id // Panics if fails to send async fn send_system_msg(&self, msg: CoreUIMsg) { - Self::send_msg(&mut self.tx.clone(), None, msg).await + Self::send_msg(&mut self.tx.clone(), None, msg).await; } // Standard core->ui communication with an id // Panics if fails to send pub async fn msg(&self, id: Uuid, msg: CoreUIMsg) { - Self::send_msg(&mut self.tx.clone(), Some(id), msg).await + Self::send_msg(&mut self.tx.clone(), Some(id), msg).await; } pub async fn send_msg(sender: &mut Sender, id: Option, msg: CoreUIMsg) { diff --git a/harbor-ui/src/bridge.rs b/harbor-ui/src/bridge.rs index 91d6354c..532e0336 100644 --- a/harbor-ui/src/bridge.rs +++ b/harbor-ui/src/bridge.rs @@ -481,7 +481,7 @@ pub fn run_core() -> impl Stream { } _ => { - warn!("Ignoring unrelated message to locked core") + warn!("Ignoring unrelated message to locked core"); } } } diff --git a/harbor-ui/src/main.rs b/harbor-ui/src/main.rs index 5264e468..52198d40 100644 --- a/harbor-ui/src/main.rs +++ b/harbor-ui/src/main.rs @@ -20,7 +20,6 @@ clippy::redundant_else, clippy::ref_option, clippy::return_self_not_must_use, - clippy::semicolon_if_nothing_returned, clippy::single_match_else, clippy::struct_excessive_bools, clippy::suboptimal_flops, @@ -398,7 +397,7 @@ impl HarborWallet { let id = Uuid::new_v4(); let task = Task::perform( Self::with_ui_handle(self.ui_handle.clone(), move |h| async move { - h.send_msg(id, msg).await + h.send_msg(id, msg).await; }), |()| Message::Noop, ); From 8f9e738159ad0690aa2310c34449167f22941cb0 Mon Sep 17 00:00:00 2001 From: Tommy Volk Date: Tue, 26 Aug 2025 10:07:56 -0500 Subject: [PATCH 20/24] chore: enforce clippy uninlined_format_args rule --- harbor-client/src/http.rs | 12 ++++++------ harbor-client/src/lib.rs | 1 - harbor-ui/src/components/transaction_details.rs | 2 +- harbor-ui/src/config.rs | 4 ++-- harbor-ui/src/lock.rs | 6 +++--- harbor-ui/src/main.rs | 5 ++--- harbor-ui/src/routes/restore.rs | 3 +-- harbor-ui/src/routes/unlock.rs | 4 ++-- harbor-ui/src/routes/welcome.rs | 3 +-- 9 files changed, 18 insertions(+), 22 deletions(-) diff --git a/harbor-client/src/http.rs b/harbor-client/src/http.rs index 251a9f38..ebff5ada 100644 --- a/harbor-client/src/http.rs +++ b/harbor-client/src/http.rs @@ -565,8 +565,8 @@ mod tests { assert!(!res.federations.is_empty()); } Err(e) => { - log::error!("Failed to fetch metadata: {:?}", e); - panic!("Failed to fetch metadata: {:?}", e); + log::error!("Failed to fetch metadata: {e:?}"); + panic!("Failed to fetch metadata: {e:?}"); } } } @@ -586,8 +586,8 @@ mod tests { assert!(!res.federations.is_empty()); } Err(e) => { - log::error!("Failed to fetch metadata: {:?}", e); - panic!("Failed to fetch metadata: {:?}", e); + log::error!("Failed to fetch metadata: {e:?}"); + panic!("Failed to fetch metadata: {e:?}"); } } } @@ -631,8 +631,8 @@ mod tests { assert!(res.get("url").is_some(), "Expected 'url' field in response"); } Err(e) => { - log::error!("Failed to follow redirect: {:?}", e); - panic!("Failed to follow redirect: {:?}", e); + log::error!("Failed to follow redirect: {e:?}"); + panic!("Failed to follow redirect: {e:?}"); } } } diff --git a/harbor-client/src/lib.rs b/harbor-client/src/lib.rs index 3e1312b9..45efe7e2 100644 --- a/harbor-client/src/lib.rs +++ b/harbor-client/src/lib.rs @@ -20,7 +20,6 @@ clippy::single_char_pattern, clippy::single_match_else, clippy::too_many_lines, - clippy::uninlined_format_args, clippy::unnecessary_wraps, clippy::unused_async, clippy::use_self diff --git a/harbor-ui/src/components/transaction_details.rs b/harbor-ui/src/components/transaction_details.rs index 0cba3122..2dbf3390 100644 --- a/harbor-ui/src/components/transaction_details.rs +++ b/harbor-ui/src/components/transaction_details.rs @@ -109,7 +109,7 @@ pub fn h_transaction_details<'a>( Network::Signet => "https://mutinynet.com/tx/", _ => panic!("Unsupported network"), }; - let url = format!("{}{}", base_url, txid); + let url = format!("{base_url}{txid}"); details = details.push( column![ text("TXID").size(16).style(subtitle), diff --git a/harbor-ui/src/config.rs b/harbor-ui/src/config.rs index d341ea37..f335011b 100644 --- a/harbor-ui/src/config.rs +++ b/harbor-ui/src/config.rs @@ -17,8 +17,8 @@ impl fmt::Display for ConfigError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { ConfigError::InvalidConfig => write!(f, "Config file is invalid"), - ConfigError::IoError(e) => write!(f, "IO error: {}", e), - ConfigError::SerdeError(e) => write!(f, "JSON error: {}", e), + ConfigError::IoError(e) => write!(f, "IO error: {e}"), + ConfigError::SerdeError(e) => write!(f, "JSON error: {e}"), } } } diff --git a/harbor-ui/src/lock.rs b/harbor-ui/src/lock.rs index 0dee18eb..fd0958fd 100644 --- a/harbor-ui/src/lock.rs +++ b/harbor-ui/src/lock.rs @@ -13,7 +13,7 @@ impl AppLock { let data_dir = data_dir(None); if !data_dir.exists() { std::fs::create_dir_all(&data_dir) - .map_err(|e| format!("Failed to create data directory: {}", e))?; + .map_err(|e| format!("Failed to create data directory: {e}"))?; } let lock_file_path = data_dir.join("harbor.lock"); @@ -24,7 +24,7 @@ impl AppLock { .create(true) .truncate(true) .open(&lock_file_path) - .map_err(|e| format!("Failed to create/open lock file: {}", e))?; + .map_err(|e| format!("Failed to create/open lock file: {e}"))?; let mut lock = RwLock::new(file); @@ -52,7 +52,7 @@ pub fn restart_app() { let executable = &args[0]; if let Err(e) = Command::new(executable).args(&args[1..]).spawn() { - eprintln!("Failed to relaunch: {}", e); + eprintln!("Failed to relaunch: {e}"); std::process::exit(1); } diff --git a/harbor-ui/src/main.rs b/harbor-ui/src/main.rs index 52198d40..d4c76086 100644 --- a/harbor-ui/src/main.rs +++ b/harbor-ui/src/main.rs @@ -24,7 +24,6 @@ clippy::struct_excessive_bools, clippy::suboptimal_flops, clippy::too_many_lines, - clippy::uninlined_format_args, clippy::unreadable_literal, clippy::unused_self, clippy::use_self @@ -78,7 +77,7 @@ pub mod routes; pub fn main() -> iced::Result { // Acquire the app lock - this prevents multiple instances from running if let Err(e) = lock::AppLock::acquire() { - eprintln!("{}", e); + eprintln!("{e}"); std::process::exit(1); } @@ -985,7 +984,7 @@ impl HarborWallet { log::info!("Url clicked: {}", url); self.confirm_modal = Some(ConfirmModalState { title: "Open External Link?".to_string(), - description: format!("This will open {} in your default browser.", url), + description: format!("This will open {url} in your default browser."), confirm_action: Box::new(Message::OpenUrl(url)), cancel_action: Box::new(Message::SetConfirmModal(None)), confirm_button_text: "Open Link".to_string(), diff --git a/harbor-ui/src/routes/restore.rs b/harbor-ui/src/routes/restore.rs index 45536b54..98ec399e 100644 --- a/harbor-ui/src/routes/restore.rs +++ b/harbor-ui/src/routes/restore.rs @@ -30,8 +30,7 @@ pub fn restore(harbor: &HarborWallet) -> Element { harbor_logo(), welcome_message, text(format!( - "Failed to initialize wallet. Config error: {}", - error + "Failed to initialize wallet. Config error: {error}" )) .size(24) .color(iced::Color::from_rgb8(250, 0, 80)) diff --git a/harbor-ui/src/routes/unlock.rs b/harbor-ui/src/routes/unlock.rs index 0b9a7441..0a4ffcb2 100644 --- a/harbor-ui/src/routes/unlock.rs +++ b/harbor-ui/src/routes/unlock.rs @@ -42,13 +42,13 @@ pub fn unlock(harbor: &HarborWallet) -> Element { .width(Length::Fixed(256.)); let page_column = page_column.push_maybe(harbor.unlock_failure_reason.as_ref().map(|r| { - text(format!("Error: {:?}", r)) + text(format!("Error: {r:?}")) .size(24) .color(Color::from_rgb8(250, 0, 80)) })); let page_column = page_column.push_maybe(harbor.init_failure_reason.as_ref().map(|r| { - text(format!("Init Error: {:?}", r)) + text(format!("Init Error: {r:?}")) .size(24) .color(Color::from_rgb8(250, 0, 80)) })); diff --git a/harbor-ui/src/routes/welcome.rs b/harbor-ui/src/routes/welcome.rs index d4a9b668..35eb808b 100644 --- a/harbor-ui/src/routes/welcome.rs +++ b/harbor-ui/src/routes/welcome.rs @@ -30,8 +30,7 @@ pub fn welcome(harbor: &HarborWallet) -> Element { harbor_logo(), welcome_message, text(format!( - "Failed to initialize wallet. Config error: {}", - error + "Failed to initialize wallet. Config error: {error}" )) .size(24) .color(iced::Color::from_rgb8(250, 0, 80)) From eba55fa53c1fdaae0a4768beb6bd868884e96755 Mon Sep 17 00:00:00 2001 From: Tommy Volk Date: Tue, 26 Aug 2025 10:10:36 -0500 Subject: [PATCH 21/24] chore: enforce clippy unnecessary_wraps rule --- harbor-client/src/http.rs | 16 ++++++---------- harbor-client/src/lib.rs | 1 - 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/harbor-client/src/http.rs b/harbor-client/src/http.rs index ebff5ada..866e3c98 100644 --- a/harbor-client/src/http.rs +++ b/harbor-client/src/http.rs @@ -336,11 +336,9 @@ where } // Create a new Hyper client with TLS support and reasonable defaults -fn create_https_client() -> anyhow::Result< - Client< - hyper_rustls::HttpsConnector, - Empty, - >, +fn create_https_client() -> Client< + hyper_rustls::HttpsConnector, + Empty, > { let https = HttpsConnectorBuilder::new() .with_webpki_roots() @@ -348,12 +346,10 @@ fn create_https_client() -> anyhow::Result< .enable_http1() .build(); - let client = Client::builder(TokioExecutor::new()) + Client::builder(TokioExecutor::new()) .pool_idle_timeout(Duration::from_secs(30)) .pool_max_idle_per_host(1) - .build(https); - - Ok(client) + .build(https) } /// Common response handling logic @@ -521,7 +517,7 @@ where log::debug!("Making direct get request to: {}", url); - let client = create_https_client()?; + let client = create_https_client(); let uri: Uri = url .parse() .map_err(|e| anyhow!("Invalid URL '{}': {}", url, e))?; diff --git a/harbor-client/src/lib.rs b/harbor-client/src/lib.rs index 45efe7e2..a7f4d5cd 100644 --- a/harbor-client/src/lib.rs +++ b/harbor-client/src/lib.rs @@ -20,7 +20,6 @@ clippy::single_char_pattern, clippy::single_match_else, clippy::too_many_lines, - clippy::unnecessary_wraps, clippy::unused_async, clippy::use_self )] From 2640b6c29f5019d40c4b6db9b15be641d3fd7d10 Mon Sep 17 00:00:00 2001 From: Tommy Volk Date: Tue, 26 Aug 2025 10:12:49 -0500 Subject: [PATCH 22/24] chore: enforce clippy unreadable_literal rule --- harbor-ui/src/components/easing.rs | 4 ++-- harbor-ui/src/main.rs | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/harbor-ui/src/components/easing.rs b/harbor-ui/src/components/easing.rs index 6e657c6f..291d7164 100644 --- a/harbor-ui/src/components/easing.rs +++ b/harbor-ui/src/components/easing.rs @@ -8,8 +8,8 @@ use std::sync::LazyLock; pub static EMPHASIZED: LazyLock = LazyLock::new(|| { Easing::builder() - .cubic_bezier_to([0.05, 0.0], [0.133333, 0.06], [0.166666, 0.4]) - .cubic_bezier_to([0.208333, 0.82], [0.25, 1.0], [1.0, 1.0]) + .cubic_bezier_to([0.05, 0.0], [0.133_333, 0.06], [0.166_666, 0.4]) + .cubic_bezier_to([0.208_333, 0.82], [0.25, 1.0], [1.0, 1.0]) .build() }); diff --git a/harbor-ui/src/main.rs b/harbor-ui/src/main.rs index d4c76086..806184e6 100644 --- a/harbor-ui/src/main.rs +++ b/harbor-ui/src/main.rs @@ -24,7 +24,6 @@ clippy::struct_excessive_bools, clippy::suboptimal_flops, clippy::too_many_lines, - clippy::unreadable_literal, clippy::unused_self, clippy::use_self )] From 4cfa1e12110555780077d3da9efee6337441eef3 Mon Sep 17 00:00:00 2001 From: Tommy Volk Date: Tue, 26 Aug 2025 10:20:33 -0500 Subject: [PATCH 23/24] chore: enforce clippy unused_async rule --- harbor-client/src/http.rs | 8 ++++---- harbor-client/src/lib.rs | 7 +++---- harbor-ui/src/bridge.rs | 20 +++++++++----------- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/harbor-client/src/http.rs b/harbor-client/src/http.rs index 866e3c98..0ed713b9 100644 --- a/harbor-client/src/http.rs +++ b/harbor-client/src/http.rs @@ -23,7 +23,7 @@ use url::Url; static TOR_CLIENT: OnceCell>> = OnceCell::new(); /// Initialize the Tor client if not already initialized -async fn initialize_tor_client() -> anyhow::Result>> { +fn initialize_tor_client() -> anyhow::Result>> { let client = TorClient::builder() .bootstrap_behavior(arti_client::BootstrapBehavior::OnDemand) .create_unbootstrapped()?; @@ -31,11 +31,11 @@ async fn initialize_tor_client() -> anyhow::Result anyhow::Result>> { +fn get_tor_client() -> anyhow::Result>> { match TOR_CLIENT.get() { Some(client) => Ok(client.clone()), _ => { - let client = initialize_tor_client().await?; + let client = initialize_tor_client()?; // It's okay if another thread beat us to initialization let _ = TOR_CLIENT.set(client.clone()); Ok(client) @@ -113,7 +113,7 @@ where } // Get a reference to the global TorClient - let tor_client = get_tor_client().await?; + let tor_client = get_tor_client()?; log::debug!("Starting bootstrap if needed"); diff --git a/harbor-client/src/lib.rs b/harbor-client/src/lib.rs index a7f4d5cd..a4f41fbd 100644 --- a/harbor-client/src/lib.rs +++ b/harbor-client/src/lib.rs @@ -20,7 +20,6 @@ clippy::single_char_pattern, clippy::single_match_else, clippy::too_many_lines, - clippy::unused_async, clippy::use_self )] @@ -1686,11 +1685,11 @@ impl HarborCore { } } - pub async fn get_seed_words(&self) -> String { + pub fn get_seed_words(&self) -> String { self.mnemonic.to_string() } - pub async fn set_onchain_receive_enabled(&self, enabled: bool) -> anyhow::Result<()> { + pub fn set_onchain_receive_enabled(&self, enabled: bool) -> anyhow::Result<()> { log::info!("Setting on-chain receive enabled to: {}", enabled); self.storage.set_onchain_receive_enabled(enabled)?; log::info!( @@ -1700,7 +1699,7 @@ impl HarborCore { Ok(()) } - pub async fn set_tor_enabled(&self, enabled: bool) -> anyhow::Result<()> { + pub fn set_tor_enabled(&self, enabled: bool) -> anyhow::Result<()> { log::info!("Setting Tor enabled to: {}", enabled); self.tor_enabled.swap(enabled, Ordering::Relaxed); self.storage.set_tor_enabled(enabled)?; diff --git a/harbor-ui/src/bridge.rs b/harbor-ui/src/bridge.rs index 532e0336..389e535e 100644 --- a/harbor-ui/src/bridge.rs +++ b/harbor-ui/src/bridge.rs @@ -796,11 +796,11 @@ async fn process_core(core_handle: &mut CoreHandle, core: &HarborCore) { } } UICoreMsg::GetSeedWords => { - let seed_words = core.get_seed_words().await; + let seed_words = core.get_seed_words(); core.msg(msg.id, CoreUIMsg::SeedWords(seed_words)).await; } UICoreMsg::SetOnchainReceiveEnabled(enabled) => { - match core.set_onchain_receive_enabled(enabled).await { + match core.set_onchain_receive_enabled(enabled) { Err(e) => { error!("error setting onchain receive enabled: {e}"); } @@ -810,16 +810,14 @@ async fn process_core(core_handle: &mut CoreHandle, core: &HarborCore) { } } } - UICoreMsg::SetTorEnabled(enabled) => { - match core.set_tor_enabled(enabled).await { - Err(e) => { - error!("error setting tor enabled: {e}"); - } - _ => { - core.msg(msg.id, CoreUIMsg::TorEnabled(enabled)).await; - } + UICoreMsg::SetTorEnabled(enabled) => match core.set_tor_enabled(enabled) { + Err(e) => { + error!("error setting tor enabled: {e}"); } - } + _ => { + core.msg(msg.id, CoreUIMsg::TorEnabled(enabled)).await; + } + }, UICoreMsg::TestStatusUpdates => { core.test_status_updates(msg.id).await; } From 0a6aa51488bc4efb408b132084ee0070cfe318fb Mon Sep 17 00:00:00 2001 From: Tommy Volk Date: Tue, 26 Aug 2025 10:27:50 -0500 Subject: [PATCH 24/24] chore: enforce clippy use_self rule --- harbor-client/src/db_models/cashu_mint.rs | 10 +++++----- harbor-client/src/db_models/fedimint.rs | 10 +++++----- harbor-client/src/db_models/mint_metadata.rs | 10 +++++----- harbor-client/src/db_models/mod.rs | 8 ++++---- harbor-client/src/db_models/profile.rs | 6 +++--- harbor-client/src/fedimint_client.rs | 10 +++++----- harbor-client/src/lib.rs | 11 +++++------ harbor-client/src/metadata.rs | 2 +- harbor-ui/src/components/indicator.rs | 6 ++---- harbor-ui/src/components/toast.rs | 6 +++--- harbor-ui/src/config.rs | 10 +++++----- harbor-ui/src/lock.rs | 2 +- harbor-ui/src/main.rs | 3 +-- 13 files changed, 45 insertions(+), 49 deletions(-) diff --git a/harbor-client/src/db_models/cashu_mint.rs b/harbor-client/src/db_models/cashu_mint.rs index 83837c3b..13bb0795 100644 --- a/harbor-client/src/db_models/cashu_mint.rs +++ b/harbor-client/src/db_models/cashu_mint.rs @@ -20,10 +20,10 @@ pub struct CashuMint { } impl CashuMint { - pub fn get(conn: &mut SqliteConnection, url: String) -> anyhow::Result> { + pub fn get(conn: &mut SqliteConnection, url: String) -> anyhow::Result> { Ok(cashu_mint::table .filter(cashu_mint::mint_url.eq(url)) - .first::(conn) + .first::(conn) .optional()?) } @@ -32,7 +32,7 @@ impl CashuMint { let exists = cashu_mint::table .filter(cashu_mint::mint_url.eq(&url)) .filter(cashu_mint::active.eq(1)) - .first::(conn) + .first::(conn) .optional()? .is_some(); @@ -79,7 +79,7 @@ impl CashuMint { // First check if the federation exists and is active let exists = cashu_mint::table .filter(cashu_mint::mint_url.eq(&mint_url)) - .first::(conn) + .first::(conn) .optional()? .is_some(); @@ -87,7 +87,7 @@ impl CashuMint { Self::set_active(conn, &mint_url)?; } - let mint = CashuMint { + let mint = Self { mint_url, active: 1, }; diff --git a/harbor-client/src/db_models/fedimint.rs b/harbor-client/src/db_models/fedimint.rs index 8c8aeefc..4e6578c8 100644 --- a/harbor-client/src/db_models/fedimint.rs +++ b/harbor-client/src/db_models/fedimint.rs @@ -17,15 +17,15 @@ impl Fedimint { pub fn get_value(conn: &mut SqliteConnection, id: String) -> anyhow::Result>> { Ok(fedimint::table .filter(fedimint::id.eq(id)) - .first::(conn) + .first::(conn) .optional()? .map(|v| v.value)) } - pub fn get(conn: &mut SqliteConnection, id: String) -> anyhow::Result> { + pub fn get(conn: &mut SqliteConnection, id: String) -> anyhow::Result> { Ok(fedimint::table .filter(fedimint::id.eq(id)) - .first::(conn) + .first::(conn) .optional()?) } @@ -34,7 +34,7 @@ impl Fedimint { let exists = fedimint::table .filter(fedimint::id.eq(&id)) .filter(fedimint::active.eq(1)) - .first::(conn) + .first::(conn) .optional()? .is_some(); @@ -101,7 +101,7 @@ pub struct NewFedimint { impl From<&NewFedimint> for Fedimint { fn from(new_fedimint: &NewFedimint) -> Self { - Fedimint { + Self { id: new_fedimint.id.clone(), invite_code: new_fedimint.invite_code.clone(), value: new_fedimint.value.clone(), diff --git a/harbor-client/src/db_models/mint_metadata.rs b/harbor-client/src/db_models/mint_metadata.rs index e49718b9..33e05e9f 100644 --- a/harbor-client/src/db_models/mint_metadata.rs +++ b/harbor-client/src/db_models/mint_metadata.rs @@ -21,7 +21,7 @@ pub struct MintMetadata { impl MintMetadata { pub fn from(id: FederationId, meta: FederationMeta) -> Self { - MintMetadata { + Self { id: id.to_string(), federation_expiry_timestamp: meta .federation_expiry_timestamp() @@ -38,10 +38,10 @@ impl MintMetadata { } } - pub fn get(conn: &mut SqliteConnection, id: String) -> anyhow::Result> { + pub fn get(conn: &mut SqliteConnection, id: String) -> anyhow::Result> { Ok(mint_metadata::table .filter(mint_metadata::id.eq(id)) - .first::(conn) + .first::(conn) .optional()?) } @@ -73,8 +73,8 @@ impl MintMetadata { } impl From for FederationMeta { - fn from(value: MintMetadata) -> FederationMeta { - FederationMeta { + fn from(value: MintMetadata) -> Self { + Self { federation_name: value.name, federation_expiry_timestamp: value.federation_expiry_timestamp.map(|f| f.to_string()), welcome_message: value.welcome_message, diff --git a/harbor-client/src/db_models/mod.rs b/harbor-client/src/db_models/mod.rs index 687ddda4..5252a6c5 100644 --- a/harbor-client/src/db_models/mod.rs +++ b/harbor-client/src/db_models/mod.rs @@ -87,10 +87,10 @@ pub enum PaymentStatus { impl PaymentStatus { pub fn from_i32(status: i32) -> Self { match status { - 0 => PaymentStatus::Pending, - 1 => PaymentStatus::WaitingConfirmation, - 2 => PaymentStatus::Success, - 3 => PaymentStatus::Failed, + 0 => Self::Pending, + 1 => Self::WaitingConfirmation, + 2 => Self::Success, + 3 => Self::Failed, _ => panic!("invalid status"), } } diff --git a/harbor-client/src/db_models/profile.rs b/harbor-client/src/db_models/profile.rs index 8870109c..fa338752 100644 --- a/harbor-client/src/db_models/profile.rs +++ b/harbor-client/src/db_models/profile.rs @@ -16,8 +16,8 @@ pub struct Profile { } impl Profile { - pub fn get_first(conn: &mut SqliteConnection) -> anyhow::Result> { - Ok(profile::table.first::(conn).optional()?) + pub fn get_first(conn: &mut SqliteConnection) -> anyhow::Result> { + Ok(profile::table.first::(conn).optional()?) } pub fn set_onchain_receive_enabled( @@ -66,7 +66,7 @@ pub struct NewProfile { impl From<&NewProfile> for Profile { fn from(new_profile: &NewProfile) -> Self { - Profile { + Self { id: new_profile.id.clone(), seed_words: new_profile.seed_words.clone(), onchain_receive_enabled: 0, diff --git a/harbor-client/src/fedimint_client.rs b/harbor-client/src/fedimint_client.rs index fcde57c2..fc321c31 100644 --- a/harbor-client/src/fedimint_client.rs +++ b/harbor-client/src/fedimint_client.rs @@ -56,15 +56,15 @@ pub enum FederationInviteOrId { impl FederationInviteOrId { pub fn federation_id(&self) -> FederationId { match self { - FederationInviteOrId::Invite(i) => i.federation_id(), - FederationInviteOrId::Id(i) => *i, + Self::Invite(i) => i.federation_id(), + Self::Id(i) => *i, } } pub fn invite_code(&self) -> Option { match self { - FederationInviteOrId::Invite(i) => Some(i.clone()), - FederationInviteOrId::Id(_) => None, + Self::Invite(i) => Some(i.clone()), + Self::Id(_) => None, } } } @@ -276,7 +276,7 @@ impl FedimintClient { debug!("Built fedimint client"); - Ok(FedimintClient { + Ok(Self { fedimint_client, stop, }) diff --git a/harbor-client/src/lib.rs b/harbor-client/src/lib.rs index a4f41fbd..8e99dc7c 100644 --- a/harbor-client/src/lib.rs +++ b/harbor-client/src/lib.rs @@ -19,8 +19,7 @@ clippy::similar_names, clippy::single_char_pattern, clippy::single_match_else, - clippy::too_many_lines, - clippy::use_self + clippy::too_many_lines )] use crate::cashu_client::{ @@ -115,15 +114,15 @@ pub enum MintIdentifier { impl MintIdentifier { pub fn federation_id(&self) -> Option { match self { - MintIdentifier::Fedimint(id) => Some(*id), - MintIdentifier::Cashu(_) => None, + Self::Fedimint(id) => Some(*id), + Self::Cashu(_) => None, } } pub fn mint_url(&self) -> Option { match self { - MintIdentifier::Cashu(url) => Some(url.clone()), - MintIdentifier::Fedimint(_) => None, + Self::Cashu(url) => Some(url.clone()), + Self::Fedimint(_) => None, } } } diff --git a/harbor-client/src/metadata.rs b/harbor-client/src/metadata.rs index e993bc5c..0e49878d 100644 --- a/harbor-client/src/metadata.rs +++ b/harbor-client/src/metadata.rs @@ -83,7 +83,7 @@ impl FederationMeta { impl From> for FederationMeta { fn from(info: Option) -> Self { - FederationMeta { + Self { federation_name: info.as_ref().and_then(|i| i.name.clone()), federation_expiry_timestamp: None, welcome_message: None, diff --git a/harbor-ui/src/components/indicator.rs b/harbor-ui/src/components/indicator.rs index ae10cd1f..bdd916a3 100644 --- a/harbor-ui/src/components/indicator.rs +++ b/harbor-ui/src/components/indicator.rs @@ -347,10 +347,8 @@ where Theme: container::Catalog + 'a, Renderer: iced::advanced::text::Renderer + 'a, { - fn from( - indicator: Indicator<'a, Message, Theme, Renderer>, - ) -> Element<'a, Message, Theme, Renderer> { - Element::new(indicator) + fn from(indicator: Indicator<'a, Message, Theme, Renderer>) -> Self { + Self::new(indicator) } } diff --git a/harbor-ui/src/components/toast.rs b/harbor-ui/src/components/toast.rs index 855bb5ab..e19ffc44 100644 --- a/harbor-ui/src/components/toast.rs +++ b/harbor-ui/src/components/toast.rs @@ -35,9 +35,9 @@ impl ToastStatus { impl fmt::Display for ToastStatus { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - ToastStatus::Neutral => "Neutral", - ToastStatus::Good => "Good", - ToastStatus::Bad => "Bad", + Self::Neutral => "Neutral", + Self::Good => "Good", + Self::Bad => "Bad", } .fmt(f) } diff --git a/harbor-ui/src/config.rs b/harbor-ui/src/config.rs index f335011b..f3996060 100644 --- a/harbor-ui/src/config.rs +++ b/harbor-ui/src/config.rs @@ -16,9 +16,9 @@ pub enum ConfigError { impl fmt::Display for ConfigError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - ConfigError::InvalidConfig => write!(f, "Config file is invalid"), - ConfigError::IoError(e) => write!(f, "IO error: {e}"), - ConfigError::SerdeError(e) => write!(f, "JSON error: {e}"), + Self::InvalidConfig => write!(f, "Config file is invalid"), + Self::IoError(e) => write!(f, "IO error: {e}"), + Self::SerdeError(e) => write!(f, "JSON error: {e}"), } } } @@ -27,13 +27,13 @@ impl Error for ConfigError {} impl From for ConfigError { fn from(error: io::Error) -> Self { - ConfigError::IoError(error) + Self::IoError(error) } } impl From for ConfigError { fn from(error: serde_json::Error) -> Self { - ConfigError::SerdeError(error) + Self::SerdeError(error) } } diff --git a/harbor-ui/src/lock.rs b/harbor-ui/src/lock.rs index fd0958fd..3a611e0f 100644 --- a/harbor-ui/src/lock.rs +++ b/harbor-ui/src/lock.rs @@ -37,7 +37,7 @@ impl AppLock { std::mem::forget(guard); std::mem::forget(lock); - Ok(AppLock {}) + Ok(Self {}) } } diff --git a/harbor-ui/src/main.rs b/harbor-ui/src/main.rs index 806184e6..0addd90d 100644 --- a/harbor-ui/src/main.rs +++ b/harbor-ui/src/main.rs @@ -24,8 +24,7 @@ clippy::struct_excessive_bools, clippy::suboptimal_flops, clippy::too_many_lines, - clippy::unused_self, - clippy::use_self + clippy::unused_self )] #![windows_subsystem = "windows"]