chore: enable safe clippy pedantic lints

This commit is contained in:
Christian Visintin
2026-03-21 15:43:16 +01:00
parent bede4adaeb
commit 1acb8b2a60
17 changed files with 50 additions and 36 deletions

View File

@@ -123,9 +123,14 @@ unused_lifetimes = "warn"
[lints.clippy]
complexity = { level = "warn", priority = -1 }
correctness = { level = "warn", priority = -1 }
cloned_instead_of_copied = "warn"
implicit_clone = "warn"
manual_string_new = "warn"
perf = { level = "warn", priority = -1 }
redundant_closure_for_method_calls = "warn"
style = { level = "warn", priority = -1 }
suspicious = { level = "warn", priority = -1 }
unnested_or_patterns = "warn"
[profile.dev]
incremental = true

View File

@@ -40,7 +40,7 @@ impl SshKeyStorage {
/// Resolve host via termscp ssh keys storage
fn resolve_host_in_termscp_storage(&self, host: &str, username: &str) -> Option<&Path> {
let key: String = Self::make_mapkey(host, username);
self.hosts.get(&key).map(|x| x.as_path())
self.hosts.get(&key).map(PathBuf::as_path)
}
/// Resolve host via ssh2 configuration

View File

@@ -160,7 +160,7 @@ impl FsWatcher {
/// Returns the list of watched paths
pub fn watched_paths(&self) -> Vec<&Path> {
Vec::from_iter(self.paths.keys().map(|x| x.as_path()))
Vec::from_iter(self.paths.keys().map(PathBuf::as_path))
}
/// Unwatch provided path.

View File

@@ -97,7 +97,7 @@ fn handle_input_ev(
code: Key::Enter, ..
}) => Some(Msg::Form(FormMsg::Connect)),
Event::Keyboard(KeyEvent {
code: Key::Char('c') | Key::Char('h') | Key::Char('r') | Key::Char('s'),
code: Key::Char('c' | 'h' | 'r' | 's'),
modifiers: KeyModifiers::CONTROL,
}) => Some(Msg::None),
Event::Keyboard(KeyEvent {

View File

@@ -3,7 +3,7 @@
//! `filetransfer_activity` is the module which implements the Filetransfer activity, which is the main activity afterall
// locals
use std::path::PathBuf;
use std::path::{Path, PathBuf};
use remotefs::File;
@@ -163,9 +163,9 @@ impl FileTransferActivity {
// NOTE: tab and methods are switched on purpose (we resolve from the opposite side)
SyncBrowsingDestination::ParentDir => {
if is_local {
self.remote().wrkdir.parent().map(|x| x.to_path_buf())
self.remote().wrkdir.parent().map(Path::to_path_buf)
} else {
self.host_bridge().wrkdir.parent().map(|x| x.to_path_buf())
self.host_bridge().wrkdir.parent().map(Path::to_path_buf)
}
}
SyncBrowsingDestination::PreviousDir => {

View File

@@ -29,9 +29,9 @@ impl FromStr for Command {
Err("cd command requires a path".to_string())
}
}
Some("exit") | Some("logout") => Ok(Command::Exit),
Some("exit" | "logout") => Ok(Command::Exit),
Some(_) => Ok(Command::Exec(s.to_string())),
None => Err("".to_string()),
None => Err(String::new()),
}
}
}
@@ -43,7 +43,7 @@ impl FileTransferActivity {
fn action_exec(&mut self, cmd: String) {
if cmd.is_empty() {
self.print_terminal("".to_string());
self.print_terminal(String::new());
return;
}

View File

@@ -191,8 +191,9 @@ impl FileTransferActivity {
Msg::PendingAction(PendingActionMsg::ReplaceSkipAll),
Msg::PendingAction(PendingActionMsg::ReplaceOverwriteAll),
]),
Msg::PendingAction(PendingActionMsg::ReplaceOverwrite)
| Msg::PendingAction(PendingActionMsg::ReplaceOverwriteAll)
Msg::PendingAction(
PendingActionMsg::ReplaceOverwrite | PendingActionMsg::ReplaceOverwriteAll
)
) {
trace!("User wants to replace file");
self.umount_radio_replace();

View File

@@ -87,7 +87,11 @@ impl MockComponent for Log {
self.props.set(attr, value);
if matches!(attr, Attribute::Content) {
self.states.set_list_len(
match self.props.get(Attribute::Content).map(|x| x.unwrap_table()) {
match self
.props
.get(Attribute::Content)
.map(AttrValue::unwrap_table)
{
Some(spans) => spans.len(),
_ => 0,
},

View File

@@ -127,7 +127,7 @@ impl ChmodPopup {
let values: Vec<usize> = state
.unwrap_vec()
.into_iter()
.map(|x| x.unwrap_usize())
.map(StateValue::unwrap_usize)
.collect();
UnixPexClass::new(
@@ -161,7 +161,7 @@ impl MockComponent for ChmodPopup {
fn perform(&mut self, cmd: Cmd) -> CmdResult {
match cmd {
Cmd::Move(Direction::Left) | Cmd::Move(Direction::Right) => {
Cmd::Move(Direction::Left | Direction::Right) => {
self.get_active_checkbox().perform(cmd)
}
Cmd::Move(Direction::Up) => {

View File

@@ -3,7 +3,7 @@ use std::path::{Path, PathBuf};
use tui_realm_stdlib::Input;
use tuirealm::command::{Cmd, CmdResult, Direction, Position};
use tuirealm::event::{Key, KeyEvent};
use tuirealm::props::{Alignment, BorderType, Borders, Color, InputType, Style};
use tuirealm::props::{Alignment, BorderType, Borders, Color, InputType, PropValue, Style};
use tuirealm::{
AttrValue, Attribute, Component, Event, MockComponent, NoUserEvent, State, StateValue,
};
@@ -92,7 +92,7 @@ impl OwnStates {
match (&self.search, &self.last_suggestion) {
(_, Some(s)) => s.clone(),
(Some(s), _) => s.clone(),
_ => "".to_string(),
_ => String::new(),
}
}
@@ -125,14 +125,14 @@ impl OwnStates {
if !suggestions.is_empty() {
let suggestion;
if let Some(last_suggestion) = self.last_suggestion.take() {
suggestion = suggestions
suggestion = (*suggestions
.iter()
.skip_while(|f| **f != &last_suggestion)
.nth(1)
.unwrap_or_else(|| suggestions.first().unwrap())
.to_string();
.unwrap_or_else(|| suggestions.first().unwrap()))
.clone();
} else {
suggestion = suggestions.first().map(|x| x.to_string()).unwrap();
suggestion = suggestions.first().map(ToString::to_string).unwrap();
}
debug!("Suggested: {suggestion}");
@@ -154,7 +154,7 @@ impl OwnStates {
let p = PathBuf::from(input_as_path);
let parent = p
.parent()
.map(|p| p.to_path_buf())
.map(Path::to_path_buf)
.unwrap_or_else(|| PathBuf::from("/"));
// if path is `.`, then return None
@@ -209,7 +209,7 @@ impl MockComponent for GotoPopup {
.unwrap_payload()
.unwrap_vec()
.into_iter()
.map(|x| x.unwrap_str())
.map(PropValue::unwrap_str)
.collect();
self.states.set_files(files);

View File

@@ -96,22 +96,22 @@ impl MockComponent for TerminalComponent {
let title = self
.query(Attribute::Title)
.map(|value| value.unwrap_string())
.map(AttrValue::unwrap_string)
.unwrap_or_else(|| "Terminal".to_string());
let fg = self
.query(Attribute::Foreground)
.map(|value| value.unwrap_color())
.map(AttrValue::unwrap_color)
.unwrap_or(tuirealm::ratatui::style::Color::Reset);
let bg = self
.query(Attribute::Background)
.map(|value| value.unwrap_color())
.map(AttrValue::unwrap_color)
.unwrap_or(tuirealm::ratatui::style::Color::Reset);
let border_color = self
.query(Attribute::Borders)
.map(|value| value.unwrap_color())
.map(AttrValue::unwrap_color)
.unwrap_or(tuirealm::ratatui::style::Color::Reset);
let terminal = PseudoTerminal::new(self.parser.screen())

View File

@@ -136,7 +136,7 @@ impl FileList {
fn has_dot_dot(&self) -> bool {
self.props
.get(Attribute::Custom(PROP_DOT_DOT))
.map(|x| x.unwrap_flag())
.map(AttrValue::unwrap_flag)
.unwrap_or(false)
}
}
@@ -169,7 +169,7 @@ impl MockComponent for FileList {
let list_items: Vec<ListItem> = match self
.props
.get(Attribute::Content)
.map(|x| x.unwrap_table())
.map(AttrValue::unwrap_table)
{
Some(table) => init_table_iter
.iter()
@@ -195,7 +195,7 @@ impl MockComponent for FileList {
let highlighted_color = self
.props
.get(Attribute::HighlightedColor)
.map(|x| x.unwrap_color());
.map(AttrValue::unwrap_color);
let modifiers = match focus {
true => TextModifiers::REVERSED,
false => TextModifiers::empty(),
@@ -220,7 +220,11 @@ impl MockComponent for FileList {
self.props.set(attr, value);
if matches!(attr, Attribute::Content) {
self.states.init_list_states(
match self.props.get(Attribute::Content).map(|x| x.unwrap_table()) {
match self
.props
.get(Attribute::Content)
.map(AttrValue::unwrap_table)
{
Some(line) => line.len(),
_ => 0,
},

View File

@@ -91,7 +91,7 @@ impl FileTransferActivity {
.username()
.map(|u| format!("{TERM_CYAN}{u}{TERM_RESET}@"))
})
.unwrap_or("".to_string());
.unwrap_or_default();
let hostname = self.get_hostbridge_hostname();
format!(
"{username}{TERM_GREEN}{hostname}:{TERM_YELLOW}{}{TERM_RESET}$ ",
@@ -111,7 +111,7 @@ impl FileTransferActivity {
.username()
.map(|u| format!("{TERM_CYAN}{u}{TERM_RESET}@"))
})
.unwrap_or("".to_string());
.unwrap_or_default();
let hostname = self.get_remote_hostname();
let fmt_path = fmt_path_elide_ex(
self.remote().wrkdir.as_path(),

View File

@@ -457,7 +457,7 @@ impl FileTransferActivity {
SelectedFile::One(file) => {
format!("changing mode for {}", file.name())
}
SelectedFile::None => "".to_string(),
SelectedFile::None => String::new(),
},
);
}

View File

@@ -469,7 +469,7 @@ fn handle_input_ev(
}
Event::Keyboard(KeyEvent {
// NOTE: escaped control sequence
code: Key::Char('h') | Key::Char('r') | Key::Char('s'),
code: Key::Char('h' | 'r' | 's'),
modifiers: KeyModifiers::CONTROL,
}) => Some(Msg::None),
Event::Keyboard(KeyEvent {

View File

@@ -226,7 +226,7 @@ impl Component<Msg, NoUserEvent> for SshHost {
}
Event::Keyboard(KeyEvent {
// NOTE: escaped control sequence
code: Key::Char('h') | Key::Char('r') | Key::Char('s'),
code: Key::Char('h' | 'r' | 's'),
modifiers: KeyModifiers::CONTROL,
}) => Some(Msg::None),
Event::Keyboard(KeyEvent {

View File

@@ -872,7 +872,7 @@ impl Component<Msg, NoUserEvent> for InputColor {
}
Event::Keyboard(KeyEvent {
// NOTE: escaped control sequence
code: Key::Char('h') | Key::Char('r') | Key::Char('s'),
code: Key::Char('h' | 'r' | 's'),
modifiers: KeyModifiers::CONTROL,
}) => Some(Msg::None),
Event::Keyboard(KeyEvent {