fix(simulation): Clippy cleanup and CI enforcement (#635)

Fix all Clippy warnings across the server codebase (2411 insertions, 1341
deletions). Raise type-complexity-threshold to 750 and too-many-arguments
to 12 in .clippy.toml for idiomatic Bevy ECS system signatures. The server
now passes `cargo clippy -- --deny warnings` cleanly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-17 10:33:15 +01:00
co-authored by Claude Opus 4.6
parent 7f7706442a
commit aa79dd97e7
84 changed files with 2409 additions and 1339 deletions
+42 -30
View File
@@ -352,7 +352,9 @@ pub fn run_npc_conversations(
}
// Start conversation
let duration = rng.rng.random_range(MIN_DURATION_TICKS..=MAX_DURATION_TICKS);
let duration = rng
.rng
.random_range(MIN_DURATION_TICKS..=MAX_DURATION_TICKS);
commands.entity(entity_a).insert(NpcConversation {
partner: entity_b,
started_tick: time.tick,
@@ -422,12 +424,15 @@ pub fn run_npc_conversations(
}
// Check termination: partner moved away or no longer ActiveSim
let partner_ok = npc_query.get(conv.partner).ok().map(|(_, pos, _, _, _, _, _, _)| {
speaker_pos
.manhattan_distance(pos)
.map(|d| d <= CONVERSATION_PROXIMITY)
.unwrap_or(false)
});
let partner_ok = npc_query
.get(conv.partner)
.ok()
.map(|(_, pos, _, _, _, _, _, _)| {
speaker_pos
.manhattan_distance(pos)
.map(|d| d <= CONVERSATION_PROXIMITY)
.unwrap_or(false)
});
if partner_ok != Some(true) {
terminate_conversation(
@@ -497,8 +502,7 @@ pub fn run_npc_conversations(
// (D-071) wires in. Function signature already accepts the value.
let ambient_noise_pct = 0u32;
let drop_pct =
compute_drop_probability(distance, ambient_noise_pct, listening);
let drop_pct = compute_drop_probability(distance, ambient_noise_pct, listening);
let occluded = occlude_line(line_text, drop_pct, &mut rng.rng);
if let (Some(s_sid), Some(t_sid)) = (speaker_sid, target_sid) {
@@ -509,11 +513,13 @@ pub fn run_npc_conversations(
.map(|e| e.known_attributes.contains_key("name"))
.unwrap_or(false);
if known {
speaker_name.clone().unwrap_or_else(|| "Unknown".to_string())
speaker_name
.clone()
.unwrap_or_else(|| "Unknown".to_string())
} else {
speaker_role
.as_deref()
.map(|r| display_label_for_role(r))
.map(display_label_for_role)
.unwrap_or_else(|| "Bystander".to_string())
}
};
@@ -525,11 +531,13 @@ pub fn run_npc_conversations(
.map(|e| e.known_attributes.contains_key("name"))
.unwrap_or(false);
if known {
partner_real_name.clone().unwrap_or_else(|| "Unknown".to_string())
partner_real_name
.clone()
.unwrap_or_else(|| "Unknown".to_string())
} else {
partner_role
.as_deref()
.map(|r| display_label_for_role(r))
.map(display_label_for_role)
.unwrap_or_else(|| "Bystander".to_string())
}
};
@@ -607,11 +615,7 @@ fn terminate_conversation(
}
}
tracing::debug!(
"NPC conversation ended: {:?} ↔ {:?}",
speaker,
partner,
);
tracing::debug!("NPC conversation ended: {:?} ↔ {:?}", speaker, partner,);
}
// ---------------------------------------------------------------------------
@@ -654,7 +658,10 @@ mod tests {
let without_focus = compute_drop_probability(2, 0, false);
let with_focus = compute_drop_probability(2, 0, true);
assert!(with_focus < without_focus, "focus should reduce drop probability");
assert!(
with_focus < without_focus,
"focus should reduce drop probability"
);
assert_eq!(without_focus, 25); // 2 * 100 / 8 = 25
assert_eq!(with_focus, 5); // 25 - 20 = 5
}
@@ -1281,13 +1288,11 @@ mod tests {
assert_eq!(buffer.events.len(), 1);
// No "name" attribute → falls back to role label
assert_eq!(
buffer.events[0].speaker_name,
"Dock Worker",
buffer.events[0].speaker_name, "Dock Worker",
"speaker with no KG name attribute should show role label"
);
assert_eq!(
buffer.events[0].target_name,
"Courier",
buffer.events[0].target_name, "Courier",
"target with no KG name attribute should show role label"
);
}
@@ -1368,13 +1373,11 @@ mod tests {
assert_eq!(buffer.events.len(), 1);
// "name" attribute present → use NpcName.0
assert_eq!(
buffer.events[0].speaker_name,
"Alice",
buffer.events[0].speaker_name, "Alice",
"speaker with KG name attribute should show real name"
);
assert_eq!(
buffer.events[0].target_name,
"Bob",
buffer.events[0].target_name, "Bob",
"target with KG name attribute should show real name"
);
}
@@ -1403,11 +1406,17 @@ mod tests {
let taken = buffer.take_events();
assert_eq!(taken.len(), 2, "take_events should return all events");
assert!(buffer.events.is_empty(), "Buffer should be empty after take_events");
assert!(
buffer.events.is_empty(),
"Buffer should be empty after take_events"
);
// Second call returns empty
let taken2 = buffer.take_events();
assert!(taken2.is_empty(), "Second take_events call should return empty vec");
assert!(
taken2.is_empty(),
"Second take_events call should return empty vec"
);
}
#[test]
@@ -1420,7 +1429,10 @@ mod tests {
let taken = buffer.take_ended();
assert_eq!(taken.len(), 1, "take_ended should return all end events");
assert!(buffer.ended.is_empty(), "ended buffer should be empty after take_ended");
assert!(
buffer.ended.is_empty(),
"ended buffer should be empty after take_ended"
);
// Second call returns empty
assert!(buffer.take_ended().is_empty());