From 784330797d947ec2ff4eb97a7325ac77f3a79e4d Mon Sep 17 00:00:00 2001 From: GeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com> Date: Mon, 27 Mar 2023 19:49:25 +0200 Subject: fix: Various clippy fixes (#243) * fix: Remove redundant return * fix: Remove unnecessary borrow * fix: Remove unnecessary import * fix: Use char for single character replacement instead of string * fix: Iterate over values directly instead of key-value pair * fix: Remove unnecessary let binding * fix: Remove unnecessary return statement * fix: Use char for single character replacement instead of string * refactor: Use struct short hand initialization --- src-tauri/src/github/release_notes.rs | 2 +- src-tauri/src/main.rs | 2 +- src-tauri/src/mod_management/mod.rs | 19 ++++++++----------- 3 files changed, 10 insertions(+), 13 deletions(-) (limited to 'src-tauri') diff --git a/src-tauri/src/github/release_notes.rs b/src-tauri/src/github/release_notes.rs index edba5761..b45442e0 100644 --- a/src-tauri/src/github/release_notes.rs +++ b/src-tauri/src/github/release_notes.rs @@ -100,5 +100,5 @@ pub async fn get_northstar_release_notes() -> Result, String> { serde_json::from_str(&res).expect("JSON was not well-formatted"); log::info!("Done checking GitHub API"); - return Ok(release_info_vector); + Ok(release_info_vector) } diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index f4712cd4..21045db1 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -166,7 +166,7 @@ fn force_panic() { #[tauri::command] /// Returns true if built in debug mode async fn is_debug_mode() -> bool { - return cfg!(debug_assertions); + cfg!(debug_assertions) } #[tauri::command] diff --git a/src-tauri/src/mod_management/mod.rs b/src-tauri/src/mod_management/mod.rs index 0c0389c8..7261619e 100644 --- a/src-tauri/src/mod_management/mod.rs +++ b/src-tauri/src/mod_management/mod.rs @@ -12,8 +12,6 @@ use std::path::PathBuf; use app::get_enabled_mods; use app::GameInstall; -use json5; - #[derive(Debug, Clone)] struct ParsedThunderstoreModString { author_name: String, @@ -25,7 +23,7 @@ impl std::str::FromStr for ParsedThunderstoreModString { type Err = (); fn from_str(s: &str) -> Result { - let mut parts = s.split("-"); + let mut parts = s.split('-'); let author_name = parts.next().unwrap().to_string(); let mod_name = parts.next().unwrap().to_string(); @@ -100,8 +98,7 @@ pub fn set_mod_enabled_status( rebuild_enabled_mods_json(game_install.clone())?; // Then try again - let res = get_enabled_mods(game_install.clone())?; - res + get_enabled_mods(game_install.clone())? } }; @@ -209,7 +206,7 @@ fn parse_installed_mods(game_install: GameInstall) -> Result, let ns_mod = NorthstarMod { name: parsed_mod_json.name, version: parsed_mod_json.version, - thunderstore_mod_string: thunderstore_mod_string, + thunderstore_mod_string, enabled: false, // Placeholder directory: mod_directory, }; @@ -276,7 +273,7 @@ async fn get_ns_mod_download_url(thunderstore_mod_string: String) -> Result f, Err(e) => return Err(e.to_string()), }; // Get Thunderstore mod author - let author = thunderstore_mod_string.split("-").next().unwrap(); + let author = thunderstore_mod_string.split('-').next().unwrap(); // Extract the mod to the mods directory match thermite::core::manage::install_mod(author, &f, std::path::Path::new(&mods_directory)) { -- cgit v1.2.3