Skip to content

Commit

Permalink
Fix various clippy warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Patrik Stas <[email protected]>
  • Loading branch information
Patrik-Stas committed Sep 25, 2023
1 parent 72825fb commit b1db2cc
Show file tree
Hide file tree
Showing 17 changed files with 34 additions and 45 deletions.
2 changes: 1 addition & 1 deletion aries_vcx/src/common/credentials/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ mod integration_tests {

assert_eq!(prover_cred.schema_id, schema.schema_id);
assert_eq!(prover_cred.cred_def_id, cred_def.get_cred_def_id());
assert_eq!(prover_cred.cred_rev_id.unwrap().to_string(), cred_rev_id);
assert_eq!(prover_cred.cred_rev_id.unwrap(), cred_rev_id);
assert_eq!(prover_cred.rev_reg_id.unwrap(), rev_reg.rev_reg_id);
})
.await;
Expand Down
2 changes: 1 addition & 1 deletion aries_vcx/src/core/profile/ledger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub fn indyvdr_build_ledger_read(
let response_cacher = Arc::new(InMemoryResponseCacher::new(cache_config));

let config_read = IndyVdrLedgerReadConfig {
request_submitter: request_submitter.clone(),
request_submitter,
response_parser,
response_cacher,
protocol_version: ProtocolVersion::node_1_4(),
Expand Down
2 changes: 1 addition & 1 deletion aries_vcx/src/handlers/proof_presentation/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ impl SelectedCredentials {
with_tails_dir: Option<String>,
) {
self.credential_for_referent.insert(
referent.to_string(),
referent,
SelectedCredentialForReferent {
credential: SelectedCredentialForReferentCredential::from(retrieved_cred),
tails_dir: with_tails_dir,
Expand Down
1 change: 0 additions & 1 deletion aries_vcx/src/protocols/connection/inviter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ use crate::{
errors::error::VcxResult,
handlers::util::{verify_thread_id, AnyInvitation},
protocols::connection::trait_bounds::ThreadId,
transport::Transport,
};

pub type InviterConnection<S> = Connection<Inviter, S>;
Expand Down
17 changes: 5 additions & 12 deletions aries_vcx/src/protocols/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,22 @@ pub mod pairwise_info;
mod serializable;
mod trait_bounds;

use std::{error::Error, sync::Arc};
use std::sync::Arc;

use aries_vcx_core::wallet::base_wallet::BaseWallet;
use chrono::Utc;
use diddoc_legacy::aries::diddoc::AriesDidDoc;
use messages::{
decorators::{thread::Thread, timing::Timing},
msg_fields::protocols::{
connection::problem_report::{
ProblemReport, ProblemReportContent, ProblemReportDecorators,
},
discover_features::{disclose::Disclose, query::QueryContent, ProtocolDescriptor},
msg_fields::protocols::discover_features::{
disclose::Disclose, query::QueryContent, ProtocolDescriptor,
},
AriesMessage,
};
use uuid::Uuid;

pub use self::generic::{GenericConnection, State, ThinState};
use self::{
generic::GenericState,
pairwise_info::PairwiseInfo,
trait_bounds::{CompletedState, HandleProblem, TheirDidDoc, ThreadId},
trait_bounds::{CompletedState, TheirDidDoc, ThreadId},
};
use crate::{
errors::error::{AriesVcxError, AriesVcxErrorKind, VcxResult},
Expand Down Expand Up @@ -108,8 +102,7 @@ where
message: &AriesMessage,
) -> VcxResult<EncryptionEnvelope> {
let sender_verkey = &self.pairwise_info().pw_vk;
EncryptionEnvelope::create(wallet, message, Some(sender_verkey), &self.their_did_doc())
.await
EncryptionEnvelope::create(wallet, message, Some(sender_verkey), self.their_did_doc()).await
}

pub fn remote_did(&self) -> &str {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,7 @@ impl VerifierSM {
(state, presentation, PresentationVerificationStatus::Invalid)
.into(),
),
_ => {
VerifierFullState::Finished((state, problem_report.clone()).into())
}
_ => VerifierFullState::Finished((state, problem_report).into()),
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions aries_vcx/src/utils/devsetup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ pub fn dev_build_profile_vdrtools(
) -> Arc<dyn Profile> {
info!("dev_build_profile_vdrtools >>");
let vcx_pool_config = VcxPoolConfig {
genesis_file_path: genesis_file_path.clone(),
genesis_file_path,
indy_vdr_config: None,
response_cache_config: None,
};
Expand All @@ -185,10 +185,10 @@ pub fn dev_build_profile_vdrtools(
build_ledger_components(wallet.clone(), vcx_pool_config).unwrap();
let anoncreds_ledger_read: Arc<dyn AnoncredsLedgerRead> = ledger_read.clone();
let anoncreds_ledger_write: Arc<dyn AnoncredsLedgerWrite> = ledger_write.clone();
let indy_ledger_read: Arc<dyn IndyLedgerRead> = ledger_read.clone();
let indy_ledger_write: Arc<dyn IndyLedgerWrite> = ledger_write.clone();
let indy_ledger_read: Arc<dyn IndyLedgerRead> = ledger_read;
let indy_ledger_write: Arc<dyn IndyLedgerWrite> = ledger_write;
Arc::new(VdrtoolsProfile::init(
wallet.clone(),
wallet,
anoncreds_ledger_read,
anoncreds_ledger_write,
indy_ledger_read,
Expand All @@ -203,7 +203,7 @@ pub fn dev_build_profile_modular(
) -> Arc<dyn Profile> {
info!("dev_build_profile_modular >>");
let vcx_pool_config = VcxPoolConfig {
genesis_file_path: genesis_file_path.clone(),
genesis_file_path,
indy_vdr_config: None,
response_cache_config: None,
};
Expand Down
2 changes: 1 addition & 1 deletion aries_vcx/tests/utils/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl Migratable for TestAgent {
let old_wh = self.profile.wallet_handle().unwrap();
let new_wh = migrate_to_new_wallet(old_wh).await;
let wallet = Arc::new(IndySdkWallet::new(new_wh));
self.profile = dev_build_profile_modular(self.genesis_file_path.clone(), wallet.clone());
self.profile = dev_build_profile_modular(self.genesis_file_path.clone(), wallet);
}
}

Expand Down
6 changes: 3 additions & 3 deletions aries_vcx/tests/utils/scenarios/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ async fn establish_connection_from_invite(
&faber.profile.inject_wallet(),
request,
"http://dummy.org".parse().unwrap(),
vec![]
vec![],
)
.await
.unwrap();
Expand Down Expand Up @@ -94,7 +94,7 @@ pub async fn create_connections_via_oob_invite(
.unwrap();
// TODO: Create a key and write on ledger instead
let inviter_pairwise_info = PairwiseInfo {
pw_did: ddo.clone().id.clone(),
pw_did: ddo.clone().id,
pw_vk: ddo.recipient_keys().unwrap().first().unwrap().to_string(),
};
establish_connection_from_invite(alice, faber, invitation, inviter_pairwise_info).await
Expand All @@ -120,7 +120,7 @@ pub async fn create_connections_via_public_invite(
.unwrap();
// TODO: Create a key and write on ledger instead
let inviter_pairwise_info = PairwiseInfo {
pw_did: ddo.clone().id.clone(),
pw_did: ddo.clone().id,
pw_vk: ddo.recipient_keys().unwrap().first().unwrap().to_string(),
};
establish_connection_from_invite(alice, faber, public_invite.clone(), inviter_pairwise_info)
Expand Down
11 changes: 5 additions & 6 deletions did_doc/src/schema/verification_method/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ mod tests {

let vm =
VerificationMethod::builder(id.clone(), controller.clone(), verification_method_type)
.add_public_key_multibase(public_key_multibase.clone())
.add_public_key_multibase(public_key_multibase)
.build();

assert_eq!(vm.id(), &id);
Expand All @@ -255,7 +255,7 @@ mod tests {

let vm =
VerificationMethod::builder(id.clone(), controller.clone(), verification_method_type)
.add_public_key_multibase(public_key_multibase.clone())
.add_public_key_multibase(public_key_multibase)
.build();

assert_eq!(vm.id(), &id);
Expand Down Expand Up @@ -298,10 +298,9 @@ mod tests {
let verification_method_type = create_valid_verification_key_type();
let public_key_multibase_expected = create_valid_multibase();

let vm =
VerificationMethod::builder(id.clone(), controller.clone(), verification_method_type)
.add_public_key_multibase(public_key_multibase_expected.clone())
.build();
let vm = VerificationMethod::builder(id, controller, verification_method_type)
.add_public_key_multibase(public_key_multibase_expected.clone())
.build();

match vm.public_key_field() {
PublicKeyField::Multibase {
Expand Down
2 changes: 1 addition & 1 deletion did_doc_sov/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl DidDocumentSovBuilder {
}

pub fn add_service(mut self, service: ServiceSov) -> Self {
self.services.push(service.clone());
self.services.push(service);
self
}

Expand Down
8 changes: 4 additions & 4 deletions did_peer/src/numalgos/numalgo2/resolve/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ fn build_service_aip1(
service.service_endpoint().parse()?,
ExtraFieldsSov::AIP1(ExtraFieldsAIP1::default()),
)
.add_service_type(service_type.to_string())?
.add_service_type(service_type)?
.build())
}

Expand All @@ -174,7 +174,7 @@ fn build_service_didcommv2(
let extra = ExtraFieldsSov::DIDCommV2(extra_builder.build());
Ok(
Service::<ExtraFieldsSov>::builder(id, service.service_endpoint().parse()?, extra)
.add_service_type(service_type.to_string())?
.add_service_type(service_type)?
.build(),
)
}
Expand Down Expand Up @@ -247,7 +247,7 @@ mod tests {
.parse()
.unwrap();
let mut index = 0;
let ddo_builder = DidDocumentBuilder::<ExtraFieldsSov>::new(did.clone());
let ddo_builder = DidDocumentBuilder::<ExtraFieldsSov>::new(did);
let built_ddo =
process_service_element(purposeless_service_element, ddo_builder, &mut index)
.unwrap()
Expand All @@ -272,7 +272,7 @@ mod tests {
.parse()
.unwrap();
let mut index = 0;
let ddo_builder = DidDocumentBuilder::<ExtraFieldsSov>::new(did.clone());
let ddo_builder = DidDocumentBuilder::<ExtraFieldsSov>::new(did);
let built_ddo =
process_service_element(purposeless_service_element, ddo_builder, &mut index)
.unwrap()
Expand Down
2 changes: 1 addition & 1 deletion did_peer/src/numalgos/numalgo2/verification_method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ fn build_verification_methods_from_bls_multikey(

let vm1 = add_public_key_to_builder(
VerificationMethod::builder(
id1.to_owned(),
id1,
did.to_owned(),
VerificationMethodType::Bls12381G1Key2020,
),
Expand Down
2 changes: 1 addition & 1 deletion did_peer/src/peer_did/numalgos/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub trait Numalgo: Sized + Default {
{
let did: Did = did.try_into().map_err(Into::into)?;

let numalgo_char = did.id().chars().nth(0).ok_or_else(|| {
let numalgo_char = did.id().chars().next().ok_or_else(|| {
DidPeerError::DidValidationError(format!(
"Invalid did: unable to read numalgo character in did {}",
did.did()
Expand Down
2 changes: 1 addition & 1 deletion did_resolver_sov/src/resolution/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ pub(super) async fn ledger_response_to_ddo<E: Default>(
did.to_string().try_into()?,
VerificationMethodType::Ed25519VerificationKey2018,
)
.add_public_key_base58(verkey.to_string())
.add_public_key_base58(verkey)
.build();

let ddo = DidDocument::builder(ddo_id)
Expand Down
4 changes: 2 additions & 2 deletions libvcx_core/src/api_vcx/api_global/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ async fn build_components_ledger(
));
let taa_configurator: Arc<dyn TaaConfigurator> = ledger_write.clone();
let anoncreds_write: Arc<dyn AnoncredsLedgerWrite> = ledger_write.clone();
let indy_write: Arc<dyn IndyLedgerWrite> = ledger_write.clone();
let indy_write: Arc<dyn IndyLedgerWrite> = ledger_write;
let anoncreds_read: Arc<dyn AnoncredsLedgerRead> = ledger_read.clone();
let indy_read: Arc<dyn IndyLedgerRead> = ledger_read.clone();
let indy_read: Arc<dyn IndyLedgerRead> = ledger_read;
Ok((
anoncreds_read,
anoncreds_write,
Expand Down
2 changes: 1 addition & 1 deletion libvcx_core/src/api_vcx/api_handle/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ pub mod test_utils {
info!("schema: {:?}", schema);
assert_eq!(schema.schema_id, schema_id.to_string());

let mut schema_data = schema.data.clone();
let mut schema_data = schema.data;
schema_data.sort();
let mut vec_data: Vec<String> = serde_json::from_str(data).unwrap();
vec_data.sort();
Expand Down

0 comments on commit b1db2cc

Please sign in to comment.