chore(v1.1.8): clippy --all-targets clean (F2)

Sweep the v1.1.8-introduced clippy warnings under
--workspace --all-targets --all-features -- -D warnings:

  * 12x map_unwrap_or in executor-core/sdk/users.rs — rewrite as
    map_or; mostly the Option<X> -> Dynamic conversion shape.
  * Doc-list-without-indentation in
    app_user_password_reset_repo.rs's module docstring — rewrap
    so a continuation line doesn't start with `+ `.
  * usize-as-i64 cast in app_user_repo.rs list — use
    i64::try_from(...).unwrap_or(i64::MAX) for the cursor cap.
  * 2x map_unwrap_or in users_service.rs env helpers — map_or.
  * single-pattern match in users_service.rs login — let-else
    rewrite so the dummy-Argon2 side-effect stays in the
    diverging branch (no semantic change).

Also updated the 10 executor-core integration-test bins
(sdk_email, sdk_kv, sdk_docs, sdk_files, sdk_pubsub,
sdk_secrets, sdk_http, sdk_subscriber_token,
module_redaction_logging, modules) to pass the new
NoopUsersService positional arg into Services::new().

NOTE — the brief specifies running this attestation under `cargo
clean` first. I skipped the clean step because an earlier
`cargo test --workspace` froze this host (the user explicitly
asked me to keep subsequent builds lighter). The incremental
cache was hot for every workspace crate when clippy ran; test
binaries appeared in the Checking output as expected. Flagged in
HANDBACK §6 F2 + §7.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
MechaCat02
2026-06-06 18:03:51 +02:00
parent 1dd28dda07
commit 7610a16a0b
14 changed files with 36 additions and 51 deletions

View File

@@ -117,9 +117,7 @@ fn bind_get(module: &mut Module, svc: &Arc<dyn UsersService>, cx: &Arc<SdkCallCx
let svc = svc.clone();
let cx = cx.clone();
let user_opt = block_on(async move { svc.get(&cx, id).await })?;
Ok(user_opt
.map(|u| Dynamic::from(user_to_map(&u)))
.unwrap_or(Dynamic::UNIT))
Ok(user_opt.map_or(Dynamic::UNIT, |u| Dynamic::from(user_to_map(&u))))
},
);
}
@@ -134,9 +132,7 @@ fn bind_find_by_email(module: &mut Module, svc: &Arc<dyn UsersService>, cx: &Arc
let svc = svc.clone();
let cx = cx.clone();
let user_opt = block_on(async move { svc.find_by_email(&cx, &email).await })?;
Ok(user_opt
.map(|u| Dynamic::from(user_to_map(&u)))
.unwrap_or(Dynamic::UNIT))
Ok(user_opt.map_or(Dynamic::UNIT, |u| Dynamic::from(user_to_map(&u))))
},
);
}
@@ -226,9 +222,7 @@ fn bind_login(module: &mut Module, svc: &Arc<dyn UsersService>, cx: &Arc<SdkCall
let cx = cx.clone();
let session_opt: Option<GeneratedSession> =
block_on(async move { svc.login(&cx, &email, &password).await })?;
Ok(session_opt
.map(|s| Dynamic::from(s.token))
.unwrap_or(Dynamic::UNIT))
Ok(session_opt.map_or(Dynamic::UNIT, |s| Dynamic::from(s.token)))
},
);
}
@@ -243,9 +237,7 @@ fn bind_verify(module: &mut Module, svc: &Arc<dyn UsersService>, cx: &Arc<SdkCal
let svc = svc.clone();
let cx = cx.clone();
let user_opt = block_on(async move { svc.verify(&cx, &token).await })?;
Ok(user_opt
.map(|u| Dynamic::from(user_to_map(&u)))
.unwrap_or(Dynamic::UNIT))
Ok(user_opt.map_or(Dynamic::UNIT, |u| Dynamic::from(user_to_map(&u))))
},
);
}
@@ -297,9 +289,7 @@ fn bind_verify_email(module: &mut Module, svc: &Arc<dyn UsersService>, cx: &Arc<
let svc = svc.clone();
let cx = cx.clone();
let user_opt = block_on(async move { svc.verify_email(&cx, &token).await })?;
Ok(user_opt
.map(|u| Dynamic::from(user_to_map(&u)))
.unwrap_or(Dynamic::UNIT))
Ok(user_opt.map_or(Dynamic::UNIT, |u| Dynamic::from(user_to_map(&u))))
},
);
}
@@ -340,9 +330,7 @@ fn bind_complete_password_reset(
let user_opt = block_on(async move {
svc.complete_password_reset(&cx, &token, &new_password).await
})?;
Ok(user_opt
.map(|u| Dynamic::from(user_to_map(&u)))
.unwrap_or(Dynamic::UNIT))
Ok(user_opt.map_or(Dynamic::UNIT, |u| Dynamic::from(user_to_map(&u))))
},
);
}
@@ -379,9 +367,7 @@ fn bind_accept_invite(module: &mut Module, svc: &Arc<dyn UsersService>, cx: &Arc
let cx = cx.clone();
let accept_opt: Option<GeneratedAccept> =
block_on(async move { svc.accept_invite(&cx, &token, &password, None).await })?;
Ok(accept_opt
.map(|a| Dynamic::from(a.session.token))
.unwrap_or(Dynamic::UNIT))
Ok(accept_opt.map_or(Dynamic::UNIT, |a| Dynamic::from(a.session.token)))
},
);
}
@@ -406,9 +392,7 @@ fn bind_accept_invite(module: &mut Module, svc: &Arc<dyn UsersService>, cx: &Arc
let accept_opt: Option<GeneratedAccept> = block_on(async move {
svc.accept_invite(&cx, &token, &password, display_name).await
})?;
Ok(accept_opt
.map(|a| Dynamic::from(a.session.token))
.unwrap_or(Dynamic::UNIT))
Ok(accept_opt.map_or(Dynamic::UNIT, |a| Dynamic::from(a.session.token)))
},
);
}
@@ -475,20 +459,17 @@ fn user_to_map(user: &AppUser) -> Map {
"display_name".into(),
user.display_name
.clone()
.map(Dynamic::from)
.unwrap_or(Dynamic::UNIT),
.map_or(Dynamic::UNIT, Dynamic::from),
);
m.insert(
"email_verified_at".into(),
user.email_verified_at
.map(|d| Dynamic::from(d.to_rfc3339()))
.unwrap_or(Dynamic::UNIT),
.map_or(Dynamic::UNIT, |d| Dynamic::from(d.to_rfc3339())),
);
m.insert(
"last_login_at".into(),
user.last_login_at
.map(|d| Dynamic::from(d.to_rfc3339()))
.unwrap_or(Dynamic::UNIT),
.map_or(Dynamic::UNIT, |d| Dynamic::from(d.to_rfc3339())),
);
m.insert("created_at".into(), Dynamic::from(user.created_at.to_rfc3339()));
m.insert("updated_at".into(), Dynamic::from(user.updated_at.to_rfc3339()));
@@ -509,8 +490,7 @@ fn list_page_to_map(page: &UsersListPage) -> Map {
m.insert(
"next_cursor".into(),
page.next_cursor
.map(|d| Dynamic::from(d.to_rfc3339()))
.unwrap_or(Dynamic::UNIT),
.map_or(Dynamic::UNIT, |d| Dynamic::from(d.to_rfc3339())),
);
m
}

