From 906803378945c2272a0ca381b03a8da3ff432a38 Mon Sep 17 00:00:00 2001 From: Lorenz Leutgeb Date: Fri, 25 Jul 2025 11:01:52 +0200 Subject: [PATCH] chore: Automated fixes generated by clippy --- crates/radicle-cli/src/commands/auth.rs | 3 +-- crates/radicle-cli/src/commands/cob.rs | 10 +++++----- crates/radicle-cli/src/commands/debug.rs | 6 +----- crates/radicle-cli/src/commands/id.rs | 3 +-- crates/radicle-cli/src/commands/issue.rs | 2 +- crates/radicle-cli/src/commands/patch/list.rs | 2 +- crates/radicle-cli/src/commands/patch/show.rs | 4 ++-- crates/radicle-cli/src/commands/sync.rs | 2 +- crates/radicle-cli/src/git.rs | 5 +---- crates/radicle-cli/src/git/ddiff.rs | 3 +-- crates/radicle-cli/src/git/unified_diff.rs | 6 +++--- crates/radicle-cli/src/terminal/format.rs | 10 +++++----- crates/radicle-cli/src/terminal/patch.rs | 2 +- crates/radicle-cli/src/warning.rs | 3 +-- crates/radicle-cli/tests/commands.rs | 4 ++-- crates/radicle-cob/src/tests.rs | 2 +- crates/radicle-fetch/src/state.rs | 4 ++-- crates/radicle-fetch/src/transport.rs | 2 +- crates/radicle-fetch/src/transport/ls_refs.rs | 3 +-- crates/radicle-node/src/control.rs | 2 +- crates/radicle-node/src/runtime.rs | 4 ++-- crates/radicle-node/src/runtime/handle.rs | 4 ++-- crates/radicle-node/src/test/simulator.rs | 10 ++++------ crates/radicle-node/src/tests/e2e.rs | 11 +++++------ crates/radicle-node/src/wire.rs | 2 +- crates/radicle-node/src/worker/channels.rs | 3 +-- crates/radicle-node/src/worker/fetch.rs | 13 +++++-------- crates/radicle-protocol/src/service.rs | 13 ++++++------- crates/radicle-protocol/src/service/gossip.rs | 2 +- crates/radicle-protocol/src/service/session.rs | 2 +- crates/radicle-protocol/src/wire/frame.rs | 2 +- crates/radicle-remote-helper/src/push.rs | 11 ++++------- crates/radicle-schemars/src/main.rs | 2 +- crates/radicle-term/src/spinner.rs | 2 +- crates/radicle/src/canonical/formatter.rs | 8 ++------ crates/radicle/src/cob/patch.rs | 6 +++--- crates/radicle/src/git.rs | 5 +---- crates/radicle/src/identity/doc/update.rs | 2 +- crates/radicle/src/node.rs | 1 - crates/radicle/src/profile.rs | 2 +- crates/radicle/src/storage.rs | 4 ++-- crates/radicle/src/storage/git.rs | 8 ++++---- crates/radicle/src/storage/git/cob.rs | 6 ++---- crates/radicle/src/storage/refs.rs | 2 +- 44 files changed, 85 insertions(+), 118 deletions(-) diff --git a/crates/radicle-cli/src/commands/auth.rs b/crates/radicle-cli/src/commands/auth.rs index d8d449f4..07f09b14 100644 --- a/crates/radicle-cli/src/commands/auth.rs +++ b/crates/radicle-cli/src/commands/auth.rs @@ -171,8 +171,7 @@ pub fn authenticate(options: Options, profile: &Profile) -> anyhow::Result<()> { } for (key, _) in &profile.config.node.extra { term::warning(format!( - "unused or deprecated configuration attribute {:?}", - key + "unused or deprecated configuration attribute {key:?}" )); } diff --git a/crates/radicle-cli/src/commands/cob.rs b/crates/radicle-cli/src/commands/cob.rs index 5249fea2..ae241acd 100644 --- a/crates/radicle-cli/src/commands/cob.rs +++ b/crates/radicle-cli/src/commands/cob.rs @@ -397,7 +397,7 @@ pub fn run(Options { op }: Options, ctx: impl term::Context) -> anyhow::Result<( oid } }; - println!("{}", oid); + println!("{oid}"); } Migrate => { let mut db = profile.cobs_db_mut()?; @@ -501,7 +501,7 @@ pub fn run(Options { op }: Options, ctx: impl term::Context) -> anyhow::Result<( } }; - println!("{}", oid); + println!("{oid}"); } } Ok(()) @@ -588,13 +588,13 @@ fn print_op_pretty(op: cob::Op>) -> anyhow::Result<()> { term::print(term::format::tertiary(format!("resource {oid}"))); } for parent in op.parents { - term::print(format!("parent {}", parent)); + term::print(format!("parent {parent}")); } for parent in op.related { - term::print(format!("rel {}", parent)); + term::print(format!("rel {parent}")); } term::print(format!("author {}", op.author)); - term::print(format!("date {}", time)); + term::print(format!("date {time}")); term::blank(); for action in op.actions { let obj: serde_json::Value = serde_json::from_slice(&action)?; diff --git a/crates/radicle-cli/src/commands/debug.rs b/crates/radicle-cli/src/commands/debug.rs index 6e92024a..21a3f62a 100644 --- a/crates/radicle-cli/src/commands/debug.rs +++ b/crates/radicle-cli/src/commands/debug.rs @@ -68,11 +68,7 @@ fn debug(profile: Option<&Profile>) -> anyhow::Result<()> { })); let debug = DebugInfo { - rad_exe: if let Ok(filename) = std::env::current_exe() { - Some(filename) - } else { - None - }, + rad_exe: std::env::current_exe().ok(), rad_version: VERSION, radicle_node_version: stdout_of("radicle-node", &["--version"]) .unwrap_or("".into()), diff --git a/crates/radicle-cli/src/commands/id.rs b/crates/radicle-cli/src/commands/id.rs index a01ce322..64723a94 100644 --- a/crates/radicle-cli/src/commands/id.rs +++ b/crates/radicle-cli/src/commands/id.rs @@ -396,8 +396,7 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> { Err(errs) => { term::error(format!("failed to verify delegates for {rid}")); term::error(format!( - "the threshold of {} delegates cannot be met..", - threshold + "the threshold of {threshold} delegates cannot be met.." )); for e in errs { print_delegate_verification_error(&e); diff --git a/crates/radicle-cli/src/commands/issue.rs b/crates/radicle-cli/src/commands/issue.rs index 75473520..39b630b4 100644 --- a/crates/radicle-cli/src/commands/issue.rs +++ b/crates/radicle-cli/src/commands/issue.rs @@ -582,7 +582,7 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> { })? .context("No issue with the given ID exists")?; if debug { - println!("{:#?}", issue); + println!("{issue:#?}"); } else { term::issue::show(&issue, &id, format, &profile)?; } diff --git a/crates/radicle-cli/src/commands/patch/list.rs b/crates/radicle-cli/src/commands/patch/list.rs index 2ce2f0ef..6a8c8e41 100644 --- a/crates/radicle-cli/src/commands/patch/list.rs +++ b/crates/radicle-cli/src/commands/patch/list.rs @@ -140,7 +140,7 @@ pub fn row( Ok([ match state { patch::State::Open { .. } => term::format::positive("●").into(), - patch::State::Archived { .. } => term::format::yellow("●").into(), + patch::State::Archived => term::format::yellow("●").into(), patch::State::Draft => term::format::dim("●").into(), patch::State::Merged { .. } => term::format::primary("✔").into(), }, diff --git a/crates/radicle-cli/src/commands/patch/show.rs b/crates/radicle-cli/src/commands/patch/show.rs index 15dd98cd..34988fc6 100644 --- a/crates/radicle-cli/src/commands/patch/show.rs +++ b/crates/radicle-cli/src/commands/patch/show.rs @@ -10,7 +10,7 @@ use super::*; fn show_patch_diff(patch: &patch::Patch, stored: &Repository) -> anyhow::Result<()> { let (from, to) = patch.range()?; - let range = format!("{}..{}", from, to); + let range = format!("{from}..{to}"); process::Command::new("git") .current_dir(stored.path()) @@ -42,7 +42,7 @@ pub fn run( }; if debug { - println!("{:#?}", patch); + println!("{patch:#?}"); return Ok(()); } term::patch::show(&patch, patch_id, verbose, stored, workdir, profile)?; diff --git a/crates/radicle-cli/src/commands/sync.rs b/crates/radicle-cli/src/commands/sync.rs index 69c9abe3..ecbcf243 100644 --- a/crates/radicle-cli/src/commands/sync.rs +++ b/crates/radicle-cli/src/commands/sync.rs @@ -741,7 +741,7 @@ impl FetcherSpinner { required )); } else { - message.push_str(&format!("required {} more seed(s)", required)); + message.push_str(&format!("required {required} more seed(s)")); } self.spinner.message(message); self.spinner.failed(); diff --git a/crates/radicle-cli/src/git.rs b/crates/radicle-cli/src/git.rs index 16cc8cd9..ac0b9ca7 100644 --- a/crates/radicle-cli/src/git.rs +++ b/crates/radicle-cli/src/git.rs @@ -388,10 +388,7 @@ pub fn commit_ssh_fingerprint(path: &Path, sha1: &str) -> Result, .output()?; if !output.status.success() { - return Err(io::Error::new( - io::ErrorKind::Other, - String::from_utf8_lossy(&output.stderr), - )); + return Err(io::Error::other(String::from_utf8_lossy(&output.stderr))); } let string = BufReader::new(output.stdout.as_slice()) diff --git a/crates/radicle-cli/src/git/ddiff.rs b/crates/radicle-cli/src/git/ddiff.rs index 55b5a71c..6b40d716 100644 --- a/crates/radicle-cli/src/git/ddiff.rs +++ b/crates/radicle-cli/src/git/ddiff.rs @@ -304,8 +304,7 @@ impl unified_diff::Decode for DiffModification { }, (v1, v2) => { return Err(unified_diff::Error::syntax(format!( - "indicator character expected, but got '{0}{1}'", - v1, v2 + "indicator character expected, but got '{v1}{v2}'" ))) } }; diff --git a/crates/radicle-cli/src/git/unified_diff.rs b/crates/radicle-cli/src/git/unified_diff.rs index d7b698d5..a9d20b6f 100644 --- a/crates/radicle-cli/src/git/unified_diff.rs +++ b/crates/radicle-cli/src/git/unified_diff.rs @@ -202,9 +202,9 @@ impl Decode for Diff { r.read_to_string(&mut s)?; let d = git::raw::Diff::from_buffer(s.as_ref()) - .map_err(|e| Error::syntax(format!("decoding unified diff: {}", e)))?; - let d = Diff::try_from(d) - .map_err(|e| Error::syntax(format!("decoding unified diff: {}", e)))?; + .map_err(|e| Error::syntax(format!("decoding unified diff: {e}")))?; + let d = + Diff::try_from(d).map_err(|e| Error::syntax(format!("decoding unified diff: {e}")))?; Ok(d) } diff --git a/crates/radicle-cli/src/terminal/format.rs b/crates/radicle-cli/src/terminal/format.rs index 77422e28..3cce6b73 100644 --- a/crates/radicle-cli/src/terminal/format.rs +++ b/crates/radicle-cli/src/terminal/format.rs @@ -350,7 +350,7 @@ pub mod patch { /// Format patch state. pub fn state(s: &State) -> term::Paint { match s { - State::Draft { .. } => term::format::dim(s.to_string()), + State::Draft => term::format::dim(s.to_string()), State::Open { .. } => term::format::positive(s.to_string()), State::Archived => term::format::yellow(s.to_string()), State::Merged { .. } => term::format::secondary(s.to_string()), @@ -366,10 +366,10 @@ pub mod identity { /// Format identity revision state. pub fn state(s: &State) -> term::Paint { match s { - State::Active { .. } => term::format::tertiary(s.to_string()), - State::Accepted { .. } => term::format::positive(s.to_string()), - State::Rejected { .. } => term::format::negative(s.to_string()), - State::Stale { .. } => term::format::dim(s.to_string()), + State::Active => term::format::tertiary(s.to_string()), + State::Accepted => term::format::positive(s.to_string()), + State::Rejected => term::format::negative(s.to_string()), + State::Stale => term::format::dim(s.to_string()), } } } diff --git a/crates/radicle-cli/src/terminal/patch.rs b/crates/radicle-cli/src/terminal/patch.rs index 7a2e1f9c..8f05be3a 100644 --- a/crates/radicle-cli/src/terminal/patch.rs +++ b/crates/radicle-cli/src/terminal/patch.rs @@ -241,7 +241,7 @@ pub fn get_create_message( /// The message shown in the editor when editing a `Patch`. fn edit_display_message(title: &str, description: &str) -> String { - format!("{}\n\n{}\n{PATCH_MSG}", title, description) + format!("{title}\n\n{description}\n{PATCH_MSG}") .trim_start() .to_string() } diff --git a/crates/radicle-cli/src/warning.rs b/crates/radicle-cli/src/warning.rs index 1e762899..7f6703c2 100644 --- a/crates/radicle-cli/src/warning.rs +++ b/crates/radicle-cli/src/warning.rs @@ -28,8 +28,7 @@ fn nodes_renamed_for_option( let old: Address = value.into(); if let Some(new) = NODES_RENAMED.get(&old) { warnings.push(format!( - "Value of configuration option `{option}` at index {i} mentions node with address '{}', which has been renamed to '{}'. Please update your configuration.", - old, new + "Value of configuration option `{option}` at index {i} mentions node with address '{old}', which has been renamed to '{new}'. Please update your configuration." )); } } diff --git a/crates/radicle-cli/tests/commands.rs b/crates/radicle-cli/tests/commands.rs index 9ef56f75..be47ec65 100644 --- a/crates/radicle-cli/tests/commands.rs +++ b/crates/radicle-cli/tests/commands.rs @@ -108,7 +108,7 @@ fn rad_cob_multiset() { log::warn!(target: "test", "`jq` not found. Succeeding prematurely."); return; } - Err(e) => panic!("while checking for jq: {}", e), + Err(e) => panic!("while checking for jq: {e}"), Ok(_) => {} } } @@ -1713,7 +1713,7 @@ fn test_cob_deletion() { ) .unwrap(); let issue_id = issue.id(); - log::debug!(target: "test", "Issue {} created", issue_id); + log::debug!(target: "test", "Issue {issue_id} created"); bob.rad("clone", &[rid.to_string().as_str()], working.path()) .unwrap(); diff --git a/crates/radicle-cob/src/tests.rs b/crates/radicle-cob/src/tests.rs index 63dd3312..683e23f2 100644 --- a/crates/radicle-cob/src/tests.rs +++ b/crates/radicle-cob/src/tests.rs @@ -312,7 +312,7 @@ fn copy_to( object: ObjectId, ) -> Result<(), git2::Error> { let original = { - let name = format!("refs/rad/{}/cobs/{}/{}", from, typename, object); + let name = format!("refs/rad/{from}/cobs/{typename}/{object}"); let r = repo.find_reference(&name)?; r.target().unwrap() }; diff --git a/crates/radicle-fetch/src/state.rs b/crates/radicle-fetch/src/state.rs index 6e47c02f..c0d006de 100644 --- a/crates/radicle-fetch/src/state.rs +++ b/crates/radicle-fetch/src/state.rs @@ -233,7 +233,7 @@ impl FetchState { .collect::>(), None => vec![], }; - log::trace!(target: "fetch", "Received refs {:?}", refs); + log::trace!(target: "fetch", "Received refs {refs:?}"); step.pre_validate(&refs)?; let wants_haves = step.wants_haves(&handle.repo, &refs)?; @@ -318,7 +318,7 @@ impl FetchState { } None => { let followed = handle.allowed(); - log::trace!(target: "fetch", "Followed nodes {:?}", followed); + log::trace!(target: "fetch", "Followed nodes {followed:?}"); let special_refs = stage::SpecialRefs { blocked: handle.blocked.clone(), remote, diff --git a/crates/radicle-fetch/src/transport.rs b/crates/radicle-fetch/src/transport.rs index eeaa3bc4..405d8925 100644 --- a/crates/radicle-fetch/src/transport.rs +++ b/crates/radicle-fetch/src/transport.rs @@ -252,7 +252,7 @@ where } fn io_other(err: impl std::error::Error + Send + Sync + 'static) -> io::Error { - io::Error::new(io::ErrorKind::Other, err) + io::Error::other(err) } #[derive(Debug, Error)] diff --git a/crates/radicle-fetch/src/transport/ls_refs.rs b/crates/radicle-fetch/src/transport/ls_refs.rs index 5a25d735..3696c67a 100644 --- a/crates/radicle-fetch/src/transport/ls_refs.rs +++ b/crates/radicle-fetch/src/transport/ls_refs.rs @@ -46,8 +46,7 @@ where } = handshake; if protocol != &Protocol::V2 { - return Err(ls_refs::Error::Io(io::Error::new( - io::ErrorKind::Other, + return Err(ls_refs::Error::Io(io::Error::other( "expected protocol version 2", ))); } diff --git a/crates/radicle-node/src/control.rs b/crates/radicle-node/src/control.rs index 6c79eee0..0f40b74d 100644 --- a/crates/radicle-node/src/control.rs +++ b/crates/radicle-node/src/control.rs @@ -56,7 +56,7 @@ where } }); } - Err(e) => log::error!(target: "control", "Failed to accept incoming connection: {}", e), + Err(e) => log::error!(target: "control", "Failed to accept incoming connection: {e}"), } } log::debug!(target: "control", "Exiting control loop.."); diff --git a/crates/radicle-node/src/runtime.rs b/crates/radicle-node/src/runtime.rs index 2aa4c598..86954152 100644 --- a/crates/radicle-node/src/runtime.rs +++ b/crates/radicle-node/src/runtime.rs @@ -138,7 +138,7 @@ impl Runtime { let policy = config.seeding_policy.into(); for (key, _) in &config.extra { - log::warn!(target: "node", "Unused or deprecated configuration attribute {:?}", key); + log::warn!(target: "node", "Unused or deprecated configuration attribute {key:?}"); } log::info!(target: "node", "Opening policy database.."); @@ -158,7 +158,7 @@ impl Runtime { } log::info!(target: "node", "Default seeding policy set to '{}'", &policy); - log::info!(target: "node", "Initializing service ({:?})..", network); + log::info!(target: "node", "Initializing service ({network:?}).."); let announcement = if let Some(ann) = fs::read(node_dir.join(node::NODE_ANNOUNCEMENT_FILE)) .ok() diff --git a/crates/radicle-node/src/runtime/handle.rs b/crates/radicle-node/src/runtime/handle.rs index cfc94ec0..f93f61cb 100644 --- a/crates/radicle-node/src/runtime/handle.rs +++ b/crates/radicle-node/src/runtime/handle.rs @@ -275,8 +275,8 @@ impl radicle::node::Handle for Handle { let query: Arc = Arc::new(move |state| { let sessions = state .sessions() - .iter() - .map(|(_, s)| radicle::node::Session::from(s)) + .values() + .map(radicle::node::Session::from) .collect(); sender.send(sessions).ok(); diff --git a/crates/radicle-node/src/test/simulator.rs b/crates/radicle-node/src/test/simulator.rs index 5ee1dff4..38ef3400 100644 --- a/crates/radicle-node/src/test/simulator.rs +++ b/crates/radicle-node/src/test/simulator.rs @@ -360,7 +360,7 @@ where if let Some((time, next)) = priority.or_else(|| self.inbox.next()) { let elapsed = (time - self.start_time).as_millis(); if matches!(next.input, Input::Wake) { - trace!(target: "sim", "{:05} {}", elapsed, next); + trace!(target: "sim", "{elapsed:05} {next}"); } else { // TODO: This can be confusing, since this event may not actually be passed to // the service. It would be best to only log the events that are being sent @@ -477,8 +477,7 @@ where // Drop message if nodes are partitioned. info!( target: "sim", - "{} -> {} (DROPPED)", - sender, receiver, + "{sender} -> {receiver} (DROPPED)", ); return; } @@ -497,8 +496,7 @@ where for msg in &msgs { info!( target: "sim", - "{:05} {} -> {} ({:?}) (+{})", - elapsed, sender, receiver, msg, latency + "{elapsed:05} {sender} -> {receiver} ({msg:?}) (+{latency})" ); } @@ -528,7 +526,7 @@ where // Fail to connect if the nodes are partitioned. if self.is_partitioned(node, remote) { - log::info!(target: "sim", "{} -/-> {} (partitioned)", node, remote); + log::info!(target: "sim", "{node} -/-> {remote} (partitioned)"); // Sometimes, the service gets a failure input, other times it just hangs. if self.rng.borrow_mut().bool() { diff --git a/crates/radicle-node/src/tests/e2e.rs b/crates/radicle-node/src/tests/e2e.rs index ff25dbb6..3a5dae18 100644 --- a/crates/radicle-node/src/tests/e2e.rs +++ b/crates/radicle-node/src/tests/e2e.rs @@ -918,7 +918,7 @@ fn test_non_fastforward_sigrefs() { let old_bob = match up { RefUpdate::Created { oid, .. } => oid, RefUpdate::Skipped { oid, .. } => oid, - _ => panic!("rad/sigrefs should have been created or skipped: {:?}", up), + _ => panic!("rad/sigrefs should have been created or skipped: {up:?}"), }; assert_eq!(bob_sigrefs, old_bob); @@ -930,7 +930,7 @@ fn test_non_fastforward_sigrefs() { .unwrap() .reference_oid(&bob.id, &radicle::storage::refs::SIGREFS_BRANCH) .unwrap(); - log::debug!(target: "test", "bob's old 'rad/sigrefs': {}", before); + log::debug!(target: "test", "bob's old 'rad/sigrefs': {before}"); } // Now Eve disconnects from Bob so she doesn't fetch his update. @@ -961,7 +961,7 @@ fn test_non_fastforward_sigrefs() { RefUpdate::Updated { new, .. } => new, // FIXME: Really it shouldn't be skipped but let's see what happens RefUpdate::Skipped { oid, .. } => oid, - _ => panic!("rad/sigrefs should have been updated {:?}", up), + _ => panic!("rad/sigrefs should have been updated {up:?}"), }; assert_eq!(bob_sigrefs, new_bob); @@ -973,7 +973,7 @@ fn test_non_fastforward_sigrefs() { .unwrap() .reference_oid(&bob.id, &radicle::storage::refs::SIGREFS_BRANCH) .unwrap(); - log::debug!(target: "test", "bob's new 'rad/sigrefs': {}", after); + log::debug!(target: "test", "bob's new 'rad/sigrefs': {after}"); } assert_matches!( @@ -1542,7 +1542,6 @@ fn test_channel_reader_limit() { assert!( reason.contains("Failed to consume the pack sent by the remote") || reason.contains("exceeded number of allowed bytes"), - "actual: {}", - reason + "actual: {reason}" ); } diff --git a/crates/radicle-node/src/wire.rs b/crates/radicle-node/src/wire.rs index 3033b353..b75f900a 100644 --- a/crates/radicle-node/src/wire.rs +++ b/crates/radicle-node/src/wire.rs @@ -959,7 +959,7 @@ where e.remove(); } Peer::Connected { nid, .. } => { - panic!("Wire::handover_transport: Unexpected handover of connected peer {} with id={id} (fd={fd})", nid); + panic!("Wire::handover_transport: Unexpected handover of connected peer {nid} with id={id} (fd={fd})"); } } } diff --git a/crates/radicle-node/src/worker/channels.rs b/crates/radicle-node/src/worker/channels.rs index a5e721bd..1dd6f6b1 100644 --- a/crates/radicle-node/src/worker/channels.rs +++ b/crates/radicle-node/src/worker/channels.rs @@ -171,8 +171,7 @@ impl ReadLimiter { self.total_read = self.total_read.saturating_add(bytes); log::trace!(target: "worker", "limit {}, total bytes read: {}", self.limit, self.total_read); if self.limit.exceeded_by(self.total_read) { - Err(io::Error::new( - io::ErrorKind::Other, + Err(io::Error::other( "sender has exceeded number of allowed bytes, aborting read", )) } else { diff --git a/crates/radicle-node/src/worker/fetch.rs b/crates/radicle-node/src/worker/fetch.rs index bd870dc6..ab9cf96d 100644 --- a/crates/radicle-node/src/worker/fetch.rs +++ b/crates/radicle-node/src/worker/fetch.rs @@ -96,7 +96,7 @@ impl Handle { validations, } => { for fail in validations.iter() { - log::error!(target: "worker", "Validation error: {}", fail); + log::error!(target: "worker", "Validation error: {fail}"); } Err(error::Fetch::Validation { threshold, @@ -109,7 +109,7 @@ impl Handle { validations, } => { for warn in validations { - log::warn!(target: "worker", "Validation error: {}", warn); + log::warn!(target: "worker", "Validation error: {warn}"); } // N.b. We do not go through handle for this since the cloning handle @@ -180,7 +180,7 @@ fn mv(tmp: tempfile::TempDir, storage: &Storage, rid: &RepoId) -> Result<(), err log::warn!(target: "worker", "Refusing to move cloned repository {rid} already exists"); return Err(Error::new( ErrorKind::AlreadyExists, - format!("repository already exists {:?}", to), + format!("repository already exists {to:?}"), ) .into()); } @@ -402,8 +402,7 @@ fn set_canonical_refs(repo: &Repository, applied: &Applied) -> Result<(), error: Err(err) => { log::warn!( target: "worker", - "Failed to calculate canonical reference: {}", - err, + "Failed to calculate canonical reference: {err}", ); continue; } @@ -416,9 +415,7 @@ fn set_canonical_refs(repo: &Repository, applied: &Applied) -> Result<(), error: ) { log::warn!( target: "worker", - "Failed to set canonical reference {}->{}: {e}", - refname, - oid + "Failed to set canonical reference {refname}->{oid}: {e}" ); } } diff --git a/crates/radicle-protocol/src/service.rs b/crates/radicle-protocol/src/service.rs index f2b53c31..8901a011 100644 --- a/crates/radicle-protocol/src/service.rs +++ b/crates/radicle-protocol/src/service.rs @@ -847,7 +847,7 @@ where } pub fn command(&mut self, cmd: Command) { - info!(target: "service", "Received command {:?}", cmd); + info!(target: "service", "Received command {cmd:?}"); match cmd { Command::Connect(nid, addr, opts) => { @@ -1396,7 +1396,7 @@ where let Some(session) = self.sessions.get_mut(&remote) else { // Since we sometimes disconnect the service eagerly, it's not unusual to get a second // disconnection event once the transport is dropped. - trace!(target: "service", "Redundant disconnection for {} ({})", remote, reason); + trace!(target: "service", "Redundant disconnection for {remote} ({reason})"); return; }; // In cases of connection conflicts, there may be disconnections of one of the two @@ -1405,7 +1405,7 @@ where return; } - info!(target: "service", "Disconnected from {} ({})", remote, reason); + info!(target: "service", "Disconnected from {remote} ({reason})"); self.emitter.emit(Event::PeerDisconnected { nid: remote, reason: reason.to_string(), @@ -1836,7 +1836,7 @@ where // // This is not ideal, but until the wire protocol and service are unified, it's the simplest // solution to converge towards the same state. - session::State::Attempted { .. } | session::State::Initial => { + session::State::Attempted | session::State::Initial => { debug!(target: "service", "Received unexpected message from connecting peer {}", peer.id); debug!(target: "service", "Transitioning peer {} to 'connected' state", peer.id); @@ -1978,7 +1978,7 @@ where if let Ok(result) = self.db.routing_mut().add_inventory([&rid], nid, time) { if let &[(_, InsertResult::SeedAdded)] = result.as_slice() { self.emitter.emit(Event::SeedDiscovered { rid, nid }); - info!(target: "service", "Routing table updated for {} with seed {nid}", rid); + info!(target: "service", "Routing table updated for {rid} with seed {nid}"); } } } @@ -2143,8 +2143,7 @@ where if refs.push(refs_at).is_err() { warn!( target: "service", - "refs announcement limit ({}) exceeded, peers will see only some of your repository references", - REF_REMOTE_LIMIT, + "refs announcement limit ({REF_REMOTE_LIMIT}) exceeded, peers will see only some of your repository references", ); break; } diff --git a/crates/radicle-protocol/src/service/gossip.rs b/crates/radicle-protocol/src/service/gossip.rs index 8ba0f16f..0d04c80f 100644 --- a/crates/radicle-protocol/src/service/gossip.rs +++ b/crates/radicle-protocol/src/service/gossip.rs @@ -12,7 +12,7 @@ pub use store::{AnnouncementId, Error, RelayStatus, Store}; /// This node's user agent string. pub static PROTOCOL_VERSION_STRING: LazyLock = LazyLock::new(|| { - FromStr::from_str(format!("/radicle:{}/", PROTOCOL_VERSION).as_str()) + FromStr::from_str(format!("/radicle:{PROTOCOL_VERSION}/").as_str()) .expect("user agent is valid") }); diff --git a/crates/radicle-protocol/src/service/session.rs b/crates/radicle-protocol/src/service/session.rs index 0fc9be0c..07103eb1 100644 --- a/crates/radicle-protocol/src/service/session.rs +++ b/crates/radicle-protocol/src/service/session.rs @@ -205,7 +205,7 @@ impl Session { } pub fn is_connecting(&self) -> bool { - matches!(self.state, State::Attempted { .. }) + matches!(self.state, State::Attempted) } pub fn is_stable(&self) -> bool { diff --git a/crates/radicle-protocol/src/wire/frame.rs b/crates/radicle-protocol/src/wire/frame.rs index 3eb45ffc..0a2fd0c8 100644 --- a/crates/radicle-protocol/src/wire/frame.rs +++ b/crates/radicle-protocol/src/wire/frame.rs @@ -347,7 +347,7 @@ impl wire::Decode for Frame { Ok(frame) } - Ok(StreamKind::Git { .. }) => { + Ok(StreamKind::Git) => { let data = varint::payload::decode(buf)?; Ok(Frame::git(stream, data)) } diff --git a/crates/radicle-remote-helper/src/push.rs b/crates/radicle-remote-helper/src/push.rs index dab29ac2..dfef5696 100644 --- a/crates/radicle-remote-helper/src/push.rs +++ b/crates/radicle-remote-helper/src/push.rs @@ -866,13 +866,10 @@ fn push_ref( [], ) .map_err(|err| { - Error::Io(std::io::Error::new( - std::io::ErrorKind::Other, - format!( - "failed to run `git push {url} {refspec}` in {:?}: {err}", - working.path() - ), - )) + Error::Io(std::io::Error::other(format!( + "failed to run `git push {url} {refspec}` in {:?}: {err}", + working.path() + ))) })?; Ok(()) diff --git a/crates/radicle-schemars/src/main.rs b/crates/radicle-schemars/src/main.rs index a8bbdefb..cb0e4c87 100644 --- a/crates/radicle-schemars/src/main.rs +++ b/crates/radicle-schemars/src/main.rs @@ -51,7 +51,7 @@ impl Schema { fn main() { if let Err(e) = print_schema() { - eprintln!("{}", e); + eprintln!("{e}"); std::process::exit(1); } } diff --git a/crates/radicle-term/src/spinner.rs b/crates/radicle-term/src/spinner.rs index a92d0e8d..e3fa276b 100644 --- a/crates/radicle-term/src/spinner.rs +++ b/crates/radicle-term/src/spinner.rs @@ -180,7 +180,7 @@ pub fn spinner_to( } => { let spinner = DEFAULT_STYLE[*cursor]; - write!(animation, "\r{}{spinner} {message}", CLEAR_UNTIL_NEWLINE,).ok(); + write!(animation, "\r{CLEAR_UNTIL_NEWLINE}{spinner} {message}",).ok(); *cursor += 1; *cursor %= DEFAULT_STYLE.len(); diff --git a/crates/radicle/src/canonical/formatter.rs b/crates/radicle/src/canonical/formatter.rs index 1c3e014b..002bbbc9 100644 --- a/crates/radicle/src/canonical/formatter.rs +++ b/crates/radicle/src/canonical/formatter.rs @@ -90,10 +90,7 @@ impl CanonicalFormatter { /// Returns a mutable reference to the top of the object stack. fn obj_mut(&mut self) -> Result<&mut Object> { self.object_stack.last_mut().ok_or_else(|| { - Error::new( - ErrorKind::Other, - "serde_json called an object method without calling begin_object first", - ) + Error::other("serde_json called an object method without calling begin_object first") }) } } @@ -192,8 +189,7 @@ impl Formatter for CanonicalFormatter { fn end_object(&mut self, writer: &mut W) -> Result<()> { let object = self.object_stack.pop().ok_or_else(|| { - Error::new( - ErrorKind::Other, + Error::other( "serde_json called Formatter::end_object object method without calling begin_object first", ) diff --git a/crates/radicle/src/cob/patch.rs b/crates/radicle/src/cob/patch.rs index af219fa4..40dd1d93 100644 --- a/crates/radicle/src/cob/patch.rs +++ b/crates/radicle/src/cob/patch.rs @@ -663,9 +663,9 @@ impl Patch { // The patch author can edit the patch and change its state. Action::Edit { .. } => Authorization::from(actor == author), Action::Lifecycle { state } => Authorization::from(match state { - Lifecycle::Open { .. } => actor == author, - Lifecycle::Draft { .. } => actor == author, - Lifecycle::Archived { .. } => actor == author, + Lifecycle::Open => actor == author, + Lifecycle::Draft => actor == author, + Lifecycle::Archived => actor == author, }), // Only delegates can carry out these actions. Action::Label { labels } => { diff --git a/crates/radicle/src/git.rs b/crates/radicle/src/git.rs index e7d13117..3e038516 100644 --- a/crates/radicle/src/git.rs +++ b/crates/radicle/src/git.rs @@ -744,10 +744,7 @@ where return Ok(String::from_utf8_lossy(out).into()); } - Err(io::Error::new( - io::ErrorKind::Other, - String::from_utf8_lossy(&output.stderr), - )) + Err(io::Error::other(String::from_utf8_lossy(&output.stderr))) } /// Functions that call to the `git` CLI instead of `git2`. diff --git a/crates/radicle/src/identity/doc/update.rs b/crates/radicle/src/identity/doc/update.rs index 9a55f681..5fd2755c 100644 --- a/crates/radicle/src/identity/doc/update.rs +++ b/crates/radicle/src/identity/doc/update.rs @@ -294,7 +294,7 @@ mod test { ) .unwrap(); let verified = super::verify(raw); - assert!(verified.is_ok(), "Unexpected error {:?}", verified); + assert!(verified.is_ok(), "Unexpected error {verified:?}"); } #[test] diff --git a/crates/radicle/src/node.rs b/crates/radicle/src/node.rs index 620b14d4..87418e72 100644 --- a/crates/radicle/src/node.rs +++ b/crates/radicle/src/node.rs @@ -784,7 +784,6 @@ impl Session { #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] - pub struct Seed { /// The Node ID. #[cfg_attr( diff --git a/crates/radicle/src/profile.rs b/crates/radicle/src/profile.rs index eefef59c..7236399b 100644 --- a/crates/radicle/src/profile.rs +++ b/crates/radicle/src/profile.rs @@ -745,7 +745,7 @@ mod test { let path = tmp.path().join("Home").join("Radicle"); fs::create_dir_all(path.clone()).unwrap(); - let last = tmp.path().components().last().unwrap(); + let last = tmp.path().components().next_back().unwrap(); let home = Home::new( tmp.path() .join("..") diff --git a/crates/radicle/src/storage.rs b/crates/radicle/src/storage.rs index dab7f1ed..9f1d1768 100644 --- a/crates/radicle/src/storage.rs +++ b/crates/radicle/src/storage.rs @@ -417,8 +417,8 @@ impl Remote { let ns = self.id.to_namespace(); // Nb. the references in Refs are expected to be Qualified self.refs - .iter() - .map(|(name, _)| { + .keys() + .map(|name| { let name = PatternString::from(ns.join(name)); Refspec { src: name.clone(), diff --git a/crates/radicle/src/storage/git.rs b/crates/radicle/src/storage/git.rs index 410f3cb6..46a022df 100644 --- a/crates/radicle/src/storage/git.rs +++ b/crates/radicle/src/storage/git.rs @@ -219,7 +219,7 @@ impl Storage { if self.contains(&rid)? { return Err(Error::Io(io::Error::new( io::ErrorKind::AlreadyExists, - format!("refusing to create '{}.lock'", rid), + format!("refusing to create '{rid}.lock'"), )) .into()); } @@ -852,7 +852,7 @@ impl WriteRepository for Repository { self.raw() .reference(&branch_ref, *new, true, "set-local-branch (radicle)")?; - log::debug!(target: "storage", "Setting ref: {} -> {}", head_ref, branch_ref); + log::debug!(target: "storage", "Setting ref: {head_ref} -> {branch_ref}"); self.raw() .reference_symbolic(&head_ref, &branch_ref, true, "set-head (radicle)")?; @@ -1023,8 +1023,8 @@ mod tests { let mut refs = repo .references_of(signer.public_key()) .unwrap() - .iter() - .map(|(r, _)| r.to_string()) + .keys() + .map(|r| r.to_string()) .collect::>(); refs.sort(); diff --git a/crates/radicle/src/storage/git/cob.rs b/crates/radicle/src/storage/git/cob.rs index a3bcce14..90a61bae 100644 --- a/crates/radicle/src/storage/git/cob.rs +++ b/crates/radicle/src/storage/git/cob.rs @@ -156,8 +156,7 @@ impl cob::object::Storage for Repository { (*entry).into(), true, &format!( - "Updating collaborative object '{}/{}' with new entry {}", - typename, object_id, entry, + "Updating collaborative object '{typename}/{object_id}' with new entry {entry}", ), )?; @@ -433,8 +432,7 @@ impl cob::object::Storage for DraftStore<'_, R> { (*entry).into(), true, &format!( - "Updating draft collaborative object '{}/{}' with new entry {}", - typename, object_id, entry, + "Updating draft collaborative object '{typename}/{object_id}' with new entry {entry}", ), )?; diff --git a/crates/radicle/src/storage/refs.rs b/crates/radicle/src/storage/refs.rs index a14c93d5..895a7c84 100644 --- a/crates/radicle/src/storage/refs.rs +++ b/crates/radicle/src/storage/refs.rs @@ -341,7 +341,7 @@ impl SignedRefs { Ok(oid) => Ok(Updated::Updated { oid: oid.into() }), Err(e) => match (e.class(), e.code()) { (git2::ErrorClass::Object, git2::ErrorCode::Modified) => { - log::warn!("Concurrent modification of refs: {:?}", e); + log::warn!("Concurrent modification of refs: {e:?}"); Err(Error::Git(e)) }