Address Clippy warnings
This commit is contained in:
parent
5028e16c5b
commit
3c4603dc7b
13 changed files with 38 additions and 36 deletions
|
|
@ -17,11 +17,11 @@ use crate::diags;
|
|||
use core::{
|
||||
action::Action,
|
||||
components::{
|
||||
footer::Footer, fps::FpsCounter, left::Left, popup, right::Right, state::StatefulList,
|
||||
title::Title, Component,
|
||||
Component, footer::Footer, fps::FpsCounter, left::Left, popup, right::Right,
|
||||
state::StatefulList, title::Title,
|
||||
},
|
||||
config::Config,
|
||||
line::{get_disk_description_right, get_part_description, DVLine},
|
||||
line::{DVLine, get_disk_description_right, get_part_description},
|
||||
state::{CloneSettings, Mode},
|
||||
system::{
|
||||
boot::{self, SafeMode},
|
||||
|
|
@ -894,7 +894,7 @@ fn build_right_items(app: &App) -> Action {
|
|||
line_colors: vec![Color::Reset],
|
||||
},
|
||||
]);
|
||||
header_lines.append(&mut get_disk_description_right(&disk, Some(parts)));
|
||||
header_lines.append(&mut get_disk_description_right(disk, Some(parts)));
|
||||
|
||||
// Add header
|
||||
if !header_lines.is_empty() {
|
||||
|
|
@ -957,10 +957,10 @@ fn build_right_items(app: &App) -> Action {
|
|||
let disk_list = app.clone.disk_list.lock().unwrap();
|
||||
disk_list
|
||||
.iter()
|
||||
.for_each(|disk| items.push(get_disk_description_right(&disk, None)));
|
||||
.for_each(|disk| items.push(get_disk_description_right(disk, None)));
|
||||
}
|
||||
Mode::SelectParts => {
|
||||
vec!["Boot", "OS"].iter().for_each(|s| {
|
||||
["Boot", "OS"].iter().for_each(|s| {
|
||||
labels.push(vec![DVLine {
|
||||
line_parts: vec![String::from(*s)],
|
||||
line_colors: vec![Color::Cyan],
|
||||
|
|
@ -971,12 +971,12 @@ fn build_right_items(app: &App) -> Action {
|
|||
let disk_list = app.clone.disk_list.lock().unwrap();
|
||||
if let Some(disk) = disk_list.get(index) {
|
||||
// Disk Details
|
||||
items.push(get_disk_description_right(&disk, None));
|
||||
items.push(get_disk_description_right(disk, None));
|
||||
|
||||
// Partition Details
|
||||
disk.parts
|
||||
.iter()
|
||||
.for_each(|part| items.push(get_part_description(&part)));
|
||||
.for_each(|part| items.push(get_part_description(part)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@
|
|||
//
|
||||
use clap::Parser;
|
||||
use color_eyre::Result;
|
||||
use core;
|
||||
|
||||
use crate::app::App;
|
||||
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ impl Component for Footer {
|
|||
}
|
||||
|
||||
fn update(&mut self, action: Action) -> Result<Option<Action>> {
|
||||
#[allow(clippy::single_match)]
|
||||
match action {
|
||||
Action::UpdateFooter(text) => self.text = text,
|
||||
_ => {}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ use ratatui::{
|
|||
};
|
||||
use tokio::sync::mpsc::UnboundedSender;
|
||||
|
||||
use super::{state::StatefulList, Component};
|
||||
use super::{Component, state::StatefulList};
|
||||
use crate::{action::Action, config::Config};
|
||||
|
||||
#[derive(Default)]
|
||||
|
|
@ -167,7 +167,7 @@ impl Component for Left {
|
|||
.map(|(index, item)| {
|
||||
let mut style = Style::default();
|
||||
let text = if self.selections[0].is_some_and(|first_index| first_index == index) {
|
||||
if let Some(label) = self.labels.get(0) {
|
||||
if let Some(label) = self.labels.first() {
|
||||
style = style.yellow();
|
||||
label.as_str()
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ use ratatui::{
|
|||
};
|
||||
use tokio::sync::mpsc::UnboundedSender;
|
||||
|
||||
use super::{state::StatefulList, Component};
|
||||
use super::{Component, state::StatefulList};
|
||||
use crate::{action::Action, config::Config, line::DVLine};
|
||||
|
||||
#[derive(Default)]
|
||||
|
|
@ -150,7 +150,7 @@ impl Component for Right {
|
|||
// First selection
|
||||
if let Some(first_index) = self.get_first() {
|
||||
if let Some(first_desc) = self.list.get(first_index) {
|
||||
if let Some(label) = self.list_labels.get(0) {
|
||||
if let Some(label) = self.list_labels.first() {
|
||||
label
|
||||
.iter()
|
||||
.for_each(|dv| body_text.push(dv.as_line().bold()));
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ impl Component for Title {
|
|||
}
|
||||
|
||||
fn update(&mut self, action: Action) -> Result<Option<Action>> {
|
||||
#[allow(clippy::match_single_binding)]
|
||||
match action {
|
||||
_ => {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ use derive_deref::{Deref, DerefMut};
|
|||
use directories::ProjectDirs;
|
||||
use lazy_static::lazy_static;
|
||||
use ratatui::style::{Color, Modifier, Style};
|
||||
use serde::{de::Deserializer, Deserialize};
|
||||
use serde::{Deserialize, de::Deserializer};
|
||||
use tracing::error;
|
||||
|
||||
use crate::{action::Action, state::Mode};
|
||||
|
|
@ -54,7 +54,7 @@ pub struct Config {
|
|||
pub styles: Styles,
|
||||
}
|
||||
|
||||
pub static PROJECT_NAME: &'static str = "DEJA-VU";
|
||||
pub static PROJECT_NAME: &str = "DEJA-VU";
|
||||
lazy_static! {
|
||||
//pub static ref PROJECT_NAME: String = env!("CARGO_PKG_NAME").to_uppercase().to_string();
|
||||
pub static ref DATA_FOLDER: Option<PathBuf> =
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ pub fn get_disk_description_right(
|
|||
let mut line_parts = vec![line.clone()];
|
||||
let mut line_colors = vec![Color::Reset];
|
||||
if let Some(indicies) = &boot_os_indicies {
|
||||
let boot_index = indicies.get(0);
|
||||
let boot_index = indicies.first();
|
||||
if boot_index.is_some_and(|i| i == &index) {
|
||||
line_parts.push(String::from(" <-- Boot Partition"));
|
||||
line_colors.push(Color::Cyan);
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ use std::{
|
|||
path::PathBuf,
|
||||
process::{Command, Stdio},
|
||||
sync::{Arc, Mutex},
|
||||
thread::{self, sleep, JoinHandle},
|
||||
thread::{self, JoinHandle, sleep},
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
|
|
@ -180,7 +180,7 @@ impl Tasks {
|
|||
));
|
||||
}
|
||||
TaskType::Diskpart(ref script) => {
|
||||
self.cur_handle = Some(run_task_diskpart(&script, task_tx));
|
||||
self.cur_handle = Some(run_task_diskpart(script, task_tx));
|
||||
}
|
||||
TaskType::ScanDisks => {
|
||||
let disk_list_arc = self.disk_list.clone();
|
||||
|
|
@ -261,7 +261,9 @@ fn run_task_command(
|
|||
let stdout = parse_bytes_as_str(output.stdout.to_owned());
|
||||
let task_result = TaskResult::Output(stdout, stderr, output.status.success());
|
||||
let err_str = format!("Failed to send TaskResult: {:?}", &task_result);
|
||||
task_tx.send(task_result).expect(err_str.as_str());
|
||||
task_tx
|
||||
.send(task_result)
|
||||
.unwrap_or_else(|_| panic!("{}", err_str));
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
@ -280,7 +282,9 @@ fn run_task_diskpart(script: &str, task_tx: mpsc::UnboundedSender<TaskResult>) -
|
|||
let stdout = parse_bytes_as_str(output.stdout.to_owned());
|
||||
let task_result = TaskResult::Output(stdout, stderr, output.status.success());
|
||||
let err_str = format!("Failed to send TaskResult: {:?}", &task_result);
|
||||
task_tx.send(task_result).expect(err_str.as_str());
|
||||
task_tx
|
||||
.send(task_result)
|
||||
.unwrap_or_else(|_| panic!("{}", err_str));
|
||||
})
|
||||
} else {
|
||||
// Simulate task if not running under Windows
|
||||
|
|
|
|||
|
|
@ -16,11 +16,11 @@
|
|||
use core::{
|
||||
action::Action,
|
||||
components::{
|
||||
footer::Footer, fps::FpsCounter, left::Left, popup, right::Right, state::StatefulList,
|
||||
title::Title, Component,
|
||||
Component, footer::Footer, fps::FpsCounter, left::Left, popup, right::Right,
|
||||
state::StatefulList, title::Title,
|
||||
},
|
||||
config::Config,
|
||||
line::{get_disk_description_right, get_part_description, DVLine},
|
||||
line::{DVLine, get_disk_description_right, get_part_description},
|
||||
state::{CloneSettings, Mode},
|
||||
system::{
|
||||
boot, cpu::get_cpu_name, disk::PartitionTableType, diskpart::build_dest_format_script,
|
||||
|
|
@ -100,7 +100,7 @@ impl App {
|
|||
}
|
||||
|
||||
pub fn prev_mode(&mut self) -> Option<Mode> {
|
||||
let new_mode = match self.cur_mode {
|
||||
match self.cur_mode {
|
||||
Mode::Home => Some(Mode::Home),
|
||||
Mode::Failed => Some(Mode::Failed),
|
||||
Mode::Done => Some(Mode::Done),
|
||||
|
|
@ -122,8 +122,7 @@ impl App {
|
|||
| Mode::InjectDrivers
|
||||
| Mode::PEMenu
|
||||
| Mode::SetBootMode => panic!("This shouldn't happen?"),
|
||||
};
|
||||
new_mode
|
||||
}
|
||||
}
|
||||
|
||||
pub fn next_mode(&mut self) -> Option<Mode> {
|
||||
|
|
@ -770,10 +769,10 @@ fn build_right_items(app: &App, cur_mode: Mode) -> Action {
|
|||
let disk_list = app.clone.disk_list.lock().unwrap();
|
||||
disk_list
|
||||
.iter()
|
||||
.for_each(|disk| items.push(get_disk_description_right(&disk, None)));
|
||||
.for_each(|disk| items.push(get_disk_description_right(disk, None)));
|
||||
}
|
||||
Mode::SelectParts => {
|
||||
vec!["Boot", "OS"].iter().for_each(|s| {
|
||||
["Boot", "OS"].iter().for_each(|s| {
|
||||
labels.push(vec![DVLine {
|
||||
line_parts: vec![String::from(*s)],
|
||||
line_colors: vec![Color::Cyan],
|
||||
|
|
@ -784,12 +783,12 @@ fn build_right_items(app: &App, cur_mode: Mode) -> Action {
|
|||
let disk_list = app.clone.disk_list.lock().unwrap();
|
||||
if let Some(disk) = disk_list.get(index) {
|
||||
// Disk Details
|
||||
items.push(get_disk_description_right(&disk, None));
|
||||
items.push(get_disk_description_right(disk, None));
|
||||
|
||||
// Partition Details
|
||||
disk.parts
|
||||
.iter()
|
||||
.for_each(|part| items.push(get_part_description(&part)));
|
||||
.for_each(|part| items.push(get_part_description(part)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@
|
|||
//
|
||||
use clap::Parser;
|
||||
use color_eyre::Result;
|
||||
use core;
|
||||
|
||||
use crate::app::App;
|
||||
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@
|
|||
use core::{
|
||||
action::Action,
|
||||
components::{
|
||||
footer::Footer, fps::FpsCounter, left::Left, popup, right::Right, state::StatefulList,
|
||||
title::Title, Component,
|
||||
Component, footer::Footer, fps::FpsCounter, left::Left, popup, right::Right,
|
||||
state::StatefulList, title::Title,
|
||||
},
|
||||
config::Config,
|
||||
line::DVLine,
|
||||
|
|
@ -230,7 +230,7 @@ impl App {
|
|||
// Run selected tool
|
||||
if let Some(tool) = self.list.get_selected() {
|
||||
info!("Run tool: {:?}", &tool);
|
||||
self.tasks.add(build_tool_command(&self, &tool));
|
||||
self.tasks.add(build_tool_command(self, &tool));
|
||||
}
|
||||
}
|
||||
Action::Resize(w, h) => self.handle_resize(tui, w, h)?,
|
||||
|
|
@ -453,7 +453,7 @@ pub fn load_tools() -> Vec<Tool> {
|
|||
entries
|
||||
.iter()
|
||||
.map(|entry| {
|
||||
let contents = fs::read_to_string(&entry).expect("Failed to read tool config file");
|
||||
let contents = fs::read_to_string(entry).expect("Failed to read tool config file");
|
||||
let tool: Tool = toml::from_str(&contents).expect("Failed to parse tool config file");
|
||||
tool
|
||||
})
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@
|
|||
//
|
||||
use clap::Parser;
|
||||
use color_eyre::Result;
|
||||
use core;
|
||||
|
||||
use crate::app::App;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue