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:
+55
-14
@@ -29,17 +29,17 @@ use std::collections::BTreeMap;
|
||||
|
||||
use bevy_ecs::prelude::*;
|
||||
|
||||
use crate::knowledge::graph::KnowledgeGraph;
|
||||
use crate::knowledge::types::{FactId, KnowledgeConfidence, StableId};
|
||||
use crate::npc::awareness::PlayerAwareness;
|
||||
use crate::npc::mood::MoodState;
|
||||
use crate::npc::vision::{NpcMemory, NpcVisionState};
|
||||
use crate::npc::{
|
||||
CombatCapability, CombatStyle, Contentment, DailyRoutine, InformationInventory, JobPerformance,
|
||||
KnownFact, Npc, PersonalityTrait, PersonalityTraits, Relationship, RelationshipKind,
|
||||
Relationships, RoutineEntry, Secret, SecretSeverity, Skill, SkillSet, Tell, TellSystem,
|
||||
TellTrigger, ToleranceThreshold, Want, WantKind, MAX_KEY_RELATIONSHIPS,
|
||||
};
|
||||
use crate::knowledge::graph::KnowledgeGraph;
|
||||
use crate::npc::mood::MoodState;
|
||||
use crate::npc::awareness::PlayerAwareness;
|
||||
use crate::npc::vision::{NpcMemory, NpcVisionState};
|
||||
use crate::simulation::movement::TilePosition;
|
||||
use crate::simulation::rng::SimRng;
|
||||
use crate::simulation::tier::ActiveSim;
|
||||
@@ -116,15 +116,30 @@ fn pick_secret_severity(idx: usize) -> SecretSeverity {
|
||||
|
||||
fn pick_relationship_kind(idx: usize) -> RelationshipKind {
|
||||
use RelationshipKind::*;
|
||||
const VARIANTS: [RelationshipKind; 7] =
|
||||
[Colleague, Friend, Rival, Romantic, Family, Superior, Subordinate];
|
||||
const VARIANTS: [RelationshipKind; 7] = [
|
||||
Colleague,
|
||||
Friend,
|
||||
Rival,
|
||||
Romantic,
|
||||
Family,
|
||||
Superior,
|
||||
Subordinate,
|
||||
];
|
||||
VARIANTS[idx % VARIANTS.len()]
|
||||
}
|
||||
|
||||
fn pick_personality_trait(idx: usize) -> PersonalityTrait {
|
||||
use PersonalityTrait::*;
|
||||
const VARIANTS: [PersonalityTrait; 10] = [
|
||||
Cautious, Bold, Honest, Deceptive, Compassionate, Ruthless, Curious, Incurious, Social,
|
||||
Cautious,
|
||||
Bold,
|
||||
Honest,
|
||||
Deceptive,
|
||||
Compassionate,
|
||||
Ruthless,
|
||||
Curious,
|
||||
Incurious,
|
||||
Social,
|
||||
Reclusive,
|
||||
];
|
||||
VARIANTS[idx % VARIANTS.len()]
|
||||
@@ -132,8 +147,16 @@ fn pick_personality_trait(idx: usize) -> PersonalityTrait {
|
||||
|
||||
fn pick_skill(idx: usize) -> Skill {
|
||||
use Skill::*;
|
||||
const VARIANTS: [Skill; 8] =
|
||||
[Combat, Intimidation, Medical, Observation, Persuasion, Piloting, Stealth, Technical];
|
||||
const VARIANTS: [Skill; 8] = [
|
||||
Combat,
|
||||
Intimidation,
|
||||
Medical,
|
||||
Observation,
|
||||
Persuasion,
|
||||
Piloting,
|
||||
Stealth,
|
||||
Technical,
|
||||
];
|
||||
VARIANTS[idx % VARIANTS.len()]
|
||||
}
|
||||
|
||||
@@ -257,7 +280,14 @@ fn gen_routine(rng: &mut SimRng, location_pool: &[(DayPhase, TilePosition)]) ->
|
||||
.iter()
|
||||
.map(|&i| {
|
||||
let (phase, location) = available[i];
|
||||
let activity_names = ["Work", "Patrol", "Rest", "Meeting", "Training", "Maintenance"];
|
||||
let activity_names = [
|
||||
"Work",
|
||||
"Patrol",
|
||||
"Rest",
|
||||
"Meeting",
|
||||
"Training",
|
||||
"Maintenance",
|
||||
];
|
||||
let act_idx = rng.rng.random_range(0..activity_names.len());
|
||||
RoutineEntry {
|
||||
phase,
|
||||
@@ -391,7 +421,9 @@ fn gen_skills(rng: &mut SimRng, role: &RoleDefinition) -> (SkillSet, Option<Comb
|
||||
extra_attempts += 1;
|
||||
let idx = rng.rng.random_range(0..8_usize);
|
||||
let skill = pick_skill(idx);
|
||||
skills.entry(skill).or_insert_with(|| rng.rng.random_range(2_u8..=5));
|
||||
skills
|
||||
.entry(skill)
|
||||
.or_insert_with(|| rng.rng.random_range(2_u8..=5));
|
||||
}
|
||||
|
||||
let combat_trained = role.combat_enabled && rng.rng.random_range(0..3_u32) < 2;
|
||||
@@ -560,7 +592,10 @@ mod tests {
|
||||
|
||||
let entity = generate_npc(&role, &mut world, &mut rng);
|
||||
|
||||
assert!(world.get_entity(entity).is_ok(), "spawned entity must exist");
|
||||
assert!(
|
||||
world.get_entity(entity).is_ok(),
|
||||
"spawned entity must exist"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -602,7 +637,10 @@ mod tests {
|
||||
world.get::<TellSystem>(entity).is_some(),
|
||||
"must have TellSystem"
|
||||
);
|
||||
assert!(world.get::<SkillSet>(entity).is_some(), "must have SkillSet");
|
||||
assert!(
|
||||
world.get::<SkillSet>(entity).is_some(),
|
||||
"must have SkillSet"
|
||||
);
|
||||
assert!(
|
||||
world.get::<MoodState>(entity).is_some(),
|
||||
"must have MoodState"
|
||||
@@ -629,7 +667,10 @@ mod tests {
|
||||
let want_a = world_a.get::<Want>(ea).unwrap();
|
||||
let want_b = world_b.get::<Want>(eb).unwrap();
|
||||
assert_eq!(want_a.primary, want_b.primary, "Want.primary must match");
|
||||
assert_eq!(want_a.intensity, want_b.intensity, "Want.intensity must match");
|
||||
assert_eq!(
|
||||
want_a.intensity, want_b.intensity,
|
||||
"Want.intensity must match"
|
||||
);
|
||||
|
||||
let tol_a = world_a.get::<ToleranceThreshold>(ea).unwrap();
|
||||
let tol_b = world_b.get::<ToleranceThreshold>(eb).unwrap();
|
||||
|
||||
Reference in New Issue
Block a user