Server overhaul: clear clippy::pedantic wins

Taken from a -W clippy::pedantic scan, no allow added: map_or/map_or_else, method references instead of closures,
clone_from, write! instead of push_str(format!), borrowed Option<&str>, push_of without a needless Option, the
envelope's entity moved instead of cloned, the scheduler's plan() no longer a needless async fn (its doc now says
what it does on failure), sort_unstable, digit separators and inline format args in tests. Not taken: missing
# Errors/# Panics docs, must_use, doc backticks, assert!(x.is_empty()) in tests, too_many_lines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TQd3pEP9UeN2uifbHknQ7B
This commit is contained in:
2026-10-18 22:33:31 +02:00
parent 8cb42f85a9
commit c942d73c66
18 changed files with 56 additions and 43 deletions
@@ -301,7 +301,14 @@ async fn an_existing_period_is_skipped_silently_by_the_unique_index() {
let (id, _) = new_template(&app, json!({"day_of_month": 1, "start_period": "2026-11"})).await;
// Another writer already created 2026-11 (as a racing scheduler run would).
let other = app
.insert_expense(ACCOUNT_1, HOME, 1250000, ADMIN_ID, (750000, 500000), false)
.insert_expense(
ACCOUNT_1,
HOME,
1_250_000,
ADMIN_ID,
(750_000, 500_000),
false,
)
.await;
sqlx::query(
"UPDATE expenses SET recurring_template_id = ?, recurring_period = '2026-11' WHERE id = ?",
@@ -469,7 +476,10 @@ async fn archived_account_continues_and_edits_affect_only_later_expenses() {
dates(&generated(&app, id).await),
["2026-10-01", "2026-11-01"]
);
assert_eq!(expense_of(&app, id, "2026-10").await["amount_ore"], 1250000);
assert_eq!(
expense_of(&app, id, "2026-10").await["amount_ore"],
1_250_000
);
let november = expense_of(&app, id, "2026-11").await;
assert_eq!(november["amount_ore"], 2000);
assert_eq!(november["account_id"], ACCOUNT_1);
@@ -81,7 +81,7 @@ async fn logs_hold_no_personal_content() {
"/recurring-templates",
&admin_token(),
Some(template_body(json!({
"description": "Hemligbeskrivning", "notes": "Hemliganteckning", "amount_ore": 987654,
"description": "Hemligbeskrivning", "notes": "Hemliganteckning", "amount_ore": 987_654,
"day_of_month": 1, "start_period": "2026-09"
}))),
)
@@ -80,7 +80,7 @@ async fn unknown_tokens_count_against_the_ip_but_known_devices_keep_working() {
200
);
for i in 0..60 {
let tok = format!("kvt_{:0>43}", i);
let tok = format!("kvt_{i:0>43}");
let reply = app.send(from("192.0.2.1:1", None, "/me", Some(&tok))).await;
assert_error(&reply, 401, "unauthorized");
}
@@ -206,7 +206,7 @@ fn canon(value: &Value, names: bool) -> Value {
Some(Value::Array(inner))
if alternative.as_object().is_some_and(|o| o.len() == 1) =>
{
flat.extend(inner.iter().cloned())
flat.extend(inner.iter().cloned());
}
_ => flat.push(alternative),
}
@@ -383,7 +383,7 @@ fn generated_document_equals_contract() {
paths
.values()
.filter_map(Value::as_object)
.map(|m| m.len())
.map(serde_json::Map::len)
.sum::<usize>()
})
.unwrap_or(0);
@@ -104,7 +104,6 @@ fn every_example_round_trips() {
checked += 1;
} else if dir_name == "push" {
// FCM payloads (SPEC §14.6) are built by the push sender, not by a wire type of this crate.
continue;
} else if check(&name, &example) {
checked += 1;
} else {
@@ -44,7 +44,7 @@ async fn generation_writes_recurring_audit_with_server_now_and_no_device() {
assert_eq!((a.client_at.as_str(), a.server_at.as_str()), (NOW, NOW));
assert_eq!(
a.changes[3],
json!({"field": "amount_ore", "old": null, "new": 1250000})
json!({"field": "amount_ore", "old": null, "new": 1_250_000})
);
// The entry reaches the phones through pull.
let page = pull(&app, &admin_token(), 0, None).await.json;
@@ -28,7 +28,7 @@ fn versions(page: &Value) -> Vec<i64> {
.map(|r| r["server_version"].as_i64().unwrap())
})
.collect();
all.sort();
all.sort_unstable();
all
}
@@ -99,7 +99,7 @@ async fn the_first_page_has_everything_in_version_order_with_the_epoch_and_serve
.map(|r| r["server_version"].as_i64().unwrap())
.collect();
let mut sorted = v.clone();
sorted.sort();
sorted.sort_unstable();
assert_eq!(v, sorted, "{a} sorted by server_version");
}
// Children come with the parent.