diff --git a/flake.lock b/flake.lock index da3c96ca..5fb2c605 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1731245184, - "narHash": "sha256-vmLS8+x+gHRv1yzj3n+GTAEObwmhxmkkukB2DwtJRdU=", + "lastModified": 1746188796, + "narHash": "sha256-ZZ38C6Wy11lqVNKV/N5DOM4hnVyJNwS0cb03yD3ZTqk=", "owner": "nixos", "repo": "nixpkgs", - "rev": "aebe249544837ce42588aa4b2e7972222ba12e8f", + "rev": "4be4d7a7758d92d60a092a503c93a381f95c71b1", "type": "github" }, "original": { @@ -29,11 +29,11 @@ ] }, "locked": { - "lastModified": 1731464916, - "narHash": "sha256-WZ5rpjr/wCt7yBOUsvDE2i22hYz9g8W921jlwVktRQ4=", + "lastModified": 1746239644, + "narHash": "sha256-wMvMBMlpS1H8CQdSSgpLeoCWS67ciEkN/GVCcwk7Apc=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "2c19bad6e881b5a154cafb7f9106879b5b356d1f", + "rev": "bd32e88bef6da0e021a42fb4120a8df2150e9b8c", "type": "github" }, "original": { diff --git a/src/gui/message.rs b/src/gui/message.rs index 5b72bd05..df50d669 100644 --- a/src/gui/message.rs +++ b/src/gui/message.rs @@ -242,10 +242,10 @@ pub struct FetchModProgress { impl FetchModProgress { fn receive(self, app: &mut App) { - if let Some(MessageHandle { rid, state, .. }) = &mut app.integrate_rid { - if *rid == self.rid { - state.insert(self.spec, self.progress); - } + if let Some(MessageHandle { rid, state, .. }) = &mut app.integrate_rid + && *rid == self.rid + { + state.insert(self.spec, self.progress); } } } @@ -339,11 +339,10 @@ impl CheckUpdates { .tag_name .strip_prefix('v') .map(semver::Version::parse), - ) { - if release_version > version { - app.available_update = Some(release); - app.show_update_time = Some(SystemTime::now()); - } + ) && release_version > version + { + app.available_update = Some(release); + app.show_update_time = Some(SystemTime::now()); } } Err(e) => tracing::warn!("failed to fetch update {e}"), @@ -594,10 +593,10 @@ pub struct FetchSelfUpdateProgress { impl FetchSelfUpdateProgress { fn receive(self, app: &mut App) { - if let Some(MessageHandle { rid, state, .. }) = &mut app.self_update_rid { - if *rid == self.rid { - *state = self.progress; - } + if let Some(MessageHandle { rid, state, .. }) = &mut app.self_update_rid + && *rid == self.rid + { + *state = self.progress; } } } diff --git a/src/gui/mod.rs b/src/gui/mod.rs index 4e415f49..22b48598 100644 --- a/src/gui/mod.rs +++ b/src/gui/mod.rs @@ -197,7 +197,7 @@ impl LastAction { let duration = Instant::now().duration_since(self.timestamp); let seconds = duration.as_secs(); if seconds < 60 { - format!("{}s ago", seconds) + format!("{seconds}s ago") } else if seconds < 3600 { format!("{}m ago", seconds / 60) } else { @@ -456,22 +456,22 @@ impl App { ui.add_enabled(false, icon); } - if mc.enabled { - if let Some(req) = &self.integrate_rid { - match req.state.get(&mc.spec) { - Some(SpecFetchProgress::Progress { progress, size }) => { - ui.add( - egui::ProgressBar::new(*progress as f32 / *size as f32) - .show_percentage() - .desired_width(100.0), - ); - } - Some(SpecFetchProgress::Complete) => { - ui.add(egui::ProgressBar::new(1.0).desired_width(100.0)); - } - None => { - ui.spinner(); - } + if mc.enabled + && let Some(req) = &self.integrate_rid + { + match req.state.get(&mc.spec) { + Some(SpecFetchProgress::Progress { progress, size }) => { + ui.add( + egui::ProgressBar::new(*progress as f32 / *size as f32) + .show_percentage() + .desired_width(100.0), + ); + } + Some(SpecFetchProgress::Complete) => { + ui.add(egui::ProgressBar::new(1.0).desired_width(100.0)); + } + None => { + ui.spinner(); } } } @@ -1033,15 +1033,14 @@ impl App { if is_committed(&res) { try_save = true; } - if ui.button("browse").clicked() { - if let Some(fsd_pak) = rfd::FileDialog::new() + if ui.button("browse").clicked() + && let Some(fsd_pak) = rfd::FileDialog::new() .add_filter("DRG Pak", &["pak"]) .pick_file() { window.drg_pak_path = fsd_pak.to_string_lossy().to_string(); window.drg_pak_path_err = None; } - } }); ui.end_row(); @@ -1287,8 +1286,8 @@ impl App { .show(ui, |ui| { const AMBER: Color32 = Color32::from_rgb(255, 191, 0); - if let Some(conflicting_mods) = &report.conflicting_mods { - if !conflicting_mods.is_empty() { + if let Some(conflicting_mods) = &report.conflicting_mods + && !conflicting_mods.is_empty() { CollapsingHeader::new( RichText::new("⚠ Mods(s) with conflicting asset modifications detected") .color(AMBER), @@ -1298,8 +1297,7 @@ impl App { conflicting_mods.iter().for_each(|(path, mods)| { CollapsingHeader::new( RichText::new(format!( - "⚠ Conflicting modification of asset `{}`", - path + "⚠ Conflicting modification of asset `{path}`" )) .color(AMBER), ) @@ -1314,10 +1312,9 @@ impl App { }); }); } - } - if let Some(asset_register_bin_mods) = &report.asset_register_bin_mods { - if !asset_register_bin_mods.is_empty() { + if let Some(asset_register_bin_mods) = &report.asset_register_bin_mods + && !asset_register_bin_mods.is_empty() { CollapsingHeader::new( RichText::new("ℹ Mod(s) with `AssetRegistry.bin` included detected") .color(Color32::LIGHT_BLUE), @@ -1342,10 +1339,9 @@ impl App { ); }); } - } - if let Some(shader_file_mods) = &report.shader_file_mods { - if !shader_file_mods.is_empty() { + if let Some(shader_file_mods) = &report.shader_file_mods + && !shader_file_mods.is_empty() { CollapsingHeader::new( RichText::new( "⚠ Mods(s) with shader files included detected", @@ -1372,10 +1368,9 @@ impl App { ); }); } - } - if let Some(outdated_pak_version_mods) = &report.outdated_pak_version_mods { - if !outdated_pak_version_mods.is_empty() { + if let Some(outdated_pak_version_mods) = &report.outdated_pak_version_mods + && !outdated_pak_version_mods.is_empty() { CollapsingHeader::new( RichText::new( "⚠ Mod(s) with outdated pak version detected", @@ -1397,10 +1392,9 @@ impl App { ); }); } - } - if let Some(empty_archive_mods) = &report.empty_archive_mods { - if !empty_archive_mods.is_empty() { + if let Some(empty_archive_mods) = &report.empty_archive_mods + && !empty_archive_mods.is_empty() { CollapsingHeader::new( RichText::new( "⚠ Mod(s) with empty archives detected", @@ -1420,10 +1414,9 @@ impl App { }); }); } - } - if let Some(archive_with_only_non_pak_files_mods) = &report.archive_with_only_non_pak_files_mods { - if !archive_with_only_non_pak_files_mods.is_empty() { + if let Some(archive_with_only_non_pak_files_mods) = &report.archive_with_only_non_pak_files_mods + && !archive_with_only_non_pak_files_mods.is_empty() { CollapsingHeader::new( RichText::new( "⚠ Mod(s) with only non-`.pak` files detected", @@ -1443,10 +1436,9 @@ impl App { }); }); } - } - if let Some(archive_with_multiple_paks_mods) = &report.archive_with_multiple_paks_mods { - if !archive_with_multiple_paks_mods.is_empty() { + if let Some(archive_with_multiple_paks_mods) = &report.archive_with_multiple_paks_mods + && !archive_with_multiple_paks_mods.is_empty() { CollapsingHeader::new( RichText::new( "⚠ Mod(s) with multiple `.pak`s detected", @@ -1464,10 +1456,9 @@ impl App { }); }); } - } - if let Some(non_asset_file_mods) = &report.non_asset_file_mods { - if !non_asset_file_mods.is_empty() { + if let Some(non_asset_file_mods) = &report.non_asset_file_mods + && !non_asset_file_mods.is_empty() { CollapsingHeader::new( RichText::new( "⚠ Mod(s) with non-asset files detected", @@ -1492,10 +1483,9 @@ impl App { }); }); } - } - if let Some(split_asset_pairs_mods) = &report.split_asset_pairs_mods { - if !split_asset_pairs_mods.is_empty() { + if let Some(split_asset_pairs_mods) = &report.split_asset_pairs_mods + && !split_asset_pairs_mods.is_empty() { CollapsingHeader::new( RichText::new( "⚠ Mod(s) with split {uexp, uasset} pairs detected", @@ -1527,10 +1517,9 @@ impl App { }); }); } - } - if let Some(unmodified_game_assets_mods) = &report.unmodified_game_assets_mods { - if !unmodified_game_assets_mods.is_empty() { + if let Some(unmodified_game_assets_mods) = &report.unmodified_game_assets_mods + && !unmodified_game_assets_mods.is_empty() { CollapsingHeader::new( RichText::new( "⚠ Mod(s) with unmodified game assets detected", @@ -1555,7 +1544,6 @@ impl App { }); }); } - } }); } else { ui.spinner(); @@ -1740,8 +1728,8 @@ impl eframe::App for App { && self.self_update_rid.is_none() && self.state.config.drg_pak_path.is_some(), |ui| { - if let Some(args) = &self.args { - if ui + if let Some(args) = &self.args + && ui .button("Launch game") .on_hover_ui(|ui| { for arg in args { @@ -1749,18 +1737,17 @@ impl eframe::App for App { } }) .clicked() - { - let args = args.clone(); - std::thread::spawn(move || { - let mut iter = args.iter(); - std::process::Command::new(iter.next().unwrap()) - .args(iter) - .spawn() - .unwrap() - .wait() - .unwrap(); - }); - } + { + let args = args.clone(); + std::thread::spawn(move || { + let mut iter = args.iter(); + std::process::Command::new(iter.next().unwrap()) + .args(iter) + .spawn() + .unwrap() + .wait() + .unwrap(); + }); } ui.add_enabled_ui(self.state.config.drg_pak_path.is_some(), |ui| { @@ -1874,18 +1861,17 @@ impl eframe::App for App { if ui.button("⚙").on_hover_text("Open settings").clicked() { self.settings_window = Some(WindowSettings::new(&self.state)); } - if let Some(available_update) = &self.available_update { - if ui + if let Some(available_update) = &self.available_update + && ui .button(egui::RichText::new("\u{26A0}").color(ui.visuals().warn_fg_color)) .on_hover_text(format!( "Update available: {}\n{}", available_update.tag_name, available_update.html_url )) .clicked() - { - ui.ctx() - .open_url(egui::OpenUrl::new_tab(&available_update.html_url)); - } + { + ui.ctx() + .open_url(egui::OpenUrl::new_tab(&available_update.html_url)); } ui.with_layout(egui::Layout::left_to_right(Align::TOP), |ui| { if let Some(last_action) = &self.last_action { diff --git a/src/integrate.rs b/src/integrate.rs index d338fe80..fe9ea0dc 100644 --- a/src/integrate.rs +++ b/src/integrate.rs @@ -854,14 +854,13 @@ fn hook_pcb(asset: &mut Asset) { .iter_mut() .enumerate() .find_map(|(i, e)| { - if let unreal_asset::exports::Export::FunctionExport(func) = e { - if func + if let unreal_asset::exports::Export::FunctionExport(func) = e + && func .get_base_export() .object_name .get_content(|n| n == "ReceiveBeginPlay") - { - return Some((PackageIndex::from_export(i as i32).unwrap(), func)); - } + { + return Some((PackageIndex::from_export(i as i32).unwrap(), func)); } None }) @@ -1065,10 +1064,10 @@ fn patch(asset: &mut Asset) -> Result<(), IntegrationError> { mut statement: TrackedStatement, ) -> Option { walk(&mut statement.ex, &|ex| { - if let KismetExpression::ExCallMath(f) = ex { - if Some(f.stack_node) == is_modded || Some(f.stack_node) == is_modded_sandbox { - *ex = ExFalse::default().into() - } + if let KismetExpression::ExCallMath(f) = ex + && (Some(f.stack_node) == is_modded || Some(f.stack_node) == is_modded_sandbox) + { + *ex = ExFalse::default().into() } }); Some(statement) @@ -1094,12 +1093,12 @@ fn patch_modding_tab(asset: &mut Asset) -> Result<(), Integra for (_pi, statements) in statements.iter_mut() { for statement in statements { walk(&mut statement.ex, &|ex| { - if let KismetExpression::ExSetArray(arr) = ex { - if arr.elements.len() == 2 { - arr.elements.retain(|e| !matches!(e, KismetExpression::ExInstanceVariable(v) if v.variable.new.as_ref().unwrap().path.last().unwrap().get_content(|c| c == "BTN_Modding"))); - if arr.elements.len() != 2 { - info!("patched modding tab visibility"); - } + if let KismetExpression::ExSetArray(arr) = ex + && arr.elements.len() == 2 + { + arr.elements.retain(|e| !matches!(e, KismetExpression::ExInstanceVariable(v) if v.variable.new.as_ref().unwrap().path.last().unwrap().get_content(|c| c == "BTN_Modding"))); + if arr.elements.len() != 2 { + info!("patched modding tab visibility"); } } }); diff --git a/src/main.rs b/src/main.rs index 108e8fbb..f87990e3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -262,6 +262,6 @@ async fn action_lint(dirs: Dirs, action: ActionLint) -> Result<()> { ) }) .await??; - println!("{:#?}", report); + println!("{report:#?}"); Ok(()) } diff --git a/src/mod_lints/asset_register_bin.rs b/src/mod_lints/asset_register_bin.rs index 07927e23..eb222f85 100644 --- a/src/mod_lints/asset_register_bin.rs +++ b/src/mod_lints/asset_register_bin.rs @@ -14,15 +14,15 @@ impl Lint for AssetRegisterBinLint { let mut asset_register_bin_mods = BTreeMap::new(); lcx.for_each_mod_file(|mod_spec, _, _, raw_path, normalized_path| { - if let Some(filename) = raw_path.file_name() { - if filename == "AssetRegistry.bin" { - asset_register_bin_mods - .entry(mod_spec.clone()) - .and_modify(|paths: &mut BTreeSet| { - paths.insert(normalized_path.clone()); - }) - .or_insert_with(|| [normalized_path.clone()].into()); - } + if let Some(filename) = raw_path.file_name() + && filename == "AssetRegistry.bin" + { + asset_register_bin_mods + .entry(mod_spec.clone()) + .and_modify(|paths: &mut BTreeSet| { + paths.insert(normalized_path.clone()); + }) + .or_insert_with(|| [normalized_path.clone()].into()); } Ok(()) diff --git a/src/mod_lints/mod.rs b/src/mod_lints/mod.rs index ece0f927..e8243b7b 100644 --- a/src/mod_lints/mod.rs +++ b/src/mod_lints/mod.rs @@ -106,10 +106,10 @@ impl LintCtxt { }) .collect::>(); - if individual_pak_readers.len() > 1 { - if let Some(ref mut handler) = multiple_pak_files_handler { - handler(mod_spec.clone()); - } + if individual_pak_readers.len() > 1 + && let Some(ref mut handler) = multiple_pak_files_handler + { + handler(mod_spec.clone()); } let mut first_pak_read_seek = individual_pak_readers.remove(0); @@ -173,20 +173,20 @@ pub(crate) fn lint_get_all_files_from_data( .by_index(i) .map_err(|_| LintError::ZipArchiveError)?; - if let Some(p) = file.enclosed_name().as_deref().map(Path::to_path_buf) { - if file.is_file() { - if p.extension().filter(|e| e == &"pak").is_some() { - let mut buf = vec![]; - file.read_to_end(&mut buf)?; - files.push(( - p.to_path_buf(), - PakOrNotPak::Pak(Box::new(Cursor::new(buf))), - )); - } else { - let mut buf = vec![]; - file.read_to_end(&mut buf)?; - files.push((p.to_path_buf(), PakOrNotPak::NotPak)); - } + if let Some(p) = file.enclosed_name().as_deref().map(Path::to_path_buf) + && file.is_file() + { + if p.extension().filter(|e| e == &"pak").is_some() { + let mut buf = vec![]; + file.read_to_end(&mut buf)?; + files.push(( + p.to_path_buf(), + PakOrNotPak::Pak(Box::new(Cursor::new(buf))), + )); + } else { + let mut buf = vec![]; + file.read_to_end(&mut buf)?; + files.push((p.to_path_buf(), PakOrNotPak::NotPak)); } } } diff --git a/src/providers/http.rs b/src/providers/http.rs index 7d5642d2..d46bd5ba 100644 --- a/src/providers/http.rs +++ b/src/providers/http.rs @@ -171,16 +171,16 @@ impl ModProvider for HttpProvider { .with_context(|_| BufferIoSnafu { url: url.0.to_string(), })?; - if let Some(size) = size { - if let Some(tx) = &tx { - tx.send(FetchProgress::Progress { - resolution: res.clone(), - progress: cursor.get_ref().len() as u64, - size, - }) - .await - .unwrap(); - } + if let Some(size) = size + && let Some(tx) = &tx + { + tx.send(FetchProgress::Progress { + resolution: res.clone(), + progress: cursor.get_ref().len() as u64, + size, + }) + .await + .unwrap(); } } diff --git a/src/providers/modio.rs b/src/providers/modio.rs index 3bea1cd6..4fd72c4d 100644 --- a/src/providers/modio.rs +++ b/src/providers/modio.rs @@ -41,9 +41,9 @@ inventory::submit! { fn format_spec(name_id: &str, mod_id: u32, file_id: Option) -> ModSpecification { ModSpecification::new(if let Some(file_id) = file_id { - format!("https://mod.io/g/drg/m/{}#{}/{}", name_id, mod_id, file_id) + format!("https://mod.io/g/drg/m/{name_id}#{mod_id}/{file_id}") } else { - format!("https://mod.io/g/drg/m/{}#{}", name_id, mod_id) + format!("https://mod.io/g/drg/m/{name_id}#{mod_id}") }) } @@ -167,15 +167,15 @@ impl Middleware for LoggingMiddleware { req.url().path() ); let res = next.clone().run(req.try_clone().unwrap(), extensions).await; - if let Ok(res) = &res { - if let Some(retry) = res.headers().get("retry-after") { - info!("retrying after: {}...", retry.to_str().unwrap()); - tokio::time::sleep(tokio::time::Duration::from_secs( - retry.to_str().unwrap().parse::().unwrap(), - )) - .await; - continue; - } + if let Ok(res) = &res + && let Some(retry) = res.headers().get("retry-after") + { + info!("retrying after: {}...", retry.to_str().unwrap()); + tokio::time::sleep(tokio::time::Duration::from_secs( + retry.to_str().unwrap().parse::().unwrap(), + )) + .await; + continue; } return res; } diff --git a/tests/lint/mod.rs b/tests/lint/mod.rs index 669be8cc..23255b9c 100644 --- a/tests/lint/mod.rs +++ b/tests/lint/mod.rs @@ -25,7 +25,7 @@ pub fn test_lint_conflicting_files() { conflicting_mods, .. } = mint::mod_lints::run_lints(&[LintId::CONFLICTING].into(), mods.into(), None).unwrap(); - println!("{:#?}", conflicting_mods); + println!("{conflicting_mods:#?}"); assert_eq!( conflicting_mods.unwrap().get("fsd/content/a.uexp"), @@ -53,7 +53,7 @@ pub fn test_lint_shader() { shader_file_mods, .. } = mint::mod_lints::run_lints(&[LintId::SHADER_FILES].into(), mods.into(), None).unwrap(); - println!("{:#?}", shader_file_mods); + println!("{shader_file_mods:#?}"); assert_eq!( shader_file_mods.unwrap().get(&a_spec), @@ -83,7 +83,7 @@ pub fn test_lint_asset_registry_bin() { } = mint::mod_lints::run_lints(&[LintId::ASSET_REGISTRY_BIN].into(), mods.into(), None) .unwrap(); - println!("{:#?}", asset_register_bin_mods); + println!("{asset_register_bin_mods:#?}"); assert_eq!( asset_register_bin_mods.unwrap().get(&a_spec), @@ -108,7 +108,7 @@ pub fn test_lint_outdated_pak_version() { } = mint::mod_lints::run_lints(&[LintId::OUTDATED_PAK_VERSION].into(), mods.into(), None) .unwrap(); - println!("{:#?}", outdated_pak_version_mods); + println!("{outdated_pak_version_mods:#?}"); assert_eq!( outdated_pak_version_mods.unwrap().get(&outdated_spec), @@ -131,7 +131,7 @@ pub fn test_lint_empty_archive() { empty_archive_mods, .. } = mint::mod_lints::run_lints(&[LintId::EMPTY_ARCHIVE].into(), mods.into(), None).unwrap(); - println!("{:#?}", empty_archive_mods); + println!("{empty_archive_mods:#?}"); assert!(empty_archive_mods.unwrap().contains(&empty_archive_spec)); } @@ -165,7 +165,7 @@ pub fn test_lint_only_non_pak_files() { ) .unwrap(); - println!("{:#?}", archive_with_only_non_pak_files_mods); + println!("{archive_with_only_non_pak_files_mods:#?}"); assert!(archive_with_only_non_pak_files_mods .unwrap() @@ -193,7 +193,7 @@ pub fn test_lint_multi_pak_archive() { ) .unwrap(); - println!("{:#?}", archive_with_multiple_paks_mods); + println!("{archive_with_multiple_paks_mods:#?}"); assert!(archive_with_multiple_paks_mods .unwrap() @@ -216,7 +216,7 @@ pub fn test_lint_non_asset_files() { .. } = mint::mod_lints::run_lints(&[LintId::NON_ASSET_FILES].into(), mods.into(), None).unwrap(); - println!("{:#?}", non_asset_file_mods); + println!("{non_asset_file_mods:#?}"); assert_eq!( non_asset_file_mods.unwrap().get(&non_asset_files_spec), @@ -240,7 +240,7 @@ pub fn test_lint_split_asset_pairs() { .. } = mint::mod_lints::run_lints(&[LintId::SPLIT_ASSET_PAIRS].into(), mods.into(), None).unwrap(); - println!("{:#?}", split_asset_pairs_mods); + println!("{split_asset_pairs_mods:#?}"); assert_eq!( split_asset_pairs_mods.unwrap().get(&split_asset_pairs_spec), @@ -286,7 +286,7 @@ pub fn test_lint_unmodified_game_assets() { ) .unwrap(); - println!("{:#?}", unmodified_game_assets_mods); + println!("{unmodified_game_assets_mods:#?}"); assert_eq!( unmodified_game_assets_mods