Skip to content

Commit

Permalink
More changes due to new clippy warning uninlined-format-args
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanmiller-spruceid committed Sep 12, 2023
1 parent ce54940 commit cc9d222
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 79 deletions.
2 changes: 1 addition & 1 deletion ssi-core/src/uri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl FromStr for URI {
impl std::fmt::Display for URI {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
Self::String(ref string) => write!(f, "{}", string),
Self::String(ref string) => write!(f, "{string}"),
}
}
}
15 changes: 5 additions & 10 deletions ssi-dids/src/did_resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -626,8 +626,7 @@ async fn dereference_primary_resource(
Err(err) => {
return (
DereferencingMetadata::from_error(&format!(
"Unable to construct service endpoint: {}",
err
"Unable to construct service endpoint: {err}"
)),
Content::Null,
ContentMetadata::default(),
Expand Down Expand Up @@ -715,8 +714,7 @@ async fn dereference_secondary_resource(
Err(error) => {
return (
DereferencingMetadata::from_error(&format!(
"Unable to find object in DID document: {}",
error
"Unable to find object in DID document: {error}"
)),
Content::Null,
ContentMetadata::default(),
Expand Down Expand Up @@ -761,10 +759,7 @@ async fn dereference_secondary_resource(
ContentMetadata::default(),
),
Some(content_type) => (
DereferencingMetadata::from_error(&format!(
"Unsupported content type: {}",
content_type
)),
DereferencingMetadata::from_error(&format!("Unsupported content type: {content_type}")),
Content::Null,
ContentMetadata::default(),
),
Expand Down Expand Up @@ -1331,7 +1326,7 @@ pub async fn easy_resolve(did: &str, resolver: &dyn DIDResolver) -> Result<Docum
return Err(Error::UnableToResolve(err));
}
let doc = doc_opt
.ok_or_else(|| Error::UnableToResolve(format!("Missing document for DID: {}", did)))?;
.ok_or_else(|| Error::UnableToResolve(format!("Missing document for DID: {did}")))?;
Ok(doc)
}

Expand Down Expand Up @@ -1380,7 +1375,7 @@ pub async fn get_verification_methods_for_all(
let vm_ids = doc
.get_verification_method_ids(verification_relationship.clone())
.map_err(|e| {
Error::UnableToResolve(format!("Unable to get verification method ids: {:?}", e))
Error::UnableToResolve(format!("Unable to get verification method ids: {e:?}"))
})?;
for id in vm_ids {
vm_ids_for_purpose.insert(id);
Expand Down
18 changes: 9 additions & 9 deletions ssi-dids/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1024,10 +1024,10 @@ impl fmt::Display for DIDURL {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}{}", self.did, self.path_abempty)?;
if let Some(ref query) = self.query {
write!(f, "?{}", query)?;
write!(f, "?{query}")?;
}
if let Some(ref fragment) = self.fragment {
write!(f, "#{}", fragment)?;
write!(f, "#{fragment}")?;
}
Ok(())
}
Expand All @@ -1038,10 +1038,10 @@ impl fmt::Display for RelativeDIDURL {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
self.path.fmt(f)?;
if let Some(ref query) = self.query {
write!(f, "?{}", query)?;
write!(f, "?{query}")?;
}
if let Some(ref fragment) = self.fragment {
write!(f, "#{}", fragment)?;
write!(f, "#{fragment}")?;
}
Ok(())
}
Expand All @@ -1063,10 +1063,10 @@ impl fmt::Display for PrimaryDIDURL {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.did)?;
if let Some(ref path) = self.path {
write!(f, "{}", path)?;
write!(f, "{path}")?;
}
if let Some(ref query) = self.query {
write!(f, "?{}", query)?;
write!(f, "?{query}")?;
}
Ok(())
}
Expand All @@ -1083,7 +1083,7 @@ impl TryFrom<String> for DIDURL {
/// needed for #[serde(into = "String")]
impl From<DIDURL> for String {
fn from(didurl: DIDURL) -> String {
format!("{}", didurl)
format!("{didurl}")
}
}

Expand All @@ -1102,7 +1102,7 @@ impl From<PrimaryDIDURL> for DIDURL {
/// needed for #[serde(into = "String")]
impl From<PrimaryDIDURL> for String {
fn from(didurl: PrimaryDIDURL) -> String {
format!("{}", didurl)
format!("{didurl}")
}
}

Expand Down Expand Up @@ -1339,7 +1339,7 @@ impl Document {
VerificationRelationship::KeyAgreement => &self.key_agreement,
VerificationRelationship::CapabilityInvocation => &self.capability_invocation,
VerificationRelationship::CapabilityDelegation => &self.capability_delegation,
rel => return Err(format!("Unsupported verification relationship: {:?}", rel)),
rel => return Err(format!("Unsupported verification relationship: {rel:?}")),
};
let vm_ids = vms.iter().flatten().map(|vm| vm.get_id(did)).collect();
Ok(vm_ids)
Expand Down
2 changes: 1 addition & 1 deletion ssi-json-ld/src/urdna2015.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ pub struct HashNDegreeQuadsOutput {
fn digest_to_lowerhex(digest: &[u8]) -> String {
digest
.iter()
.map(|byte| format!("{:02x}", byte))
.map(|byte| format!("{byte:02x}"))
.collect::<String>()
}

Expand Down
3 changes: 1 addition & 2 deletions ssi-jws/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,7 @@ pub fn verify_bytes_warnable(
// For user convenience, output the normalized signature.
let sig_normalized_b64 = base64::encode_config(s, base64::URL_SAFE_NO_PAD);
warnings.push(format!(
"Non-normalized ES256K signature. Normalized: {}",
sig_normalized_b64
"Non-normalized ES256K signature. Normalized: {sig_normalized_b64}"
));
s
} else {
Expand Down
10 changes: 5 additions & 5 deletions ssi-ldp/src/eip712.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,19 +240,19 @@ impl fmt::Display for EIP712Type {
match self {
EIP712Type::Bytes => write!(f, "bytes"),
EIP712Type::String => write!(f, "string"),
EIP712Type::BytesN(n) => write!(f, "bytes{}", n),
EIP712Type::UintN(n) => write!(f, "uint{}", n),
EIP712Type::IntN(n) => write!(f, "int{}", n),
EIP712Type::BytesN(n) => write!(f, "bytes{n}"),
EIP712Type::UintN(n) => write!(f, "uint{n}"),
EIP712Type::IntN(n) => write!(f, "int{n}"),
EIP712Type::Bool => write!(f, "bool"),
EIP712Type::Address => write!(f, "address"),
EIP712Type::Array(type_) => {
write!(f, "{}[]", *type_)
}
EIP712Type::ArrayN(type_, n) => {
write!(f, "{}[{}]", *type_, n)
write!(f, "{}[{n}]", *type_)
}
EIP712Type::Struct(name) => {
write!(f, "{}", name)
write!(f, "{name}")
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions ssi-ucan/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,8 @@ pub enum UcanResource {
impl Display for UcanResource {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match &self {
Self::Proof(p) => write!(f, "{}", p),
Self::URI(u) => write!(f, "{}", u),
Self::Proof(p) => write!(f, "{p}"),
Self::URI(u) => write!(f, "{u}"),
}
}
}
Expand Down Expand Up @@ -422,7 +422,7 @@ impl UcanRevocation {
Ok(Self {
issuer,
revoke,
challenge: sign_bytes(algorithm, format!("REVOKE:{}", revoke).as_bytes(), jwk)?,
challenge: sign_bytes(algorithm, format!("REVOKE:{revoke}").as_bytes(), jwk)?,
})
}
pub async fn verify_signature(
Expand Down
46 changes: 20 additions & 26 deletions ssi-vc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ impl Credential {
Err(err) => {
return (
None,
VerificationResult::error(&format!("Unable to split JWS: {}", err)),
VerificationResult::error(&format!("Unable to split JWS: {err}")),
);
}
};
Expand All @@ -782,7 +782,7 @@ impl Credential {
Err(err) => {
return (
None,
VerificationResult::error(&format!("Unable to decode JWS: {}", err)),
VerificationResult::error(&format!("Unable to decode JWS: {err}")),
);
}
};
Expand All @@ -791,7 +791,7 @@ impl Credential {
Err(err) => {
return (
None,
VerificationResult::error(&format!("Unable to decode JWS claims: {}", err)),
VerificationResult::error(&format!("Unable to decode JWS claims: {err}")),
);
}
};
Expand All @@ -801,16 +801,15 @@ impl Credential {
return (
None,
VerificationResult::error(&format!(
"Unable to convert JWT claims to VC: {}",
err
"Unable to convert JWT claims to VC: {err}"
)),
);
}
};
if let Err(err) = vc.validate_unsigned() {
return (
None,
VerificationResult::error(&format!("Invalid VC: {}", err)),
VerificationResult::error(&format!("Invalid VC: {err}")),
);
}
// TODO: error if any unconvertable claims
Expand All @@ -823,7 +822,7 @@ impl Credential {
Err(err) => {
return (
None,
VerificationResult::error(&format!("Unable to filter proofs: {}", err)),
VerificationResult::error(&format!("Unable to filter proofs: {err}")),
);
}
};
Expand All @@ -838,7 +837,7 @@ impl Credential {
Err(err) => {
return (
None,
VerificationResult::error(&format!("Unable to resolve key for JWS: {}", err)),
VerificationResult::error(&format!("Unable to resolve key for JWS: {err}")),
);
}
};
Expand All @@ -852,7 +851,7 @@ impl Credential {
}
Err(err) => results
.errors
.push(format!("Unable to verify signature: {}", err)),
.push(format!("Unable to verify signature: {err}")),
}
return (Some(vc), results);
}
Expand Down Expand Up @@ -995,7 +994,7 @@ impl Credential {
let (proofs, _) = match self.filter_proofs(options, None, resolver).await {
Ok(proofs) => proofs,
Err(err) => {
return VerificationResult::error(&format!("Unable to filter proofs: {}", err));
return VerificationResult::error(&format!("Unable to filter proofs: {err}"));
}
};
if proofs.is_empty() {
Expand Down Expand Up @@ -1070,18 +1069,14 @@ impl Credential {
Ok(status) => status,
Err(e) => {
return VerificationResult::error(&format!(
"Unable to convert credentialStatus: {}",
e
"Unable to convert credentialStatus: {e}"
))
}
};
let checkable_status: CheckableStatus = match serde_json::from_value(status_value) {
Ok(checkable_status) => checkable_status,
Err(e) => {
return VerificationResult::error(&format!(
"Unable to parse credentialStatus: {}",
e
))
return VerificationResult::error(&format!("Unable to parse credentialStatus: {e}"))
}
};
let mut result = checkable_status.check(self, resolver, context_loader).await;
Expand Down Expand Up @@ -1322,7 +1317,7 @@ impl Presentation {
Err(err) => {
return (
None,
VerificationResult::error(&format!("Unable to split JWS: {}", err)),
VerificationResult::error(&format!("Unable to split JWS: {err}")),
);
}
};
Expand All @@ -1336,7 +1331,7 @@ impl Presentation {
Err(err) => {
return (
None,
VerificationResult::error(&format!("Unable to decode JWS: {}", err)),
VerificationResult::error(&format!("Unable to decode JWS: {err}")),
);
}
};
Expand All @@ -1345,7 +1340,7 @@ impl Presentation {
Err(err) => {
return (
None,
VerificationResult::error(&format!("Unable to decode JWS claims: {}", err)),
VerificationResult::error(&format!("Unable to decode JWS claims: {err}")),
);
}
};
Expand All @@ -1355,16 +1350,15 @@ impl Presentation {
return (
None,
VerificationResult::error(&format!(
"Unable to convert JWT claims to VP: {}",
err
"Unable to convert JWT claims to VP: {err}"
)),
);
}
};
if let Err(err) = vp.validate_unsigned() {
return (
None,
VerificationResult::error(&format!("Invalid VP: {}", err)),
VerificationResult::error(&format!("Invalid VP: {err}")),
);
}
let mut results = VerificationResult::new();
Expand All @@ -1378,7 +1372,7 @@ impl Presentation {
Err(err) => {
return (
None,
VerificationResult::error(&format!("Unable to filter proofs: {}", err)),
VerificationResult::error(&format!("Unable to filter proofs: {err}")),
);
}
};
Expand All @@ -1393,7 +1387,7 @@ impl Presentation {
Err(err) => {
return (
None,
VerificationResult::error(&format!("Unable to resolve key for JWS: {}", err)),
VerificationResult::error(&format!("Unable to resolve key for JWS: {err}")),
);
}
};
Expand All @@ -1406,7 +1400,7 @@ impl Presentation {
}
Err(err) => results
.errors
.push(format!("Unable to filter proofs: {}", err)),
.push(format!("Unable to filter proofs: {err}")),
}
return (Some(vp), results);
}
Expand Down Expand Up @@ -1583,7 +1577,7 @@ impl Presentation {
let (proofs, _) = match self.filter_proofs(options, None, resolver).await {
Ok(proofs) => proofs,
Err(err) => {
return VerificationResult::error(&format!("Unable to filter proofs: {}", err));
return VerificationResult::error(&format!("Unable to filter proofs: {err}"));
}
};
if proofs.is_empty() {
Expand Down
Loading

0 comments on commit cc9d222

Please sign in to comment.