mirror of
https://github.com/forkless/NotAlterra.git
synced 2026-08-18 09:19:15 +02:00
Fix all clippy warnings for CI compatibility
This commit is contained in:
+4
-6
@@ -90,14 +90,13 @@ pub fn discover_save_folders() -> Vec<DiscoveredFolder> {
|
||||
if let Some(home) = dirs::home_dir() {
|
||||
for (label, rel) in KNOWN_PATTERNS {
|
||||
let candidate = home.join(rel);
|
||||
if candidate.exists() && candidate.is_dir() {
|
||||
if has_save_files(&candidate) && seen.insert(candidate.clone()) {
|
||||
if candidate.exists() && candidate.is_dir()
|
||||
&& has_save_files(&candidate) && seen.insert(candidate.clone()) {
|
||||
found.push(DiscoveredFolder {
|
||||
label: label.to_string(),
|
||||
path: candidate,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -309,14 +308,13 @@ fn walk_for_subnautica(
|
||||
let path = entry.path();
|
||||
let name = path.file_name().map(|n| n.to_string_lossy().to_lowercase()).unwrap_or_default();
|
||||
|
||||
if name.contains("subnautica") {
|
||||
if has_save_files(&path) && seen.insert(path.clone()) {
|
||||
if name.contains("subnautica")
|
||||
&& has_save_files(&path) && seen.insert(path.clone()) {
|
||||
found.push(DiscoveredFolder {
|
||||
label: label.to_string(),
|
||||
path: path.clone(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if path.is_dir() {
|
||||
queue.push_back(path);
|
||||
|
||||
@@ -118,8 +118,6 @@ pub fn sanitize_path(p: &str) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
/// Check whether a path looks like a network/UNC path (for warning purposes).
|
||||
|
||||
/// Check whether a path looks like a network/UNC path (for warning purposes).
|
||||
pub fn is_network_path(p: &str) -> bool {
|
||||
p.starts_with("\\\\") || p.starts_with("//")
|
||||
|
||||
+9
-12
@@ -85,8 +85,8 @@ impl App {
|
||||
|
||||
let save_folder = config.save_path.as_deref().map(PathBuf::from);
|
||||
|
||||
let mut tui_state = tui::AppState::default();
|
||||
tui_state.version = VERSION.to_string();
|
||||
let mut tui_state = tui::AppState { version: VERSION.to_string(), ..Default::default() };
|
||||
|
||||
tui_state.save_path = save_folder.as_ref().map(|p| p.display().to_string());
|
||||
|
||||
// Refresh stats for the dashboard
|
||||
@@ -231,9 +231,8 @@ fn run_app<B: Backend>(terminal: &mut Terminal<B>) -> Result<()> {
|
||||
4 => action_inspect_saves(terminal, &mut app)?,
|
||||
5 => run_ini_submenu(terminal, &mut app)?,
|
||||
6 => {
|
||||
match run_disclaimer(terminal, &mut app)? {
|
||||
Some(false) => return Ok(()), // declined → exit
|
||||
_ => {} // accepted or cancelled → stay
|
||||
if let Some(false) = run_disclaimer(terminal, &mut app)? {
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
7 => return Ok(()), // Exit
|
||||
@@ -300,9 +299,8 @@ fn run_disclaimer<B: Backend>(terminal: &mut Terminal<B>, app: &mut App) -> Resu
|
||||
/// Scan the local filesystem for Subnautica 2 save folders.
|
||||
///
|
||||
/// Spawns a background thread for the scan and shows a live elapsed timer.
|
||||
/// Caches the first match as `save_path` in config.ini.
|
||||
// ── menu actions ───────────────────────────────────────────────────────────
|
||||
|
||||
/// Caches the first match as `save_path` in config.ini.
|
||||
fn action_locate_saves<B: Backend>(terminal: &mut Terminal<B>, app: &mut App) -> Result<()> {
|
||||
// Run scan on a background thread so we can show a live elapsed timer.
|
||||
let (tx, rx) = std::sync::mpsc::channel();
|
||||
@@ -879,8 +877,8 @@ fn ini_delete_action<B: Backend>(
|
||||
let name = file_name.to_string_lossy();
|
||||
name.starts_with("ini_backup_")
|
||||
&& e.path().is_dir()
|
||||
&& std::fs::read_dir(e.path()).map_or(false, |mut d| {
|
||||
d.any(|f| f.ok().map_or(false, |f| {
|
||||
&& std::fs::read_dir(e.path()).is_ok_and(|mut d| {
|
||||
d.any(|f| f.ok().is_some_and(|f| {
|
||||
f.file_name().to_string_lossy().ends_with(".ini")
|
||||
}))
|
||||
})
|
||||
@@ -943,7 +941,7 @@ fn action_inspect_saves<B: Backend>(terminal: &mut Terminal<B>, app: &mut App) -
|
||||
let item_refs: Vec<&str> = items.iter().map(|s| s.as_str()).collect();
|
||||
let filenames: Vec<String> = files.iter().map(|e| e.file_name().to_string_lossy().to_string()).collect();
|
||||
let descs = vec!["Press Enter to view full GVAS metadata"; files.len()];
|
||||
let desc_refs: Vec<&str> = descs.iter().map(|s| *s).collect();
|
||||
let desc_refs: Vec<&str> = descs.to_vec();
|
||||
let mut state = ListState::default().with_selected(Some(2)); // skip header + blank
|
||||
|
||||
loop {
|
||||
@@ -1118,7 +1116,7 @@ fn ok_dialog<B: Backend>(terminal: &mut Terminal<B>, app: &App, title: &str, msg
|
||||
/// Internal helper — see module-level documentation for context.
|
||||
fn has_existing_backup(app: &App) -> bool {
|
||||
let root = app.backup_root();
|
||||
root.exists() && std::fs::read_dir(&root).map_or(false, |mut d| d.any(|e| e.map_or(false, |e| e.path().is_dir())))
|
||||
root.exists() && std::fs::read_dir(&root).is_ok_and(|mut d| d.any(|e| e.is_ok_and(|e| e.path().is_dir())))
|
||||
}
|
||||
|
||||
/// Internal helper — see module-level documentation for context.
|
||||
@@ -1211,7 +1209,6 @@ fn wait_for_key<B: Backend>(terminal: &mut Terminal<B>, app: &App) -> Result<()>
|
||||
Ok(())
|
||||
}
|
||||
/// Create a rectangle anchored to the bottom of the parent area.
|
||||
|
||||
fn centered_bottom(area: Rect) -> Rect {
|
||||
Rect {
|
||||
x: area.x,
|
||||
|
||||
+5
-5
@@ -245,8 +245,8 @@ pub fn delete_ini_files(config_path: &Path, backup_root: &Path) -> Result<usize>
|
||||
let name = file_name.to_string_lossy();
|
||||
name.starts_with("ini_backup_")
|
||||
&& e.path().is_dir()
|
||||
&& std::fs::read_dir(e.path()).map_or(false, |mut d| {
|
||||
d.any(|f| f.ok().map_or(false, |f| {
|
||||
&& std::fs::read_dir(e.path()).is_ok_and(|mut d| {
|
||||
d.any(|f| f.ok().is_some_and(|f| {
|
||||
f.file_name().to_string_lossy().ends_with(".ini")
|
||||
}))
|
||||
})
|
||||
@@ -438,8 +438,8 @@ pub fn folder_stats(
|
||||
let name = file_name.to_string_lossy();
|
||||
name.starts_with("ini_backup_")
|
||||
&& e.path().is_dir()
|
||||
&& std::fs::read_dir(e.path()).map_or(false, |mut d| {
|
||||
d.any(|f| f.ok().map_or(false, |f| {
|
||||
&& std::fs::read_dir(e.path()).is_ok_and(|mut d| {
|
||||
d.any(|f| f.ok().is_some_and(|f| {
|
||||
f.file_name().to_string_lossy().ends_with(".ini")
|
||||
}))
|
||||
})
|
||||
@@ -470,7 +470,7 @@ fn copy_save_files(
|
||||
}
|
||||
if meta.is_file() && name_str.starts_with("savegame_") {
|
||||
let dest_path = dest.join(&name);
|
||||
fs::copy(&entry.path(), &dest_path)?;
|
||||
fs::copy(entry.path(), &dest_path)?;
|
||||
*count += 1;
|
||||
*total_size += meta.len();
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
//! Design principles:
|
||||
//! - Dashboard layout: header bar, main panel, status line
|
||||
//! - Keyboard-first: arrow keys + Enter/Esc, no mouse dependency
|
||||
//!
|
||||
//! Terminal UI rendering for NotAlterra.
|
||||
//!
|
||||
//! Uses ratatui + crossterm to draw menu screens, picker lists, dialogs,
|
||||
|
||||
Reference in New Issue
Block a user