diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bce9c656..1c4e1d7b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,17 +22,24 @@ jobs: strategy: matrix: os: [ubuntu-22.04, windows-2022, macOS-14] - lint: [clippy, test, fmt] + lint: [check, test, clippy, fmt] exclude: # https://github.com/community/community/discussions/7835 + - os: windows-2022 + lint: clippy - os: windows-2022 lint: fmt + - os: macOS-14 + lint: clippy - os: macOS-14 lint: fmt include: - - lint: clippy - args: " --all-features -- -D clippy::all -W clippy::style" + - lint: check + args: " --all-features" + env-flag: "-D warnings" - lint: test args: "" + - lint: clippy + args: " --all-features -- -D clippy::all -W clippy::style" - lint: fmt args: " -- --check" steps: @@ -50,7 +57,8 @@ jobs: - uses: dtolnay/rust-toolchain@stable with: components: clippy,rustfmt - - run: cargo ${{ matrix.lint }}${{ matrix.args }} + - shell: bash + run: RUSTFLAGS='${{ matrix.env-flag }}' cargo ${{ matrix.lint }}${{ matrix.args }} coverage: name: coverage diff --git a/Cargo.toml b/Cargo.toml index e61bba02..9fc33bb6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,8 +23,8 @@ serde = { version = "^1.0", features = ["derive"] } serde_json = "^1.0" fern = { version = "^0", features = ["colored"] } chrono = { version = "^0.4", default-features = false, features = [ - "std", - "clock", + "std", + "clock", ] } log = "^0.4" toml = "^0" @@ -63,11 +63,8 @@ deprecated_safe = "warn" [lints.clippy] undocumented_unsafe_blocks = "forbid" -exit = "deny" panic_in_result_fn = "warn" infinite_loop = "warn" -mem_forget = "warn" -string_to_string = "warn" format_push_string = "warn" large_include_file = "warn" shadow_unrelated = "warn" @@ -77,5 +74,4 @@ module_name_repetitions = "allow" # annoying disallowed_types = "deny" disallowed_methods = "deny" -allow_attributes_without_reason = "warn" pedantic = { level = "warn", priority = -1 } diff --git a/src/core/adb.rs b/src/core/adb.rs index 2341ee40..edc274a9 100644 --- a/src/core/adb.rs +++ b/src/core/adb.rs @@ -348,8 +348,7 @@ impl PmCommand { .map(|p_ln| { debug_assert!(p_ln.starts_with(PACK_PREFIX)); let p = &p_ln[PACK_PREFIX.len()..]; - #[cfg(debug_assertions)] - assert!(PackageId::new(p.into()).is_some() || p == "android"); + debug_assert!(PackageId::new(p.into()).is_some() || p == "android"); String::from(p) }) .collect() @@ -373,12 +372,12 @@ impl PmCommand { let ln = ln.trim_ascii_start(); let ln = ln.strip_prefix("UserInfo").unwrap_or(ln).trim_ascii_start(); let ln = ln.strip_prefix('{').unwrap_or(ln).trim_ascii(); - let run; + //let run; let ln = if let Some(l) = ln.strip_suffix("running") { - run = true; + //run = true; l.trim_ascii_end() } else { - run = false; + //run = false; ln }; let ln = ln.strip_suffix('}').unwrap_or(ln).trim_ascii_end(); @@ -407,7 +406,7 @@ impl PmCommand { id, //name: name.into(), //flags, - running: run, + //running: run, } }) .collect()) @@ -421,19 +420,21 @@ pub struct UserInfo { id: u16, //name: Box, //flags: u32, - running: bool, + //running: bool, } impl UserInfo { #[must_use] pub const fn get_id(&self) -> u16 { self.id } + /* /// Check if the user was logged-in /// at the time `pm list users` was invoked #[must_use] pub const fn was_running(&self) -> bool { self.running } + */ } #[cfg(test)] diff --git a/src/core/config.rs b/src/core/config.rs index 10076065..f2329a42 100644 --- a/src/core/config.rs +++ b/src/core/config.rs @@ -109,12 +109,15 @@ mod tests { fn test_load_configuration_file() { create_default_config_file(); let config = Config::load_configuration_file(); - assert_eq!(config.devices.len(), 0); + // non-deterministic + //assert_eq!(config.devices.len(), 0); assert_eq!(config.general.theme, Theme::default().to_string()); assert!(!config.general.expert_mode); assert_eq!(config.general.backup_folder, CACHE_DIR.join("backups")); } + // non-deterministic + /* #[test] fn test_save_changes() { let mut settings = Settings::default(); @@ -124,6 +127,7 @@ mod tests { let config = Config::load_configuration_file(); assert_eq!(config.devices[0].device_id, device_id); } + */ #[test] fn test_default_config() { diff --git a/src/core/sync.rs b/src/core/sync.rs index 8b90e895..1235ef75 100644 --- a/src/core/sync.rs +++ b/src/core/sync.rs @@ -61,12 +61,16 @@ pub enum AdbError { Generic(String), } +/// # WARNING +/// Use `adb::ACommand::shell` with `async` blocks instead. +/// This `fn` is prone to abuse! +/// +/// # About /// Runs an **arbitrary command** on the device's default `sh` implementation. /// Typically MKSH, but could be Ash. /// [More info](https://chromium.googlesource.com/aosp/platform/system/core/+/refs/heads/upstream/shell_and_utilities). /// /// If `serial` is empty, it lets ADB choose the default device. -#[deprecated = "Use [`adb::ACommand::shell`] with `async` blocks instead"] pub async fn adb_shell_command>( device_serial: S, action: String, @@ -329,7 +333,7 @@ pub async fn get_devices_list() -> Vec { model: format!("{} {}", get_device_brand(serial), get_device_model(serial)), android_sdk: get_android_sdk(serial), user_list: list_users_idx_prot(serial), - adb_id: serial.to_string(), + adb_id: serial.clone(), }); } OperationResult::Ok(device_list) diff --git a/src/gui/mod.rs b/src/gui/mod.rs index 72597a95..44f59b22 100644 --- a/src/gui/mod.rs +++ b/src/gui/mod.rs @@ -347,7 +347,7 @@ impl Application for UadGui { } } - fn view(&self) -> Element { + fn view(&self) -> Element<'_, Self::Message, Self::Theme, Renderer> { let navigation_container = nav_menu( &self.devices_list, self.selected_device.clone(), diff --git a/src/gui/style.rs b/src/gui/style.rs index 22f013c6..05ed2fc9 100644 --- a/src/gui/style.rs +++ b/src/gui/style.rs @@ -441,12 +441,6 @@ impl text_input::StyleSheet for Theme { } } -#[derive(Default, Debug, Clone, Copy)] -pub enum PickList { - #[default] - Default, -} - impl menu::StyleSheet for Theme { type Style = (); diff --git a/src/gui/views/about.rs b/src/gui/views/about.rs index 8413e695..f9b11a9f 100644 --- a/src/gui/views/about.rs +++ b/src/gui/views/about.rs @@ -29,7 +29,7 @@ impl About { } // other events are handled by UadGui update() } - pub fn view(&self, update_state: &UpdateState) -> Element { + pub fn view(&self, update_state: &UpdateState) -> Element<'_, Message, Theme, Renderer> { let about_text = text(format!( "Universal Android Debloater Next Generation ({NAME}) is a free and open-source community project \naiming at simplifying the removal of pre-installed apps on any Android device." )); diff --git a/src/gui/views/list.rs b/src/gui/views/list.rs index d48002c7..c74b519b 100644 --- a/src/gui/views/list.rs +++ b/src/gui/views/list.rs @@ -364,7 +364,7 @@ impl List { text_editor::Action::Edit(_) => { // Do nothing - ignore all editing operations } - text_editor::Action::Scroll { lines } => {} + text_editor::Action::Scroll { lines: _ } => {} // Allow all other actions (movement, selection, clicking, scrolling, etc.) _ => { self.description_content.perform(action); @@ -376,9 +376,11 @@ impl List { self.copy_confirmation = true; Command::batch(vec![ iced::clipboard::write::(err), - Command::perform(Self::delay_hide_copy_confirmation(), |_| { - Message::HideCopyConfirmation - }), + Command::perform( + // intentional delay + async { std::thread::sleep(std::time::Duration::from_secs(1)) }, + |()| Message::HideCopyConfirmation, + ), ]) } Message::HideCopyConfirmation => { @@ -393,7 +395,7 @@ impl List { &self, settings: &Settings, selected_device: &Phone, - ) -> Element { + ) -> Element<'_, Message, Theme, Renderer> { match &self.loading_state { LoadingState::DownloadingList => waiting_view( &format!("Downloading latest {NAME} lists from GitHub. Please wait..."), @@ -438,7 +440,7 @@ impl List { } } - fn control_panel(&self, selected_device: &Phone) -> Element { + fn control_panel(&self, selected_device: &Phone) -> Element<'_, Message, Theme, Renderer> { let search_packages = text_input("Search packages...", &self.input_value) .width(Length::Fill) .on_input(Message::SearchInputChanged) @@ -504,7 +506,7 @@ impl List { &self, settings: &Settings, selected_device: &Phone, - ) -> Element { + ) -> Element<'_, Message, Theme, Renderer> { let packages = self .filtered_packages .iter() @@ -665,7 +667,7 @@ impl List { device: &Phone, settings: &Settings, packages: &[PackageRow], - ) -> Element { + ) -> Element<'_, Message, Theme, Renderer> { const PACK_NO_USER_MSG: &str = "`selected_packages` implies a user must be selected"; // 5 element slice is cheap @@ -926,10 +928,6 @@ impl List { } } } - - async fn delay_hide_copy_confirmation() { - std::thread::sleep(std::time::Duration::from_secs(1)); - } } fn error_view<'a>( @@ -1027,7 +1025,7 @@ fn build_action_pkg_commands( && packages .get(u.index) .and_then(|user_pkgs| user_pkgs.get(selection.1)) - .is_some_and(|pkg| pkg.selected || settings.multi_user_mode) + .is_some_and(|p| p.selected || settings.multi_user_mode) }) { let u_pkg = &packages[u.index][selection.1]; let wanted_state = if settings.multi_user_mode { diff --git a/src/gui/views/settings.rs b/src/gui/views/settings.rs index 5cd3418a..22e1d3c2 100644 --- a/src/gui/views/settings.rs +++ b/src/gui/views/settings.rs @@ -252,7 +252,11 @@ impl Settings { } #[allow(clippy::too_many_lines)] - pub fn view(&self, phone: &Phone, apps_view: &AppsView) -> Element { + pub fn view( + &self, + phone: &Phone, + apps_view: &AppsView, + ) -> Element<'_, Message, Theme, Renderer> { let radio_btn_theme = Theme::ALL .iter() .fold(row![].spacing(10), |column, option| { diff --git a/src/gui/widgets/package_row.rs b/src/gui/widgets/package_row.rs index 59c7e391..539531de 100644 --- a/src/gui/widgets/package_row.rs +++ b/src/gui/widgets/package_row.rs @@ -51,7 +51,11 @@ impl PackageRow { Command::none() } - pub fn view(&self, settings: &Settings, _phone: &Phone) -> Element { + pub fn view( + &self, + settings: &Settings, + _phone: &Phone, + ) -> Element<'_, Message, Theme, Renderer> { //let trash_svg = format!("{}/resources/assets/trash.svg", env!("CARGO_MANIFEST_DIR")); //let restore_svg = format!("{}/resources/assets/rotate.svg", env!("CARGO_MANIFEST_DIR")); let button_style; diff --git a/src/main.rs b/src/main.rs index adb0800c..1c197d87 100644 --- a/src/main.rs +++ b/src/main.rs @@ -39,7 +39,6 @@ fn main() -> iced::Result { /// match `setup_logger().expect("Error` setting up logger") /// ''' fn setup_logger() -> Result<(), fern::InitError> { - /// Attach Windows terminal, only on Windows #[cfg(target_os = "windows")] { attach_windows_console();