From 1d5aa03f781098c7673bb3a33eb12a549051534a Mon Sep 17 00:00:00 2001
From: cgeek <cem.moreau@gmail.com>
Date: Mon, 20 Sep 2021 19:32:55 +0200
Subject: [PATCH] refact: remove warnings

---
 src/bma/lookup_identity.rs      | 10 +++++-----
 src/bma/mod.rs                  |  7 -------
 src/bma/wot/mod.rs              |  4 +---
 src/cli/certify.rs              |  8 ++++----
 src/cli/mod.rs                  |  2 +-
 src/crypto/duniter_signature.rs |  4 ++--
 src/lib.rs                      |  2 ++
 src/main.rs                     | 11 +++--------
 8 files changed, 18 insertions(+), 30 deletions(-)

diff --git a/src/bma/lookup_identity.rs b/src/bma/lookup_identity.rs
index c775a02..d15c01e 100644
--- a/src/bma/lookup_identity.rs
+++ b/src/bma/lookup_identity.rs
@@ -39,11 +39,11 @@ pub fn lookup2identities(lookup_result: &LookupResult) -> Vec<LookupIdentity> {
         let pubkey = result["pubkey"].as_str().unwrap();
         let empty: &Vec<Value> = &Vec::new();
         let uids: &Vec<Value> = result["uids"].as_array().unwrap_or(empty);
-        for anUid in uids.iter() {
-            let uid = anUid["uid"].as_str().unwrap();
-            let blockstamp = anUid["meta"]["timestamp"].as_str().unwrap();
-            let signature = anUid["self"].as_str().unwrap();
-            let revoked = anUid["revoked"].as_bool().unwrap();
+        for an_uid in uids.iter() {
+            let uid = an_uid["uid"].as_str().unwrap();
+            let blockstamp = an_uid["meta"]["timestamp"].as_str().unwrap();
+            let signature = an_uid["self"].as_str().unwrap();
+            let revoked = an_uid["revoked"].as_bool().unwrap();
             identities.push(LookupIdentity::new(pubkey, uid, blockstamp, signature,revoked));
         }
     }
diff --git a/src/bma/mod.rs b/src/bma/mod.rs
index 4f89f3a..4973afb 100644
--- a/src/bma/mod.rs
+++ b/src/bma/mod.rs
@@ -1,11 +1,4 @@
-use std::error::Error;
-use reqwest;
-use std::fmt::Display;
 pub use crate::bma::node::BmaNode;
-use serde_json::Value;
-use reqwest::blocking::Response;
-use crate::bma::lookup_identity::{LookupIdentity, lookup2identities, lookup_print, LookupResult};
-use std::process::id;
 
 mod node;
 pub mod lookup_identity;
diff --git a/src/bma/wot/mod.rs b/src/bma/wot/mod.rs
index 9a5ec04..9046a95 100644
--- a/src/bma/wot/mod.rs
+++ b/src/bma/wot/mod.rs
@@ -1,10 +1,8 @@
 use std::fmt::{Display, Formatter};
 
-use reqwest::{blocking, StatusCode};
 use serde::{Deserialize, Serialize};
 
 use crate::bma::BmaNode;
-use crate::bma::lookup_identity::LookupIdentity;
 
 #[derive(Serialize, Deserialize)]
 struct BmaCertification {
@@ -18,7 +16,7 @@ impl Display for BmaCertification {
 }
 
 pub fn certify(node: &BmaNode, idty: &String, sig: &String) -> Result<(), String> {
-    let mut cert = BmaCertification { cert: format!("{}{}\n", idty, sig) };
+    let cert = BmaCertification { cert: format!("{}{}\n", idty, sig) };
     let address = node.get_address();
     let client = reqwest::blocking::Client::new();
     let resp = client.post(format!("{}/wot/certify", address))
diff --git a/src/cli/certify.rs b/src/cli/certify.rs
index d9ce5f7..a51a4cb 100644
--- a/src/cli/certify.rs
+++ b/src/cli/certify.rs
@@ -1,9 +1,9 @@
 use crate::bma::BmaNode;
 use crate::bma::lookup_identity::{LookupResult, lookup2identities, lookup_print};
-use duniter_mini_client::crypto::scrypt_duniter_key::ScryptDuniterKey;
-use duniter_mini_client::crypto::duniter_key::ToDuniterKey;
-use duniter_mini_client::dubp::documents::certification::Certification;
-use duniter_mini_client::crypto::signable::Signable;
+use crate::crypto::scrypt_duniter_key::ScryptDuniterKey;
+use crate::crypto::duniter_key::ToDuniterKey;
+use crate::dubp::documents::certification::Certification;
+use crate::crypto::signable::Signable;
 
 pub fn certify(node: BmaNode, uid_or_pub: String) -> Result<(), String> {
     let address = node.get_address();
diff --git a/src/cli/mod.rs b/src/cli/mod.rs
index cff0cae..4f69eae 100644
--- a/src/cli/mod.rs
+++ b/src/cli/mod.rs
@@ -4,7 +4,7 @@ use crate::cli::Command::*;
 use crate::bma::BmaNode;
 use std::env;
 
-pub(crate) mod certify;
+pub mod certify;
 
 const DEFAULT_NODE: &str = "https://g1-test.duniter.org";
 
diff --git a/src/crypto/duniter_signature.rs b/src/crypto/duniter_signature.rs
index 770fecb..decf48a 100644
--- a/src/crypto/duniter_signature.rs
+++ b/src/crypto/duniter_signature.rs
@@ -6,8 +6,8 @@ pub struct DuniterSignature([u8; SIGNATURE_LENGTH]);
 
 /// A DuniterSignature wraps an actuel signature (64 bytes data)
 impl DuniterSignature {
-    pub fn new(signature: [u8; SIGNATURE_LENGTH]) -> DuniterSignature {
-        DuniterSignature(signature)
+    pub fn new(signature: [u8; SIGNATURE_LENGTH]) -> Self {
+        Self(signature)
     }
     pub fn as_bytes(&self) -> [u8; SIGNATURE_LENGTH] {
         self.0
diff --git a/src/lib.rs b/src/lib.rs
index 6d83bd1..ea003ab 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,5 +1,7 @@
 pub mod crypto;
 pub mod dubp;
+pub mod cli;
+pub mod bma;
 
 use crate::crypto::duniter_key::{ToDuniterKey};
 
diff --git a/src/main.rs b/src/main.rs
index 8a65a1c..0eb54a9 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,15 +1,10 @@
 use std::env;
 
-use duniter_mini_client::{compute_pub, compute_sec, compute_key};
-
-use crate::cli::Command;
-use crate::cli::Command::*;
+use duniter_mini_client::{compute_pub, compute_sec, compute_key, cli, bma};
+use duniter_mini_client::cli::Command;
+use duniter_mini_client::cli::Command::{UNKNOWN, PUB, SEC, KEYRING, LOOKUP, CERTIFY};
 use duniter_mini_client::crypto::duniter_key::ScryptDuniterKey;
 
-mod cli;
-mod crypto;
-mod bma;
-
 fn main() {
     let command = Command::from(env::args());
 
-- 
GitLab