diff options
| author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2026-06-13 01:36:41 +0200 |
|---|---|---|
| committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2026-06-13 01:36:41 +0200 |
| commit | 47b76481e51451827530714512b30882d85e3a9a (patch) | |
| tree | 3e64edfa304e11e4dff506683dd0a7ea7929123e | |
| parent | chore(treewide): Fix some of `clippy`'s error (diff) | |
| download | atuin-47b76481e51451827530714512b30882d85e3a9a.zip | |
chore(treewide): Also fix all `clippy` warnings
23 files changed, 110 insertions, 114 deletions
diff --git a/crates/turtle/src/atuin_client/database.rs b/crates/turtle/src/atuin_client/database.rs index 24f017be..c730b1d4 100644 --- a/crates/turtle/src/atuin_client/database.rs +++ b/crates/turtle/src/atuin_client/database.rs @@ -178,6 +178,7 @@ impl ClientSqlite { Ok(()) } + #[expect(clippy::needless_pass_by_value)] fn query_history_inner(row: SqliteRow) -> History { let deleted_at: Option<i64> = row.get("deleted_at"); let hostname: String = row.get("hostname"); @@ -205,7 +206,8 @@ impl ClientSqlite { .author(author) .intent(intent) .deleted_at( - deleted_at.and_then(|t| OffsetDateTime::from_unix_timestamp_nanos(i128::from(t)).ok()), + deleted_at + .and_then(|t| OffsetDateTime::from_unix_timestamp_nanos(i128::from(t)).ok()), ) .build() .into() @@ -265,11 +267,10 @@ impl ClientSqlite { query.and_where_is_null("deleted_at"); } - let git_root = if let Some(git_root) = context.git_root.clone() { - git_root.to_str().unwrap_or("/").to_string() - } else { - context.cwd.clone() - }; + let git_root = context.git_root.clone().map_or_else( + || context.cwd.clone(), + |git_root| git_root.to_str().unwrap_or("/").to_string(), + ); let session_start = get_session_start_time(&context.session); @@ -352,6 +353,7 @@ impl ClientSqlite { // Yes I know, it's a lot. // Could maybe break it down to a searchparams struct or smth but that feels a little... pointless. // Been debating maybe a DSL for search? eg "before:time limit:1 the query" + #[expect(clippy::too_many_lines)] pub(crate) async fn search( &self, search_mode: SearchMode, @@ -380,11 +382,10 @@ impl ClientSqlite { sql.order_desc("timestamp"); } - let git_root = if let Some(git_root) = context.git_root.clone() { - git_root.to_str().unwrap_or("/").to_string() - } else { - context.cwd.clone() - }; + let git_root = context.git_root.clone().map_or_else( + || context.cwd.clone(), + |git_root| git_root.to_str().unwrap_or("/").to_string(), + ); let session_start = get_session_start_time(&context.session); @@ -1120,6 +1121,7 @@ mod test { } #[tokio::test(flavor = "multi_thread")] + #[expect(clippy::similar_names)] async fn test_paged_basic() { let mut db = ClientSqlite::new("sqlite::memory:", test_local_timeout()) .await @@ -1188,8 +1190,8 @@ mod test { // With unique flag - should get 3 (duplicates collapsed) let mut paged_unique = db.all_paged(10, false, true); - let page_unique = paged_unique.next().await.unwrap().unwrap(); - assert_eq!(page_unique.len(), 3); + let paged_unique = paged_unique.next().await.unwrap().unwrap(); + assert_eq!(paged_unique.len(), 3); } #[tokio::test(flavor = "multi_thread")] @@ -1301,11 +1303,12 @@ impl<'a> Iterator for QueryTokenizer<'a> { return Some(QueryToken::Or); } - let mut is_inverse = false; - if let Some(s) = part.strip_prefix('!') { + let is_inverse = part.strip_prefix('!').is_some_and(|s| { part = s; - is_inverse = true; - } + true + }); + + #[expect(clippy::option_if_let_else, reason = "It's too ugly")] let token = if let Some(s) = part.strip_prefix('^') { QueryToken::MatchStart(s, is_inverse) } else if let Some(s) = part.strip_suffix('$') { diff --git a/crates/turtle/src/atuin_client/encryption.rs b/crates/turtle/src/atuin_client/encryption.rs index 661a6669..f1c921cb 100644 --- a/crates/turtle/src/atuin_client/encryption.rs +++ b/crates/turtle/src/atuin_client/encryption.rs @@ -63,7 +63,7 @@ pub(crate) fn encode_key(key: &Key) -> Result<String> { Ok(buf) } -pub(crate) fn decode_key(key: String) -> Result<Key> { +pub(crate) fn decode_key(key: &str) -> Result<Key> { use rmp::decode; let buf = BASE64_STANDARD @@ -102,8 +102,6 @@ pub(crate) fn decode_key(key: String) -> Result<Key> { #[cfg(test)] mod test { - use pretty_assertions::assert_eq; - #[test] fn key_encodings() { use super::{Key, decode_key, encode_key}; @@ -138,7 +136,7 @@ mod test { ]; for k in valid_encodings { - assert_eq!(decode_key(k.to_owned()).expect(k), key); + assert_eq!(decode_key(k).expect(k), key); } } } diff --git a/crates/turtle/src/atuin_client/ordering.rs b/crates/turtle/src/atuin_client/ordering.rs index 446a5dac..84001f52 100644 --- a/crates/turtle/src/atuin_client/ordering.rs +++ b/crates/turtle/src/atuin_client/ordering.rs @@ -9,6 +9,7 @@ pub(crate) fn reorder_fuzzy(mode: SearchMode, query: &str, res: Vec<History>) -> } } +#[expect(clippy::needless_pass_by_value, reason = "makes things easier")] fn reorder<F, A>(query: &str, f: F, res: Vec<A>) -> Vec<A> where F: Fn(&A) -> &String, @@ -18,14 +19,12 @@ where let qvec = &query.chars().collect(); r.sort_by_cached_key(|h| { // TODO for fzf search we should sum up scores for each matched term - let (from, to) = match minspan::span(qvec, &(f(h).chars().collect())) { - Some(x) => x, - // this is a little unfortunate: when we are asked to match a query that is found nowhere, - // we don't want to return a None, as the comparison behaviour would put the worst matches - // at the front. therefore, we'll return a set of indices that are one larger than the longest - // possible legitimate match. This is meaningless except as a comparison. - None => (0, res.len()), - }; + // + // The fallback is a little unfortunate: when we are asked to match a query that is found nowhere, + // we don't want to return a None, as the comparison behaviour would put the worst matches + // at the front. Therefore, we'll return a set of indices that are one larger than the longest + // possible legitimate match. This is meaningless except as a comparison. + let (from, to) = minspan::span(qvec, &(f(h).chars().collect())).unwrap_or((0, res.len())); 1 + to - from }); r diff --git a/crates/turtle/src/atuin_client/record/sqlite_store.rs b/crates/turtle/src/atuin_client/record/sqlite_store.rs index 12f9fc4e..8a9afe45 100644 --- a/crates/turtle/src/atuin_client/record/sqlite_store.rs +++ b/crates/turtle/src/atuin_client/record/sqlite_store.rs @@ -95,6 +95,10 @@ impl SqliteStore { Ok(()) } + #[expect( + clippy::needless_pass_by_value, + reason = "this is used in a place with fixed function signature" + )] fn query_row(row: SqliteRow) -> Record<EncryptedData> { let idx: i64 = row.get("idx"); let timestamp: i64 = row.get("timestamp"); diff --git a/crates/turtle/src/atuin_client/settings.rs b/crates/turtle/src/atuin_client/settings.rs index bfb8d001..c02221eb 100644 --- a/crates/turtle/src/atuin_client/settings.rs +++ b/crates/turtle/src/atuin_client/settings.rs @@ -62,9 +62,7 @@ impl SearchMode { // if the user is using skim, we go to skim Self::FullText if settings.search_mode == Self::Skim => Self::Skim, // if the user is using daemon-fuzzy, we go to daemon-fuzzy - Self::FullText if settings.search_mode == Self::DaemonFuzzy => { - Self::DaemonFuzzy - } + Self::FullText if settings.search_mode == Self::DaemonFuzzy => Self::DaemonFuzzy, // otherwise fuzzy. Self::FullText => Self::Fuzzy, Self::Fuzzy | Self::Skim | Self::DaemonFuzzy => Self::Prefix, @@ -845,6 +843,7 @@ impl Sync { } pub(crate) fn encryption_key(&self) -> Result<Option<Key>> { Self::try_read_file(self.encryption_key_path.as_ref())? + .as_deref() .map(decode_key) .transpose() } diff --git a/crates/turtle/src/atuin_common/utils.rs b/crates/turtle/src/atuin_common/utils.rs index aa662979..92b4e781 100644 --- a/crates/turtle/src/atuin_common/utils.rs +++ b/crates/turtle/src/atuin_common/utils.rs @@ -102,13 +102,9 @@ pub(crate) fn logs_dir() -> PathBuf { pub(crate) fn get_current_dir() -> String { // Prefer PWD environment variable over cwd if available to better support symbolic links - match env::var("PWD") { - Ok(v) => v, - Err(_) => match env::current_dir() { - Ok(dir) => dir.display().to_string(), - Err(_) => String::new(), - }, - } + env::var("PWD").unwrap_or_else(|_| { + env::current_dir().map_or_else(|_| String::new(), |dir| dir.display().to_string()) + }) } pub(crate) fn broken_symlink<P: Into<PathBuf>>(path: P) -> bool { @@ -150,22 +146,11 @@ impl<T: AsRef<str>> Escapable for T {} #[cfg(test)] mod tests { - use pretty_assertions::assert_ne; use super::*; use std::collections::HashSet; - #[cfg(not(windows))] - #[test] - fn test_dirs() { - // these tests need to be run sequentially to prevent race condition - test_config_dir_xdg(); - test_config_dir(); - test_data_dir_xdg(); - test_data_dir(); - } - #[test] fn uuid_is_unique() { let how_many: usize = 1_000_000; @@ -216,7 +201,7 @@ mod tests { #[test] fn in_git_repo_regular() { // regular git repo should resolve to the directory containing .git - let tmp = std::env::temp_dir().join("atuin-test-regular-git"); + let tmp = env::temp_dir().join("atuin-test-regular-git"); drop(std::fs::remove_dir_all(&tmp)); let subdir = tmp.join("src").join("deep"); std::fs::create_dir_all(&subdir).unwrap(); @@ -233,7 +218,7 @@ mod tests { fn in_git_repo_worktree_resolves_to_main_repo() { // worktree .git is a file pointing back to the main repo — // in_git_repo should follow it so all worktrees share a workspace - let tmp = std::env::temp_dir().join("atuin-test-worktree-git"); + let tmp = env::temp_dir().join("atuin-test-worktree-git"); drop(std::fs::remove_dir_all(&tmp)); // main repo at tmp/main with a real .git directory diff --git a/crates/turtle/src/atuin_daemon/components/search.rs b/crates/turtle/src/atuin_daemon/components/search.rs index bcb18865..bcd60cc4 100644 --- a/crates/turtle/src/atuin_daemon/components/search.rs +++ b/crates/turtle/src/atuin_daemon/components/search.rs @@ -60,6 +60,7 @@ impl SearchComponent { } /// Rebuild the entire search index from the database. + #[expect(clippy::significant_drop_tightening, reason = "false positive")] async fn rebuild_index(&self) -> Result<()> { let handle_guard = self.handle.read().await; let handle = handle_guard @@ -114,6 +115,7 @@ impl Component for SearchComponent { "search" } + #[expect(clippy::significant_drop_tightening, reason = "false positive")] async fn start(&mut self, handle: DaemonHandle) -> Result<()> { *self.handle.write().await = Some(handle.clone()); @@ -179,6 +181,7 @@ impl Component for SearchComponent { Ok(()) } + #[expect(clippy::significant_drop_tightening, reason = "false positive")] async fn handle_event(&mut self, event: &DaemonEvent) -> Result<()> { match event { DaemonEvent::RecordsAdded(records) => { @@ -314,7 +317,7 @@ impl SearchSvc for SearchGrpcService { ); // Convert proto FilterMode + context to IndexFilterMode - let index_filter = convert_filter_mode(filter_mode, &proto_context); + let index_filter = convert_filter_mode(filter_mode, proto_context.as_ref()); // Build QueryContext from proto context let query_context = proto_context @@ -368,21 +371,21 @@ impl SearchSvc for SearchGrpcService { /// Convert proto `FilterMode` and context to `IndexFilterMode`. fn convert_filter_mode( mode: FilterMode, - context: &Option<search::SearchContext>, + context: Option<&search::SearchContext>, ) -> IndexFilterMode { + #[expect( + clippy::match_same_arms, + reason = "wildcard pattern used in second one" + )] match (mode, context) { (FilterMode::Global, _) => IndexFilterMode::Global, (FilterMode::Directory, Some(ctx)) => { IndexFilterMode::Directory(with_trailing_slash(&ctx.cwd)) } - (FilterMode::Workspace, Some(ctx)) => { - if let Some(ref git_root) = ctx.git_root { - IndexFilterMode::Workspace(with_trailing_slash(git_root)) - } else { - // Fall back to directory if no git root - IndexFilterMode::Directory(with_trailing_slash(&ctx.cwd)) - } - } + (FilterMode::Workspace, Some(ctx)) => ctx.git_root.as_ref().map_or_else( + || IndexFilterMode::Directory(with_trailing_slash(&ctx.cwd)), + |git_root| IndexFilterMode::Workspace(with_trailing_slash(git_root)), + ), (FilterMode::Host, Some(ctx)) => IndexFilterMode::Host(ctx.hostname.clone()), (FilterMode::Session, Some(ctx)) => IndexFilterMode::Session(ctx.session_id.clone()), (FilterMode::SessionPreload, Some(ctx)) => { diff --git a/crates/turtle/src/atuin_daemon/components/semantic.rs b/crates/turtle/src/atuin_daemon/components/semantic.rs index 69ffc134..e1d376de 100644 --- a/crates/turtle/src/atuin_daemon/components/semantic.rs +++ b/crates/turtle/src/atuin_daemon/components/semantic.rs @@ -197,7 +197,7 @@ impl SemanticState { let record = SemanticCommandRecord { capture, history }; log_record(&record, "recorded semantic command capture"); - self.push_record(session_id, history_id, record); + self.push_record(&session_id, history_id, record); true } @@ -271,11 +271,11 @@ impl SemanticState { fn push_record( &mut self, - session_id: SessionId, + session_id: &SessionId, history_id: HistoryId, record: SemanticCommandRecord, ) { - self.touch_session(&session_id); + self.touch_session(session_id); let (capture_id, evicted) = { let session = self.sessions.entry(session_id.clone()).or_default(); @@ -290,7 +290,7 @@ impl SemanticState { for evicted in evicted { self.remove_history_index_if_matches( - &session_id, + session_id, &evicted.history_id, evicted.capture_id, ); diff --git a/crates/turtle/src/atuin_daemon/components/sync.rs b/crates/turtle/src/atuin_daemon/components/sync.rs index 933d5ae1..20d49839 100644 --- a/crates/turtle/src/atuin_daemon/components/sync.rs +++ b/crates/turtle/src/atuin_daemon/components/sync.rs @@ -112,6 +112,7 @@ impl Component for SyncComponent { /// /// This runs in a spawned task and handles periodic sync as well as /// force sync requests. +#[expect(clippy::significant_drop_tightening, reason = "false positive")] async fn sync_loop(handle: DaemonHandle, mut cmd_rx: mpsc::Receiver<SyncCommand>) { tracing::info!("sync loop starting"); diff --git a/crates/turtle/src/atuin_daemon/control/mod.rs b/crates/turtle/src/atuin_daemon/control/mod.rs index 7015db5b..79398d61 100644 --- a/crates/turtle/src/atuin_daemon/control/mod.rs +++ b/crates/turtle/src/atuin_daemon/control/mod.rs @@ -52,7 +52,7 @@ impl Control for ControlService { .event .ok_or_else(|| Status::invalid_argument("event is required"))?; - let daemon_event = proto_event_to_daemon_event(event)?; + let daemon_event = proto_event_to_daemon_event(event); info!(?daemon_event, "received control event"); self.handle.emit(daemon_event); @@ -62,15 +62,15 @@ impl Control for ControlService { } /// Convert a proto event to a daemon event. -fn proto_event_to_daemon_event(event: Event) -> Result<DaemonEvent, Status> { +fn proto_event_to_daemon_event(event: Event) -> DaemonEvent { match event { - Event::HistoryPruned(_) => Ok(DaemonEvent::HistoryPruned), - Event::HistoryRebuilt(_) => Ok(DaemonEvent::HistoryRebuilt), - Event::HistoryDeleted(e) => Ok(DaemonEvent::HistoryDeleted { + Event::HistoryPruned(_) => DaemonEvent::HistoryPruned, + Event::HistoryRebuilt(_) => DaemonEvent::HistoryRebuilt, + Event::HistoryDeleted(e) => DaemonEvent::HistoryDeleted { ids: e.ids.into_iter().map(HistoryId).collect(), - }), - Event::ForceSync(_) => Ok(DaemonEvent::ForceSync), - Event::SettingsReloaded(_) => Ok(DaemonEvent::SettingsReloaded), - Event::Shutdown(_) => Ok(DaemonEvent::ShutdownRequested), + }, + Event::ForceSync(_) => DaemonEvent::ForceSync, + Event::SettingsReloaded(_) => DaemonEvent::SettingsReloaded, + Event::Shutdown(_) => DaemonEvent::ShutdownRequested, } } diff --git a/crates/turtle/src/atuin_daemon/generated.rs b/crates/turtle/src/atuin_daemon/generated.rs index e43f7523..a3ea4d9d 100644 --- a/crates/turtle/src/atuin_daemon/generated.rs +++ b/crates/turtle/src/atuin_daemon/generated.rs @@ -1,6 +1,12 @@ -#![allow( +#![expect( unreachable_pub, unused_qualifications, + clippy::doc_markdown, + clippy::default_trait_access, + clippy::too_many_lines, + clippy::trivially_copy_pass_by_ref, + clippy::allow_attributes, + clippy::derive_partial_eq_without_eq, reason = "All of these lints are triggered by the generated code" )] diff --git a/crates/turtle/src/atuin_pty_proxy/capture.rs b/crates/turtle/src/atuin_pty_proxy/capture.rs index dbcb81fb..efba3c0b 100644 --- a/crates/turtle/src/atuin_pty_proxy/capture.rs +++ b/crates/turtle/src/atuin_pty_proxy/capture.rs @@ -187,6 +187,7 @@ fn normalize_screen_contents(contents: &str) -> String { lines.join("\n") } +#[expect(clippy::naive_bytecount, reason = "This is just an estimation")] fn estimated_rows(bytes: &[u8], cols: u16) -> u16 { let newline_rows = bytes.iter().filter(|byte| **byte == b'\n').count() + 1; let wrapped_rows = bytes.len() / cols as usize; diff --git a/crates/turtle/src/atuin_pty_proxy/debug.rs b/crates/turtle/src/atuin_pty_proxy/debug.rs index bf311281..c2a1691c 100644 --- a/crates/turtle/src/atuin_pty_proxy/debug.rs +++ b/crates/turtle/src/atuin_pty_proxy/debug.rs @@ -31,7 +31,7 @@ impl Osc133DebugHighlighter { rendered.extend_from_slice(&data[start..offset]); } - rendered.extend_from_slice(event_label(&located.event)); + rendered.extend_from_slice(event_label(located.event)); rendered.extend_from_slice(RESET); start = offset; } @@ -41,7 +41,7 @@ impl Osc133DebugHighlighter { } } -fn event_label(event: &Event) -> &'static [u8] { +fn event_label(event: Event) -> &'static [u8] { match event { Event::PromptStart => b"\x1b[1;37;45m[OSC133:A prompt]\x1b[0m", Event::CommandStart => b"\x1b[1;30;43m[OSC133:B input]\x1b[0m", diff --git a/crates/turtle/src/atuin_pty_proxy/pty_proxy.rs b/crates/turtle/src/atuin_pty_proxy/pty_proxy.rs index 70a53318..ef4b0c37 100644 --- a/crates/turtle/src/atuin_pty_proxy/pty_proxy.rs +++ b/crates/turtle/src/atuin_pty_proxy/pty_proxy.rs @@ -27,14 +27,16 @@ pub(crate) struct Init { #[derive(Clone, Copy, Debug, Eq, PartialEq, ValueEnum)] #[value(rename_all = "lower")] -#[expect(clippy::enum_variant_names, clippy::doc_markdown)] enum Shell { /// Zsh setup Zsh, + /// Bash setup Bash, + /// Fish setup Fish, + /// Nu setup Nu, } @@ -126,6 +128,10 @@ fn env_flag(name: &str) -> bool { }) } +#[expect( + clippy::literal_string_with_formatting_args, + reason = "It's shell code" +)] fn render_init(shell: Shell) -> &'static str { match shell { Shell::Bash | Shell::Zsh => { diff --git a/crates/turtle/src/atuin_pty_proxy/screen.rs b/crates/turtle/src/atuin_pty_proxy/screen.rs index c51a0c7d..58ebd2eb 100644 --- a/crates/turtle/src/atuin_pty_proxy/screen.rs +++ b/crates/turtle/src/atuin_pty_proxy/screen.rs @@ -18,12 +18,7 @@ pub(crate) fn spawn_parser_thread(rows: u16, cols: u16, msg_rx: Receiver<Msg>) { std::thread::spawn(move || { let mut parser = vt100::Parser::new(rows, cols, 0); - loop { - let first = match msg_rx.recv() { - Ok(msg) => msg, - Err(_) => break, - }; - + while let Ok(first) = msg_rx.recv() { handle_parser_msg(&mut parser, first); while let Ok(msg) = msg_rx.try_recv() { @@ -44,10 +39,7 @@ pub(crate) fn spawn_socket_server(sock_path: PathBuf, screen_tx: SyncSender<Msg> }; for stream in listener.incoming() { - let mut stream = match stream { - Ok(s) => s, - Err(_) => break, - }; + let Ok(mut stream) = stream else { break }; let (reply_tx, reply_rx) = mpsc::channel(); if screen_tx.send(Msg::ScreenRequest(reply_tx)).is_err() { diff --git a/crates/turtle/src/atuin_server/metrics.rs b/crates/turtle/src/atuin_server/metrics.rs index 556de6fb..6380bef1 100644 --- a/crates/turtle/src/atuin_server/metrics.rs +++ b/crates/turtle/src/atuin_server/metrics.rs @@ -28,10 +28,10 @@ pub(crate) fn setup_metrics_recorder() -> PrometheusHandle { pub(crate) async fn track_metrics(req: Request, next: Next) -> impl IntoResponse { let start = Instant::now(); - let path = match req.extensions().get::<MatchedPath>() { - Some(matched_path) => matched_path.as_str().to_owned(), - _ => req.uri().path().to_owned(), - }; + let path = req.extensions().get::<MatchedPath>().map_or_else( + || req.uri().path().to_owned(), + |matched_path| matched_path.as_str().to_owned(), + ); let method = req.method().clone(); diff --git a/crates/turtle/src/atuin_server/settings.rs b/crates/turtle/src/atuin_server/settings.rs index 9424715d..1aa9059d 100644 --- a/crates/turtle/src/atuin_server/settings.rs +++ b/crates/turtle/src/atuin_server/settings.rs @@ -43,19 +43,21 @@ pub(crate) struct Settings { pub(crate) fake_version: Option<String>, #[serde(flatten)] + #[expect(clippy::struct_field_names)] pub(crate) db_settings: DbSettings, } impl Settings { pub(crate) fn new() -> Result<Self> { - let mut config_file = if let Ok(p) = std::env::var("ATUIN_CONFIG_DIR") { - PathBuf::from(p) - } else { - let mut config_file = PathBuf::new(); - let config_dir = crate::atuin_common::utils::config_dir(); - config_file.push(config_dir); - config_file - }; + let mut config_file = std::env::var("ATUIN_CONFIG_DIR").map_or_else( + |_| { + let mut config_file = PathBuf::new(); + let config_dir = crate::atuin_common::utils::config_dir(); + config_file.push(config_dir); + config_file + }, + PathBuf::from, + ); config_file.push("server.toml"); diff --git a/crates/turtle/src/command/client/history.rs b/crates/turtle/src/command/client/history.rs index e574a2e9..fcc622d7 100644 --- a/crates/turtle/src/command/client/history.rs +++ b/crates/turtle/src/command/client/history.rs @@ -202,7 +202,7 @@ pub(crate) fn print_list( ListMode::CmdOnly => std::iter::once(ParseSegment::Key("command")).collect(), }; - #[allow(trivial_casts)] + #[expect(trivial_casts)] let iterator = if reverse { Box::new(h.iter().rev()) as Box<dyn Iterator<Item = &History>> } else { diff --git a/crates/turtle/src/command/client/init.rs b/crates/turtle/src/command/client/init.rs index 0cdcd425..0db9b143 100644 --- a/crates/turtle/src/command/client/init.rs +++ b/crates/turtle/src/command/client/init.rs @@ -26,18 +26,23 @@ pub(crate) struct Cmd { #[derive(Clone, Copy, ValueEnum, Debug)] #[value(rename_all = "lower")] -#[expect(clippy::enum_variant_names, clippy::doc_markdown)] +#[expect(clippy::enum_variant_names)] pub(crate) enum Shell { /// Zsh setup Zsh, + /// Bash setup Bash, + /// Fish setup Fish, + /// Nu setup Nu, + /// Xonsh setup Xonsh, + /// PowerShell setup PowerShell, } diff --git a/crates/turtle/src/command/client/search.rs b/crates/turtle/src/command/client/search.rs index 5c51caea..359864cb 100644 --- a/crates/turtle/src/command/client/search.rs +++ b/crates/turtle/src/command/client/search.rs @@ -163,12 +163,7 @@ impl Cmd { let query = self.query.unwrap_or_else(|| { std::env::var("ATUIN_QUERY").map_or_else( |_| vec![], - |query| { - query - .split(' ') - .map(ToString::to_string) - .collect() - }, + |query| query.split(' ').map(ToString::to_string).collect(), ) }); @@ -302,7 +297,6 @@ impl Cmd { // This is supposed to more-or-less mirror the command line version, so ofc // it is going to have a lot of args -#[expect(clippy::too_many_arguments, clippy::cast_possible_truncation)] async fn run_non_interactive( settings: &Settings, filter_options: OptFilters, diff --git a/crates/turtle/src/command/client/search/duration.rs b/crates/turtle/src/command/client/search/duration.rs index bc8dbed3..0d70353a 100644 --- a/crates/turtle/src/command/client/search/duration.rs +++ b/crates/turtle/src/command/client/search/duration.rs @@ -1,7 +1,6 @@ use core::fmt; use std::{ops::ControlFlow, time::Duration}; -#[expect(clippy::module_name_repetitions)] pub(crate) fn format_duration_into(dur: Duration, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn item(unit: &'static str, value: u64) -> ControlFlow<(&'static str, u64)> { if value > 0 { @@ -53,7 +52,6 @@ pub(crate) fn format_duration_into(dur: Duration, f: &mut fmt::Formatter<'_>) -> } } -#[expect(clippy::module_name_repetitions)] pub(crate) fn format_duration(f: Duration) -> String { struct F(Duration); impl fmt::Display for F { diff --git a/crates/turtle/src/command/client/store/rekey.rs b/crates/turtle/src/command/client/store/rekey.rs index e89d83c2..2b379327 100644 --- a/crates/turtle/src/command/client/store/rekey.rs +++ b/crates/turtle/src/command/client/store/rekey.rs @@ -27,7 +27,7 @@ impl Rekey { }; let current_key: [u8; 32] = load_key(settings)?.into(); - let new_key: [u8; 32] = decode_key(key.clone())?.into(); + let new_key: [u8; 32] = decode_key(&key)?.into(); store.re_encrypt(¤t_key, &new_key).await?; diff --git a/crates/turtle/src/main.rs b/crates/turtle/src/main.rs index 7ea08a9b..12858140 100644 --- a/crates/turtle/src/main.rs +++ b/crates/turtle/src/main.rs @@ -1,5 +1,5 @@ #![forbid(unsafe_code)] -#![warn(clippy::pedantic, clippy::nursery)] +#![warn(clippy::pedantic, clippy::nursery, clippy::allow_attributes)] #