From b73669ea3798d3b1b3dba204d4a44041ea1bca56 Mon Sep 17 00:00:00 2001 From: dkijania Date: Mon, 29 Mar 2021 17:26:04 +0200 Subject: [PATCH] cargo clippy --- iapyx/src/backend/mod.rs | 33 ++------------------- iapyx/src/cli/args/interactive/command.rs | 8 ++--- iapyx/src/cli/args/qr/address.rs | 4 +-- iapyx/src/cli/args/qr/mod.rs | 8 ++--- iapyx/src/cli/args/qr/secret.rs | 4 +-- iapyx/src/data.rs | 1 + iapyx/src/qr/mod.rs | 4 +-- iapyx/src/utils/serde.rs | 6 ++-- integration-tests/src/lib.rs | 6 ++-- snapshot-trigger-service/src/client/rest.rs | 2 +- vitup/src/mock/mock_state.rs | 4 +-- vitup/src/scenario/vit_station/data.rs | 8 ++--- 12 files changed, 28 insertions(+), 60 deletions(-) diff --git a/iapyx/src/backend/mod.rs b/iapyx/src/backend/mod.rs index 283fb515..d7b61743 100644 --- a/iapyx/src/backend/mod.rs +++ b/iapyx/src/backend/mod.rs @@ -127,34 +127,6 @@ impl WalletBackend { &self, _identifier: AccountIdentifier, ) -> Result, WalletBackendError> { - /* - let vote_plan_statuses = self.vote_plan_statuses().unwrap(); - let proposals = self.proposals().unwrap(); - - - let mut active_votes = Vec::new(); - for vote_plan_status in vote_plan_statuses { - for proposal in vote_plan_status.proposals { - for (account, payload) in proposal.votes.iter() { - if *account == identifier { - let vit_proposal = proposals - .iter() - .find(|x| { - x.chain_proposal_id_as_str() - == proposal.proposal_id.clone().to_string() - }) - .unwrap(); - active_votes.push(SimpleVoteStatus { - chain_proposal_id: vit_proposal.chain_proposal_id_as_str(), - proposal_title: vit_proposal.proposal_title.clone(), - choice: vit_proposal.get_option_text(payload.choice().unwrap().clone()), - }); - } - } - } - } - Ok(active_votes) - */ unimplemented!() } @@ -162,8 +134,7 @@ impl WalletBackend { let block0 = self.block0()?; let mut block0_bytes = ReadBuf::from(&block0); let block0 = Block::read(&mut block0_bytes).map_err(WalletBackendError::Block0ReadError)?; - Ok(Settings::new(&block0) - .map_err(|e| WalletBackendError::SettingsReadError(Box::new(e)))?) + Settings::new(&block0).map_err(|e| WalletBackendError::SettingsReadError(Box::new(e))) } pub fn account_exists(&self, id: AccountId) -> Result { @@ -180,7 +151,7 @@ pub enum WalletBackendError { #[error("node rest error")] ProxyConnectionError(#[from] ProxyClientError), #[error("io error")] - IOError(#[from] std::io::Error), + IoError(#[from] std::io::Error), #[error("block0 retrieve error")] Block0ReadError(#[from] chain_core::mempack::ReadError), #[error("block0 retrieve error")] diff --git a/iapyx/src/cli/args/interactive/command.rs b/iapyx/src/cli/args/interactive/command.rs index 89e37ae1..438acf9c 100644 --- a/iapyx/src/cli/args/interactive/command.rs +++ b/iapyx/src/cli/args/interactive/command.rs @@ -311,7 +311,7 @@ pub enum Recover { /// recover wallet funds from mnemonic Mnemonics(RecoverFromMnemonics), /// recover wallet funds from qr code - QR(RecoverFromQR), + Qr(RecoverFromQr), /// recover wallet funds from private key Secret(RecoverFromSecretKey), } @@ -320,7 +320,7 @@ impl Recover { pub fn exec(&self, model: &mut UserInteractionContoller) -> Result<(), IapyxCommandError> { match self { Recover::Mnemonics(mnemonics) => mnemonics.exec(model), - Recover::QR(qr) => qr.exec(model), + Recover::Qr(qr) => qr.exec(model), Recover::Secret(sk) => sk.exec(model), } } @@ -345,7 +345,7 @@ impl RecoverFromSecretKey { } #[derive(StructOpt, Debug)] -pub struct RecoverFromQR { +pub struct RecoverFromQr { #[structopt(short = "q", long = "qr")] pub qr_code: PathBuf, @@ -353,7 +353,7 @@ pub struct RecoverFromQR { pub password: String, } -impl RecoverFromQR { +impl RecoverFromQr { pub fn exec(&self, model: &mut UserInteractionContoller) -> Result<(), IapyxCommandError> { model.controller = Some(Controller::recover_from_qr( model.backend_address.clone(), diff --git a/iapyx/src/cli/args/qr/address.rs b/iapyx/src/cli/args/qr/address.rs index cf0d6b6d..692b27a7 100644 --- a/iapyx/src/cli/args/qr/address.rs +++ b/iapyx/src/cli/args/qr/address.rs @@ -18,7 +18,7 @@ use std::path::PathBuf; use structopt::StructOpt; use url::Url; #[derive(StructOpt, Debug)] -pub struct GetAddressFromQRCommand { +pub struct GetAddressFromQrCommand { #[structopt(long = "qr")] pub qr: PathBuf, @@ -40,7 +40,7 @@ pub struct GetAddressFromQRCommand { pub block0: Option, } -impl GetAddressFromQRCommand { +impl GetAddressFromQrCommand { pub fn exec(&self) -> Result<(), IapyxQrCommandError> { println!("Decoding qr from file: {:?}...", self.qr); let pin_read_mode = PinReadMode::new(self.read_pin_from_filename, &self.pin); diff --git a/iapyx/src/cli/args/qr/mod.rs b/iapyx/src/cli/args/qr/mod.rs index 543b28c8..f02227d3 100644 --- a/iapyx/src/cli/args/qr/mod.rs +++ b/iapyx/src/cli/args/qr/mod.rs @@ -1,8 +1,8 @@ mod address; mod secret; mod verify; -use crate::cli::args::qr::secret::GetSecretFromQRCommand; -use address::GetAddressFromQRCommand; +use crate::cli::args::qr::secret::GetSecretFromQrCommand; +use address::GetAddressFromQrCommand; use jormungandr_lib::interfaces::Block0ConfigurationError; use structopt::StructOpt; use thiserror::Error; @@ -11,8 +11,8 @@ use verify::VerifyQrCommand; #[derive(StructOpt, Debug)] pub enum IapyxQrCommand { Verify(VerifyQrCommand), - CheckAddress(GetAddressFromQRCommand), - Secret(GetSecretFromQRCommand), + CheckAddress(GetAddressFromQrCommand), + Secret(GetSecretFromQrCommand), } impl IapyxQrCommand { diff --git a/iapyx/src/cli/args/qr/secret.rs b/iapyx/src/cli/args/qr/secret.rs index 6214a070..4b6dbdc4 100644 --- a/iapyx/src/cli/args/qr/secret.rs +++ b/iapyx/src/cli/args/qr/secret.rs @@ -11,7 +11,7 @@ use std::path::PathBuf; use structopt::StructOpt; #[derive(StructOpt, Debug)] -pub struct GetSecretFromQRCommand { +pub struct GetSecretFromQrCommand { #[structopt(long = "qr")] pub qr: PathBuf, @@ -22,7 +22,7 @@ pub struct GetSecretFromQRCommand { pub read_pin_from_filename: bool, } -impl GetSecretFromQRCommand { +impl GetSecretFromQrCommand { pub fn exec(&self) -> Result<(), IapyxQrCommandError> { println!("Decoding qr from file: {:?}...", self.qr); let pin_read_mode = PinReadMode::new(self.read_pin_from_filename, &self.pin); diff --git a/iapyx/src/data.rs b/iapyx/src/data.rs index 7d86fa15..70401358 100644 --- a/iapyx/src/data.rs +++ b/iapyx/src/data.rs @@ -157,6 +157,7 @@ impl Proposal { } } +#[allow(clippy::from_over_into)] impl Into for Proposal { fn into(self) -> wallet_core::Proposal { let chain_proposal_index = self.chain_proposal_index as u8; diff --git a/iapyx/src/qr/mod.rs b/iapyx/src/qr/mod.rs index a26f765f..89e27d91 100644 --- a/iapyx/src/qr/mod.rs +++ b/iapyx/src/qr/mod.rs @@ -30,9 +30,9 @@ pub enum PinReadError { #[error("cannot split file name from path {0:?}")] UnableToSplitFileName(PathBuf), #[error("Cannot read qr from file")] - UnableToReadQR(#[from] std::io::Error), + UnableToReadQr(#[from] std::io::Error), #[error("Cannot decode qr from file")] - UnableToDecodeQR(#[from] KeyQrCodeError), + UnableToDecodeQr(#[from] KeyQrCodeError), #[error("cannot open image")] UnableToOpenImage(#[from] image::ImageError), } diff --git a/iapyx/src/utils/serde.rs b/iapyx/src/utils/serde.rs index 0b157b3d..8dc05260 100644 --- a/iapyx/src/utils/serde.rs +++ b/iapyx/src/utils/serde.rs @@ -19,9 +19,9 @@ pub fn deserialize_unix_timestamp_from_rfc3339<'de, D>(deserializer: D) -> Resul where D: Deserializer<'de>, { - struct RFC3339Deserializer(); + struct Rfc3339Deserializer(); - impl<'de> Visitor<'de> for RFC3339Deserializer { + impl<'de> Visitor<'de> for Rfc3339Deserializer { type Value = DateTime; fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { @@ -40,7 +40,7 @@ where } deserializer - .deserialize_str(RFC3339Deserializer()) + .deserialize_str(Rfc3339Deserializer()) .map(|datetime| datetime.timestamp()) } diff --git a/integration-tests/src/lib.rs b/integration-tests/src/lib.rs index 66946d5e..d72202a4 100644 --- a/integration-tests/src/lib.rs +++ b/integration-tests/src/lib.rs @@ -27,7 +27,7 @@ pub enum Error { #[allow(dead_code)] pub enum Vote { - BLANK = 0, - YES = 1, - NO = 2, + Blank = 0, + Yes = 1, + No = 2, } diff --git a/snapshot-trigger-service/src/client/rest.rs b/snapshot-trigger-service/src/client/rest.rs index 31c188f2..e0e267ad 100644 --- a/snapshot-trigger-service/src/client/rest.rs +++ b/snapshot-trigger-service/src/client/rest.rs @@ -125,5 +125,5 @@ pub enum Error { #[error("yaml response serialization error")] SerdeYamlError(#[from] serde_yaml::Error), #[error("io error")] - IOError(#[from] std::io::Error), + IoError(#[from] std::io::Error), } diff --git a/vitup/src/mock/mock_state.rs b/vitup/src/mock/mock_state.rs index a87a06d6..970f52c3 100644 --- a/vitup/src/mock/mock_state.rs +++ b/vitup/src/mock/mock_state.rs @@ -21,7 +21,7 @@ pub struct MockState { vit_state: Snapshot, } -pub fn context(testing_directory: &PathBuf) -> Context { +pub fn context>(testing_directory: P) -> Context { let jormungandr = prepare_command(PathBuf::from_str("jormungandr").unwrap()); let jcli = prepare_command(PathBuf::from_str("jcli").unwrap()); let seed = Seed::generate(rand::rngs::OsRng); @@ -32,7 +32,7 @@ pub fn context(testing_directory: &PathBuf) -> Context { seed, jormungandr, jcli, - Some(testing_directory.clone()), + Some(testing_directory.as_ref().to_path_buf()), generate_documentation, ProgressBarMode::None, log_level, diff --git a/vitup/src/scenario/vit_station/data.rs b/vitup/src/scenario/vit_station/data.rs index 319143f1..77fc0198 100644 --- a/vitup/src/scenario/vit_station/data.rs +++ b/vitup/src/scenario/vit_station/data.rs @@ -1,5 +1,5 @@ use assert_fs::TempDir; -use std::path::PathBuf; +use std::path::Path; use vit_servicing_station_tests::common::data::ValidVotePlanParameters; use vit_servicing_station_tests::common::data::{ ValidVotePlanGenerator, ValidVotingTemplateGenerator, @@ -14,11 +14,7 @@ impl DbGenerator { Self { parameters } } - pub fn build( - self, - db_file: &PathBuf, - template_generator: &mut dyn ValidVotingTemplateGenerator, - ) { + pub fn build(self, db_file: &Path, template_generator: &mut dyn ValidVotingTemplateGenerator) { std::fs::File::create(&db_file).unwrap(); let mut generator = ValidVotePlanGenerator::new(self.parameters);