diff --git a/apis/c++/node/src/lib.rs b/apis/c++/node/src/lib.rs index 4e06e11a..82643e74 100644 --- a/apis/c++/node/src/lib.rs +++ b/apis/c++/node/src/lib.rs @@ -87,10 +87,6 @@ mod ffi { } } -mod arrow_ffi { - pub use arrow::ffi::{FFI_ArrowArray, FFI_ArrowSchema}; -} - #[cfg(feature = "ros2-bridge")] pub mod ros2 { pub use dora_ros2_bridge::*; @@ -215,7 +211,7 @@ unsafe fn event_as_arrow_input( } } Err(e) => ffi::DoraResult { - error: format!("Error exporting Arrow array to C++: {:?}", e), + error: format!("Error exporting Arrow array to C++: {e:?}"), }, } } @@ -276,7 +272,7 @@ unsafe fn send_arrow_output( } } Err(e) => ffi::DoraResult { - error: format!("Error importing array from C++: {:?}", e), + error: format!("Error importing array from C++: {e:?}"), }, } } diff --git a/apis/python/node/src/lib.rs b/apis/python/node/src/lib.rs index a203f0ba..abe5527c 100644 --- a/apis/python/node/src/lib.rs +++ b/apis/python/node/src/lib.rs @@ -320,6 +320,7 @@ impl Events { } } +#[allow(clippy::large_enum_variant)] enum EventsInner { Dora(EventStream), Merged(Box> + Unpin + Send + Sync>), diff --git a/apis/python/operator/src/lib.rs b/apis/python/operator/src/lib.rs index 59c9dbc1..8856e82c 100644 --- a/apis/python/operator/src/lib.rs +++ b/apis/python/operator/src/lib.rs @@ -214,25 +214,13 @@ pub fn pydict_to_metadata(dict: Option>) -> Result()?)) } else if value.is_instance_of::() { parameters.insert(key, Parameter::String(value.extract()?)) - } else if value.is_instance_of::() + } else if (value.is_instance_of::() || value.is_instance_of::()) && value.len()? > 0 && value.get_item(0)?.is_exact_instance_of::() { let list: Vec = value.extract()?; parameters.insert(key, Parameter::ListInt(list)) - } else if value.is_instance_of::() - && value.len()? > 0 - && value.get_item(0)?.is_exact_instance_of::() - { - let list: Vec = value.extract()?; - parameters.insert(key, Parameter::ListInt(list)) - } else if value.is_instance_of::() - && value.len()? > 0 - && value.get_item(0)?.is_exact_instance_of::() - { - let list: Vec = value.extract()?; - parameters.insert(key, Parameter::ListFloat(list)) - } else if value.is_instance_of::() + } else if (value.is_instance_of::() || value.is_instance_of::()) && value.len()? > 0 && value.get_item(0)?.is_exact_instance_of::() { diff --git a/apis/rust/node/src/event_stream/merged.rs b/apis/rust/node/src/event_stream/merged.rs index adeeafad..b1f13618 100644 --- a/apis/rust/node/src/event_stream/merged.rs +++ b/apis/rust/node/src/event_stream/merged.rs @@ -8,6 +8,7 @@ use futures_concurrency::stream::Merge; /// A Dora event or an event from an external source. #[derive(Debug)] +#[allow(clippy::large_enum_variant)] pub enum MergedEvent { /// A Dora event Dora(super::Event), diff --git a/binaries/cli/src/command/self_.rs b/binaries/cli/src/command/self_.rs index 097a7f4b..1914e46b 100644 --- a/binaries/cli/src/command/self_.rs +++ b/binaries/cli/src/command/self_.rs @@ -55,25 +55,24 @@ impl Executable for SelfSubCommand { ); } else { println!( - "Dora CLI is already at the latest version: {}", - current_version + "Dora CLI is already at the latest version: {current_version}" ); } } - Err(e) => println!("Failed to check for updates: {}", e), + Err(e) => println!("Failed to check for updates: {e}"), } } else { // Perform the actual update match status.update() { Ok(update_status) => match update_status { self_update::Status::UpToDate(version) => { - println!("Dora CLI is already at the latest version: {}", version); + println!("Dora CLI is already at the latest version: {version}"); } self_update::Status::Updated(version) => { - println!("Successfully updated Dora CLI to version: {}", version); + println!("Successfully updated Dora CLI to version: {version}"); } }, - Err(e) => println!("Failed to update: {}", e), + Err(e) => println!("Failed to update: {e}"), } } } diff --git a/binaries/daemon/src/lib.rs b/binaries/daemon/src/lib.rs index d23dd2b8..cc33b50f 100644 --- a/binaries/daemon/src/lib.rs +++ b/binaries/daemon/src/lib.rs @@ -1070,7 +1070,7 @@ impl Daemon { for task in tasks { let NodeBuildTask { node_id, - dynamic_node, + dynamic_node: _, task, } = task; let node = task @@ -2680,6 +2680,7 @@ impl Event { } #[derive(Debug)] +#[allow(clippy::large_enum_variant)] pub enum DaemonNodeEvent { OutputsDone { reply_sender: oneshot::Sender, diff --git a/binaries/daemon/src/log.rs b/binaries/daemon/src/log.rs index 12deadbf..ce71d548 100644 --- a/binaries/daemon/src/log.rs +++ b/binaries/daemon/src/log.rs @@ -416,7 +416,7 @@ struct Indent<'a>(&'a str); impl std::fmt::Display for Indent<'_> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { for line in self.0.lines() { - write!(f, " {}", line)?; + write!(f, " {line}")?; } Ok(()) } diff --git a/binaries/daemon/src/node_communication/mod.rs b/binaries/daemon/src/node_communication/mod.rs index 31b11aa4..8ed9af0b 100644 --- a/binaries/daemon/src/node_communication/mod.rs +++ b/binaries/daemon/src/node_communication/mod.rs @@ -152,7 +152,7 @@ pub async fn spawn_listener_loop( if !tmpfile_dir.exists() { std::fs::create_dir_all(&tmpfile_dir).context("could not create tmp dir")?; } - let socket_file = tmpfile_dir.join(format!("{}.sock", node_id)); + let socket_file = tmpfile_dir.join(format!("{node_id}.sock")); let socket = match UnixListener::bind(&socket_file) { Ok(socket) => socket, Err(err) => { diff --git a/binaries/daemon/src/node_communication/shmem.rs b/binaries/daemon/src/node_communication/shmem.rs index 9f94b25a..eb3aaf7d 100644 --- a/binaries/daemon/src/node_communication/shmem.rs +++ b/binaries/daemon/src/node_communication/shmem.rs @@ -42,6 +42,7 @@ pub async fn listener_loop( Listener::run(connection, daemon_tx, clock).await } +#[allow(clippy::large_enum_variant)] enum Operation { Receive(oneshot::Sender>>>), Send { diff --git a/binaries/daemon/src/spawn.rs b/binaries/daemon/src/spawn.rs index c4a3e285..39ac086a 100644 --- a/binaries/daemon/src/spawn.rs +++ b/binaries/daemon/src/spawn.rs @@ -633,7 +633,7 @@ async fn path_spawn_command( .wrap_err("failed to download custom node")? } else { resolve_path(source, working_dir) - .wrap_err_with(|| format!("failed to resolve node source `{}`", source))? + .wrap_err_with(|| format!("failed to resolve node source `{source}`"))? }; // If extension is .py, use python to run the script diff --git a/examples/benchmark/node/src/main.rs b/examples/benchmark/node/src/main.rs index ab2d1e9c..e8deca6b 100644 --- a/examples/benchmark/node/src/main.rs +++ b/examples/benchmark/node/src/main.rs @@ -34,7 +34,7 @@ fn main() -> eyre::Result<()> { for data in &data { for _ in 0..1 { node.send_output_raw(latency.clone(), Default::default(), data.len(), |out| { - out.copy_from_slice(&data); + out.copy_from_slice(data); })?; // sleep a bit to avoid queue buildup @@ -49,7 +49,7 @@ fn main() -> eyre::Result<()> { for data in &data { for _ in 0..100 { node.send_output_raw(throughput.clone(), Default::default(), data.len(), |out| { - out.copy_from_slice(&data); + out.copy_from_slice(data); })?; } // notify sink that all messages have been sent diff --git a/examples/multiple-daemons/sink/src/main.rs b/examples/multiple-daemons/sink/src/main.rs index 59316aba..feb01395 100644 --- a/examples/multiple-daemons/sink/src/main.rs +++ b/examples/multiple-daemons/sink/src/main.rs @@ -14,7 +14,7 @@ fn main() -> eyre::Result<()> { "message" => { let received_string: &str = TryFrom::try_from(&data).context("expected string message")?; - println!("sink received message: {}", received_string); + println!("sink received message: {received_string}"); if !received_string.starts_with("operator received random value ") { bail!("unexpected message format (should start with 'operator received random value')") } diff --git a/examples/rust-dataflow/sink-dynamic/src/main.rs b/examples/rust-dataflow/sink-dynamic/src/main.rs index db5164b7..5bda47f6 100644 --- a/examples/rust-dataflow/sink-dynamic/src/main.rs +++ b/examples/rust-dataflow/sink-dynamic/src/main.rs @@ -15,7 +15,7 @@ fn main() -> eyre::Result<()> { "message" => { let received_string: &str = TryFrom::try_from(&data).context("expected string message")?; - println!("sink received message: {}", received_string); + println!("sink received message: {received_string}"); if !received_string.starts_with("operator received random value ") { bail!("unexpected message format (should start with 'operator received random value')") } diff --git a/examples/rust-dataflow/sink/src/main.rs b/examples/rust-dataflow/sink/src/main.rs index 59316aba..feb01395 100644 --- a/examples/rust-dataflow/sink/src/main.rs +++ b/examples/rust-dataflow/sink/src/main.rs @@ -14,7 +14,7 @@ fn main() -> eyre::Result<()> { "message" => { let received_string: &str = TryFrom::try_from(&data).context("expected string message")?; - println!("sink received message: {}", received_string); + println!("sink received message: {received_string}"); if !received_string.starts_with("operator received random value ") { bail!("unexpected message format (should start with 'operator received random value')") } diff --git a/examples/rust-dataflow/status-node/src/main.rs b/examples/rust-dataflow/status-node/src/main.rs index ff97b97e..99be97c6 100644 --- a/examples/rust-dataflow/status-node/src/main.rs +++ b/examples/rust-dataflow/status-node/src/main.rs @@ -17,10 +17,8 @@ fn main() -> eyre::Result<()> { "random" => { let value = u64::try_from(&data).context("unexpected data type")?; - let output = format!( - "operator received random value {value:#x} after {} ticks", - ticks - ); + let output = + format!("operator received random value {value:#x} after {ticks} ticks"); node.send_output( status_output.clone(), metadata.parameters, diff --git a/libraries/communication-layer/pub-sub/src/zenoh.rs b/libraries/communication-layer/pub-sub/src/zenoh.rs index 76be1a54..b185376d 100644 --- a/libraries/communication-layer/pub-sub/src/zenoh.rs +++ b/libraries/communication-layer/pub-sub/src/zenoh.rs @@ -21,10 +21,7 @@ impl ZenohCommunicationLayer { /// and [`subscriber`][Self::subscribe] methods. Pass an empty string if no prefix is /// desired. pub fn init(config: Config, prefix: String) -> Result { - let zenoh = ::zenoh::open(config) - .res_sync() - .map_err(BoxError::from)? - .into_arc(); + let zenoh = ::zenoh::open(config).res_sync()?.into_arc(); Ok(Self { zenoh, topic_prefix: prefix, @@ -43,8 +40,7 @@ impl CommunicationLayer for ZenohCommunicationLayer { .declare_publisher(self.prefixed(topic)) .congestion_control(CongestionControl::Block) .priority(Priority::RealTime) - .res_sync() - .map_err(BoxError::from)?; + .res_sync()?; Ok(Box::new(ZenohPublisher { publisher })) } @@ -54,8 +50,7 @@ impl CommunicationLayer for ZenohCommunicationLayer { .zenoh .declare_subscriber(self.prefixed(topic)) .reliable() - .res_sync() - .map_err(BoxError::from)?; + .res_sync()?; Ok(Box::new(ZenohReceiver(subscriber))) } @@ -102,10 +97,7 @@ impl<'a> crate::PublishSample<'a> for ZenohPublishSample { } fn publish(self: Box) -> Result<(), BoxError> { - self.publisher - .put(self.sample) - .res_sync() - .map_err(BoxError::from) + self.publisher.put(self.sample).res_sync() } } diff --git a/libraries/core/src/build/git.rs b/libraries/core/src/build/git.rs index 7e06f2e0..128bd156 100644 --- a/libraries/core/src/build/git.rs +++ b/libraries/core/src/build/git.rs @@ -15,7 +15,7 @@ pub struct GitManager { pub clones_in_use: BTreeMap>, /// Builds that are prepared, but not done yet. prepared_builds: BTreeMap, - reuse_for: BTreeMap, + // reuse_for: BTreeMap, } #[derive(Default)] diff --git a/libraries/core/src/metadata.rs b/libraries/core/src/metadata.rs index 1aa85275..e74ed262 100644 --- a/libraries/core/src/metadata.rs +++ b/libraries/core/src/metadata.rs @@ -8,6 +8,11 @@ use eyre::Context; pub trait ArrowTypeInfoExt { fn empty() -> Self; fn byte_array(data_len: usize) -> Self; + + /// # Safety + /// + /// This function assumes that the `ArrayData` is backed by a memory region that starts at `region_start` + /// and has a length of `region_len`. It will panic if the `ArrayData` does not conform to this assumption. unsafe fn from_array( array: &ArrayData, region_start: *const u8, diff --git a/libraries/extensions/ros2-bridge/msg-gen/src/parser/action.rs b/libraries/extensions/ros2-bridge/msg-gen/src/parser/action.rs index eb279d66..c2ebf56a 100644 --- a/libraries/extensions/ros2-bridge/msg-gen/src/parser/action.rs +++ b/libraries/extensions/ros2-bridge/msg-gen/src/parser/action.rs @@ -40,17 +40,17 @@ fn parse_action_string(pkg_name: &str, action_name: &str, action_string: &str) - name: action_name.into(), goal: parse_message_string( pkg_name, - &format!("{}{}", action_name, ACTION_GOAL_SUFFIX), + &format!("{action_name}{ACTION_GOAL_SUFFIX}"), action_blocks[0], )?, result: parse_message_string( pkg_name, - &format!("{}{}", action_name, ACTION_RESULT_SUFFIX), + &format!("{action_name}{ACTION_RESULT_SUFFIX}"), action_blocks[1], )?, feedback: parse_message_string( pkg_name, - &format!("{}{}", action_name, ACTION_FEEDBACK_SUFFIX), + &format!("{action_name}{ACTION_FEEDBACK_SUFFIX}"), action_blocks[2], )?, }) diff --git a/libraries/extensions/ros2-bridge/msg-gen/src/parser/member.rs b/libraries/extensions/ros2-bridge/msg-gen/src/parser/member.rs index c52380e9..57c4a5db 100644 --- a/libraries/extensions/ros2-bridge/msg-gen/src/parser/member.rs +++ b/libraries/extensions/ros2-bridge/msg-gen/src/parser/member.rs @@ -18,11 +18,9 @@ fn nestable_type_default(nestable_type: NestableType, default: &str) -> Result { - Err(RclMsgError::InvalidDefaultError(format!("{}", t)).into()) - } + NestableType::NamedType(t) => Err(RclMsgError::InvalidDefaultError(format!("{t}")).into()), NestableType::NamespacedType(t) => { - Err(RclMsgError::InvalidDefaultError(format!("{}", t)).into()) + Err(RclMsgError::InvalidDefaultError(format!("{t}")).into()) } NestableType::GenericString(t) => { let (rest, default) = literal::get_string_literal_parser(t)(default) @@ -41,11 +39,9 @@ fn array_type_default(value_type: NestableType, default: &str) -> Result { - Err(RclMsgError::InvalidDefaultError(format!("{}", t)).into()) - } + NestableType::NamedType(t) => Err(RclMsgError::InvalidDefaultError(format!("{t}")).into()), NestableType::NamespacedType(t) => { - Err(RclMsgError::InvalidDefaultError(format!("{}", t)).into()) + Err(RclMsgError::InvalidDefaultError(format!("{t}")).into()) } NestableType::GenericString(_) => { let (rest, default) = literal::string_literal_sequence(default) diff --git a/libraries/extensions/ros2-bridge/msg-gen/src/parser/service.rs b/libraries/extensions/ros2-bridge/msg-gen/src/parser/service.rs index 033b5b10..1ab74f31 100644 --- a/libraries/extensions/ros2-bridge/msg-gen/src/parser/service.rs +++ b/libraries/extensions/ros2-bridge/msg-gen/src/parser/service.rs @@ -39,12 +39,12 @@ fn parse_service_string(pkg_name: &str, srv_name: &str, service_string: &str) -> name: srv_name.into(), request: parse_message_string( pkg_name, - &format!("{}{}", srv_name, SERVICE_REQUEST_SUFFIX), + &format!("{srv_name}{SERVICE_REQUEST_SUFFIX}"), service_blocks[0], )?, response: parse_message_string( pkg_name, - &format!("{}{}", srv_name, SERVICE_RESPONSE_SUFFIX), + &format!("{srv_name}{SERVICE_RESPONSE_SUFFIX}"), service_blocks[1], )?, }) diff --git a/libraries/extensions/ros2-bridge/msg-gen/src/types/action.rs b/libraries/extensions/ros2-bridge/msg-gen/src/types/action.rs index 8947bcda..6e2a9219 100644 --- a/libraries/extensions/ros2-bridge/msg-gen/src/types/action.rs +++ b/libraries/extensions/ros2-bridge/msg-gen/src/types/action.rs @@ -97,7 +97,7 @@ impl Action { let request = Message { package: self.package.clone(), - name: format!("{}_Request", common), + name: format!("{common}_Request"), members: vec![ goal_id_type(), Member { @@ -115,7 +115,7 @@ impl Action { }; let response = Message { package: self.package.clone(), - name: format!("{}_Response", common), + name: format!("{common}_Response"), members: vec![ Member { name: "accepted".into(), @@ -149,13 +149,13 @@ impl Action { let request = Message { package: self.package.clone(), - name: format!("{}_Request", common), + name: format!("{common}_Request"), members: vec![goal_id_type()], constants: vec![], }; let response = Message { package: self.package.clone(), - name: format!("{}_Response", common), + name: format!("{common}_Response"), members: vec![ Member { name: "status".into(), diff --git a/libraries/message/src/daemon_to_daemon.rs b/libraries/message/src/daemon_to_daemon.rs index 7de899e7..b1452a9a 100644 --- a/libraries/message/src/daemon_to_daemon.rs +++ b/libraries/message/src/daemon_to_daemon.rs @@ -7,6 +7,7 @@ use crate::{ }; #[derive(Debug, serde::Deserialize, serde::Serialize)] +#[allow(clippy::large_enum_variant)] pub enum InterDaemonEvent { Output { dataflow_id: DataflowId, diff --git a/libraries/message/src/daemon_to_node.rs b/libraries/message/src/daemon_to_node.rs index 75c59bba..7d520f42 100644 --- a/libraries/message/src/daemon_to_node.rs +++ b/libraries/message/src/daemon_to_node.rs @@ -46,6 +46,7 @@ pub enum DaemonCommunication { #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] #[must_use] +#[allow(clippy::large_enum_variant)] pub enum DaemonReply { Result(Result<(), String>), PreparedMessage { shared_memory_id: SharedMemoryId }, @@ -56,6 +57,7 @@ pub enum DaemonReply { } #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] +#[allow(clippy::large_enum_variant)] pub enum NodeEvent { Stop, Reload { diff --git a/libraries/message/src/descriptor.rs b/libraries/message/src/descriptor.rs index f6a2ba9c..1e640eb9 100644 --- a/libraries/message/src/descriptor.rs +++ b/libraries/message/src/descriptor.rs @@ -108,6 +108,7 @@ pub struct ResolvedNode { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "lowercase")] +#[allow(clippy::large_enum_variant)] pub enum CoreNodeKind { /// Dora runtime node #[serde(rename = "operators")] diff --git a/node-hub/dora-dav1d/src/lib.rs b/node-hub/dora-dav1d/src/lib.rs index b6aeed30..45e8477d 100644 --- a/node-hub/dora-dav1d/src/lib.rs +++ b/node-hub/dora-dav1d/src/lib.rs @@ -72,12 +72,12 @@ pub fn lib_main() -> Result<()> { .map(|s| s.as_str()) .unwrap_or("av1"); if encoding != "av1" { - warn!("Unsupported encoding {}", encoding); + warn!("Unsupported encoding {encoding}"); continue; } match dec.send_data(data, None, None, None) { Err(e) => { - warn!("Error sending data to the decoder: {}", e); + warn!("Error sending data to the decoder: {e}"); } Ok(()) => { if let Ok(p) = dec.get_picture() { @@ -136,8 +136,7 @@ pub fn lib_main() -> Result<()> { } _ => { warn!( - "Unsupported output encoding {}", - output_encoding + "Unsupported output encoding {output_encoding}" ); continue; } diff --git a/node-hub/dora-kit-car/src/lib.rs b/node-hub/dora-kit-car/src/lib.rs index 11456925..2e883074 100644 --- a/node-hub/dora-kit-car/src/lib.rs +++ b/node-hub/dora-kit-car/src/lib.rs @@ -32,7 +32,7 @@ pub fn lib_main() -> eyre::Result<()> { let mut com = serial::open(&serial_port).wrap_err(Error::Connect(serial_port))?; com.configure(&COM_SETTINGS) - .wrap_err(Error::SettingsSet(format!("{:?}", COM_SETTINGS)))?; + .wrap_err(Error::SettingsSet(format!("{COM_SETTINGS:?}")))?; com.set_timeout(Duration::from_millis(1000)) .wrap_err(Error::SetTimeout("1000ms".to_string()))?; diff --git a/node-hub/dora-mistral-rs/src/main.rs b/node-hub/dora-mistral-rs/src/main.rs index e9227633..6bb623c9 100644 --- a/node-hub/dora-mistral-rs/src/main.rs +++ b/node-hub/dora-mistral-rs/src/main.rs @@ -13,7 +13,7 @@ async fn main() -> eyre::Result<()> { .with_logging() .build() .await - .map_err(|e| Report::msg(format!("Model Build error: {}", e))) // Convert error + .map_err(|e| Report::msg(format!("Model Build error: {e}"))) // Convert error .expect("Failed to build model"); while let Some(event) = events.recv_async().await { @@ -33,7 +33,7 @@ async fn main() -> eyre::Result<()> { let response = model .send_chat_request(messages) .await - .map_err(|e| Report::msg(format!("Model Response error: {}", e))) // Convert error + .map_err(|e| Report::msg(format!("Model Response error: {e}"))) // Convert error .expect("Failed to get response from model"); let output = response.choices[0].message.content.as_ref().unwrap(); diff --git a/node-hub/dora-rav1e/src/lib.rs b/node-hub/dora-rav1e/src/lib.rs index abba7c8e..9ce9f1fd 100644 --- a/node-hub/dora-rav1e/src/lib.rs +++ b/node-hub/dora-rav1e/src/lib.rs @@ -76,7 +76,7 @@ fn metadata_to_exif(metadata: &MetadataParameters) -> Result> { } let vector = metadata_exif.as_u8_vec(little_exif::filetype::FileExtension::HEIF)?; - return Ok(vector); + Ok(vector) } fn bgr8_to_yuv420(bgr_data: Vec, width: usize, height: usize) -> (Vec, Vec, Vec) { diff --git a/node-hub/dora-record/src/main.rs b/node-hub/dora-record/src/main.rs index e6ac8b58..f0ab232f 100644 --- a/node-hub/dora-record/src/main.rs +++ b/node-hub/dora-record/src/main.rs @@ -79,7 +79,7 @@ async fn main() -> eyre::Result<()> { if let Err(e) = write_event(&mut writer, data, &metadata, schema.clone()).await { - println!("Error writing event data into parquet file: {:?}", e) + println!("Error writing event data into parquet file: {e:?}") }; } writer.close().await @@ -101,7 +101,7 @@ async fn main() -> eyre::Result<()> { Some(tx) => drop(tx), }, Event::Error(err) => { - println!("Error: {}", err); + println!("Error: {err}"); } event => { println!("Event: {event:#?}") diff --git a/node-hub/dora-rerun/src/boxes2d.rs b/node-hub/dora-rerun/src/boxes2d.rs index f07280ae..ea1e34bd 100644 --- a/node-hub/dora-rerun/src/boxes2d.rs +++ b/node-hub/dora-rerun/src/boxes2d.rs @@ -147,7 +147,7 @@ pub fn update_boxes2d( }); } - if values.len() == 0 { + if values.is_empty() { rec.log(id.as_str(), &rerun::Clear::flat()) .wrap_err("Could not log Boxes2D")?; return Ok(()); @@ -178,7 +178,7 @@ pub fn update_boxes2d( }); } - if values.len() == 0 { + if values.is_empty() { rec.log(id.as_str(), &rerun::Clear::flat()) .wrap_err("Could not log Boxes2D")?; return Ok(()); @@ -209,7 +209,7 @@ pub fn update_boxes2d( }); } - if values.len() == 0 { + if values.is_empty() { rec.log(id.as_str(), &rerun::Clear::flat()) .wrap_err("Could not log Boxes2D")?; return Ok(()); @@ -239,7 +239,7 @@ pub fn update_boxes2d( } }); } - if values.len() == 0 { + if values.is_empty() { rec.log(id.as_str(), &rerun::Clear::flat()) .wrap_err("Could not log Boxes2D")?; return Ok(()); diff --git a/node-hub/dora-rerun/src/lib.rs b/node-hub/dora-rerun/src/lib.rs index 48037074..62105173 100644 --- a/node-hub/dora-rerun/src/lib.rs +++ b/node-hub/dora-rerun/src/lib.rs @@ -76,7 +76,7 @@ pub fn lib_main() -> Result<()> { let id = node.dataflow_id(); let path = Path::new("out") .join(id.to_string()) - .join(format!("archive-{}.rerun", id)); + .join(format!("archive-{id}.rerun")); rerun::RecordingStreamBuilder::new("dora-rerun") .save(path) @@ -368,7 +368,7 @@ pub fn lib_main() -> Result<()> { "jointstate" }; if encoding != "jointstate" { - warn!("Got unexpected encoding: {} on position pose", encoding); + warn!("Got unexpected encoding: {encoding} on position pose"); continue; } // Convert to Vec @@ -386,6 +386,7 @@ pub fn lib_main() -> Result<()> { if dof < positions.len() { positions.truncate(dof); } else { + #[allow(clippy::same_item_push)] for _ in 0..(dof - positions.len()) { positions.push(0.); } @@ -393,7 +394,7 @@ pub fn lib_main() -> Result<()> { update_visualization(&rec, chain, &id, &positions)?; } else { - println!("Could not find chain for {}. You may not have set its", id); + println!("Could not find chain for {id}. You may not have set its"); } } else if id.as_str().contains("series") { update_series(&rec, id, data).context("could not plot series")?; @@ -452,7 +453,7 @@ pub fn lib_main() -> Result<()> { .context("could not log points")?; } } else { - println!("Could not find handler for {}", id); + println!("Could not find handler for {id}"); } } } diff --git a/node-hub/dora-rerun/src/urdf.rs b/node-hub/dora-rerun/src/urdf.rs index ffe763d9..4bc68525 100644 --- a/node-hub/dora-rerun/src/urdf.rs +++ b/node-hub/dora-rerun/src/urdf.rs @@ -82,7 +82,7 @@ pub fn init_urdf(rec: &RecordingStream) -> Result>> { PathBuf::from(urdf_path) }; let chain = k::Chain::::from_urdf_file(&urdf_path) - .context(format!("Could not load URDF {:#?}", urdf_path))?; + .context(format!("Could not load URDF {urdf_path:#?}"))?; let path = key.replace("_urdf", ".urdf").replace("_URDF", ".urdf"); let transform = key.replace("_urdf", "_transform"); @@ -94,10 +94,9 @@ pub fn init_urdf(rec: &RecordingStream) -> Result>> { } rec.log_file_from_path(&urdf_path, None, true) .context(format!( - "Could not log URDF file {:#?} within rerun-urdf-loader", - urdf_path + "Could not log URDF file {urdf_path:#?} within rerun-urdf-loader" ))?; - println!("Logging URDF file: {:#?}", urdf_path); + println!("Logging URDF file: {urdf_path:#?}"); // Get transform by replacing URDF_ with TRANSFORM_ if let Ok(transform) = std::env::var(transform) { diff --git a/node-hub/openai-proxy-server/src/main.rs b/node-hub/openai-proxy-server/src/main.rs index 4cee442f..7689dad4 100644 --- a/node-hub/openai-proxy-server/src/main.rs +++ b/node-hub/openai-proxy-server/src/main.rs @@ -320,7 +320,7 @@ async fn chat_completions_handler( let body_bytes = match to_bytes(req.body_mut()).await { Ok(body_bytes) => body_bytes, Err(e) => { - let err_msg = format!("Fail to read buffer from request body. {}", e); + let err_msg = format!("Fail to read buffer from request body. {e}"); // log error!(target: "stdout", "{}", &err_msg); @@ -331,10 +331,10 @@ async fn chat_completions_handler( let mut chat_request: ChatCompletionRequest = match serde_json::from_slice(&body_bytes) { Ok(chat_request) => chat_request, Err(e) => { - let mut err_msg = format!("Fail to deserialize chat completion request: {}.", e); + let mut err_msg = format!("Fail to deserialize chat completion request: {e}."); if let Ok(json_value) = serde_json::from_slice::(&body_bytes) { - err_msg = format!("{}\njson_value: {}", err_msg, json_value); + err_msg = format!("{err_msg}\njson_value: {json_value}"); } // log @@ -393,7 +393,7 @@ async fn chat_completions_handler( response } Err(e) => { - let err_msg = format!("Failed chat completions in stream mode. Reason: {}", e); + let err_msg = format!("Failed chat completions in stream mode. Reason: {e}"); // log error!(target: "stdout", "{}", &err_msg); @@ -411,7 +411,7 @@ async fn chat_completions_handler( let s = match serde_json::to_string(&chat_completion_object) { Ok(s) => s, Err(e) => { - let err_msg = format!("Failed to serialize chat completion object. {}", e); + let err_msg = format!("Failed to serialize chat completion object. {e}"); // log error!(target: "stdout", "{}", &err_msg); @@ -438,7 +438,7 @@ async fn chat_completions_handler( } Err(e) => { let err_msg = - format!("Failed chat completions in non-stream mode. Reason: {}", e); + format!("Failed chat completions in non-stream mode. Reason: {e}"); // log error!(target: "stdout", "{}", &err_msg); @@ -448,7 +448,7 @@ async fn chat_completions_handler( } } Err(e) => { - let err_msg = format!("Failed to get chat completions. Reason: {}", e); + let err_msg = format!("Failed to get chat completions. Reason: {e}"); // log error!(target: "stdout", "{}", &err_msg); diff --git a/node-hub/terminal-print/src/main.rs b/node-hub/terminal-print/src/main.rs index f6cc7f34..49f1a94a 100644 --- a/node-hub/terminal-print/src/main.rs +++ b/node-hub/terminal-print/src/main.rs @@ -19,10 +19,10 @@ fn main() -> eyre::Result<()> { dora_node_api::arrow::datatypes::DataType::Utf8 => { let received_string: &str = TryFrom::try_from(&data).context("expected string message")?; - println!("Received id: {}, data: {}", id, received_string); + println!("Received id: {id}, data: {received_string}"); } _other => { - println!("Received id: {}, data: {:#?}", id, data); + println!("Received id: {id}, data: {data:#?}"); } }, _other => {} @@ -33,7 +33,7 @@ fn main() -> eyre::Result<()> { } Err(err) => { if err.to_string() == printed_error { - println!("{:#?}", err); + println!("{err:#?}"); println!("🕐 waiting for node `terminal-print` to be available..."); printed_error = err.to_string(); } diff --git a/tests/queue_size_latest_data_rust/receive_data/src/main.rs b/tests/queue_size_latest_data_rust/receive_data/src/main.rs index 55d635c8..52b21411 100644 --- a/tests/queue_size_latest_data_rust/receive_data/src/main.rs +++ b/tests/queue_size_latest_data_rust/receive_data/src/main.rs @@ -26,7 +26,7 @@ fn main() -> eyre::Result<()> { let _time: u64 = data.values()[0]; let time_metadata = metadata.timestamp(); let duration_metadata = time_metadata.get_time().to_system_time().elapsed()?; - println!("Latency duration: {:?}", duration_metadata); + println!("Latency duration: {duration_metadata:?}"); assert!( duration_metadata < Duration::from_millis(500), "Time difference should be less than 500ms"