From 7610a16a0bbebaaa4a4d6b9bc09b20ef6ab79455 Mon Sep 17 00:00:00 2001 From: MechaCat02 Date: Sat, 6 Jun 2026 18:03:51 +0200 Subject: [PATCH] chore(v1.1.8): clippy --all-targets clean (F2) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 -> 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) --- crates/executor-core/src/sdk/users.rs | 44 +++++-------------- .../tests/module_redaction_logging.rs | 1 + crates/executor-core/tests/modules.rs | 1 + crates/executor-core/tests/sdk_docs.rs | 1 + crates/executor-core/tests/sdk_email.rs | 1 + crates/executor-core/tests/sdk_files.rs | 1 + crates/executor-core/tests/sdk_http.rs | 1 + crates/executor-core/tests/sdk_kv.rs | 1 + crates/executor-core/tests/sdk_pubsub.rs | 1 + crates/executor-core/tests/sdk_secrets.rs | 1 + .../tests/sdk_subscriber_token.rs | 1 + .../src/app_user_password_reset_repo.rs | 12 ++--- crates/manager-core/src/app_user_repo.rs | 2 +- crates/manager-core/src/users_service.rs | 19 +++----- 14 files changed, 36 insertions(+), 51 deletions(-) diff --git a/crates/executor-core/src/sdk/users.rs b/crates/executor-core/src/sdk/users.rs index c35d8c3..dfe4084 100644 --- a/crates/executor-core/src/sdk/users.rs +++ b/crates/executor-core/src/sdk/users.rs @@ -117,9 +117,7 @@ fn bind_get(module: &mut Module, svc: &Arc, cx: &Arc, 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, cx: &Arc = 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, cx: &Arc, 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, cx: &Arc let cx = cx.clone(); let accept_opt: Option = 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, cx: &Arc let accept_opt: Option = 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 } diff --git a/crates/executor-core/tests/module_redaction_logging.rs b/crates/executor-core/tests/module_redaction_logging.rs index 8806871..4330b93 100644 --- a/crates/executor-core/tests/module_redaction_logging.rs +++ b/crates/executor-core/tests/module_redaction_logging.rs @@ -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); diff --git a/crates/executor-core/tests/modules.rs b/crates/executor-core/tests/modules.rs index 7217c9d..9f63847 100644 --- a/crates/executor-core/tests/modules.rs +++ b/crates/executor-core/tests/modules.rs @@ -101,6 +101,7 @@ fn services_with(modules: Arc) -> Services { Arc::new(picloud_shared::NoopPubsubService), Arc::new(picloud_shared::NoopSecretsService), Arc::new(picloud_shared::NoopEmailService), + Arc::new(picloud_shared::NoopUsersService), ) } diff --git a/crates/executor-core/tests/sdk_docs.rs b/crates/executor-core/tests/sdk_docs.rs index 9abf55e..87d8553 100644 --- a/crates/executor-core/tests/sdk_docs.rs +++ b/crates/executor-core/tests/sdk_docs.rs @@ -232,6 +232,7 @@ fn make_engine() -> Arc { 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)) } diff --git a/crates/executor-core/tests/sdk_email.rs b/crates/executor-core/tests/sdk_email.rs index 8f2b64c..99d4c67 100644 --- a/crates/executor-core/tests/sdk_email.rs +++ b/crates/executor-core/tests/sdk_email.rs @@ -41,6 +41,7 @@ fn engine_with(rec: Arc) -> Arc { Arc::new(picloud_shared::NoopPubsubService), Arc::new(picloud_shared::NoopSecretsService), rec, + Arc::new(picloud_shared::NoopUsersService), ); Arc::new(Engine::new(Limits::default(), services)) } diff --git a/crates/executor-core/tests/sdk_files.rs b/crates/executor-core/tests/sdk_files.rs index 8247a34..61fce83 100644 --- a/crates/executor-core/tests/sdk_files.rs +++ b/crates/executor-core/tests/sdk_files.rs @@ -169,6 +169,7 @@ fn make_engine() -> Arc { 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)) } diff --git a/crates/executor-core/tests/sdk_http.rs b/crates/executor-core/tests/sdk_http.rs index 26b7025..9f944a6 100644 --- a/crates/executor-core/tests/sdk_http.rs +++ b/crates/executor-core/tests/sdk_http.rs @@ -92,6 +92,7 @@ fn engine_with(http: Arc) -> Arc { 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)) } diff --git a/crates/executor-core/tests/sdk_kv.rs b/crates/executor-core/tests/sdk_kv.rs index c3ce92a..dfc1a33 100644 --- a/crates/executor-core/tests/sdk_kv.rs +++ b/crates/executor-core/tests/sdk_kv.rs @@ -111,6 +111,7 @@ fn make_engine() -> Arc { 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)) } diff --git a/crates/executor-core/tests/sdk_pubsub.rs b/crates/executor-core/tests/sdk_pubsub.rs index e3acf5a..628a9e0 100644 --- a/crates/executor-core/tests/sdk_pubsub.rs +++ b/crates/executor-core/tests/sdk_pubsub.rs @@ -49,6 +49,7 @@ fn make_engine(svc: Arc) -> Arc { svc, Arc::new(picloud_shared::NoopSecretsService), Arc::new(picloud_shared::NoopEmailService), + Arc::new(picloud_shared::NoopUsersService), ); Arc::new(Engine::new(Limits::default(), services)) } diff --git a/crates/executor-core/tests/sdk_secrets.rs b/crates/executor-core/tests/sdk_secrets.rs index 787fa33..53c70ce 100644 --- a/crates/executor-core/tests/sdk_secrets.rs +++ b/crates/executor-core/tests/sdk_secrets.rs @@ -102,6 +102,7 @@ fn make_engine() -> Arc { 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)) } diff --git a/crates/executor-core/tests/sdk_subscriber_token.rs b/crates/executor-core/tests/sdk_subscriber_token.rs index 49dad49..f365cc1 100644 --- a/crates/executor-core/tests/sdk_subscriber_token.rs +++ b/crates/executor-core/tests/sdk_subscriber_token.rs @@ -96,6 +96,7 @@ fn make_engine() -> Arc { 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)) } diff --git a/crates/manager-core/src/app_user_password_reset_repo.rs b/crates/manager-core/src/app_user_password_reset_repo.rs index 676dfc6..997327a 100644 --- a/crates/manager-core/src/app_user_password_reset_repo.rs +++ b/crates/manager-core/src/app_user_password_reset_repo.rs @@ -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}; diff --git a/crates/manager-core/src/app_user_repo.rs b/crates/manager-core/src/app_user_repo.rs index 45fba24..23d8c97 100644 --- a/crates/manager-core/src/app_user_repo.rs +++ b/crates/manager-core/src/app_user_repo.rs @@ -225,7 +225,7 @@ impl AppUserRepository for PostgresAppUserRepository { }; let mut items: Vec = 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 { diff --git a/crates/manager-core/src/users_service.rs b/crates/manager-core/src/users_service.rs index 191075b..e2e5213 100644 --- a/crates/manager-core/src/users_service.rs +++ b/crates/manager-core/src/users_service.rs @@ -109,16 +109,14 @@ fn env_duration_hours(var: &str, default: Duration) -> Duration { std::env::var(var) .ok() .and_then(|s| s.parse::().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::().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(_) => { - // 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 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