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
+68 -24
View File
@@ -16,11 +16,11 @@
use bevy_ecs::prelude::*;
use crate::npc::mood::{MoodState, NpcMood};
use crate::npc::routine::ActivityState;
use crate::npc::{
Contentment, DailyRoutine, JobPerformance, Npc, Relationships, ToleranceThreshold,
};
use crate::npc::mood::{MoodState, NpcMood};
use crate::npc::routine::ActivityState;
use crate::simulation::tier::BackgroundSim;
use crate::simulation::time::{SimulationTime, TICKS_PER_GAME_MINUTE};
@@ -110,7 +110,7 @@ pub fn background_tick(
>,
) {
// Fire once per game-minute (D-031: 10 ticks/minute)
if time.tick % TICKS_PER_GAME_MINUTE != 0 {
if !time.tick.is_multiple_of(TICKS_PER_GAME_MINUTE) {
return;
}
@@ -185,16 +185,16 @@ pub fn background_tick(
#[cfg(test)]
mod tests {
use super::*;
use crate::knowledge::types::StableId;
use crate::npc::mood::{MoodState, NpcMood};
use crate::npc::routine::ActivityState;
use crate::npc::{
Contentment, DailyRoutine, JobPerformance, Npc, Relationship, RelationshipKind,
Relationships, RoutineEntry, ToleranceThreshold,
};
use crate::npc::mood::{MoodState, NpcMood};
use crate::npc::routine::ActivityState;
use crate::simulation::movement::TilePosition;
use crate::simulation::tier::{ActiveSim, BackgroundSim};
use crate::simulation::time::{DayPhase, SimulationTime, TICKS_PER_GAME_MINUTE};
use crate::knowledge::types::StableId;
use bevy_ecs::world::World;
// --- derive_background_mood ---
@@ -311,7 +311,10 @@ mod tests {
Npc,
BackgroundSim,
MoodState::default(),
ToleranceThreshold { current_stress: 60, threshold: 50 },
ToleranceThreshold {
current_stress: 60,
threshold: 50,
},
))
.id();
@@ -333,7 +336,10 @@ mod tests {
Npc,
BackgroundSim,
MoodState::default(),
ToleranceThreshold { current_stress: 60, threshold: 50 },
ToleranceThreshold {
current_stress: 60,
threshold: 50,
},
))
.id();
@@ -353,7 +359,10 @@ mod tests {
Npc,
BackgroundSim,
MoodState::default(),
ToleranceThreshold { current_stress: 60, threshold: 50 },
ToleranceThreshold {
current_stress: 60,
threshold: 50,
},
))
.id();
@@ -379,14 +388,21 @@ mod tests {
mood: NpcMood::Warm,
changed_tick: 0,
},
ToleranceThreshold { current_stress: 60, threshold: 50 },
ToleranceThreshold {
current_stress: 60,
threshold: 50,
},
))
.id();
run_system(&mut world);
let mood = world.get::<MoodState>(npc).unwrap();
assert_eq!(mood.mood, NpcMood::Warm, "ActiveSim NPC must not be updated by background_tick");
assert_eq!(
mood.mood,
NpcMood::Warm,
"ActiveSim NPC must not be updated by background_tick"
);
}
// --- Mood state machine ---
@@ -401,7 +417,10 @@ mod tests {
Npc,
BackgroundSim,
MoodState::default(),
ToleranceThreshold { current_stress: 50, threshold: 50 },
ToleranceThreshold {
current_stress: 50,
threshold: 50,
},
))
.id();
@@ -416,9 +435,7 @@ mod tests {
world.resource_mut::<SimulationTime>().tick = 0;
// No ToleranceThreshold → defaults (0, 50) → Content (0 < 20)
let npc = world
.spawn((Npc, BackgroundSim, MoodState::default()))
.id();
let npc = world.spawn((Npc, BackgroundSim, MoodState::default())).id();
run_system(&mut world);
@@ -434,8 +451,14 @@ mod tests {
.spawn((
Npc,
BackgroundSim,
MoodState { mood: NpcMood::Warm, changed_tick: 0 },
ToleranceThreshold { current_stress: 55, threshold: 50 },
MoodState {
mood: NpcMood::Warm,
changed_tick: 0,
},
ToleranceThreshold {
current_stress: 55,
threshold: 50,
},
))
.id();
@@ -456,7 +479,10 @@ mod tests {
.spawn((
Npc,
BackgroundSim,
MoodState { mood: NpcMood::Content, changed_tick: 42 },
MoodState {
mood: NpcMood::Content,
changed_tick: 42,
},
))
.id();
@@ -464,7 +490,10 @@ mod tests {
let mood = world.get::<MoodState>(npc).unwrap();
assert_eq!(mood.mood, NpcMood::Content);
assert_eq!(mood.changed_tick, 42, "changed_tick must not update when mood unchanged");
assert_eq!(
mood.changed_tick, 42,
"changed_tick must not update when mood unchanged"
);
}
// --- Schedule state machine ---
@@ -564,7 +593,10 @@ mod tests {
run_system(&mut world);
let rels = world.get::<Relationships>(npc).unwrap();
assert_eq!(rels.entries[0].trust_level, 4, "positive trust decrements by 1");
assert_eq!(
rels.entries[0].trust_level, 4,
"positive trust decrements by 1"
);
}
#[test]
@@ -591,7 +623,10 @@ mod tests {
run_system(&mut world);
let rels = world.get::<Relationships>(npc).unwrap();
assert_eq!(rels.entries[0].trust_level, -3, "negative trust increments by 1");
assert_eq!(
rels.entries[0].trust_level, -3,
"negative trust increments by 1"
);
}
#[test]
@@ -709,7 +744,10 @@ mod tests {
Npc,
BackgroundSim,
MoodState::default(),
ToleranceThreshold { current_stress: 5, threshold: 50 },
ToleranceThreshold {
current_stress: 5,
threshold: 50,
},
))
.id();
@@ -718,13 +756,19 @@ mod tests {
Npc,
BackgroundSim,
MoodState::default(),
ToleranceThreshold { current_stress: 55, threshold: 50 },
ToleranceThreshold {
current_stress: 55,
threshold: 50,
},
))
.id();
run_system(&mut world);
assert_eq!(world.get::<MoodState>(calm).unwrap().mood, NpcMood::Content);
assert_eq!(world.get::<MoodState>(hostile).unwrap().mood, NpcMood::Hostile);
assert_eq!(
world.get::<MoodState>(hostile).unwrap().mood,
NpcMood::Hostile
);
}
}