From 3b10ea4bcbbd9db1d8354a0765afbd4383005b8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Fern=C3=A1ndez=20Serrata?= <76864299+Rudxain@users.noreply.github.com> Date: Fri, 5 Jul 2024 12:25:11 -0400 Subject: [PATCH 01/17] build(cargo): `deny` `unsafe`, `warn` `unwrap` --- Cargo.toml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 2f0df93..d74aec3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,3 +51,10 @@ strip = "symbols" [build-dependencies] embed-resource = "2.4.2" + +[lints.rust] +# "deny" is temp, "forbid" later +unsafe_code = "deny" + +[lints.clippy] +unwrap_used = "warn" From 897b658d14760d6fef9f60c54d65b871ae87d5fb Mon Sep 17 00:00:00 2001 From: Rudxain Date: Wed, 10 Jul 2024 19:58:33 -0400 Subject: [PATCH 02/17] docs(lint): `unsafe` should stay as `deny` --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index d74aec3..8ba1c06 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -53,7 +53,7 @@ strip = "symbols" embed-resource = "2.4.2" [lints.rust] -# "deny" is temp, "forbid" later +# "forbid" may cause conflicts with libs (static and dynamic) unsafe_code = "deny" [lints.clippy] From 1915ea04f48eea4bd9c63bbe3b9e611e1f665271 Mon Sep 17 00:00:00 2001 From: Rudxain Date: Wed, 10 Jul 2024 20:41:19 -0400 Subject: [PATCH 03/17] refactor(gui): fix 1 `unwrap` lint warning --- src/gui/mod.rs | 38 ++++++++++++++------------------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/src/gui/mod.rs b/src/gui/mod.rs index 095524c..7ee8798 100644 --- a/src/gui/mod.rs +++ b/src/gui/mod.rs @@ -192,22 +192,18 @@ impl Application for UadGui { return self.update(Message::RefreshButtonPressed); } } - SettingsMessage::MultiUserMode(toggled) => { - if toggled { - for user in self.apps_view.phone_packages.clone() { - for (i, _) in - user.iter().enumerate().filter(|&(_, pkg)| pkg.selected) + SettingsMessage::MultiUserMode(toggled) if toggled => { + for user in self.apps_view.phone_packages.clone() { + for (i, _) in user.iter().filter(|&pkg| pkg.selected).enumerate() { + for u in self + .selected_device + .as_ref() + .unwrap() + .user_list + .iter() + .filter(|&u| !u.protected) { - for u in self - .selected_device - .as_ref() - .unwrap() - .user_list - .iter() - .filter(|&u| !u.protected) - { - self.apps_view.phone_packages[u.index][i].selected = true; - } + self.apps_view.phone_packages[u.index][i].selected = true; } } } @@ -235,19 +231,13 @@ impl Application for UadGui { } AboutMessage::DoSelfUpdate => { #[cfg(feature = "self-update")] - if self.update_state.self_update.latest_release.is_some() { + if let Some(release) = self.update_state.self_update.latest_release.as_ref() + { self.update_state.self_update.status = SelfUpdateStatus::Updating; self.apps_view.loading_state = ListLoadingState::_UpdatingUad; let bin_name = bin_name().to_owned(); - let release = self - .update_state - .self_update - .latest_release - .as_ref() - .unwrap() - .clone(); Command::perform( - download_update_to_temp_file(bin_name, release), + download_update_to_temp_file(bin_name, release.clone()), Message::_NewReleaseDownloaded, ) } else { From b01d3106019e370b29dfcf3924e32dcf82f284e5 Mon Sep 17 00:00:00 2001 From: Rudxain Date: Wed, 10 Jul 2024 21:30:37 -0400 Subject: [PATCH 04/17] chore(gui): `expect` `selected_device` rather than `unwrap` --- src/gui/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/mod.rs b/src/gui/mod.rs index 7ee8798..d20cfc3 100644 --- a/src/gui/mod.rs +++ b/src/gui/mod.rs @@ -198,7 +198,7 @@ impl Application for UadGui { for u in self .selected_device .as_ref() - .unwrap() + .expect("Device should be selected") .user_list .iter() .filter(|&u| !u.protected) From ae2cf07fc59313a0410898c6ca4892cd61d25a5c Mon Sep 17 00:00:00 2001 From: Rudxain Date: Wed, 10 Jul 2024 21:53:12 -0400 Subject: [PATCH 05/17] chore(widgets): assume `Layout`s must have at least 1 child --- src/gui/widgets/modal.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/gui/widgets/modal.rs b/src/gui/widgets/modal.rs index 708187a..edb010b 100644 --- a/src/gui/widgets/modal.rs +++ b/src/gui/widgets/modal.rs @@ -190,14 +190,17 @@ where clipboard: &mut dyn Clipboard, shell: &mut Shell<'_, Message>, ) -> event::Status { - let content_bounds = layout.children().next().unwrap().bounds(); - if let Some(message) = self.on_blur.as_ref() { if matches!( event, Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left)) ) { if let Some(cursor_position) = cursor.position() { + let content_bounds = layout + .children() + .next() + .unwrap_or_else(|| unreachable!("Layout must have at least 1 child")) + .bounds(); if !content_bounds.contains(cursor_position) { shell.publish(message.clone()); return event::Status::Captured; From c0f2ea5beb3c85d3433a120b583b12052f433b52 Mon Sep 17 00:00:00 2001 From: Rudxain Date: Wed, 10 Jul 2024 21:58:08 -0400 Subject: [PATCH 06/17] chore(widgets): `unreachable` -> `expect` --- src/gui/widgets/modal.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/widgets/modal.rs b/src/gui/widgets/modal.rs index edb010b..44b2e1f 100644 --- a/src/gui/widgets/modal.rs +++ b/src/gui/widgets/modal.rs @@ -199,7 +199,7 @@ where let content_bounds = layout .children() .next() - .unwrap_or_else(|| unreachable!("Layout must have at least 1 child")) + .expect("Layout must have at least 1 child") .bounds(); if !content_bounds.contains(cursor_position) { shell.publish(message.clone()); From 82223608d8fdba29a33e7591953f276e4cbe38b9 Mon Sep 17 00:00:00 2001 From: Rudxain Date: Thu, 11 Jul 2024 12:53:18 -0400 Subject: [PATCH 07/17] build(lint): `deny` `exit` --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index 8ba1c06..6c31660 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -58,3 +58,4 @@ unsafe_code = "deny" [lints.clippy] unwrap_used = "warn" +exit = "deny" From fdaeb2368de0f4f9833cf7aa72e5f9f38fbf108e Mon Sep 17 00:00:00 2001 From: Rudxain Date: Thu, 11 Jul 2024 12:54:54 -0400 Subject: [PATCH 08/17] build(lint): `warn` `format_push_string` --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index 6c31660..e59b359 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,3 +59,4 @@ unsafe_code = "deny" [lints.clippy] unwrap_used = "warn" exit = "deny" +format_push_string = "warn" From 6e52a3d554661508991cb831920f9577c30a45d8 Mon Sep 17 00:00:00 2001 From: Rudxain Date: Thu, 11 Jul 2024 12:57:26 -0400 Subject: [PATCH 09/17] build(lint): `warn` `infinite_loop` --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index e59b359..e8b0c73 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,4 +59,5 @@ unsafe_code = "deny" [lints.clippy] unwrap_used = "warn" exit = "deny" +infinite_loop = "warn" format_push_string = "warn" From d7f7d98c8fb97b80d07fa36933bbb774dead32b9 Mon Sep 17 00:00:00 2001 From: Rudxain Date: Thu, 11 Jul 2024 13:10:33 -0400 Subject: [PATCH 10/17] build(lint): `warn` `large_include_file` --- Cargo.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index e8b0c73..2bcf59b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -57,7 +57,8 @@ embed-resource = "2.4.2" unsafe_code = "deny" [lints.clippy] -unwrap_used = "warn" exit = "deny" +unwrap_used = "warn" infinite_loop = "warn" format_push_string = "warn" +large_include_file = "warn" From 9948472c41cd57a6351cbf91b71dc0a9a3349e69 Mon Sep 17 00:00:00 2001 From: Rudxain Date: Thu, 11 Jul 2024 13:15:28 -0400 Subject: [PATCH 11/17] build(lint): `warn` `mem_forget` --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index 2bcf59b..5e363d8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -60,5 +60,6 @@ unsafe_code = "deny" exit = "deny" unwrap_used = "warn" infinite_loop = "warn" +mem_forget = "warn" format_push_string = "warn" large_include_file = "warn" From a070d1f1797e080c5cdcddbd01156bbf3b6e7ef3 Mon Sep 17 00:00:00 2001 From: Rudxain Date: Thu, 11 Jul 2024 13:19:31 -0400 Subject: [PATCH 12/17] build(lint): `warn` `panic_in_result_fn` --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index 5e363d8..55c69c7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -58,6 +58,7 @@ unsafe_code = "deny" [lints.clippy] exit = "deny" +panic_in_result_fn = "warn" unwrap_used = "warn" infinite_loop = "warn" mem_forget = "warn" From 8b8a6c8f4bfa745f2844a10ed4e9738839082210 Mon Sep 17 00:00:00 2001 From: Rudxain Date: Thu, 11 Jul 2024 13:27:44 -0400 Subject: [PATCH 13/17] build(lint): `warn` `shadow_unrelated` --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index 55c69c7..8722d47 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -64,3 +64,4 @@ infinite_loop = "warn" mem_forget = "warn" format_push_string = "warn" large_include_file = "warn" +shadow_unrelated = "warn" From 6a456c278d1ea885ac9ed765ac14be244ca73ca1 Mon Sep 17 00:00:00 2001 From: Rudxain Date: Thu, 11 Jul 2024 13:40:38 -0400 Subject: [PATCH 14/17] refactor(lint): `deny` `string_to_string`, and fix errors --- Cargo.toml | 1 + src/core/sync.rs | 2 +- src/gui/views/settings.rs | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8722d47..be65752 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -62,6 +62,7 @@ panic_in_result_fn = "warn" unwrap_used = "warn" infinite_loop = "warn" mem_forget = "warn" +string_to_string = "deny" format_push_string = "warn" large_include_file = "warn" shadow_unrelated = "warn" diff --git a/src/core/sync.rs b/src/core/sync.rs index e5ea5c7..bab4846 100644 --- a/src/core/sync.rs +++ b/src/core/sync.rs @@ -141,7 +141,7 @@ pub async fn perform_adb_commands( label, action, err ))); } - Err(AdbError::Generic(err.to_string())) + Err(AdbError::Generic(err)) } } } diff --git a/src/gui/views/settings.rs b/src/gui/views/settings.rs index 827e58c..277e95b 100644 --- a/src/gui/views/settings.rs +++ b/src/gui/views/settings.rs @@ -207,7 +207,7 @@ impl Settings { Command::batch(commands) } Err(e) => { - self.device.backup.backup_state = e.to_string(); + self.device.backup.backup_state = e.clone(); error!("{} - {}", self.device.backup.selected.as_ref().unwrap(), e); Command::none() } From 20683fa6c47efc6636b8e3e22a4f1103ee9b4b73 Mon Sep 17 00:00:00 2001 From: Rudxain Date: Thu, 11 Jul 2024 13:45:04 -0400 Subject: [PATCH 15/17] build(lint): `forbid` `undocumented_unsafe_blocks` --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index be65752..99c93f8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -57,6 +57,7 @@ embed-resource = "2.4.2" unsafe_code = "deny" [lints.clippy] +undocumented_unsafe_blocks = "forbid" exit = "deny" panic_in_result_fn = "warn" unwrap_used = "warn" From 4c0615ad1b57e0e3f68595d2bda0a2d732e5b57c Mon Sep 17 00:00:00 2001 From: Rudxain Date: Thu, 11 Jul 2024 13:53:31 -0400 Subject: [PATCH 16/17] build(clippy): `warn` `pedantic` group --- Cargo.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 99c93f8..e5d292a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -67,3 +67,5 @@ string_to_string = "deny" format_push_string = "warn" large_include_file = "warn" shadow_unrelated = "warn" + +pedantic = { level = "warn", priority = -1 } From 0209d28ddf249c6ca41e285373d8ae28ef13bd40 Mon Sep 17 00:00:00 2001 From: Anonymoussaurus <50231698+AnonymousWP@users.noreply.github.com> Date: Fri, 12 Jul 2024 18:14:55 +0200 Subject: [PATCH 17/17] build(release): add testing label --- .github/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/release.yml b/.github/release.yml index 45aa989..7e4865a 100644 --- a/.github/release.yml +++ b/.github/release.yml @@ -11,6 +11,7 @@ changelog: - refactor - dependencies - documentation + - testing - title: Packages/apps labels: - package::documentation