From 5ed52cb0d836335338150f701ef6d6dfb8bf9a7c Mon Sep 17 00:00:00 2001
From: cgeek <cem.moreau@gmail.com>
Date: Fri, 22 Sep 2023 22:02:01 +0200
Subject: [PATCH] fix(#125): clippy

---
 end2end-tests/tests/common/mod.rs       |  2 +-
 node/src/chain_spec/gdev.rs             |  2 +-
 node/src/chain_spec/gen_genesis_data.rs | 24 ++++++++++++------------
 3 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/end2end-tests/tests/common/mod.rs b/end2end-tests/tests/common/mod.rs
index f3b2b25bb..1667ff60e 100644
--- a/end2end-tests/tests/common/mod.rs
+++ b/end2end-tests/tests/common/mod.rs
@@ -174,7 +174,7 @@ fn spawn_full_node(
     let mut envs = Vec::new();
     if let Some(genesis_conf_file) = maybe_genesis_conf_file {
         envs.push(("DUNITER_GENESIS_CONFIG", genesis_conf_file.clone()));
-        envs.push(("DUNITER_GENESIS_DATA", genesis_conf_file.clone()));
+        envs.push(("DUNITER_GENESIS_DATA", genesis_conf_file));
     }
 
     // Logs
diff --git a/node/src/chain_spec/gdev.rs b/node/src/chain_spec/gdev.rs
index 7f49e0774..701b07798 100644
--- a/node/src/chain_spec/gdev.rs
+++ b/node/src/chain_spec/gdev.rs
@@ -292,7 +292,7 @@ fn genesis_data_to_gdev_genesis_conf(
             &path,
             serde_json::to_string(&export).expect("should be serializable"),
         )
-        .expect(format!("Could not export genesis data to {}", &path).as_str());
+        .unwrap_or_else(|_| panic!("Could not export genesis data to {}", &path));
     }
 
     let super::gen_genesis_data::GenesisData {
diff --git a/node/src/chain_spec/gen_genesis_data.rs b/node/src/chain_spec/gen_genesis_data.rs
index f6d69f72d..9b769ed0d 100644
--- a/node/src/chain_spec/gen_genesis_data.rs
+++ b/node/src/chain_spec/gen_genesis_data.rs
@@ -160,9 +160,9 @@ where
     )?;
 
     if smith_identities.is_some() && clique_smiths.is_some() {
-        return Err(format!(
-            "'smiths' and 'clique_smiths' cannot be both defined at the same time"
-        ));
+        return Err(
+            "'smiths' and 'clique_smiths' cannot be both defined at the same time".to_string(),
+        );
     }
 
     let GenesisMigrationData {
@@ -187,10 +187,10 @@ where
     // If this authority is defined (most likely Alice), then it must exist in both _identities_
     // and _smiths_. We create all this, for *development purposes* (used with --dev option).
     if let Some((name, _)) = &maybe_force_authority {
-        if let None = idty_index_of.get(&name) {
+        if idty_index_of.get(&name).is_none() {
             // Not found: we must create it
             idty_index += 1;
-            idty_index_of.insert(&name, idty_index);
+            idty_index_of.insert(name, idty_index);
             identities.insert(
                 name.clone(),
                 Idty {
@@ -290,6 +290,8 @@ where
     }
 
     // CERTIFICATIONS //
+    // TODO: exclude expired certs?
+    // TODO: check monetary mass and allocate difference to treasury?
 
     let mut certs_by_receiver = BTreeMap::new();
     for (idty_name, identity) in &identities {
@@ -341,7 +343,7 @@ where
     let smiths = if let Some(clique) = &clique_smiths {
         // From a clique
         clique
-            .into_iter()
+            .iter()
             .map(|smith| SmithData {
                 name: smith.name.clone(),
                 session_keys: smith.session_keys.clone(),
@@ -352,8 +354,7 @@ where
         // From explicit smith WoT
         smith_identities
             .expect("existence has been tested earlier")
-            .into_iter()
-            .map(|(_, smith)| smith)
+            .into_values()
             .collect::<Vec<SmithData>>()
     };
     // Then create the smith WoT
@@ -687,8 +688,7 @@ fn check_parameters_consistency(
             "`first_ud` ({}) should be lower than `first_ud_reeval` ({})",
             first_ud.unwrap(),
             first_reeval.unwrap()
-        )
-        .to_owned());
+        ));
     }
     if *ud == 0 {
         return Err("`ud` is expected to be > 0".to_owned());
@@ -714,8 +714,8 @@ fn get_genesis_config<P: Default + DeserializeOwned>(
 }
 
 fn get_genesis_migration_data() -> Result<GenesisMigrationData, String> {
-    let json_file_path =
-        std::env::var("DUNITER_GENESIS_DATA").unwrap_or("./resources/g1-data.json".to_owned());
+    let json_file_path = std::env::var("DUNITER_GENESIS_DATA")
+        .unwrap_or_else(|_| "./resources/g1-data.json".to_owned());
     let file = std::fs::File::open(&json_file_path)
         .map_err(|e| format!("Error opening gen conf file `{}`: {}", json_file_path, e))?;
     let bytes = unsafe {
-- 
GitLab