From c5b309acdd270f1d44e5be9bea45310f33fbd508 Mon Sep 17 00:00:00 2001 From: Ben C Date: Mon, 27 Apr 2026 14:20:00 -0400 Subject: [PATCH] [CHORE] Fix formatting, clippy errors --- owmods_cli/src/logging.rs | 2 +- owmods_cli/src/main.rs | 9 +++++++-- owmods_core/src/owml.rs | 28 +++++++++++++++------------- owmods_core/src/remove.rs | 2 +- owmods_gui/backend/src/commands.rs | 3 +-- owmods_gui/backend/src/events.rs | 4 ++-- xtask/src/cli_tasks.rs | 2 +- xtask/src/gui_tasks.rs | 2 +- 8 files changed, 29 insertions(+), 23 deletions(-) diff --git a/owmods_cli/src/logging.rs b/owmods_cli/src/logging.rs index 67366203..6430d806 100644 --- a/owmods_cli/src/logging.rs +++ b/owmods_cli/src/logging.rs @@ -6,7 +6,7 @@ use std::{ use colored::Colorize; use indicatif::{MultiProgress, ProgressBar, ProgressStyle}; -use log::{error, warn, Level}; +use log::{Level, error, warn}; use owmods_core::{ db::LocalDatabase, mods::local::UnsafeLocalMod, diff --git a/owmods_cli/src/main.rs b/owmods_cli/src/main.rs index ec020a64..8a472723 100644 --- a/owmods_cli/src/main.rs +++ b/owmods_cli/src/main.rs @@ -82,7 +82,12 @@ async fn run_from_cli(cli: BaseCli) -> Result<()> { } => { if let Some(owml_path) = owml_path { let mut new_config = config.clone(); - let path = owml_path.canonicalize().context("Failed to resolve OWML path")?.to_str().unwrap().to_string(); + let path = owml_path + .canonicalize() + .context("Failed to resolve OWML path")? + .to_str() + .unwrap() + .to_string(); new_config.owml_path = path; if new_config.check_owml() { info!("Path to OWML is valid! Updating config..."); @@ -151,7 +156,7 @@ async fn run_from_cli(cli: BaseCli) -> Result<()> { mods.len(), config.owml_path ); - mods.sort_by(|a, b| b.enabled.cmp(&a.enabled)); + mods.sort_by_key(|m| !m.enabled); for local_mod in mods.iter() { output += &format!( "({}) {} v{} by {} ({})\n", diff --git a/owmods_core/src/owml.rs b/owmods_core/src/owml.rs index c54f47db..cab75eb0 100644 --- a/owmods_core/src/owml.rs +++ b/owmods_core/src/owml.rs @@ -197,7 +197,7 @@ mod tests { use std::fs; - use crate::test_utils::{get_test_file, TestContext}; + use crate::test_utils::{TestContext, get_test_file}; use super::*; @@ -229,12 +229,13 @@ mod tests { let owml_conf: OWMLConfig = serde_json::from_str(include_str!("../test_files/OWML.Config.json")).unwrap(); owml_conf.save(&ctx.config).unwrap(); - assert!(ctx - .temp_dir - .path() - .join("OWML") - .join("OWML.Config.json") - .is_file()); + assert!( + ctx.temp_dir + .path() + .join("OWML") + .join("OWML.Config.json") + .is_file() + ); } #[test] @@ -254,11 +255,12 @@ mod tests { setup_default_conf(&ctx); let conf = OWMLConfig::get(&ctx.config).unwrap(); assert!(conf.debug_mode); - assert!(ctx - .temp_dir - .path() - .join("OWML") - .join("OWML.Config.json") - .is_file()); + assert!( + ctx.temp_dir + .path() + .join("OWML") + .join("OWML.Config.json") + .is_file() + ); } } diff --git a/owmods_core/src/remove.rs b/owmods_core/src/remove.rs index 10c22985..f225318c 100644 --- a/owmods_core/src/remove.rs +++ b/owmods_core/src/remove.rs @@ -9,7 +9,7 @@ use glob::glob; use crate::{ db::LocalDatabase, file::check_file_matches_paths, - mods::local::{get_paths_to_preserve, FailedMod, LocalMod}, + mods::local::{FailedMod, LocalMod, get_paths_to_preserve}, }; /// Uninstall a mod diff --git a/owmods_gui/backend/src/commands.rs b/owmods_gui/backend/src/commands.rs index 68740773..b898e49a 100644 --- a/owmods_gui/backend/src/commands.rs +++ b/owmods_gui/backend/src/commands.rs @@ -237,7 +237,7 @@ pub async fn get_remote_mods( .filter(|m| m.unique_name != OWML_UNIQUE_NAME) .collect(); if filter.is_empty() { - mods.sort_by(|a, b| b.download_count.cmp(&a.download_count)); + mods.sort_by_key(|m| m.download_count); } else { mods = remote_db.search(filter); } @@ -438,7 +438,6 @@ pub async fn open_mod_readme(unique_name: &str, state: tauri::State<'_, State>) Ok(()) } - #[tauri::command] pub async fn open_owml_logs_folder(state: tauri::State<'_, State>) -> Result { let config = state.config.read().await; diff --git a/owmods_gui/backend/src/events.rs b/owmods_gui/backend/src/events.rs index b33de0de..991977e3 100644 --- a/owmods_gui/backend/src/events.rs +++ b/owmods_gui/backend/src/events.rs @@ -1,10 +1,10 @@ -use anyhow::{anyhow, Result}; +use anyhow::{Result, anyhow}; use owmods_core::protocol::ProtocolPayload; use serde::{Deserialize, Serialize}; use tauri::{AppHandle, Emitter, Listener, Window}; use typeshare::typeshare; -use crate::{game::GameMessage, LogPort}; +use crate::{LogPort, game::GameMessage}; pub const INVOKE_URI: &str = "owmods://events/invoke"; diff --git a/xtask/src/cli_tasks.rs b/xtask/src/cli_tasks.rs index e82afb6e..b0a56453 100644 --- a/xtask/src/cli_tasks.rs +++ b/xtask/src/cli_tasks.rs @@ -1,4 +1,4 @@ -use std::fs::{create_dir_all, File}; +use std::fs::{File, create_dir_all}; use std::io::Write; use anyhow::Result; diff --git a/xtask/src/gui_tasks.rs b/xtask/src/gui_tasks.rs index b4f8623a..e8d8e2ca 100644 --- a/xtask/src/gui_tasks.rs +++ b/xtask/src/gui_tasks.rs @@ -1,4 +1,4 @@ -use std::fs::{create_dir_all, File}; +use std::fs::{File, create_dir_all}; use std::io::Write; use anyhow::Result; -- 2.51.2