fix: resolve fmt and clippy violations

This commit is contained in:
DanConwayDev
2026-06-19 11:36:11 +00:00
parent 493e3f2668
commit 3ee160e855
6 changed files with 13 additions and 23 deletions
+4 -15
View File
@@ -188,10 +188,8 @@ fn clone_url_prs_identifier_for_relay(
// Scheme: http or https only, case-insensitive.
let rest = if let Some(r) = strip_prefix_ignore_ascii_case(url, "http://") {
r
} else if let Some(r) = strip_prefix_ignore_ascii_case(url, "https://") {
r
} else {
return None;
strip_prefix_ignore_ascii_case(url, "https://")?
};
// Reject query strings and fragments outright.
@@ -200,10 +198,7 @@ fn clone_url_prs_identifier_for_relay(
}
// Split authority and path on the first `/`.
let slash_idx = match rest.find('/') {
Some(i) => i,
None => return None,
};
let slash_idx = rest.find('/')?;
let authority = &rest[..slash_idx];
let path = &rest[slash_idx..]; // includes leading `/`.
@@ -213,10 +208,7 @@ fn clone_url_prs_identifier_for_relay(
let path = path.trim_end_matches('/');
let inner = match path.strip_prefix(&format!("/{}/", PRS_URL_PREFIX)) {
Some(s) => s,
None => return None,
};
let inner = path.strip_prefix(&format!("/{}/", PRS_URL_PREFIX))?;
// Exactly two segments: `<npub>` and `<repo>.git`.
let segments: Vec<&str> = inner.split('/').collect();
@@ -237,10 +229,7 @@ fn clone_url_prs_identifier_for_relay(
return None;
}
let d_encoded = match repo_segment.strip_suffix(".git") {
Some(s) => s,
None => return None,
};
let d_encoded = repo_segment.strip_suffix(".git")?;
if d_encoded.is_empty() {
return None;
}
+1
View File
@@ -98,6 +98,7 @@ impl std::fmt::Debug for Nip34WritePolicy {
}
impl Nip34WritePolicy {
#[allow(clippy::too_many_arguments)]
pub fn new(
database: SharedDatabase,
tombstones: crate::nostr::tombstones::Tombstones,
+1 -1
View File
@@ -166,7 +166,7 @@ impl ReplaceableHistoryStore {
.into_iter()
.filter_map(|metadata| {
let superseded_at = parse_timestamp_tag(&metadata, HISTORY_SUPERSEDED_AT_TAG)
.or_else(|| Some(metadata.created_at));
.or(Some(metadata.created_at));
if superseded_at.is_some_and(|ts| ts > before_or_at) {
return None;
}
+1 -4
View File
@@ -295,10 +295,7 @@ impl DeletionPolicy {
Self::a_tag_coordinates(event)
.into_iter()
.filter_map(|coordinate| {
let Some((kind, coord_pubkey, identifier)) = Self::parse_coordinate(&coordinate)
else {
return None;
};
let (kind, coord_pubkey, identifier) = Self::parse_coordinate(&coordinate)?;
if kind == Kind::RepoState && coord_pubkey == event.pubkey {
Some(identifier)
+1
View File
@@ -84,6 +84,7 @@ pub struct PolicyContext {
}
impl PolicyContext {
#[allow(clippy::too_many_arguments)]
pub fn new(
domain: impl Into<String>,
database: SharedDatabase,
+5 -3
View File
@@ -538,9 +538,11 @@ async fn purgatory_promotion_recovery_respects_state_tombstones() {
#[tokio::test]
async fn purgatory_promotion_tombstoned_pr_events_do_not_restore_pr_refs() {
let fixture =
setup_parked_announcement_with_failed_ingest_recovery("promotion-recovery-pr-tombstones", false)
.await;
let fixture = setup_parked_announcement_with_failed_ingest_recovery(
"promotion-recovery-pr-tombstones",
false,
)
.await;
fixture
.client