From 877ade660676e5f32ed771ac51f8b1f8d19f0bb9 Mon Sep 17 00:00:00 2001 From: Akhil T Thomas Date: Mon, 25 Dec 2023 03:04:47 +0530 Subject: [PATCH] fix clippy warnings Signed-off-by: Akhil T Thomas --- .../databroker-cli/src/kuksa_cli.rs | 8 +++--- kuksa_databroker/databroker/src/broker.rs | 25 +++++++++++++++++++ .../src/grpc/kuksa_val_v1/conversions.rs | 6 +++-- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/kuksa_databroker/databroker-cli/src/kuksa_cli.rs b/kuksa_databroker/databroker-cli/src/kuksa_cli.rs index 38966b7c..a3987f06 100644 --- a/kuksa_databroker/databroker-cli/src/kuksa_cli.rs +++ b/kuksa_databroker/databroker-cli/src/kuksa_cli.rs @@ -218,7 +218,7 @@ pub async fn kuksa_main(_cli: Cli) -> Result<(), Box> { entry .metadata .and_then(|meta| meta.unit) - .map(|unit| format!("{}", unit)) + .map(|unit| unit.to_string()) .unwrap_or_else(|| "".to_string()) ); } else { @@ -532,10 +532,8 @@ pub async fn kuksa_main(_cli: Cli) -> Result<(), Box> { .and_then( |meta| meta.unit ) - .map(|unit| format!( - "{}", - unit - )) + .map(|unit| unit + .to_string()) .unwrap_or_else( || "".to_string() ) diff --git a/kuksa_databroker/databroker/src/broker.rs b/kuksa_databroker/databroker/src/broker.rs index 617c5260..0ae45e0b 100644 --- a/kuksa_databroker/databroker/src/broker.rs +++ b/kuksa_databroker/databroker/src/broker.rs @@ -1138,6 +1138,7 @@ pub struct AuthorizedAccess<'a, 'b> { } impl<'a, 'b> AuthorizedAccess<'a, 'b> { + #[allow(clippy::too_many_arguments)] pub async fn add_entry( &self, name: String, @@ -1647,6 +1648,7 @@ mod tests { data_type: None, description: None, allowed: None, + unit: None, }, )]) .await @@ -1677,6 +1679,7 @@ mod tests { data_type: None, description: None, allowed: None, + unit: None, }, )]) .await @@ -1697,6 +1700,7 @@ mod tests { data_type: None, description: None, allowed: None, + unit: None, }, )]) .await @@ -1767,6 +1771,7 @@ mod tests { data_type: None, description: None, allowed: Some(Some(DataValue::Int32Array(vec![100]))), + unit: None, }, )]) .await @@ -1788,6 +1793,7 @@ mod tests { data_type: None, description: None, allowed: Some(Some(DataValue::BoolArray(vec![true]))), + unit: None, }, )]) .await @@ -1809,6 +1815,7 @@ mod tests { data_type: None, description: None, allowed: Some(None), + unit: None, }, )]) .await @@ -1830,6 +1837,7 @@ mod tests { data_type: None, description: None, allowed: None, + unit: None, }, )]) .await @@ -1899,6 +1907,7 @@ mod tests { data_type: None, description: None, allowed: None, + unit: None, }, )]) .await @@ -1999,6 +2008,7 @@ mod tests { data_type: None, description: None, allowed: None, + unit: None, }, )]) .await @@ -2080,6 +2090,7 @@ mod tests { data_type: None, description: None, allowed: None, + unit: None, }, )]) .await @@ -2137,6 +2148,7 @@ mod tests { data_type: None, description: None, allowed: None, + unit: None, }, )]) .await @@ -2233,6 +2245,7 @@ mod tests { data_type: None, description: None, allowed: None, + unit: None, }, ), ( @@ -2248,6 +2261,7 @@ mod tests { data_type: None, description: None, allowed: None, + unit: None, }, ), ]) @@ -2309,6 +2323,7 @@ mod tests { data_type: None, description: None, allowed: None, + unit: None, }, )]) .await @@ -2377,6 +2392,7 @@ mod tests { data_type: None, description: None, allowed: None, + unit: None, }, )]) .await @@ -2455,6 +2471,7 @@ mod tests { data_type: None, description: None, allowed: None, + unit: None, }, )]) .await @@ -2510,6 +2527,7 @@ mod tests { data_type: None, description: None, allowed: None, + unit: None, }, )]) .await @@ -2563,6 +2581,7 @@ mod tests { data_type: None, description: None, allowed: None, + unit: None, }, )]) .await @@ -2607,6 +2626,7 @@ mod tests { data_type: None, description: None, allowed: None, + unit: None, }, )]) .await @@ -2634,6 +2654,7 @@ mod tests { data_type: None, description: None, allowed: None, + unit: None, }, )]) .await @@ -2689,6 +2710,7 @@ mod tests { data_type: None, description: None, allowed: None, + unit: None, }, )]) .await @@ -2716,6 +2738,7 @@ mod tests { data_type: None, description: None, allowed: None, + unit: None, }, )]) .await @@ -2774,6 +2797,7 @@ mod tests { data_type: None, description: None, allowed: None, + unit: None, }, )]) .await @@ -2859,6 +2883,7 @@ mod tests { data_type: None, description: None, allowed: None, + unit: None, }, )]) .await diff --git a/kuksa_databroker/databroker/src/grpc/kuksa_val_v1/conversions.rs b/kuksa_databroker/databroker/src/grpc/kuksa_val_v1/conversions.rs index 62c9c295..699771d2 100644 --- a/kuksa_databroker/databroker/src/grpc/kuksa_val_v1/conversions.rs +++ b/kuksa_databroker/databroker/src/grpc/kuksa_val_v1/conversions.rs @@ -328,8 +328,10 @@ impl From for proto::DataEntry { None => None, }, metadata: { - let mut metadata = proto::Metadata::default(); - metadata.unit = from.unit; + let metadata = proto::Metadata { + unit: from.unit, + ..Default::default() + }; Some(metadata) }, }