diff options
author | Didier Wenzek <didier.wenzek@acidalie.com> | 2022-08-16 13:49:05 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-16 13:49:05 +0200 |
commit | 368cd633f4d2094146df530294d0fb04fa324451 (patch) | |
tree | 42e9fba9bb6697ece292c0dab523fc5dc2d8717b | |
parent | d7863fc8c154135d95f99da81a0e4e8f30e0a8d2 (diff) | |
parent | 14fba690025dfdaa269dc85d00af2614377e75af (diff) |
Merge pull request #1311 from matthiasbeyer/remove-let-nothing-equals
Remove let nothing equals
-rw-r--r-- | crates/core/c8y_translator/src/serializer.rs | 4 | ||||
-rw-r--r-- | crates/core/tedge/src/cli/connect/command.rs | 4 | ||||
-rw-r--r-- | crates/core/tedge_mapper/src/c8y/tests.rs | 50 | ||||
-rw-r--r-- | plugins/c8y_configuration_plugin/src/main.rs | 4 |
4 files changed, 30 insertions, 32 deletions
diff --git a/crates/core/c8y_translator/src/serializer.rs b/crates/core/c8y_translator/src/serializer.rs index e268235a..fb2d788a 100644 --- a/crates/core/c8y_translator/src/serializer.rs +++ b/crates/core/c8y_translator/src/serializer.rs @@ -48,12 +48,12 @@ impl C8yJsonSerializer { // object referenced by "externalId", instead of root device object // referenced by MQTT client's Device ID. let _ = json.write_key("externalSource"); - let _ = json.write_open_obj(); + json.write_open_obj(); let _ = json.write_key("externalId"); let _ = json.write_str(child_id); let _ = json.write_key("type"); let _ = json.write_str("c8y_Serial"); - let _ = json.write_close_obj(); + json.write_close_obj(); } Self { diff --git a/crates/core/tedge/src/cli/connect/command.rs b/crates/core/tedge/src/cli/connect/command.rs index faed5fde..8714bdd7 100644 --- a/crates/core/tedge/src/cli/connect/command.rs +++ b/crates/core/tedge/src/cli/connect/command.rs @@ -489,7 +489,7 @@ fn clean_up( bridge_config: &BridgeConfig, ) -> Result<(), ConnectError> { let path = get_bridge_config_file_path(config_location, bridge_config); - let _ = std::fs::remove_file(&path).or_else(ok_if_not_found)?; + std::fs::remove_file(&path).or_else(ok_if_not_found)?; Ok(()) } @@ -516,7 +516,7 @@ fn write_bridge_config_to_file( .join(TEDGE_BRIDGE_CONF_DIR_PATH); // This will forcefully create directory structure if it doesn't exist, we should find better way to do it, maybe config should deal with it? - let _ = create_directories(&dir_path)?; + create_directories(&dir_path)?; let common_config_path = get_common_mosquitto_config_file_path(config_location, common_mosquitto_config); diff --git a/crates/core/tedge_mapper/src/c8y/tests.rs b/crates/core/tedge_mapper/src/c8y/tests.rs index 0413c33a..2d37ce87 100644 --- a/crates/core/tedge_mapper/src/c8y/tests.rs +++ b/crates/core/tedge_mapper/src/c8y/tests.rs @@ -76,8 +76,8 @@ async fn mapper_publishes_software_update_request() { let (_tmp_dir, sm_mapper) = start_c8y_mapper(broker.port).await.unwrap(); // Prepare and publish a software update smartrest request on `c8y/s/ds`. let smartrest = r#"528,external_id,nodered,1.0.0::debian,,install"#; - let _ = broker.publish("c8y/s/ds", smartrest).await.unwrap(); - let _ = publish_a_fake_jwt_token(broker).await; + broker.publish("c8y/s/ds", smartrest).await.unwrap(); + publish_a_fake_jwt_token(broker).await; let expected_update_list = r#" "updateList": [ @@ -114,7 +114,7 @@ async fn mapper_publishes_software_update_status_onto_c8y_topic() { // Start SM Mapper let (_tmp_dir, sm_mapper) = start_c8y_mapper(broker.port).await.unwrap(); - let _ = publish_a_fake_jwt_token(broker).await; + publish_a_fake_jwt_token(broker).await; // Prepare and publish a software update status response message `executing` on `tedge/commands/res/software/update`. let json_response = r#"{ @@ -122,7 +122,7 @@ async fn mapper_publishes_software_update_status_onto_c8y_topic() { "status": "executing" }"#; - let _ = broker + broker .publish("tedge/commands/res/software/update", json_response) .await .unwrap(); @@ -145,7 +145,7 @@ async fn mapper_publishes_software_update_status_onto_c8y_topic() { ]} ]}"#; - let _ = broker + broker .publish("tedge/commands/res/software/update", json_response) .await .unwrap(); @@ -169,7 +169,7 @@ async fn mapper_publishes_software_update_failed_status_onto_c8y_topic() { // Start SM Mapper let (_tmp_dir, sm_mapper) = start_c8y_mapper(broker.port).await.unwrap(); - let _ = publish_a_fake_jwt_token(broker).await; + publish_a_fake_jwt_token(broker).await; // The agent publish an error let json_response = r#" @@ -191,7 +191,7 @@ async fn mapper_publishes_software_update_failed_status_onto_c8y_topic() { "failures":[] }"#; - let _ = broker + broker .publish("tedge/commands/res/software/update", json_response) .await .unwrap(); @@ -235,8 +235,8 @@ async fn mapper_fails_during_sw_update_recovers_and_process_response() -> Result // Prepare and publish a software update smartrest request on `c8y/s/ds`. let smartrest = r#"528,external_id,nodered,1.0.0::debian,,install"#; - let _ = broker.publish("c8y/s/ds", smartrest).await.unwrap(); - let _ = publish_a_fake_jwt_token(broker).await; + broker.publish("c8y/s/ds", smartrest).await.unwrap(); + publish_a_fake_jwt_token(broker).await; let expected_update_list = r#" "updateList": [ @@ -278,7 +278,7 @@ async fn mapper_fails_during_sw_update_recovers_and_process_response() -> Result ] } ]}"#; - let _ = broker + broker .publish( "tedge/commands/res/software/update", &remove_whitespace(json_response), @@ -319,7 +319,7 @@ async fn mapper_publishes_software_update_request_with_wrong_action() { let (_tmp_dir, _sm_mapper) = start_c8y_mapper(broker.port).await.unwrap(); // Prepare and publish a c8y_SoftwareUpdate smartrest request on `c8y/s/ds` that contains a wrong action `remove`, that is not known by c8y. let smartrest = r#"528,external_id,nodered,1.0.0::debian,,remove"#; - let _ = broker.publish("c8y/s/ds", smartrest).await.unwrap(); + broker.publish("c8y/s/ds", smartrest).await.unwrap(); // Expect a 501 (executing) followed by a 502 (failed) mqtt_tests::assert_received_all_expected( @@ -341,7 +341,7 @@ async fn c8y_mapper_alarm_mapping_to_smartrest() { // Start the C8Y Mapper let (_tmp_dir, sm_mapper) = start_c8y_mapper(broker.port).await.unwrap(); - let _ = broker + broker .publish_with_opts( "tedge/alarms/major/temperature_alarm", r#"{ "text": "Temperature high" }"#, @@ -360,7 +360,7 @@ async fn c8y_mapper_alarm_mapping_to_smartrest() { .await; //Clear the previously published alarm - let _ = broker + broker .publish_with_opts( "tedge/alarms/major/temperature_alarm", "", @@ -385,7 +385,7 @@ async fn c8y_mapper_child_alarm_mapping_to_smartrest() { // Start the C8Y Mapper let (_tmp_dir, sm_mapper) = start_c8y_mapper(broker.port).await.unwrap(); - let _ = broker + broker .publish_with_opts( "tedge/alarms/minor/temperature_high/external_sensor", r#"{ "text": "Temperature high" }"#, @@ -395,7 +395,7 @@ async fn c8y_mapper_child_alarm_mapping_to_smartrest() { .await .unwrap(); - let _ = broker + broker .publish_with_opts( "tedge/alarms/minor/temperature_high/external_sensor", r#"{ "text": "Temperature high" }"#, @@ -414,7 +414,7 @@ async fn c8y_mapper_child_alarm_mapping_to_smartrest() { .await; //Clear the previously published alarm - let _ = broker + broker .publish_with_opts( "tedge/alarms/minor/temperature_high/external_sensor", "", @@ -441,7 +441,7 @@ async fn c8y_mapper_syncs_pending_alarms_on_startup() { .messages_published_on("c8y-internal/alarms/critical/temperature_alarm") .await; - let _ = broker + broker .publish_with_opts( "tedge/alarms/critical/temperature_alarm", r#"{ "text": "Temperature very high" }"#, @@ -471,7 +471,7 @@ async fn c8y_mapper_syncs_pending_alarms_on_startup() { sm_mapper.abort(); //Publish a new alarm while the mapper is down - let _ = broker + broker .publish_with_opts( "tedge/alarms/critical/pressure_alarm", r#"{ "text": "Pressure very high" }"#, @@ -483,8 +483,7 @@ async fn c8y_mapper_syncs_pending_alarms_on_startup() { // Ignored until the rumqttd broker bug that doesn't handle empty retained messages //Clear the existing alarm while the mapper is down - // let _ = broker - // .publish_with_opts( + // broker.publish_with_opts( // "tedge/alarms/critical/temperature_alarm", // "", // mqtt_channel::QoS::AtLeastOnce, @@ -533,7 +532,7 @@ async fn c8y_mapper_syncs_pending_child_alarms_on_startup() { .messages_published_on("c8y-internal/alarms/critical/temperature_alarm/external_sensor") .await; - let _ = broker + broker .publish_with_opts( "tedge/alarms/critical/temperature_alarm/external_sensor", r#"{ "text": "Temperature very high" }"#, @@ -563,7 +562,7 @@ async fn c8y_mapper_syncs_pending_child_alarms_on_startup() { sm_mapper.abort(); //Publish a new alarm while the mapper is down - let _ = broker + broker .publish_with_opts( "tedge/alarms/critical/pressure_alarm/external_sensor", r#"{ "text": "Pressure very high" }"#, @@ -573,7 +572,7 @@ async fn c8y_mapper_syncs_pending_child_alarms_on_startup() { .await .unwrap(); - let _ = broker + broker .publish_with_opts( "tedge/alarms/critical/pressure_alarm/external_sensor", r#"{ "text": "Pressure very high" }"#, @@ -585,8 +584,7 @@ async fn c8y_mapper_syncs_pending_child_alarms_on_startup() { // Ignored until the rumqttd broker bug that doesn't handle empty retained messages //Clear the existing alarm while the mapper is down - // let _ = broker - // .publish_with_opts( + // broker.publish_with_opts( // "tedge/alarms/critical/temperature_alarm/external_sensor", // "", // mqtt_channel::QoS::AtLeastOnce, @@ -1169,5 +1167,5 @@ fn remove_whitespace(s: &str) -> String { } async fn publish_a_fake_jwt_token(broker: &MqttProcessHandler) { - let _ = broker.publish("c8y/s/dat", "71,1111").await.unwrap(); + broker.publish("c8y/s/dat", "71,1111").await.unwrap(); } diff --git a/plugins/c8y_configuration_plugin/src/main.rs b/plugins/c8y_configuration_plugin/src/main.rs index 6f9ddf7b..2e1f620e 100644 --- a/plugins/c8y_configuration_plugin/src/main.rs +++ b/plugins/c8y_configuration_plugin/src/main.rs @@ -64,7 +64,7 @@ pub struct ConfigPluginOpt { async fn create_mqtt_client(mqtt_port: u16) -> Result<mqtt_channel::Connection, anyhow::Error> { let mut topic_filter = mqtt_channel::TopicFilter::new_unchecked(C8yTopic::SmartRestRequest.as_str()); - let _ = topic_filter.add_all(health_check_topics("c8y-configuration-plugin")); + topic_filter.add_all(health_check_topics("c8y-configuration-plugin")); let mqtt_config = mqtt_channel::Config::default() .with_port(mqtt_port) @@ -360,7 +360,7 @@ mod tests { .await; // Send a software upload request to the plugin - let _ = broker + broker .publish( "c8y/s/ds", format!("526,tedge-device,{test_config_type}").as_str(), |