View File

@@ -103,6 +103,7 @@ async fn original_backend_error_is_logged_at_error_level() {
Arc::new(picloud_shared::NoopPubsubService),
Arc::new(picloud_shared::NoopSecretsService),
Arc::new(picloud_shared::NoopEmailService),
Arc::new(picloud_shared::NoopUsersService),
);
let engine = Engine::new(Limits::default(), services);

View File

@@ -101,6 +101,7 @@ fn services_with(modules: Arc<dyn ModuleSource>) -> Services {
Arc::new(picloud_shared::NoopPubsubService),
Arc::new(picloud_shared::NoopSecretsService),
Arc::new(picloud_shared::NoopEmailService),
Arc::new(picloud_shared::NoopUsersService),
)
}

View File

@@ -232,6 +232,7 @@ fn make_engine() -> Arc<Engine> {
Arc::new(picloud_shared::NoopPubsubService),
Arc::new(picloud_shared::NoopSecretsService),
Arc::new(picloud_shared::NoopEmailService),
Arc::new(picloud_shared::NoopUsersService),
);
Arc::new(Engine::new(Limits::default(), services))
}

View File

@@ -41,6 +41,7 @@ fn engine_with(rec: Arc<RecordingEmail>) -> Arc<Engine> {
Arc::new(picloud_shared::NoopPubsubService),
Arc::new(picloud_shared::NoopSecretsService),
rec,
Arc::new(picloud_shared::NoopUsersService),
);
Arc::new(Engine::new(Limits::default(), services))
}

View File

@@ -169,6 +169,7 @@ fn make_engine() -> Arc<Engine> {
Arc::new(picloud_shared::NoopPubsubService),
Arc::new(picloud_shared::NoopSecretsService),
Arc::new(picloud_shared::NoopEmailService),
Arc::new(picloud_shared::NoopUsersService),
);
Arc::new(Engine::new(Limits::default(), services))
}

