mirror of
https://github.com/veeso/termscp.git
synced 2026-09-26 05:51:20 -07:00
chore: enable safe clippy pedantic lints
This commit is contained in:
@@ -123,9 +123,14 @@ unused_lifetimes = "warn"
|
|||||||
[lints.clippy]
|
[lints.clippy]
|
||||||
complexity = { level = "warn", priority = -1 }
|
complexity = { level = "warn", priority = -1 }
|
||||||
correctness = { 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 }
|
perf = { level = "warn", priority = -1 }
|
||||||
|
redundant_closure_for_method_calls = "warn"
|
||||||
style = { level = "warn", priority = -1 }
|
style = { level = "warn", priority = -1 }
|
||||||
suspicious = { level = "warn", priority = -1 }
|
suspicious = { level = "warn", priority = -1 }
|
||||||
|
unnested_or_patterns = "warn"
|
||||||
|
|
||||||
[profile.dev]
|
[profile.dev]
|
||||||
incremental = true
|
incremental = true
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ impl SshKeyStorage {
|
|||||||
/// Resolve host via termscp ssh keys storage
|
/// Resolve host via termscp ssh keys storage
|
||||||
fn resolve_host_in_termscp_storage(&self, host: &str, username: &str) -> Option<&Path> {
|
fn resolve_host_in_termscp_storage(&self, host: &str, username: &str) -> Option<&Path> {
|
||||||
let key: String = Self::make_mapkey(host, username);
|
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
|
/// Resolve host via ssh2 configuration
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ impl FsWatcher {
|
|||||||
|
|
||||||
/// Returns the list of watched paths
|
/// Returns the list of watched paths
|
||||||
pub fn watched_paths(&self) -> Vec<&Path> {
|
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.
|
/// Unwatch provided path.
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ fn handle_input_ev(
|
|||||||
code: Key::Enter, ..
|
code: Key::Enter, ..
|
||||||
}) => Some(Msg::Form(FormMsg::Connect)),
|
}) => Some(Msg::Form(FormMsg::Connect)),
|
||||||
Event::Keyboard(KeyEvent {
|
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,
|
modifiers: KeyModifiers::CONTROL,
|
||||||
}) => Some(Msg::None),
|
}) => Some(Msg::None),
|
||||||
Event::Keyboard(KeyEvent {
|
Event::Keyboard(KeyEvent {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
//! `filetransfer_activity` is the module which implements the Filetransfer activity, which is the main activity afterall
|
//! `filetransfer_activity` is the module which implements the Filetransfer activity, which is the main activity afterall
|
||||||
|
|
||||||
// locals
|
// locals
|
||||||
use std::path::PathBuf;
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
use remotefs::File;
|
use remotefs::File;
|
||||||
|
|
||||||
@@ -163,9 +163,9 @@ impl FileTransferActivity {
|
|||||||
// NOTE: tab and methods are switched on purpose (we resolve from the opposite side)
|
// NOTE: tab and methods are switched on purpose (we resolve from the opposite side)
|
||||||
SyncBrowsingDestination::ParentDir => {
|
SyncBrowsingDestination::ParentDir => {
|
||||||
if is_local {
|
if is_local {
|
||||||
self.remote().wrkdir.parent().map(|x| x.to_path_buf())
|
self.remote().wrkdir.parent().map(Path::to_path_buf)
|
||||||
} else {
|
} else {
|
||||||
self.host_bridge().wrkdir.parent().map(|x| x.to_path_buf())
|
self.host_bridge().wrkdir.parent().map(Path::to_path_buf)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SyncBrowsingDestination::PreviousDir => {
|
SyncBrowsingDestination::PreviousDir => {
|
||||||
|
|||||||
@@ -29,9 +29,9 @@ impl FromStr for Command {
|
|||||||
Err("cd command requires a path".to_string())
|
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())),
|
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) {
|
fn action_exec(&mut self, cmd: String) {
|
||||||
if cmd.is_empty() {
|
if cmd.is_empty() {
|
||||||
self.print_terminal("".to_string());
|
self.print_terminal(String::new());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -191,8 +191,9 @@ impl FileTransferActivity {
|
|||||||
Msg::PendingAction(PendingActionMsg::ReplaceSkipAll),
|
Msg::PendingAction(PendingActionMsg::ReplaceSkipAll),
|
||||||
Msg::PendingAction(PendingActionMsg::ReplaceOverwriteAll),
|
Msg::PendingAction(PendingActionMsg::ReplaceOverwriteAll),
|
||||||
]),
|
]),
|
||||||
Msg::PendingAction(PendingActionMsg::ReplaceOverwrite)
|
Msg::PendingAction(
|
||||||
| Msg::PendingAction(PendingActionMsg::ReplaceOverwriteAll)
|
PendingActionMsg::ReplaceOverwrite | PendingActionMsg::ReplaceOverwriteAll
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
trace!("User wants to replace file");
|
trace!("User wants to replace file");
|
||||||
self.umount_radio_replace();
|
self.umount_radio_replace();
|
||||||
|
|||||||
@@ -87,7 +87,11 @@ impl MockComponent for Log {
|
|||||||
self.props.set(attr, value);
|
self.props.set(attr, value);
|
||||||
if matches!(attr, Attribute::Content) {
|
if matches!(attr, Attribute::Content) {
|
||||||
self.states.set_list_len(
|
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(),
|
Some(spans) => spans.len(),
|
||||||
_ => 0,
|
_ => 0,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ impl ChmodPopup {
|
|||||||
let values: Vec<usize> = state
|
let values: Vec<usize> = state
|
||||||
.unwrap_vec()
|
.unwrap_vec()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|x| x.unwrap_usize())
|
.map(StateValue::unwrap_usize)
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
UnixPexClass::new(
|
UnixPexClass::new(
|
||||||
@@ -161,7 +161,7 @@ impl MockComponent for ChmodPopup {
|
|||||||
|
|
||||||
fn perform(&mut self, cmd: Cmd) -> CmdResult {
|
fn perform(&mut self, cmd: Cmd) -> CmdResult {
|
||||||
match cmd {
|
match cmd {
|
||||||
Cmd::Move(Direction::Left) | Cmd::Move(Direction::Right) => {
|
Cmd::Move(Direction::Left | Direction::Right) => {
|
||||||
self.get_active_checkbox().perform(cmd)
|
self.get_active_checkbox().perform(cmd)
|
||||||
}
|
}
|
||||||
Cmd::Move(Direction::Up) => {
|
Cmd::Move(Direction::Up) => {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use std::path::{Path, PathBuf};
|
|||||||
use tui_realm_stdlib::Input;
|
use tui_realm_stdlib::Input;
|
||||||
use tuirealm::command::{Cmd, CmdResult, Direction, Position};
|
use tuirealm::command::{Cmd, CmdResult, Direction, Position};
|
||||||
use tuirealm::event::{Key, KeyEvent};
|
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::{
|
use tuirealm::{
|
||||||
AttrValue, Attribute, Component, Event, MockComponent, NoUserEvent, State, StateValue,
|
AttrValue, Attribute, Component, Event, MockComponent, NoUserEvent, State, StateValue,
|
||||||
};
|
};
|
||||||
@@ -92,7 +92,7 @@ impl OwnStates {
|
|||||||
match (&self.search, &self.last_suggestion) {
|
match (&self.search, &self.last_suggestion) {
|
||||||
(_, Some(s)) => s.clone(),
|
(_, Some(s)) => s.clone(),
|
||||||
(Some(s), _) => s.clone(),
|
(Some(s), _) => s.clone(),
|
||||||
_ => "".to_string(),
|
_ => String::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,14 +125,14 @@ impl OwnStates {
|
|||||||
if !suggestions.is_empty() {
|
if !suggestions.is_empty() {
|
||||||
let suggestion;
|
let suggestion;
|
||||||
if let Some(last_suggestion) = self.last_suggestion.take() {
|
if let Some(last_suggestion) = self.last_suggestion.take() {
|
||||||
suggestion = suggestions
|
suggestion = (*suggestions
|
||||||
.iter()
|
.iter()
|
||||||
.skip_while(|f| **f != &last_suggestion)
|
.skip_while(|f| **f != &last_suggestion)
|
||||||
.nth(1)
|
.nth(1)
|
||||||
.unwrap_or_else(|| suggestions.first().unwrap())
|
.unwrap_or_else(|| suggestions.first().unwrap()))
|
||||||
.to_string();
|
.clone();
|
||||||
} else {
|
} else {
|
||||||
suggestion = suggestions.first().map(|x| x.to_string()).unwrap();
|
suggestion = suggestions.first().map(ToString::to_string).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
debug!("Suggested: {suggestion}");
|
debug!("Suggested: {suggestion}");
|
||||||
@@ -154,7 +154,7 @@ impl OwnStates {
|
|||||||
let p = PathBuf::from(input_as_path);
|
let p = PathBuf::from(input_as_path);
|
||||||
let parent = p
|
let parent = p
|
||||||
.parent()
|
.parent()
|
||||||
.map(|p| p.to_path_buf())
|
.map(Path::to_path_buf)
|
||||||
.unwrap_or_else(|| PathBuf::from("/"));
|
.unwrap_or_else(|| PathBuf::from("/"));
|
||||||
|
|
||||||
// if path is `.`, then return None
|
// if path is `.`, then return None
|
||||||
@@ -209,7 +209,7 @@ impl MockComponent for GotoPopup {
|
|||||||
.unwrap_payload()
|
.unwrap_payload()
|
||||||
.unwrap_vec()
|
.unwrap_vec()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|x| x.unwrap_str())
|
.map(PropValue::unwrap_str)
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
self.states.set_files(files);
|
self.states.set_files(files);
|
||||||
|
|||||||
@@ -96,22 +96,22 @@ impl MockComponent for TerminalComponent {
|
|||||||
|
|
||||||
let title = self
|
let title = self
|
||||||
.query(Attribute::Title)
|
.query(Attribute::Title)
|
||||||
.map(|value| value.unwrap_string())
|
.map(AttrValue::unwrap_string)
|
||||||
.unwrap_or_else(|| "Terminal".to_string());
|
.unwrap_or_else(|| "Terminal".to_string());
|
||||||
|
|
||||||
let fg = self
|
let fg = self
|
||||||
.query(Attribute::Foreground)
|
.query(Attribute::Foreground)
|
||||||
.map(|value| value.unwrap_color())
|
.map(AttrValue::unwrap_color)
|
||||||
.unwrap_or(tuirealm::ratatui::style::Color::Reset);
|
.unwrap_or(tuirealm::ratatui::style::Color::Reset);
|
||||||
|
|
||||||
let bg = self
|
let bg = self
|
||||||
.query(Attribute::Background)
|
.query(Attribute::Background)
|
||||||
.map(|value| value.unwrap_color())
|
.map(AttrValue::unwrap_color)
|
||||||
.unwrap_or(tuirealm::ratatui::style::Color::Reset);
|
.unwrap_or(tuirealm::ratatui::style::Color::Reset);
|
||||||
|
|
||||||
let border_color = self
|
let border_color = self
|
||||||
.query(Attribute::Borders)
|
.query(Attribute::Borders)
|
||||||
.map(|value| value.unwrap_color())
|
.map(AttrValue::unwrap_color)
|
||||||
.unwrap_or(tuirealm::ratatui::style::Color::Reset);
|
.unwrap_or(tuirealm::ratatui::style::Color::Reset);
|
||||||
|
|
||||||
let terminal = PseudoTerminal::new(self.parser.screen())
|
let terminal = PseudoTerminal::new(self.parser.screen())
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ impl FileList {
|
|||||||
fn has_dot_dot(&self) -> bool {
|
fn has_dot_dot(&self) -> bool {
|
||||||
self.props
|
self.props
|
||||||
.get(Attribute::Custom(PROP_DOT_DOT))
|
.get(Attribute::Custom(PROP_DOT_DOT))
|
||||||
.map(|x| x.unwrap_flag())
|
.map(AttrValue::unwrap_flag)
|
||||||
.unwrap_or(false)
|
.unwrap_or(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -169,7 +169,7 @@ impl MockComponent for FileList {
|
|||||||
let list_items: Vec<ListItem> = match self
|
let list_items: Vec<ListItem> = match self
|
||||||
.props
|
.props
|
||||||
.get(Attribute::Content)
|
.get(Attribute::Content)
|
||||||
.map(|x| x.unwrap_table())
|
.map(AttrValue::unwrap_table)
|
||||||
{
|
{
|
||||||
Some(table) => init_table_iter
|
Some(table) => init_table_iter
|
||||||
.iter()
|
.iter()
|
||||||
@@ -195,7 +195,7 @@ impl MockComponent for FileList {
|
|||||||
let highlighted_color = self
|
let highlighted_color = self
|
||||||
.props
|
.props
|
||||||
.get(Attribute::HighlightedColor)
|
.get(Attribute::HighlightedColor)
|
||||||
.map(|x| x.unwrap_color());
|
.map(AttrValue::unwrap_color);
|
||||||
let modifiers = match focus {
|
let modifiers = match focus {
|
||||||
true => TextModifiers::REVERSED,
|
true => TextModifiers::REVERSED,
|
||||||
false => TextModifiers::empty(),
|
false => TextModifiers::empty(),
|
||||||
@@ -220,7 +220,11 @@ impl MockComponent for FileList {
|
|||||||
self.props.set(attr, value);
|
self.props.set(attr, value);
|
||||||
if matches!(attr, Attribute::Content) {
|
if matches!(attr, Attribute::Content) {
|
||||||
self.states.init_list_states(
|
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(),
|
Some(line) => line.len(),
|
||||||
_ => 0,
|
_ => 0,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ impl FileTransferActivity {
|
|||||||
.username()
|
.username()
|
||||||
.map(|u| format!("{TERM_CYAN}{u}{TERM_RESET}@"))
|
.map(|u| format!("{TERM_CYAN}{u}{TERM_RESET}@"))
|
||||||
})
|
})
|
||||||
.unwrap_or("".to_string());
|
.unwrap_or_default();
|
||||||
let hostname = self.get_hostbridge_hostname();
|
let hostname = self.get_hostbridge_hostname();
|
||||||
format!(
|
format!(
|
||||||
"{username}{TERM_GREEN}{hostname}:{TERM_YELLOW}{}{TERM_RESET}$ ",
|
"{username}{TERM_GREEN}{hostname}:{TERM_YELLOW}{}{TERM_RESET}$ ",
|
||||||
@@ -111,7 +111,7 @@ impl FileTransferActivity {
|
|||||||
.username()
|
.username()
|
||||||
.map(|u| format!("{TERM_CYAN}{u}{TERM_RESET}@"))
|
.map(|u| format!("{TERM_CYAN}{u}{TERM_RESET}@"))
|
||||||
})
|
})
|
||||||
.unwrap_or("".to_string());
|
.unwrap_or_default();
|
||||||
let hostname = self.get_remote_hostname();
|
let hostname = self.get_remote_hostname();
|
||||||
let fmt_path = fmt_path_elide_ex(
|
let fmt_path = fmt_path_elide_ex(
|
||||||
self.remote().wrkdir.as_path(),
|
self.remote().wrkdir.as_path(),
|
||||||
|
|||||||
@@ -457,7 +457,7 @@ impl FileTransferActivity {
|
|||||||
SelectedFile::One(file) => {
|
SelectedFile::One(file) => {
|
||||||
format!("changing mode for {}…", file.name())
|
format!("changing mode for {}…", file.name())
|
||||||
}
|
}
|
||||||
SelectedFile::None => "".to_string(),
|
SelectedFile::None => String::new(),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -469,7 +469,7 @@ fn handle_input_ev(
|
|||||||
}
|
}
|
||||||
Event::Keyboard(KeyEvent {
|
Event::Keyboard(KeyEvent {
|
||||||
// NOTE: escaped control sequence
|
// NOTE: escaped control sequence
|
||||||
code: Key::Char('h') | Key::Char('r') | Key::Char('s'),
|
code: Key::Char('h' | 'r' | 's'),
|
||||||
modifiers: KeyModifiers::CONTROL,
|
modifiers: KeyModifiers::CONTROL,
|
||||||
}) => Some(Msg::None),
|
}) => Some(Msg::None),
|
||||||
Event::Keyboard(KeyEvent {
|
Event::Keyboard(KeyEvent {
|
||||||
|
|||||||
@@ -226,7 +226,7 @@ impl Component<Msg, NoUserEvent> for SshHost {
|
|||||||
}
|
}
|
||||||
Event::Keyboard(KeyEvent {
|
Event::Keyboard(KeyEvent {
|
||||||
// NOTE: escaped control sequence
|
// NOTE: escaped control sequence
|
||||||
code: Key::Char('h') | Key::Char('r') | Key::Char('s'),
|
code: Key::Char('h' | 'r' | 's'),
|
||||||
modifiers: KeyModifiers::CONTROL,
|
modifiers: KeyModifiers::CONTROL,
|
||||||
}) => Some(Msg::None),
|
}) => Some(Msg::None),
|
||||||
Event::Keyboard(KeyEvent {
|
Event::Keyboard(KeyEvent {
|
||||||
|
|||||||
@@ -872,7 +872,7 @@ impl Component<Msg, NoUserEvent> for InputColor {
|
|||||||
}
|
}
|
||||||
Event::Keyboard(KeyEvent {
|
Event::Keyboard(KeyEvent {
|
||||||
// NOTE: escaped control sequence
|
// NOTE: escaped control sequence
|
||||||
code: Key::Char('h') | Key::Char('r') | Key::Char('s'),
|
code: Key::Char('h' | 'r' | 's'),
|
||||||
modifiers: KeyModifiers::CONTROL,
|
modifiers: KeyModifiers::CONTROL,
|
||||||
}) => Some(Msg::None),
|
}) => Some(Msg::None),
|
||||||
Event::Keyboard(KeyEvent {
|
Event::Keyboard(KeyEvent {
|
||||||
|
|||||||
Reference in New Issue
Block a user