Commit

Author:

Hash:

Timestamp:

+17 -29 +/-6 browse

Kevin Schoon [me@kevinschoon.com]

5152ce6178a66649babe22977c46b031c118db99

Tue, 05 Aug 2025 15:20:42 +0000 (3 months ago)

appease clippy
1diff --git a/ayllu-keys/src/main.rs b/ayllu-keys/src/main.rs
2index 4602c97..281cbfb 100644
3--- a/ayllu-keys/src/main.rs
4+++ b/ayllu-keys/src/main.rs
5 @@ -16,9 +16,6 @@ use clap::Parser;
6
7 use serde::{Deserialize, Serialize};
8
9- const GLOBAL_AYLLU_CONFIG: &str = "/etc/ayllu/config.toml";
10- const DEFAULT_AYLLU_SHELL_PATH: &str = "/usr/bin/ayllu-shell";
11-
12 #[derive(Serialize, Deserialize, Clone, Default)]
13 pub struct Config {
14 // path to the ayllu-shell executable
15 @@ -49,7 +46,7 @@ fn authorized_keys(home_dir: &Path) -> ExitCode {
16 Ok(_) => ExitCode::SUCCESS,
17 Err(e) => {
18 // results in access denied
19- eprintln!("Failed to read authorized keys file: {}", e);
20+ eprintln!("Failed to read authorized keys file: {e}");
21 ExitCode::FAILURE
22 }
23 }
24 @@ -60,7 +57,7 @@ fn authorized_keys(home_dir: &Path) -> ExitCode {
25
26 fn identify<'a>(config: &'a Config, ca_key_type: &str, certificate: &str) -> Option<&'a Identity> {
27 let user_key =
28- match ayllu_identity::PublicKey::parse(&format!("{} {}", ca_key_type, certificate)) {
29+ match ayllu_identity::PublicKey::parse(&format!("{ca_key_type} {certificate}")) {
30 Ok(key) => key,
31 Err(e) => {
32 eprintln!("Cannot parse SSH key from sshd: {e:?}");
33 @@ -72,8 +69,7 @@ fn identify<'a>(config: &'a Config, ca_key_type: &str, certificate: &str) -> Opt
34 identity
35 .authorized_keys
36 .iter()
37- .find(|authorized_key| authorized_key.0 == user_key)
38- .is_some()
39+ .any(|authorized_key| authorized_key.0 == user_key)
40 }) {
41 Some(identity) => Some(identity),
42 None => {
43 @@ -98,13 +94,6 @@ fn main() -> ExitCode {
44 }
45 };
46
47- let ayllu_shell_path = args
48- .ayllu_shell
49- .as_ref()
50- .map_or(DEFAULT_AYLLU_SHELL_PATH.to_string(), |pb| {
51- pb.to_string_lossy().to_string()
52- });
53-
54 eprintln!(
55 "Login attempt for user: {} home={:?}, key_type={}, certificate={}",
56 args.username, args.home_dir, args.ca_key_type, args.certificate
57 diff --git a/ayllu-shell/src/main.rs b/ayllu-shell/src/main.rs
58index 3919b03..7a23919 100644
59--- a/ayllu-shell/src/main.rs
60+++ b/ayllu-shell/src/main.rs
61 @@ -114,7 +114,7 @@ fn execute(args: Arguments) -> Result<(), Box<dyn std::error::Error>> {
62 }
63 None => {
64 print!("{}", config.shell.motd);
65- println!("\nYou are authenticated as: {}\n", username);
66+ println!("\nYou are authenticated as: {username}\n");
67 let menu = ui::Prompt {
68 config: &config,
69 identity,
70 @@ -132,7 +132,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
71 let args = Arguments::parse();
72 if let Some(cmd) = args.c {
73 let unescaped = cmd.replace("\'", "").replace("\"", "");
74- let parts = unescaped.split(" ").into_iter().fold(
75+ let parts = unescaped.split(" ").fold(
76 vec!["ayllu-shell".to_string()],
77 |mut accm, part| {
78 accm.push(part.to_string());
79 diff --git a/ayllu-shell/src/ui.rs b/ayllu-shell/src/ui.rs
80index c47fbb1..abd0c51 100644
81--- a/ayllu-shell/src/ui.rs
82+++ b/ayllu-shell/src/ui.rs
83 @@ -106,18 +106,18 @@ mod helpers {
84 let src_path = src.path.join(Path::new(name));
85 let dst_path = dst.path.join(Path::new(name));
86 std::fs::rename(&src_path, &dst_path)?;
87- println!("Moved {:?} --> {:?}", src_path, dst_path);
88+ println!("Moved {src_path:?} --> {dst_path:?}");
89 Ok(())
90 }
91
92 pub fn remove(src: &Collection, name: &str, trash_base: &Path) -> Result<(), Error> {
93 let src_path = src.path.join(Path::new(name));
94 if !trash_base.exists() {
95- std::fs::create_dir_all(&trash_base)?;
96+ std::fs::create_dir_all(trash_base)?;
97 }
98 let dst_path = trash_base.join(Path::new(name));
99 std::fs::rename(&src_path, &dst_path)?;
100- println!("Moved {:?} --> {:?}", src_path, dst_path);
101+ println!("Moved {src_path:?} --> {dst_path:?}");
102 Ok(())
103 }
104 }
105 @@ -202,7 +202,7 @@ mod menu {
106 pub(crate) fn select_collection(collections: &[Collection]) -> Option<&Collection> {
107 let items: Vec<Item> = collections
108 .iter()
109- .map(|other| Item::Collection(other))
110+ .map(Item::Collection)
111 .collect();
112 if items.is_empty() {
113 println!("No collections are configured");
114 @@ -278,7 +278,7 @@ impl Prompt<'_> {
115 self.execute(None, None)
116 }
117 Some(menu::Item::Edit { collection, name }) => {
118- let repository = helpers::open(collection, &name)?;
119+ let repository = helpers::open(collection, name)?;
120 let mut config = repository.config()?;
121 config.description = maybe_string(&string_input_default!(
122 "Description",
123 @@ -363,13 +363,13 @@ impl Prompt<'_> {
124 Some(menu::Item::Move { collection, name }) => {
125 match menu::select_collection(self.config.collections.as_slice()) {
126 Some(other) => {
127- helpers::r#move(collection, &other, name)?;
128+ helpers::r#move(collection, other, name)?;
129 self.execute(None, None)
130 }
131 None => self.execute(None, None),
132 }
133 }
134- Some(menu::Item::Exit) => return Ok(()),
135+ Some(menu::Item::Exit) => Ok(()),
136 Some(menu::Item::Repository {
137 collection,
138 name,
139 diff --git a/ayllu/src/main.rs b/ayllu/src/main.rs
140index 8488636..61aa9bd 100644
141--- a/ayllu/src/main.rs
142+++ b/ayllu/src/main.rs
143 @@ -78,7 +78,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
144 cfg.collections.push(Collection {
145 name: String::from("Default"),
146 description: Some(format!("Collection @ {}", path.to_string_lossy())),
147- path: path,
148+ path,
149 ..Default::default()
150 })
151 }
152 diff --git a/ayllu/src/readme.rs b/ayllu/src/readme.rs
153index 0c87ee7..5cd8764 100644
154--- a/ayllu/src/readme.rs
155+++ b/ayllu/src/readme.rs
156 @@ -164,7 +164,6 @@ impl Renderer<'_> {
157 }
158
159 #[cfg(test)]
160-
161 mod tests {
162
163 use super::*;
164 diff --git a/crates/git/src/wrapper.rs b/crates/git/src/wrapper.rs
165index 480a542..184f647 100644
166--- a/crates/git/src/wrapper.rs
167+++ b/crates/git/src/wrapper.rs
168 @@ -577,8 +577,8 @@ impl Wrapper {
169 pub fn log(&self, selector: Selector) -> Result<Vec<lite::Commit>, Error> {
170 let mut commits: Vec<lite::Commit> = Vec::new();
171 let mut revwalk = self.repository.revwalk()?;
172- let id = match selector.commit.clone() {
173- Some(commit) => Oid::from_str(&commit)?,
174+ let id = match selector.commit {
175+ Some(commit) => Oid::from_str(commit)?,
176 None => {
177 let head = self.repository.head()?;
178 head.target().unwrap()
179 @@ -592,7 +592,7 @@ impl Wrapper {
180 }
181 let id = rev?;
182 let commit = self.repository.find_commit(id)?;
183- if let Some(email) = selector.email.clone() {
184+ if let Some(email) = selector.email {
185 if commit
186 .author()
187 .email()
188 @@ -601,7 +601,7 @@ impl Wrapper {
189 continue;
190 }
191 };
192- if let Some(name) = selector.username.clone() {
193+ if let Some(name) = selector.username {
194 if commit
195 .author()
196 .name()