From b4e68d085da69e68529720bd3faf1dd3ad369a74 Mon Sep 17 00:00:00 2001 From: GeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com> Date: Sun, 2 Apr 2023 18:02:22 +0200 Subject: fix: Another set of various clippy fixes (#246) * fix: Remove unnecessary clone * fix: Remove redundant field name in struct init * fix: Single-char string constant used as pattern * fix: calling `push_str()` using a single-character string literal * fix: this pattern reimplements `Option::unwrap_or` * fix: Remove unnecessary borrow * fix: Remove useless use of `format!` * fix: called `inspect(..).for_each(..)` on an `Iterator` * fix: Formatting --- src-tauri/src/github/mod.rs | 19 ++++++++++++------- src-tauri/src/lib.rs | 9 +++------ src-tauri/src/repair_and_verify/mod.rs | 2 +- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src-tauri/src/github/mod.rs b/src-tauri/src/github/mod.rs index 87ea629c..c46d7c60 100644 --- a/src-tauri/src/github/mod.rs +++ b/src-tauri/src/github/mod.rs @@ -49,7 +49,7 @@ pub fn get_list_of_tags() -> Result, String> { // Fetch the list of tags for the repository as a `Vec`. let tags_url = format!("https://api.github.com/repos/{}/tags", FLIGHTCORE_REPO_NAME); - let tags: Vec = client.get(&tags_url).send().unwrap().json().unwrap(); + let tags: Vec = client.get(tags_url).send().unwrap().json().unwrap(); // Map each `Tag` element to a `TagWrapper` element with the desired label and `Tag` value. let tag_wrappers: Vec = tags @@ -102,10 +102,15 @@ pub fn compare_tags(first_tag: Tag, second_tag: Tag) -> Result { commit.sha, commit.commit.message.split('\n').next().unwrap() ); - patch_notes.push(format!( - "{}", - commit.commit.message.split('\n').next().unwrap() - )); + patch_notes.push( + commit + .commit + .message + .split('\n') + .next() + .unwrap() + .to_string(), + ); } full_patch_notes += &generate_flightcore_release_notes(patch_notes); @@ -140,7 +145,7 @@ fn generate_flightcore_release_notes(commits: Vec) -> String { release_notes.push_str(&format!("- {}\n", commit_message)); } - release_notes.push_str("\n"); + release_notes.push('\n'); } } } @@ -155,7 +160,7 @@ fn group_commits_by_type(commits: Vec) -> HashMap> { let mut other_commits: Vec = vec![]; for commit in commits { - let commit_parts: Vec<&str> = commit.splitn(2, ":").collect(); + let commit_parts: Vec<&str> = commit.splitn(2, ':').collect(); if commit_parts.len() == 2 { let commit_type = commit_parts[0].to_lowercase(); let commit_description = commit_parts[1].trim().to_string(); diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 3bcbdfa6..ff1445e5 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -113,7 +113,7 @@ pub fn find_game_install_location() -> Result { match windows::origin_install_location_detection() { Ok(game_path) => { let game_install = GameInstall { - game_path: game_path, + game_path, install_type: InstallType::ORIGIN, }; return Ok(game_install); @@ -190,7 +190,7 @@ async fn do_install(nmod: &thermite::model::ModVersion, game_path: &std::path::P std::fs::create_dir_all(download_directory.clone())?; - let download_path = format!("{}/{}", download_directory.clone(), filename); + let download_path = format!("{}/{}", download_directory, filename); log::info!("Download path: {download_path}"); let nfile = thermite::core::manage::download_file(&nmod.url, download_path).unwrap(); @@ -282,10 +282,7 @@ pub fn launch_northstar( )); } - let bypass_checks = match bypass_checks { - Some(bypass_checks) => bypass_checks, - None => false, - }; + let bypass_checks = bypass_checks.unwrap_or(false); // Only check guards if bypassing checks is not enabled if !bypass_checks { diff --git a/src-tauri/src/repair_and_verify/mod.rs b/src-tauri/src/repair_and_verify/mod.rs index 31b31040..b3dbe3b2 100644 --- a/src-tauri/src/repair_and_verify/mod.rs +++ b/src-tauri/src/repair_and_verify/mod.rs @@ -51,7 +51,7 @@ pub fn clean_up_download_folder( // dbg!(download_dir_contents); let mut count = 0; - download_dir_contents.inspect(|_| count += 1).for_each(drop); + download_dir_contents.for_each(|_| count += 1); if count > 0 && !force { return Err(anyhow!("Folder not empty, not deleting")); -- cgit v1.2.3