From 0194e94c6c0329c589d74ae8eb245e2f8ce36e11 Mon Sep 17 00:00:00 2001
From: librelois <elois@ifee.fr>
Date: Tue, 10 Jul 2018 18:34:05 +0200
Subject: [PATCH] [ci] comply latest clippy version

---
 Cargo.lock            | 13 +++++++++++++
 blockchain/Cargo.toml |  1 +
 blockchain/lib.rs     | 13 ++++++++-----
 conf/Cargo.toml       |  1 +
 conf/lib.rs           | 13 ++++---------
 core/Cargo.toml       |  1 +
 core/lib.rs           | 10 +++++-----
 dal/dal_requests.rs   |  4 ++--
 dal/tools.rs          | 18 ++++++++----------
 module/lib.rs         |  1 +
 src/main.rs           | 10 ++++++++--
 wotb/lib.rs           | 10 ++++++++--
 12 files changed, 60 insertions(+), 35 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock
index eca11a63..9d5feab3 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -166,6 +166,15 @@ dependencies = [
  "cfg-if 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
+[[package]]
+name = "dirs"
+version = "1.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
 [[package]]
 name = "dtoa"
 version = "0.4.2"
@@ -175,6 +184,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 name = "duniter-blockchain"
 version = "0.1.0-a0.1"
 dependencies = [
+ "dirs 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "duniter-conf 0.1.0-a0.1",
  "duniter-crypto 0.2.0-a0.1",
  "duniter-dal 0.1.0-a0.1",
@@ -199,6 +209,7 @@ dependencies = [
 name = "duniter-conf"
 version = "0.1.0-a0.1"
 dependencies = [
+ "dirs 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "duniter-crypto 0.2.0-a0.1",
  "duniter-module 0.1.0-a0.1",
  "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -212,6 +223,7 @@ name = "duniter-core"
 version = "0.1.0-a0.1"
 dependencies = [
  "clap 2.31.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "dirs 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "duniter-blockchain 0.1.0-a0.1",
  "duniter-conf 0.1.0-a0.1",
  "duniter-crypto 0.2.0-a0.1",
@@ -1134,6 +1146,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 "checksum crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f739f8c5363aca78cfb059edf753d8f0d36908c348f3d8d1503f03d8b75d9cf3"
 "checksum crossbeam-epoch 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "927121f5407de9956180ff5e936fe3cf4324279280001cd56b669d28ee7e9150"
 "checksum crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2760899e32a1d58d5abb31129f8fae5de75220bc2176e77ff7c627ae45c918d9"
+"checksum dirs 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "37a76dd8b997af7107d0bb69d43903cf37153a18266f8b3fdb9911f28efb5444"
 "checksum dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "09c3753c3db574d215cba4ea76018483895d7bff25a31b49ba45db21c48e50ab"
 "checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0"
 "checksum failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "934799b6c1de475a012a02dab0ace1ace43789ee4b99bcfbf1a2e3e8ced5de82"
diff --git a/blockchain/Cargo.toml b/blockchain/Cargo.toml
index dd30659f..44ba92d6 100644
--- a/blockchain/Cargo.toml
+++ b/blockchain/Cargo.toml
@@ -9,6 +9,7 @@ license = "AGPL-3.0"
 path = "lib.rs"
 
 [dependencies]
+dirs = "1.0.2"
 duniter-conf = { path = "../conf" }
 duniter-crypto = { path = "../crypto" }
 duniter-dal = { path = "../dal" }
diff --git a/blockchain/lib.rs b/blockchain/lib.rs
index 09706d58..40d25627 100644
--- a/blockchain/lib.rs
+++ b/blockchain/lib.rs
@@ -16,7 +16,10 @@
 //! Module managing the Duniter blockchain.
 
 #![cfg_attr(feature = "strict", deny(warnings))]
-#![cfg_attr(feature = "cargo-clippy", allow(unused_collect, duration_subsec))]
+#![cfg_attr(
+    feature = "cargo-clippy",
+    allow(unused_collect, duration_subsec)
+)]
 #![deny(
     missing_docs,
     missing_debug_implementations,
@@ -32,6 +35,7 @@
 #[macro_use]
 extern crate log;
 
+extern crate dirs;
 extern crate duniter_conf;
 extern crate duniter_crypto;
 extern crate duniter_dal;
@@ -53,7 +57,6 @@ mod sync;
 mod ts_parsers;
 
 use std::collections::HashMap;
-use std::env;
 use std::fmt::Debug;
 use std::ops::Deref;
 use std::path::PathBuf;
@@ -210,11 +213,11 @@ impl BlockchainModule {
         verif_inner_hash: bool,
     ) {
         // get db_ts_path
-        let mut db_ts_path = match env::home_dir() {
+        let mut db_ts_path = match dirs::config_dir() {
             Some(path) => path,
-            None => panic!("Impossible to get your home dir!"),
+            None => panic!("Impossible to get user config directory !"),
         };
-        db_ts_path.push(".config/duniter/");
+        db_ts_path.push("duniter/");
         db_ts_path.push(ts_profile);
         db_ts_path.push("duniter.db");
         if !db_ts_path.as_path().exists() {
diff --git a/conf/Cargo.toml b/conf/Cargo.toml
index f5482419..12e9ed34 100644
--- a/conf/Cargo.toml
+++ b/conf/Cargo.toml
@@ -13,6 +13,7 @@ rand = "0.4.*"
 serde = "1.0.*"
 serde_derive = "1.0.*"
 serde_json = "1.0.*"
+dirs = "1.0.2"
 duniter-crypto = { path = "../crypto" }
 duniter-module = { path = "../module" }
 
diff --git a/conf/lib.rs b/conf/lib.rs
index 3e3935bd..7ebf86f2 100644
--- a/conf/lib.rs
+++ b/conf/lib.rs
@@ -34,6 +34,7 @@ extern crate serde_derive;
 #[macro_use]
 extern crate serde_json;
 
+extern crate dirs;
 extern crate duniter_crypto;
 extern crate duniter_module;
 extern crate rand;
@@ -43,7 +44,6 @@ use duniter_module::{Currency, DuniterConf, ModuleId, RequiredKeys, RequiredKeys
 use rand::Rng;
 use serde::ser::{Serialize, SerializeStruct, Serializer};
 use std::collections::HashSet;
-use std::env;
 use std::fs;
 use std::fs::File;
 use std::io::prelude::*;
@@ -277,14 +277,10 @@ pub fn datas_path(profile: &str, currency: &Currency) -> PathBuf {
 /// Returns the path to the folder containing the user data of the running profile
 pub fn get_profile_path(profile: &str) -> PathBuf {
     // Define and create datas directory if not exist
-    let mut profile_path = match env::home_dir() {
+    let mut profile_path = match dirs::config_dir() {
         Some(path) => path,
-        None => panic!("Impossible to get your home dir !"),
+        None => panic!("Impossible to get user config directory !"),
     };
-    profile_path.push(".config/");
-    if !profile_path.as_path().exists() {
-        fs::create_dir(profile_path.as_path()).expect("Impossible to create ~/.config dir !");
-    }
     profile_path.push(USER_DATAS_FOLDER);
     if !profile_path.as_path().exists() {
         fs::create_dir(profile_path.as_path()).unwrap_or_else(|_| {
@@ -431,11 +427,10 @@ pub fn get_blockchain_db_path(profile: &str, currency: &Currency) -> PathBuf {
 
 /// Returns the path to the binary file containing the state of the web of trust
 pub fn get_wot_path(profile: String, currency: &Currency) -> PathBuf {
-    let mut wot_path = match env::home_dir() {
+    let mut wot_path = match dirs::config_dir() {
         Some(path) => path,
         None => panic!("Impossible to get your home dir!"),
     };
-    wot_path.push(".config/");
     wot_path.push(USER_DATAS_FOLDER);
     wot_path.push(profile);
     wot_path.push(currency.to_string());
diff --git a/core/Cargo.toml b/core/Cargo.toml
index 087eb9f5..550ca8c0 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -10,6 +10,7 @@ path = "lib.rs"
 
 [dependencies]
 clap = {version = "2.31.2", features = ["yaml"]}
+dirs = "1.0.2"
 duniter-blockchain = { path = "../blockchain" }
 duniter-conf = { path = "../conf" }
 duniter-crypto = { path = "../crypto" }
diff --git a/core/lib.rs b/core/lib.rs
index 005e1b03..c4e2d091 100644
--- a/core/lib.rs
+++ b/core/lib.rs
@@ -35,6 +35,7 @@ extern crate clap;
 #[macro_use]
 extern crate log;
 
+extern crate dirs;
 extern crate duniter_blockchain;
 extern crate duniter_conf;
 extern crate duniter_crypto;
@@ -58,7 +59,6 @@ use duniter_network::{NetworkModule, SyncEndpoint};
 use log::Level;
 use simplelog::*;
 use std::collections::HashSet;
-use std::env;
 use std::fs;
 use std::fs::{File, OpenOptions};
 use std::sync::mpsc;
@@ -283,9 +283,9 @@ impl DuniterCore<DuRsConf> {
             }
             None
         } else if let Some(matches) = cli_args.subcommand_matches("reset") {
-            let mut profile_path = match env::home_dir() {
+            let mut profile_path = match dirs::config_dir() {
                 Some(path) => path,
-                None => panic!("Impossible to get your home dir !"),
+                None => panic!("Impossible to get user config directory !"),
             };
             profile_path.push(".config");
             profile_path.push(duniter_conf::get_user_datas_folder());
@@ -685,9 +685,9 @@ pub fn dbex<DC: DuniterConf>(profile: &str, conf: &DC, csv: bool, query: &DBExQu
 /// Initialize logger
 pub fn init_logger(profile: &str, soft_name: &'static str, cli_args: &ArgMatches) {
     // Get datas folder path
-    let mut log_file_path = match env::home_dir() {
+    let mut log_file_path = match dirs::config_dir() {
         Some(path) => path,
-        None => panic!("Fatal error : Impossible to get your home dir!"),
+        None => panic!("Fatal error : Impossible to get user config directory"),
     };
     log_file_path.push(".config");
     if !log_file_path.as_path().exists() {
diff --git a/dal/dal_requests.rs b/dal/dal_requests.rs
index 366a5cb5..8f9e76c6 100644
--- a/dal/dal_requests.rs
+++ b/dal/dal_requests.rs
@@ -80,7 +80,7 @@ pub enum DALResPendings {
     /// All pending identities without their pending certifications
     AllPendingIdentitiesWithoutCerts(HashMap<Hash, PendingIdtyDatas>),
     /// All pending datas for given pubkey
-    PendingWotDatasForPubkey(PendingIdtyDatas),
+    PendingWotDatasForPubkey(Box<PendingIdtyDatas>),
 }
 
 #[derive(Debug, Clone)]
@@ -102,5 +102,5 @@ pub enum DALResponse {
     /// Response to a DALReqBlockchain request
     Blockchain(Box<DALResBlockchain>),
     /// Response to a DALReqPendings request
-    Pendings(ModuleReqFullId, DALResPendings),
+    Pendings(ModuleReqFullId, Box<DALResPendings>),
 }
diff --git a/dal/tools.rs b/dal/tools.rs
index bc65497a..15cad56e 100644
--- a/dal/tools.rs
+++ b/dal/tools.rs
@@ -52,24 +52,22 @@ pub fn get_sentry_requirement(members_count: usize, step_max: u32) -> u32 {
                 9
             } else if members_count < 100_001 {
                 10
-            } else if members_count < 100_001 {
-                11
             } else if members_count < 161_052 {
-                12
+                11
             } else if members_count < 248_833 {
-                13
+                12
             } else if members_count < 371_294 {
-                14
+                13
             } else if members_count < 537_825 {
-                15
+                14
             } else if members_count < 759_376 {
-                16
+                15
             } else if members_count < 1_048_577 {
-                17
+                16
             } else if members_count < 1_419_858 {
-                18
+                17
             } else if members_count < 1_889_569 {
-                19
+                18
             } else {
                 panic!(
                     "get_sentry_requirement not define for members_count greater than 1_889_569 !"
diff --git a/module/lib.rs b/module/lib.rs
index 8b575027..a11db064 100644
--- a/module/lib.rs
+++ b/module/lib.rs
@@ -17,6 +17,7 @@
 //! as well as the DuniterModule trait that all modules must implement.
 
 #![cfg_attr(feature = "strict", deny(warnings))]
+#![cfg_attr(feature = "cargo-clippy", allow(implicit_hasher))]
 #![deny(
     missing_docs,
     missing_debug_implementations,
diff --git a/src/main.rs b/src/main.rs
index eacbede7..f275ed88 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -17,8 +17,14 @@
 
 #![cfg_attr(feature = "strict", deny(warnings))]
 #![deny(
-    missing_docs, missing_debug_implementations, missing_copy_implementations, trivial_casts,
-    trivial_numeric_casts, unsafe_code, unstable_features, unused_import_braces,
+    missing_docs,
+    missing_debug_implementations,
+    missing_copy_implementations,
+    trivial_casts,
+    trivial_numeric_casts,
+    unsafe_code,
+    unstable_features,
+    unused_import_braces,
     unused_qualifications
 )]
 
diff --git a/wotb/lib.rs b/wotb/lib.rs
index a68352c5..3926037b 100644
--- a/wotb/lib.rs
+++ b/wotb/lib.rs
@@ -28,8 +28,14 @@
 
 #![cfg_attr(feature = "strict", deny(warnings))]
 #![deny(
-    missing_docs, missing_debug_implementations, missing_copy_implementations, trivial_casts,
-    trivial_numeric_casts, unsafe_code, unstable_features, unused_import_braces,
+    missing_docs,
+    missing_debug_implementations,
+    missing_copy_implementations,
+    trivial_casts,
+    trivial_numeric_casts,
+    unsafe_code,
+    unstable_features,
+    unused_import_braces,
     unused_qualifications
 )]
 
-- 
GitLab