Skip to content

Commit

Permalink
cargo clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
dkijania committed Mar 29, 2021
1 parent cdfc323 commit b73669e
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 60 deletions.
33 changes: 2 additions & 31 deletions iapyx/src/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,43 +127,14 @@ impl WalletBackend {
&self,
_identifier: AccountIdentifier,
) -> Result<Vec<SimpleVoteStatus>, 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!()
}

pub fn settings(&self) -> Result<Settings, WalletBackendError> {
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<bool, WalletBackendError> {
Expand All @@ -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")]
Expand Down
8 changes: 4 additions & 4 deletions iapyx/src/cli/args/interactive/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand All @@ -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),
}
}
Expand All @@ -345,15 +345,15 @@ impl RecoverFromSecretKey {
}

#[derive(StructOpt, Debug)]
pub struct RecoverFromQR {
pub struct RecoverFromQr {
#[structopt(short = "q", long = "qr")]
pub qr_code: PathBuf,

#[structopt(short = "p", long = "password")]
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(),
Expand Down
4 changes: 2 additions & 2 deletions iapyx/src/cli/args/qr/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand All @@ -40,7 +40,7 @@ pub struct GetAddressFromQRCommand {
pub block0: Option<String>,
}

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);
Expand Down
8 changes: 4 additions & 4 deletions iapyx/src/cli/args/qr/mod.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions iapyx/src/cli/args/qr/secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand All @@ -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);
Expand Down
1 change: 1 addition & 0 deletions iapyx/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ impl Proposal {
}
}

#[allow(clippy::from_over_into)]
impl Into<wallet_core::Proposal> for Proposal {
fn into(self) -> wallet_core::Proposal {
let chain_proposal_index = self.chain_proposal_index as u8;
Expand Down
4 changes: 2 additions & 2 deletions iapyx/src/qr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand Down
6 changes: 3 additions & 3 deletions iapyx/src/utils/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Utc>;

fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
Expand All @@ -40,7 +40,7 @@ where
}

deserializer
.deserialize_str(RFC3339Deserializer())
.deserialize_str(Rfc3339Deserializer())
.map(|datetime| datetime.timestamp())
}

Expand Down
6 changes: 3 additions & 3 deletions integration-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
2 changes: 1 addition & 1 deletion snapshot-trigger-service/src/client/rest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
4 changes: 2 additions & 2 deletions vitup/src/mock/mock_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub struct MockState {
vit_state: Snapshot,
}

pub fn context(testing_directory: &PathBuf) -> Context {
pub fn context<P: AsRef<Path>>(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);
Expand All @@ -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,
Expand Down
8 changes: 2 additions & 6 deletions vitup/src/scenario/vit_station/data.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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);
Expand Down

0 comments on commit b73669e

Please sign in to comment.