View File

@@ -92,6 +92,7 @@ fn engine_with(http: Arc<dyn HttpService>) -> Arc<Engine> {
Arc::new(picloud_shared::NoopPubsubService),
Arc::new(picloud_shared::NoopSecretsService),
Arc::new(picloud_shared::NoopEmailService),
Arc::new(picloud_shared::NoopUsersService),
);
Arc::new(Engine::new(Limits::default(), services))
}

View File

@@ -111,6 +111,7 @@ fn make_engine() -> Arc<Engine> {
Arc::new(picloud_shared::NoopPubsubService),
Arc::new(picloud_shared::NoopSecretsService),
Arc::new(picloud_shared::NoopEmailService),
Arc::new(picloud_shared::NoopUsersService),
);
Arc::new(Engine::new(Limits::default(), services))
}

View File

@@ -49,6 +49,7 @@ fn make_engine(svc: Arc<RecordingPubsub>) -> Arc<Engine> {
svc,
Arc::new(picloud_shared::NoopSecretsService),
Arc::new(picloud_shared::NoopEmailService),
Arc::new(picloud_shared::NoopUsersService),
);
Arc::new(Engine::new(Limits::default(), services))
}

View File

@@ -102,6 +102,7 @@ fn make_engine() -> Arc<Engine> {
Arc::new(picloud_shared::NoopPubsubService),
Arc::new(InMemorySecrets::default()),
Arc::new(picloud_shared::NoopEmailService),
Arc::new(picloud_shared::NoopUsersService),
);
Arc::new(Engine::new(Limits::default(), services))
}

View File

@@ -96,6 +96,7 @@ fn make_engine() -> Arc<Engine> {
Arc::new(FakeMintPubsub),
Arc::new(picloud_shared::NoopSecretsService),
Arc::new(picloud_shared::NoopEmailService),
Arc::new(picloud_shared::NoopUsersService),
);
Arc::new(Engine::new(Limits::default(), services))
}

View File

@@ -1,11 +1,11 @@
//! CRUD over `app_user_password_resets` (v1.1.8 commit 6).
//!
//! Same shape and one-shot semantics as
//! `app_user_verification_repo`. Kept as a separate repo so the
//! distinct lifecycles (consume + revoke-sessions for reset; consume
//! + mark-email-verified for verification) stay obvious at the call
//! site. A future v1.2 cleanup may merge them behind a `kind`
//! discriminator if the duplication becomes load-bearing.
//! Same shape and one-shot semantics as `app_user_verification_repo`.
//! Kept as a separate repo so the distinct lifecycles (consume then
//! revoke-sessions for reset; consume then mark-email-verified for
//! verification) stay obvious at the call site. A future v1.2 cleanup
//! may merge them behind a `kind` discriminator if the duplication
//! becomes load-bearing.
use async_trait::async_trait;
use chrono::{DateTime, Utc};

View File

@@ -225,7 +225,7 @@ impl AppUserRepository for PostgresAppUserRepository {
};
let mut items: Vec<AppUserRow> = rows.into_iter().map(Into::into).collect();
let next_cursor = if items.len() as i64 > limit {
let next_cursor = if i64::try_from(items.len()).unwrap_or(i64::MAX) > limit {
let cursor_row = items.pop().expect("len > limit so there is a row");
Some(cursor_row.created_at)
} else {

View File

@@ -109,16 +109,14 @@ fn env_duration_hours(var: &str, default: Duration) -> Duration {
std::env::var(var)
.ok()
.and_then(|s| s.parse::<u64>().ok())
.map(|h| Duration::from_secs(h * 3600))
.unwrap_or(default)
.map_or(default, |h| Duration::from_secs(h * 3600))
}
fn env_duration_days(var: &str, default: Duration) -> Duration {
std::env::var(var)
.ok()
.and_then(|s| s.parse::<u64>().ok())
.map(|d| Duration::from_secs(d * 24 * 3600))
.unwrap_or(default)
.map_or(default, |d| Duration::from_secs(d * 24 * 3600))
}
/// Postgres-backed `UsersService`.
@@ -485,14 +483,11 @@ impl UsersService for UsersServiceImpl {
.await?;
// Both branches normalize the email so an attacker can't probe
// existence via "" / "x" / very-long-string differences.
let normalized = match validate_email(email) {
Ok(e) => e,
Err(_) => {
let Ok(normalized) = validate_email(email) else {
// Still run a dummy verify so the timing of an invalid
// email shape matches the timing of a legitimate miss.
let _ = verify_password(TIMING_FLAT_DUMMY_HASH, password);
return Ok(None);
}
};
let creds = self
.users