diff options
author | Didier Wenzek <didier.wenzek@acidalie.com> | 2022-08-18 15:50:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-18 15:50:02 +0200 |
commit | 52b5b185ba9e0564c11da74f26af99035fafa151 (patch) | |
tree | db5a0157fdf51209f2759a99bf0859719d6f12f5 | |
parent | 42c1d7bb3e39f6c8da77ab81d9c34f722affcffb (diff) | |
parent | 5c9cc5387a08eea6c167e9ebd74e5ee68eebbac8 (diff) |
Merge pull request #1279 from matthiasbeyer/remove-let-unit
Clippy: Remove let unit
41 files changed, 121 insertions, 132 deletions
diff --git a/crates/common/certificate/src/lib.rs b/crates/common/certificate/src/lib.rs index 0c81a73d..ecfbd88a 100644 --- a/crates/common/certificate/src/lib.rs +++ b/crates/common/certificate/src/lib.rs @@ -110,7 +110,7 @@ impl KeyCertPair { id: &str, not_before: OffsetDateTime, ) -> Result<KeyCertPair, CertificateError> { - let () = KeyCertPair::check_identifier(id, config.max_cn_size)?; + KeyCertPair::check_identifier(id, config.max_cn_size)?; let mut distinguished_name = rcgen::DistinguishedName::new(); distinguished_name.push(rcgen::DnType::CommonName, id); distinguished_name.push(rcgen::DnType::OrganizationName, &config.organization_name); diff --git a/crates/common/download/examples/simple_download.rs b/crates/common/download/examples/simple_download.rs index e583b0eb..763a91c0 100644 --- a/crates/common/download/examples/simple_download.rs +++ b/crates/common/download/examples/simple_download.rs @@ -14,10 +14,10 @@ async fn main() -> Result<()> { let downloader = Downloader::new("test_download", &None, "/tmp"); // Call `download` method to get data from url. - let () = downloader.download(&url_data).await?; + downloader.download(&url_data).await?; // Call cleanup method to remove downloaded file if no longer necessary. - let () = downloader.cleanup().await?; + downloader.cleanup().await?; Ok(()) } diff --git a/crates/common/download/src/download.rs b/crates/common/download/src/download.rs index cc96f689..692cb1a7 100644 --- a/crates/common/download/src/download.rs +++ b/crates/common/download/src/download.rs @@ -219,7 +219,7 @@ mod tests { let url = DownloadInfo::new(&target_url); let downloader = Downloader::new(&name, &version, target_dir_path.path()); - let () = downloader.download(&url).await?; + downloader.download(&url).await?; let log_content = std::fs::read(downloader.filename())?; diff --git a/crates/common/flockfile/src/unix.rs b/crates/common/flockfile/src/unix.rs index 4ef847d2..5980397f 100644 --- a/crates/common/flockfile/src/unix.rs +++ b/crates/common/flockfile/src/unix.rs @@ -56,7 +56,7 @@ impl Flockfile { } }; - let () = match flock(file.as_raw_fd(), FlockArg::LockExclusiveNonblock) { + match flock(file.as_raw_fd(), FlockArg::LockExclusiveNonblock) { Ok(()) => (), Err(err) => { return Err(FlockfileError::FromNix { path, source: err }); diff --git a/crates/common/json_writer/src/lib.rs b/crates/common/json_writer/src/lib.rs index df92765b..c5a3c23f 100644 --- a/crates/common/json_writer/src/lib.rs +++ b/crates/common/json_writer/src/lib.rs @@ -41,7 +41,7 @@ impl JsonWriter { pub fn write_key(&mut self, key: &str) -> Result<(), JsonWriterError> { self.maybe_separate(); - let () = serde_json::to_writer(&mut self.buffer, key)?; + serde_json::to_writer(&mut self.buffer, key)?; self.buffer.push(b':'); self.needs_separator = false; Ok(()) @@ -49,7 +49,7 @@ impl JsonWriter { pub fn write_str(&mut self, s: &str) -> Result<(), JsonWriterError> { self.maybe_separate(); - let () = serde_json::to_writer(&mut self.buffer, s)?; + serde_json::to_writer(&mut self.buffer, s)?; self.needs_separator = true; Ok(()) } @@ -58,7 +58,7 @@ impl JsonWriter { self.maybe_separate(); match value.classify() { FpCategory::Normal | FpCategory::Zero | FpCategory::Subnormal => { - let () = serde_json::to_writer(&mut self.buffer, &value)?; + serde_json::to_writer(&mut self.buffer, &value)?; self.needs_separator = true; Ok(()) } diff --git a/crates/common/mqtt_channel/src/tests.rs b/crates/common/mqtt_channel/src/tests.rs index fb30eac7..7a8201e5 100644 --- a/crates/common/mqtt_channel/src/tests.rs +++ b/crates/common/mqtt_channel/src/tests.rs @@ -99,7 +99,7 @@ mod tests { ] .into_iter() { - let () = broker.publish(topic, payload).await?; + broker.publish(topic, payload).await?; assert_eq!( MaybeMessage::Next(message(topic, payload)), next_message(&mut messages).await @@ -113,7 +113,7 @@ mod tests { ] .into_iter() { - let () = broker.publish(topic, payload).await?; + broker.publish(topic, payload).await?; assert_eq!(MaybeMessage::Timeout, next_message(&mut messages).await); } diff --git a/crates/common/tedge_config/src/tedge_config_repository.rs b/crates/common/tedge_config/src/tedge_config_repository.rs index 5c818c7b..894116d8 100644 --- a/crates/common/tedge_config/src/tedge_config_repository.rs +++ b/crates/common/tedge_config/src/tedge_config_repository.rs @@ -32,10 +32,10 @@ impl ConfigRepository<TEdgeConfig> for TEdgeConfigRepository { // Create `$HOME/.tedge` or `/etc/tedge` directory in case it does not exist yet if !self.config_location.tedge_config_root_path.exists() { - let () = fs::create_dir(self.config_location.tedge_config_root_path())?; + fs::create_dir(self.config_location.tedge_config_root_path())?; } - let () = atomically_write_file_sync( + atomically_write_file_sync( self.config_location.temporary_tedge_config_file_path(), self.config_location.tedge_config_file_path(), toml.as_bytes(), diff --git a/crates/common/tedge_utils/src/file.rs b/crates/common/tedge_utils/src/file.rs index 4da9f1bf..f3659d56 100644 --- a/crates/common/tedge_utils/src/file.rs +++ b/crates/common/tedge_utils/src/file.rs @@ -74,19 +74,19 @@ impl PermissionEntry { pub fn apply(&self, path: &Path) -> Result<(), FileError> { match (&self.user, &self.group) { (Some(user), Some(group)) => { - let () = change_user_and_group(path, user, group)?; + change_user_and_group(path, user, group)?; } (Some(user), None) => { - let () = change_user(path, user)?; + change_user(path, user)?; } (None, Some(group)) => { - let () = change_group(path, group)?; + change_group(path, group)?; } (None, None) => {} } if let Some(mode) = &self.mode { - let () = change_mode(path, *mode)?; + change_mode(path, *mode)?; } Ok(()) @@ -95,7 +95,7 @@ impl PermissionEntry { fn create_directory(&self, dir: &Path) -> Result<(), FileError> { match fs::create_dir(dir) { Ok(_) => { - let () = self.apply(dir)?; + self.apply(dir)?; Ok(()) } Err(e) if e.kind() == io::ErrorKind::AlreadyExists => Ok(()), @@ -119,7 +119,7 @@ impl PermissionEntry { .open(file) { Ok(mut f) => { - let () = self.apply(file)?; + self.apply(file)?; if let Some(default_content) = default_content { f.write(default_content.as_bytes()).map_err(|e| { FileError::WriteContentFailed { @@ -342,7 +342,7 @@ mod tests { assert!(format!("{:o}", perm.mode()).contains("644")); let permission_set = PermissionEntry::new(None, None, Some(0o444)); - let () = permission_set.apply(Path::new(file_path.as_str())).unwrap(); + permission_set.apply(Path::new(file_path.as_str())).unwrap(); let meta = fs::metadata(file_path.as_str()).unwrap(); let perm = meta.permissions(); diff --git a/crates/common/tedge_utils/src/fs.rs b/crates/common/tedge_utils/src/fs.rs index fff39647..6f679891 100644 --- a/crates/common/tedge_utils/src/fs.rs +++ b/crates/common/tedge_utils/src/fs.rs @@ -41,14 +41,14 @@ pub async fn atomically_write_file_async( .await?; if let Err(err) = file.write_all(content).await { - let () = tokio_fs::remove_file(tempfile).await?; + tokio_fs::remove_file(tempfile).await?; return Err(err); } file.flush().await?; if let Err(err) = tokio_fs::rename(tempfile.as_ref(), dest).await { - let () = tokio_fs::remove_file(tempfile).await?; + tokio_fs::remove_file(tempfile).await?; return Err(err); } @@ -69,7 +69,7 @@ mod tests { let content = "test_data"; - let () = atomically_write_file_async(&temp_path, &destination_path, content.as_bytes()) + atomically_write_file_async(&temp_path, &destination_path, content.as_bytes()) .await .unwrap(); diff --git a/crates/common/tedge_utils/src/fs_notify.rs b/crates/common/tedge_utils/src/fs_notify.rs index 414fca57..6745c180 100644 --- a/crates/common/tedge_utils/src/fs_notify.rs +++ b/crates/common/tedge_utils/src/fs_notify.rs @@ -536,8 +536,8 @@ mod tests { ttd_clone.file("file_b").with_raw_content("content"); }); - let () = fs_notify_handler.await.unwrap(); - let () = file_handler.await.unwrap(); + fs_notify_handler.await.unwrap(); + file_handler.await.unwrap(); } #[tokio::test] @@ -568,7 +568,7 @@ mod tests { ttd_clone.file("file_c").delete(); // should match CREATE, DELETE }); - let () = fs_notify_handler.await.unwrap(); - let () = file_handler.await.unwrap(); + fs_notify_handler.await.unwrap(); + file_handler.await.unwrap(); } } diff --git a/crates/core/c8y_api/src/http_proxy.rs b/crates/core/c8y_api/src/http_proxy.rs index 3d1288d6..83d9b6bf 100644 --- a/crates/core/c8y_api/src/http_proxy.rs +++ b/crates/core/c8y_api/src/http_proxy.rs @@ -157,8 +157,7 @@ impl C8yMqttJwtTokenRetriever { #[async_trait] impl C8yJwtTokenRetriever for C8yMqttJwtTokenRetriever { async fn get_jwt_token(&mut self) -> Result<SmartRestJwtResponse, SMCumulocityMapperError> { - let () = self - .mqtt_con + self.mqtt_con .published .publish(mqtt_channel::Message::new( &Topic::new_unchecked("c8y/s/uat"), @@ -237,7 +236,7 @@ impl JwtAuthHttpProxy { let mut mqtt_con = Connection::new(&mqtt_config).await?; // Ignore errors on this connection - let () = mqtt_con.errors.close(); + mqtt_con.errors.close(); let jwt_token_retriver = Box::new(C8yMqttJwtTokenRetriever::new(mqtt_con)); diff --git a/crates/core/c8y_smartrest/src/smartrest_deserializer.rs b/crates/core/c8y_smartrest/src/smartrest_deserializer.rs index 54e96855..63b031fc 100644 --- a/crates/core/c8y_smartrest/src/smartrest_deserializer.rs +++ b/crates/core/c8y_smartrest/src/smartrest_deserializer.rs @@ -57,7 +57,7 @@ impl Default for SmartRestUpdateSoftware { impl SmartRestUpdateSoftware { pub fn from_smartrest(&self, smartrest: &str) -> Result<Self, SmartRestDeserializerError> { let mut message_id = smartrest.to_string(); - let () = message_id.truncate(3); + message_id.truncate(3); let mut rdr = ReaderBuilder::new() .has_headers(false) @@ -461,7 +461,7 @@ mod tests { url: Some("url1".into()), file_path: None, })); - let () = expected_thin_edge_json.add_update(SoftwareModuleUpdate::remove(SoftwareModule { + expected_thin_edge_json.add_update(SoftwareModuleUpdate::remove(SoftwareModule { module_type: Some("".to_string()), name: "software2".to_string(), version: None, diff --git a/crates/core/c8y_translator/src/json.rs b/crates/core/c8y_translator/src/json.rs index 0ecacd4f..41d8ae35 100644 --- a/crates/core/c8y_translator/src/json.rs +++ b/crates/core/c8y_translator/src/json.rs @@ -50,7 +50,7 @@ fn from_thin_edge_json_with_timestamp( maybe_child_id: Option<&str>, ) -> Result<String, CumulocityJsonError> { let mut serializer = serializer::C8yJsonSerializer::new(timestamp, maybe_child_id); - let () = parse_str(input, &mut serializer)?; + parse_str(input, &mut serializer)?; Ok(serializer.into_string()?) } diff --git a/crates/core/plugin_sm/src/operation_logs.rs b/crates/core/plugin_sm/src/operation_logs.rs index 7bf08eab..7912eaa7 100644 --- a/crates/core/plugin_sm/src/operation_logs.rs +++ b/crates/core/plugin_sm/src/operation_logs.rs @@ -108,10 +108,10 @@ impl OperationLogs { for (key, value) in log_tracker.iter_mut() { if key.starts_with("software-list") { // only allow one update list file in logs - let () = remove_old_logs(value, &self.log_dir, 1)?; + remove_old_logs(value, &self.log_dir, 1)?; } else { // allow most recent five - let () = remove_old_logs(value, &self.log_dir, 5)?; + remove_old_logs(value, &self.log_dir, 5)?; } } diff --git a/crates/core/plugin_sm/tests/plugin.rs b/crates/core/plugin_sm/tests/plugin.rs index 724813fb..366bfbcf 100644 --- a/crates/core/plugin_sm/tests/plugin.rs +++ b/crates/core/plugin_sm/tests/plugin.rs @@ -410,7 +410,7 @@ mod tests { fn get_dummy_plugin_tmp_path() -> PathBuf { let path = PathBuf::from_str("/tmp/.tedge_dummy_plugin").unwrap(); if !&path.exists() { - let () = fs::create_dir(&path).unwrap(); + fs::create_dir(&path).unwrap(); } path } diff --git a/crates/core/tedge/src/cli/certificate/create.rs b/crates/core/tedge/src/cli/certificate/create.rs index 2d1589c9..83eeb45f 100644 --- a/crates/core/tedge/src/cli/certificate/create.rs +++ b/crates/core/tedge/src/cli/certificate/create.rs @@ -28,7 +28,7 @@ impl Command for CreateCertCmd { fn execute(&self) -> anyhow::Result<()> { let config = NewCertificateConfig::default(); - let () = self.create_test_certificate(&config)?; + self.create_test_certificate(&config)?; Ok(()) } } diff --git a/crates/core/tedge/src/cli/certificate/remove.rs b/crates/core/tedge/src/cli/certificate/remove.rs index 8f978972..c1007b44 100644 --- a/crates/core/tedge/src/cli/certificate/remove.rs +++ b/crates/core/tedge/src/cli/certificate/remove.rs @@ -18,7 +18,7 @@ impl Command for RemoveCertCmd { } fn execute(&self) -> anyhow::Result<()> { - let () = self.remove_certificate()?; + self.remove_certificate()?; Ok(()) } } diff --git a/crates/core/tedge/src/cli/certificate/show.rs b/crates/core/tedge/src/cli/certificate/show.rs index 8890f308..24bc493d 100644 --- a/crates/core/tedge/src/cli/certificate/show.rs +++ b/crates/core/tedge/src/cli/certificate/show.rs @@ -16,7 +16,7 @@ impl Command for ShowCertCmd { } fn execute(&self) -> anyhow::Result<()> { - let () = self.show_certificate()?; + self.show_certificate()?; Ok(()) } } diff --git a/crates/core/tedge/src/cli/config/commands/set.rs b/crates/core/tedge/src/cli/config/commands/set.rs index 715f2664..ce2493a6 100644 --- a/crates/core/tedge/src/cli/config/commands/set.rs +++ b/crates/core/tedge/src/cli/config/commands/set.rs @@ -18,7 +18,7 @@ impl Command for SetConfigCommand { fn execute(&self) -> anyhow::Result<()> { let mut config = self.config_repository.load()?; - let () = (self.config_key.set)(&mut config, self.value.to_string())?; + (self.config_key.set)(&mut config, self.value.to_string())?; self.config_repository.store(&config)?; Ok(()) } diff --git a/crates/core/tedge/src/cli/config/commands/unset.rs b/crates/core/tedge/src/cli/config/commands/unset.rs index 222d8a3e..a975a58d 100644 --- a/crates/core/tedge/src/cli/config/commands/unset.rs +++ b/crates/core/tedge/src/cli/config/commands/unset.rs @@ -17,7 +17,7 @@ impl Command for UnsetConfigCommand { fn execute(&self) -> anyhow::Result<()> { let mut config = self.config_repository.load()?; - let () = (self.config_key.unset)(&mut config)?; + (self.config_key.unset)(&mut config)?; self.config_repository.store(&config)?; Ok(()) } diff --git a/crates/core/tedge/src/cli/connect/c8y_direct_connection.rs b/crates/core/tedge/src/cli/connect/c8y_direct_connection.rs index 89400667..1683b4d8 100644 --- a/crates/core/tedge/src/cli/connect/c8y_direct_connection.rs +++ b/crates/core/tedge/src/cli/connect/c8y_direct_connection.rs @@ -29,7 +29,7 @@ pub fn create_device_with_direct_connection( let mut client_config = ClientConfig::new(); - let () = load_root_certs( + load_root_certs( &mut client_config.root_store, bridge_config.bridge_root_cert_path.clone(), )?; diff --git a/crates/core/tedge/src/cli/connect/command.rs b/crates/core/tedge/src/cli/connect/command.rs index 8714bdd7..c525eb1d 100644 --- a/crates/core/tedge/src/cli/connect/command.rs +++ b/crates/core/tedge/src/cli/connect/command.rs @@ -242,7 +242,7 @@ where TEdgeConfig: ConfigSettingAccessor<T>, { let value = config.query(setting)?; - let () = config.update(setting, value)?; + config.update(setting, value)?; Ok(()) } @@ -402,17 +402,14 @@ fn new_bridge( } println!("Checking if configuration for requested bridge already exists.\n"); - let () = bridge_config_exists(config_location, bridge_config)?; + bridge_config_exists(config_location, bridge_config)?; println!("Validating the bridge certificates.\n"); - let () = bridge_config.validate()?; + bridge_config.validate()?; if bridge_config.cloud_name.eq("c8y") { println!("Creating the device in Cumulocity cloud.\n"); - let () = c8y_direct_connection::create_device_with_direct_connection( - bridge_config, - device_type, - )?; + c8y_direct_connection::create_device_with_direct_connection(bridge_config, device_type)?; } println!("Saving configuration for requested bridge.\n"); @@ -522,12 +519,12 @@ fn write_bridge_config_to_file( get_common_mosquitto_config_file_path(config_location, common_mosquitto_config); let mut common_draft = DraftFile::new(&common_config_path)?; common_mosquitto_config.serialize(&mut common_draft)?; - let () = common_draft.persist()?; + common_draft.persist()?; let config_path = get_bridge_config_file_path(config_location, bridge_config); let mut config_draft = DraftFile::new(config_path)?; bridge_config.seriali |