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
+72 -49
View File
@@ -223,9 +223,15 @@ pub fn process_examine_interaction(
// Try NPC examine path first
if let Ok((target_pos, mood_opt, tolerance_opt, traits_opt)) = npc_query.get(target) {
let distance = player_pos.manhattan_distance(target_pos).unwrap_or(u32::MAX);
let distance = player_pos
.manhattan_distance(target_pos)
.unwrap_or(u32::MAX);
if distance > CLOSE_RANGE {
tracing::info!(distance, "Examine: NPC target out of range (max {})", CLOSE_RANGE);
tracing::info!(
distance,
"Examine: NPC target out of range (max {})",
CLOSE_RANGE
);
commands.entity(player_entity).remove::<ExamineRequest>();
return;
}
@@ -243,12 +249,18 @@ pub fn process_examine_interaction(
},
});
let target_entity_id = registry.to_stable(target).map(|sid| sid.0).unwrap_or_else(|| {
tracing::warn!(?target, "Examine: NPC not in EntityRegistry, using bits");
target.to_bits()
});
let target_entity_id = registry
.to_stable(target)
.map(|sid| sid.0)
.unwrap_or_else(|| {
tracing::warn!(?target, "Examine: NPC not in EntityRegistry, using bits");
target.to_bits()
});
result_buffer.result = Some(ExamineResultEvent { text, target_entity_id });
result_buffer.result = Some(ExamineResultEvent {
text,
target_entity_id,
});
tracing::debug!(target_entity_id, "Examine: NPC result written to buffer");
commands.entity(player_entity).remove::<ExamineRequest>();
return;
@@ -256,9 +268,15 @@ pub fn process_examine_interaction(
// Object examine path: entity has a TilePosition but no NPC mood components.
if let Ok((target_pos, examine_text_opt)) = examine_text_query.get(target) {
let distance = player_pos.manhattan_distance(target_pos).unwrap_or(u32::MAX);
let distance = player_pos
.manhattan_distance(target_pos)
.unwrap_or(u32::MAX);
if distance > CLOSE_RANGE {
tracing::info!(distance, "Examine: object target out of range (max {})", CLOSE_RANGE);
tracing::info!(
distance,
"Examine: object target out of range (max {})",
CLOSE_RANGE
);
commands.entity(player_entity).remove::<ExamineRequest>();
return;
}
@@ -267,18 +285,27 @@ pub fn process_examine_interaction(
.map(|et| et.0.clone())
.unwrap_or_else(|| "No further details are apparent.".to_string());
let target_entity_id = registry.to_stable(target).map(|sid| sid.0).unwrap_or_else(|| {
tracing::warn!(?target, "Examine: object not in EntityRegistry, using bits");
target.to_bits()
});
let target_entity_id = registry
.to_stable(target)
.map(|sid| sid.0)
.unwrap_or_else(|| {
tracing::warn!(?target, "Examine: object not in EntityRegistry, using bits");
target.to_bits()
});
result_buffer.result = Some(ExamineResultEvent { text, target_entity_id });
result_buffer.result = Some(ExamineResultEvent {
text,
target_entity_id,
});
tracing::debug!(target_entity_id, "Examine: object result written to buffer");
commands.entity(player_entity).remove::<ExamineRequest>();
return;
}
tracing::warn!(?target, "process_examine_interaction: target has no position component");
tracing::warn!(
?target,
"process_examine_interaction: target has no position component"
);
commands.entity(player_entity).remove::<ExamineRequest>();
}
@@ -297,35 +324,29 @@ mod tests {
#[test]
fn smuggler_hostile_npc_gives_threat_read() {
let text = generate_examine_text(
NpcMood::Hostile,
20,
CharacterArchetype::Smuggler,
None,
let text = generate_examine_text(NpcMood::Hostile, 20, CharacterArchetype::Smuggler, None);
assert!(
text.contains("Threat posture"),
"expected threat read, got: {text}"
);
assert!(text.contains("Threat posture"), "expected threat read, got: {text}");
}
#[test]
fn smuggler_focused_npc_notes_attention() {
let text = generate_examine_text(
NpcMood::Focused,
30,
CharacterArchetype::Smuggler,
None,
let text = generate_examine_text(NpcMood::Focused, 30, CharacterArchetype::Smuggler, None);
assert!(
text.contains("close attention"),
"expected attention note, got: {text}"
);
assert!(text.contains("close attention"), "expected attention note, got: {text}");
}
#[test]
fn smuggler_high_stress_identifies_distraction() {
let text = generate_examine_text(
NpcMood::Anxious,
80,
CharacterArchetype::Smuggler,
None,
let text = generate_examine_text(NpcMood::Anxious, 80, CharacterArchetype::Smuggler, None);
assert!(
text.contains("Too distracted"),
"expected distraction read, got: {text}"
);
assert!(text.contains("Too distracted"), "expected distraction read, got: {text}");
}
#[test]
@@ -337,17 +358,15 @@ mod tests {
CharacterArchetype::Detective,
Some(&t),
);
assert!(text.contains("Controlled affect"), "expected concealment note, got: {text}");
assert!(
text.contains("Controlled affect"),
"expected concealment note, got: {text}"
);
}
#[test]
fn detective_anxious_npc_notes_stress_markers() {
let text = generate_examine_text(
NpcMood::Anxious,
50,
CharacterArchetype::Detective,
None,
);
let text = generate_examine_text(NpcMood::Anxious, 50, CharacterArchetype::Detective, None);
assert!(
text.contains("stress markers"),
"expected stress markers, got: {text}"
@@ -356,12 +375,7 @@ mod tests {
#[test]
fn detective_content_npc_notes_low_guard() {
let text = generate_examine_text(
NpcMood::Content,
10,
CharacterArchetype::Detective,
None,
);
let text = generate_examine_text(NpcMood::Content, 10, CharacterArchetype::Detective, None);
assert!(
text.contains("Less guarded"),
"expected low guard note, got: {text}"
@@ -370,19 +384,28 @@ mod tests {
#[test]
fn stress_ratio_zero_when_threshold_zero() {
let t = ToleranceThreshold { current_stress: 50, threshold: 0 };
let t = ToleranceThreshold {
current_stress: 50,
threshold: 0,
};
assert_eq!(stress_ratio(&t), 0);
}
#[test]
fn stress_ratio_clamped_at_100() {
let t = ToleranceThreshold { current_stress: 200, threshold: 100 };
let t = ToleranceThreshold {
current_stress: 200,
threshold: 100,
};
assert_eq!(stress_ratio(&t), 100);
}
#[test]
fn stress_ratio_negative_stress_is_zero() {
let t = ToleranceThreshold { current_stress: -10, threshold: 70 };
let t = ToleranceThreshold {
current_stress: -10,
threshold: 70,
};
assert_eq!(stress_ratio(&t), 0);
}