diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 51b1d008..81df0434 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -26,7 +26,7 @@ jobs: - name: Install rust uses: dtolnay/rust-toolchain@master with: - toolchain: 1.86 + toolchain: 1.88 - uses: actions/cache@v4 with: @@ -97,7 +97,7 @@ jobs: - name: Install rust uses: dtolnay/rust-toolchain@master with: - toolchain: 1.86 + toolchain: 1.88 - uses: taiki-e/install-action@v2 name: Install nextest @@ -127,7 +127,7 @@ jobs: - name: Install rust uses: dtolnay/rust-toolchain@master with: - toolchain: 1.86 + toolchain: 1.88 - uses: actions/cache@v4 with: @@ -171,7 +171,7 @@ jobs: - name: Install rust uses: dtolnay/rust-toolchain@master with: - toolchain: 1.86 + toolchain: 1.88 - uses: taiki-e/install-action@v2 name: Install nextest @@ -200,7 +200,7 @@ jobs: - name: Install latest rust uses: dtolnay/rust-toolchain@master with: - toolchain: 1.86 + toolchain: 1.88 components: clippy - uses: actions/cache@v4 @@ -223,7 +223,7 @@ jobs: - name: Install latest rust uses: dtolnay/rust-toolchain@master with: - toolchain: 1.86 + toolchain: 1.88 components: rustfmt - name: Format diff --git a/Cargo.toml b/Cargo.toml index c5b335ee..5ada8f44 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ exclude = ["ui/backend"] [workspace.package] version = "18.7.1" authors = ["Ellie Huxtable "] -rust-version = "1.86" +rust-version = "1.88" license = "MIT" homepage = "https://atuin.sh" repository = "https://github.com/atuinsh/atuin" diff --git a/crates/atuin-client/src/api_client.rs b/crates/atuin-client/src/api_client.rs index c2bdfadc..78f374d6 100644 --- a/crates/atuin-client/src/api_client.rs +++ b/crates/atuin-client/src/api_client.rs @@ -41,7 +41,7 @@ fn make_url(address: &str, path: &str) -> Result { let address = if address.ends_with("/") { address } else { - &format!("{}/", address) + &format!("{address}/") }; // passing a path with a leading `/` will cause `join()` to replace the entire URL path @@ -148,8 +148,8 @@ pub fn ensure_version(response: &Response) -> Result { println!( "Atuin version mismatch! In order to successfully sync, the server needs to run a newer version of Atuin" ); - println!("Client: {}", ATUIN_CARGO_VERSION); - println!("Server: {}", version); + println!("Client: {ATUIN_CARGO_VERSION}"); + println!("Server: {version}"); return Ok(false); } diff --git a/crates/atuin-client/src/encryption.rs b/crates/atuin-client/src/encryption.rs index a1e844e7..a56dbd09 100644 --- a/crates/atuin-client/src/encryption.rs +++ b/crates/atuin-client/src/encryption.rs @@ -300,7 +300,7 @@ mod test { // test decryption works // this should pass match decrypt(e1, &key1) { - Err(e) => panic!("failed to decrypt, got {}", e), + Err(e) => panic!("failed to decrypt, got {e}"), Ok(h) => assert_eq!(h, history), }; diff --git a/crates/atuin-client/src/import/bash.rs b/crates/atuin-client/src/import/bash.rs index 2c4b29b8..99a44a58 100644 --- a/crates/atuin-client/src/import/bash.rs +++ b/crates/atuin-client/src/import/bash.rs @@ -111,11 +111,11 @@ impl<'a> From<&'a [u8]> for LineType<'a> { if line.is_empty() { return LineType::Empty; } - let parsed = match try_parse_line_as_timestamp(line) { + + match try_parse_line_as_timestamp(line) { Some(time) => LineType::Timestamp(time), None => LineType::Command(line), - }; - parsed + } } } diff --git a/crates/atuin-client/src/theme.rs b/crates/atuin-client/src/theme.rs index 429f08ab..b53c2e7a 100644 --- a/crates/atuin-client/src/theme.rs +++ b/crates/atuin-client/src/theme.rs @@ -198,7 +198,7 @@ fn from_string(name: &str) -> Result { // For full flexibility, we need to use serde_json, given // crossterm's approach. serde_json::from_str::(format!("\"{}\"", &name[1..]).as_str()) - .map_err(|_| format!("Could not convert color name {} to Crossterm color", name)) + .map_err(|_| format!("Could not convert color name {name} to Crossterm color")) } _ => { let srgb = named::from_str(name).ok_or("No such color in palette")?; @@ -382,7 +382,7 @@ impl ThemeManager { theme_file }; - let theme_toml = format!["{}.toml", name]; + let theme_toml = format!["{name}.toml"]; theme_file.push(theme_toml); let mut config_builder = Config::builder(); @@ -797,8 +797,7 @@ mod theme_tests { assert_eq!( from_string(inp), Err(format!( - "Could not convert color name {} to Crossterm color", - inp + "Could not convert color name {inp} to Crossterm color" )) ); }); diff --git a/crates/atuin-common/src/shell.rs b/crates/atuin-common/src/shell.rs index 0d495369..995c7bcb 100644 --- a/crates/atuin-common/src/shell.rs +++ b/crates/atuin-common/src/shell.rs @@ -31,7 +31,7 @@ impl std::fmt::Display for Shell { Shell::Unknown => "unknown", }; - write!(f, "{}", shell) + write!(f, "{shell}") } } diff --git a/crates/atuin-dotfiles/src/shell/bash.rs b/crates/atuin-dotfiles/src/shell/bash.rs index 05f2cbe1..2b9b4c88 100644 --- a/crates/atuin-dotfiles/src/shell/bash.rs +++ b/crates/atuin-dotfiles/src/shell/bash.rs @@ -46,7 +46,7 @@ pub async fn alias_config(store: &AliasStore) -> String { } if let Err(e) = store.build().await { - return format!("echo 'Atuin: failed to generate aliases: {}'", e); + return format!("echo 'Atuin: failed to generate aliases: {e}'"); } cached_aliases(aliases, store).await @@ -61,7 +61,7 @@ pub async fn var_config(store: &VarStore) -> String { } if let Err(e) = store.build().await { - return format!("echo 'Atuin: failed to generate vars: {}'", e); + return format!("echo 'Atuin: failed to generate vars: {e}'"); } cached_vars(vars, store).await diff --git a/crates/atuin-dotfiles/src/shell/fish.rs b/crates/atuin-dotfiles/src/shell/fish.rs index 72d95dd7..6d472f67 100644 --- a/crates/atuin-dotfiles/src/shell/fish.rs +++ b/crates/atuin-dotfiles/src/shell/fish.rs @@ -47,7 +47,7 @@ pub async fn alias_config(store: &AliasStore) -> String { } if let Err(e) = store.build().await { - return format!("echo 'Atuin: failed to generate aliases: {}'", e); + return format!("echo 'Atuin: failed to generate aliases: {e}'"); } cached_aliases(aliases, store).await @@ -62,7 +62,7 @@ pub async fn var_config(store: &VarStore) -> String { } if let Err(e) = store.build().await { - return format!("echo 'Atuin: failed to generate vars: {}'", e); + return format!("echo 'Atuin: failed to generate vars: {e}'"); } cached_vars(vars, store).await diff --git a/crates/atuin-dotfiles/src/shell/xonsh.rs b/crates/atuin-dotfiles/src/shell/xonsh.rs index b87e3585..1e56fc1d 100644 --- a/crates/atuin-dotfiles/src/shell/xonsh.rs +++ b/crates/atuin-dotfiles/src/shell/xonsh.rs @@ -46,7 +46,7 @@ pub async fn alias_config(store: &AliasStore) -> String { } if let Err(e) = store.build().await { - return format!("echo 'Atuin: failed to generate aliases: {}'", e); + return format!("echo 'Atuin: failed to generate aliases: {e}'"); } cached_aliases(aliases, store).await @@ -61,7 +61,7 @@ pub async fn var_config(store: &VarStore) -> String { } if let Err(e) = store.build().await { - return format!("echo 'Atuin: failed to generate vars: {}'", e); + return format!("echo 'Atuin: failed to generate vars: {e}'"); } cached_vars(vars, store).await diff --git a/crates/atuin-dotfiles/src/shell/zsh.rs b/crates/atuin-dotfiles/src/shell/zsh.rs index 161fd9a7..117e9403 100644 --- a/crates/atuin-dotfiles/src/shell/zsh.rs +++ b/crates/atuin-dotfiles/src/shell/zsh.rs @@ -46,7 +46,7 @@ pub async fn alias_config(store: &AliasStore) -> String { } if let Err(e) = store.build().await { - return format!("echo 'Atuin: failed to generate aliases: {}'", e); + return format!("echo 'Atuin: failed to generate aliases: {e}'"); } cached_aliases(aliases, store).await @@ -61,7 +61,7 @@ pub async fn var_config(store: &VarStore) -> String { } if let Err(e) = store.build().await { - return format!("echo 'Atuin: failed to generate aliases: {}'", e); + return format!("echo 'Atuin: failed to generate aliases: {e}'"); } cached_vars(vars, store).await diff --git a/crates/atuin-history/src/stats.rs b/crates/atuin-history/src/stats.rs index 5e8d59da..8bf03e42 100644 --- a/crates/atuin-history/src/stats.rs +++ b/crates/atuin-history/src/stats.rs @@ -324,7 +324,7 @@ mod tests { .into(); let stats = compute(&settings, &[history], 10, 1).expect("failed to compute stats"); - assert_eq!(stats.top.get(0).unwrap().0, vec!["echo"]); + assert_eq!(stats.top.first().unwrap().0, vec!["echo"]); } #[test] diff --git a/crates/atuin-kv/src/store.rs b/crates/atuin-kv/src/store.rs index 3394b8c0..23fd7934 100644 --- a/crates/atuin-kv/src/store.rs +++ b/crates/atuin-kv/src/store.rs @@ -199,10 +199,7 @@ mod tests { let ns_list = store.list(None).await.unwrap(); assert_eq!(ns_list, expected); - store - .delete("test", &vec!["key".to_string()]) - .await - .unwrap(); + store.delete("test", &["key".to_string()]).await.unwrap(); let value = store.get("test", "key").await.unwrap(); assert_eq!(value, None); diff --git a/crates/atuin-scripts/src/execution.rs b/crates/atuin-scripts/src/execution.rs index 90f7c4eb..8605d142 100644 --- a/crates/atuin-scripts/src/execution.rs +++ b/crates/atuin-scripts/src/execution.rs @@ -13,11 +13,11 @@ use tracing::debug; pub fn build_executable_script(script: String, shebang: String) -> String { if shebang.is_empty() { // Default to bash if no shebang is provided - format!("#!/usr/bin/env bash\n{}", script) + format!("#!/usr/bin/env bash\n{script}") } else if script.starts_with("#!") { - format!("{}\n{}", shebang, script) + format!("{shebang}\n{script}") } else { - format!("#!{}\n{}", shebang, script) + format!("#!{shebang}\n{script}") } } @@ -149,7 +149,7 @@ pub async fn execute_script_interactive( let mut child = match child_result { Ok(child) => child, Err(e) => { - return Err(format!("Failed to execute script: {}", e).into()); + return Err(format!("Failed to execute script: {e}").into()); } }; @@ -176,11 +176,11 @@ pub async fn execute_script_interactive( tokio::spawn(async move { while let Some(input) = stdin_rx.recv().await { if let Err(e) = stdin.write_all(input.as_bytes()).await { - eprintln!("Error writing to stdin: {}", e); + eprintln!("Error writing to stdin: {e}"); break; } if let Err(e) = stdin.flush().await { - eprintln!("Error flushing stdin: {}", e); + eprintln!("Error flushing stdin: {e}"); break; } } @@ -199,16 +199,16 @@ pub async fn execute_script_interactive( Ok(0) => break, // End of stdout Ok(n) => { if let Err(e) = stdout_writer.write_all(&buffer[0..n]).await { - eprintln!("Error writing to stdout: {}", e); + eprintln!("Error writing to stdout: {e}"); break; } if let Err(e) = stdout_writer.flush().await { - eprintln!("Error flushing stdout: {}", e); + eprintln!("Error flushing stdout: {e}"); break; } } Err(e) => { - eprintln!("Error reading from process stdout: {}", e); + eprintln!("Error reading from process stdout: {e}"); break; } } @@ -227,16 +227,16 @@ pub async fn execute_script_interactive( Ok(0) => break, // End of stderr Ok(n) => { if let Err(e) = stderr_writer.write_all(&buffer[0..n]).await { - eprintln!("Error writing to stderr: {}", e); + eprintln!("Error writing to stderr: {e}"); break; } if let Err(e) = stderr_writer.flush().await { - eprintln!("Error flushing stderr: {}", e); + eprintln!("Error flushing stderr: {e}"); break; } } Err(e) => { - eprintln!("Error reading from process stderr: {}", e); + eprintln!("Error reading from process stderr: {e}"); break; } } @@ -257,7 +257,7 @@ pub async fn execute_script_interactive( status } Err(e) => { - eprintln!("Error waiting for child process: {}", e); + eprintln!("Error waiting for child process: {e}"); // Send a default error code let _ = exit_code_tx.send(-1).await; return; @@ -266,11 +266,11 @@ pub async fn execute_script_interactive( // Wait for stdout/stderr tasks to complete if let Err(e) = stdout_handle.await { - eprintln!("Error joining stdout task: {}", e); + eprintln!("Error joining stdout task: {e}"); } if let Err(e) = stderr_handle.await { - eprintln!("Error joining stderr task: {}", e); + eprintln!("Error joining stderr task: {e}"); } // Send the exit code diff --git a/crates/atuin-server-postgres/src/lib.rs b/crates/atuin-server-postgres/src/lib.rs index 005e8765..65e8efbf 100644 --- a/crates/atuin-server-postgres/src/lib.rs +++ b/crates/atuin-server-postgres/src/lib.rs @@ -55,8 +55,7 @@ impl Database for Postgres { if pg_major_version < MIN_PG_VERSION { return Err(DbError::Other(eyre::Report::msg(format!( - "unsupported PostgreSQL version {}, minimum required is {}", - pg_major_version, MIN_PG_VERSION + "unsupported PostgreSQL version {pg_major_version}, minimum required is {MIN_PG_VERSION}" )))); } diff --git a/crates/atuin-server/src/handlers/user.rs b/crates/atuin-server/src/handlers/user.rs index 60956e6e..e493e714 100644 --- a/crates/atuin-server/src/handlers/user.rs +++ b/crates/atuin-server/src/handlers/user.rs @@ -229,8 +229,7 @@ pub async fn send_verification( .subject(settings.mail.verification.subject) .to(user.email) .body(postmark::api::Body::text(format!( - "Please run the following command to finalize your Atuin account verification. It is valid for 15 minutes:\n\natuin account verify --token '{}'", - verification_token + "Please run the following command to finalize your Atuin account verification. It is valid for 15 minutes:\n\natuin account verify --token '{verification_token}'" ))) .build(); diff --git a/crates/atuin/build.rs b/crates/atuin/build.rs index f24cf1bf..75d53ee0 100644 --- a/crates/atuin/build.rs +++ b/crates/atuin/build.rs @@ -7,5 +7,5 @@ fn main() { Err(_) => String::from("NO_GIT"), }; - println!("cargo:rustc-env=GIT_HASH={}", sha); + println!("cargo:rustc-env=GIT_HASH={sha}"); } diff --git a/crates/atuin/src/command/client/history.rs b/crates/atuin/src/command/client/history.rs index 74d9e155..1879c1d7 100644 --- a/crates/atuin/src/command/client/history.rs +++ b/crates/atuin/src/command/client/history.rs @@ -342,27 +342,6 @@ fn parse_fmt(format: &str) -> ParsedFmt { } } -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_format_string_no_panic() { - // Don't panic but provide helpful output (issue #2776) - let malformed_json = r#"{"command":"{command}","key":"value"}"#; - - let result = std::panic::catch_unwind(|| parse_fmt(malformed_json)); - - assert!(result.is_ok()); - } - - #[test] - fn test_valid_formats_still_work() { - assert!(std::panic::catch_unwind(|| parse_fmt("{command}")).is_ok()); - assert!(std::panic::catch_unwind(|| parse_fmt("{time} - {command}")).is_ok()); - } -} - impl Cmd { #[allow(clippy::too_many_lines, clippy::cast_possible_truncation)] async fn handle_start( @@ -772,3 +751,24 @@ impl Cmd { } } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_format_string_no_panic() { + // Don't panic but provide helpful output (issue #2776) + let malformed_json = r#"{"command":"{command}","key":"value"}"#; + + let result = std::panic::catch_unwind(|| parse_fmt(malformed_json)); + + assert!(result.is_ok()); + } + + #[test] + fn test_valid_formats_still_work() { + assert!(std::panic::catch_unwind(|| parse_fmt("{command}")).is_ok()); + assert!(std::panic::catch_unwind(|| parse_fmt("{time} - {command}")).is_ok()); + } +} diff --git a/crates/atuin/src/command/client/import.rs b/crates/atuin/src/command/client/import.rs index 892d6f77..a30659cb 100644 --- a/crates/atuin/src/command/client/import.rs +++ b/crates/atuin/src/command/client/import.rs @@ -45,6 +45,7 @@ pub enum Cmd { const BATCH_SIZE: usize = 100; impl Cmd { + #[allow(clippy::cognitive_complexity)] pub async fn run(&self, db: &DB) -> Result<()> { println!(" Atuin "); println!("======================"); diff --git a/crates/atuin/src/command/client/scripts.rs b/crates/atuin/src/command/client/scripts.rs index cd1b13ba..755cee1e 100644 --- a/crates/atuin/src/command/client/scripts.rs +++ b/crates/atuin/src/command/client/scripts.rs @@ -437,6 +437,7 @@ impl Cmd { } } + #[allow(clippy::cognitive_complexity)] async fn handle_edit( _settings: &Settings, edit: Edit, diff --git a/crates/atuin/src/command/client/search/interactive.rs b/crates/atuin/src/command/client/search/interactive.rs index 0fd7cbb6..ec40cc8d 100644 --- a/crates/atuin/src/command/client/search/interactive.rs +++ b/crates/atuin/src/command/client/search/interactive.rs @@ -862,13 +862,12 @@ impl State { } fn build_stats(&self, theme: &Theme) -> Paragraph { - let stats = Paragraph::new(Text::from(Span::raw(format!( + Paragraph::new(Text::from(Span::raw(format!( "history count: {}", self.history_count, )))) .style(theme.as_style(Meaning::Annotation)) - .alignment(Alignment::Right); - stats + .alignment(Alignment::Right) } fn build_results_list<'a>( @@ -962,7 +961,8 @@ impl State { }) .join("\n") }; - let preview = if compact { + + if compact { Paragraph::new(command).style(theme.as_style(Meaning::Annotation)) } else { Paragraph::new(command).block( @@ -971,8 +971,7 @@ impl State { .border_type(BorderType::Rounded) .title(format!("{:─>width$}", "", width = chunk_width - 2)), ) - }; - preview + } } } @@ -1045,7 +1044,11 @@ impl Write for Stdout { // this is a big blob of horrible! clean it up! // for now, it works. But it'd be great if it were more easily readable, and // modular. I'd like to add some more stats and stuff at some point -#[allow(clippy::cast_possible_truncation, clippy::too_many_lines)] +#[allow( + clippy::cast_possible_truncation, + clippy::too_many_lines, + clippy::cognitive_complexity +)] pub async fn history( query: &[String], settings: &Settings, diff --git a/crates/atuin/src/command/client/store/rekey.rs b/crates/atuin/src/command/client/store/rekey.rs index ec41cc2b..918bb335 100644 --- a/crates/atuin/src/command/client/store/rekey.rs +++ b/crates/atuin/src/command/client/store/rekey.rs @@ -20,7 +20,7 @@ impl Rekey { let key = if let Some(key) = self.key.clone() { println!("Re-encrypting store with specified key"); - let key = match bip39::Mnemonic::from_phrase(&key, bip39::Language::English) { + match bip39::Mnemonic::from_phrase(&key, bip39::Language::English) { Ok(mnemonic) => encode_key(Key::from_slice(mnemonic.entropy()))?, Err(err) => { match err.downcast_ref::() { @@ -44,9 +44,7 @@ impl Rekey { } } } - }; - - key + } } else { println!("Re-encrypting store with freshly-generated key"); let (_, encoded) = generate_encoded_key()?; diff --git a/flake.nix b/flake.nix index adca7b34..8c8175d9 100644 --- a/flake.nix +++ b/flake.nix @@ -32,7 +32,7 @@ fenix.packages.${system}.fromToolchainFile { file = ./rust-toolchain.toml; - sha256 = "sha256-X/4ZBHO3iW0fOenQ3foEvscgAPJYl2abspaBThDOukI="; + sha256 = "sha256-Qxt8XAuaUR2OMdKbN4u8dBJOhSHxS+uS06Wl9+flVEk="; }; in pkgs.makeRustPlatform { diff --git a/rust-toolchain.toml b/rust-toolchain.toml index e7f22fb8..c95c9057 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.86" +channel = "1.88"