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:
@@ -7,24 +7,22 @@
|
||||
//! - DoorState persists in SaveStateV1.open_doors.
|
||||
|
||||
use bevy_ecs::{prelude::*, schedule::Schedule, world::World};
|
||||
use settled_reach_server::knowledge::KnowledgeGraph;
|
||||
use settled_reach_server::simulation::triangle::TemplateReferenceMap;
|
||||
use settled_reach_server::{
|
||||
knowledge::{registry::EntityRegistry, registry::StableEntityId, types::StableId},
|
||||
npc::relationships::RelationshipGraph,
|
||||
simulation::{
|
||||
examine::{
|
||||
process_examine_interaction, ExamineRequest, ExamineResultBuffer, ExamineText,
|
||||
},
|
||||
examine::{process_examine_interaction, ExamineRequest, ExamineResultBuffer, ExamineText},
|
||||
interaction::{
|
||||
process_door_interaction, process_terminal_interaction, DoorInteractRequest,
|
||||
DoorState, Interactable, ObjectType, TerminalInteractRequest, TerminalInteractedQueue,
|
||||
process_door_interaction, process_terminal_interaction, DoorInteractRequest, DoorState,
|
||||
Interactable, ObjectType, TerminalInteractRequest, TerminalInteractedQueue,
|
||||
},
|
||||
movement::{PlayerCharacter, TilePosition, WalkabilityMap},
|
||||
save_state::{SaveStateV1, SAVE_FORMAT_VERSION},
|
||||
time::{SimulationTime, TickRate},
|
||||
},
|
||||
};
|
||||
use settled_reach_server::knowledge::KnowledgeGraph;
|
||||
use settled_reach_server::simulation::triangle::TemplateReferenceMap;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Helpers
|
||||
@@ -39,10 +37,7 @@ fn make_world_with_walkability(width: i32, height: i32) -> World {
|
||||
|
||||
fn spawn_player(world: &mut World, x: i32, y: i32) -> Entity {
|
||||
world
|
||||
.spawn((
|
||||
PlayerCharacter,
|
||||
TilePosition::new(x, y, 0),
|
||||
))
|
||||
.spawn((PlayerCharacter, TilePosition::new(x, y, 0)))
|
||||
.id()
|
||||
}
|
||||
|
||||
@@ -85,7 +80,9 @@ fn door_toggle_flips_walkability_both_ways() {
|
||||
schedule.run(&mut world);
|
||||
|
||||
assert!(
|
||||
world.resource::<WalkabilityMap>().can_move_to(&TilePosition::new(10, 5, 0)),
|
||||
world
|
||||
.resource::<WalkabilityMap>()
|
||||
.can_move_to(&TilePosition::new(10, 5, 0)),
|
||||
"after Open: blocking tile must become walkable"
|
||||
);
|
||||
assert!(
|
||||
@@ -106,7 +103,9 @@ fn door_toggle_flips_walkability_both_ways() {
|
||||
schedule.run(&mut world);
|
||||
|
||||
assert!(
|
||||
!world.resource::<WalkabilityMap>().can_move_to(&TilePosition::new(10, 5, 0)),
|
||||
!world
|
||||
.resource::<WalkabilityMap>()
|
||||
.can_move_to(&TilePosition::new(10, 5, 0)),
|
||||
"after Close: blocking tile must be impassable again"
|
||||
);
|
||||
assert!(
|
||||
@@ -136,7 +135,9 @@ fn door_starts_open_toggle_closes_it() {
|
||||
|
||||
// Tile starts walkable (default map is all walkable)
|
||||
assert!(
|
||||
world.resource::<WalkabilityMap>().can_move_to(&TilePosition::new(10, 5, 0)),
|
||||
world
|
||||
.resource::<WalkabilityMap>()
|
||||
.can_move_to(&TilePosition::new(10, 5, 0)),
|
||||
"precondition: tile is walkable when door starts open"
|
||||
);
|
||||
|
||||
@@ -150,7 +151,9 @@ fn door_starts_open_toggle_closes_it() {
|
||||
schedule.run(&mut world);
|
||||
|
||||
assert!(
|
||||
!world.resource::<WalkabilityMap>().can_move_to(&TilePosition::new(10, 5, 0)),
|
||||
!world
|
||||
.resource::<WalkabilityMap>()
|
||||
.can_move_to(&TilePosition::new(10, 5, 0)),
|
||||
"toggling an open door must block the tile"
|
||||
);
|
||||
assert!(
|
||||
@@ -166,9 +169,9 @@ fn door_interact_without_door_state_does_not_panic() {
|
||||
let player = spawn_player(&mut world, 5, 5);
|
||||
let not_a_door = world.spawn(TilePosition::new(5, 6, 0)).id();
|
||||
|
||||
world
|
||||
.entity_mut(player)
|
||||
.insert(DoorInteractRequest { door_entity: not_a_door });
|
||||
world.entity_mut(player).insert(DoorInteractRequest {
|
||||
door_entity: not_a_door,
|
||||
});
|
||||
|
||||
let mut schedule = Schedule::default();
|
||||
schedule.add_systems(process_door_interaction);
|
||||
@@ -208,7 +211,9 @@ fn examine_readable_returns_authored_text() {
|
||||
TilePosition::new(5, 6, 0),
|
||||
Interactable,
|
||||
ObjectType::Readable,
|
||||
ExamineText("A logistics manifest. Freight records dating back three cycles.".to_string()),
|
||||
ExamineText(
|
||||
"A logistics manifest. Freight records dating back three cycles.".to_string(),
|
||||
),
|
||||
))
|
||||
.id();
|
||||
|
||||
@@ -220,10 +225,7 @@ fn examine_readable_returns_authored_text() {
|
||||
schedule.add_systems(process_examine_interaction);
|
||||
schedule.run(&mut world);
|
||||
|
||||
let event = world
|
||||
.get_mut::<ExamineResultBuffer>(player)
|
||||
.unwrap()
|
||||
.take();
|
||||
let event = world.get_mut::<ExamineResultBuffer>(player).unwrap().take();
|
||||
assert!(
|
||||
event.is_some(),
|
||||
"ExamineResultBuffer must contain a result after examining a Readable"
|
||||
@@ -274,16 +276,16 @@ fn examine_readable_without_examine_text_returns_fallback() {
|
||||
schedule.add_systems(process_examine_interaction);
|
||||
schedule.run(&mut world);
|
||||
|
||||
let event = world
|
||||
.get_mut::<ExamineResultBuffer>(player)
|
||||
.unwrap()
|
||||
.take();
|
||||
let event = world.get_mut::<ExamineResultBuffer>(player).unwrap().take();
|
||||
assert!(
|
||||
event.is_some(),
|
||||
"ExamineResultBuffer must contain a result even without ExamineText"
|
||||
);
|
||||
let text = event.unwrap().text;
|
||||
assert!(!text.is_empty(), "fallback text must be non-empty, got: '{text}'");
|
||||
assert!(
|
||||
!text.is_empty(),
|
||||
"fallback text must be non-empty, got: '{text}'"
|
||||
);
|
||||
}
|
||||
|
||||
/// Examine out of range returns no result.
|
||||
@@ -322,11 +324,11 @@ fn examine_readable_out_of_range_returns_no_result() {
|
||||
schedule.add_systems(process_examine_interaction);
|
||||
schedule.run(&mut world);
|
||||
|
||||
let event = world
|
||||
.get_mut::<ExamineResultBuffer>(player)
|
||||
.unwrap()
|
||||
.take();
|
||||
assert!(event.is_none(), "examining an out-of-range Readable must not produce a result");
|
||||
let event = world.get_mut::<ExamineResultBuffer>(player).unwrap().take();
|
||||
assert!(
|
||||
event.is_none(),
|
||||
"examining an out-of-range Readable must not produce a result"
|
||||
);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -355,19 +357,27 @@ fn terminal_use_emits_terminal_interacted_event() {
|
||||
|
||||
// Register terminal in EntityRegistry so stable ID resolves
|
||||
let terminal_sid = StableId(42);
|
||||
world.entity_mut(terminal).insert(StableEntityId(terminal_sid));
|
||||
world.resource_mut::<EntityRegistry>().register_existing(terminal, terminal_sid);
|
||||
|
||||
world
|
||||
.entity_mut(player)
|
||||
.insert(TerminalInteractRequest { terminal_entity: terminal });
|
||||
.entity_mut(terminal)
|
||||
.insert(StableEntityId(terminal_sid));
|
||||
world
|
||||
.resource_mut::<EntityRegistry>()
|
||||
.register_existing(terminal, terminal_sid);
|
||||
|
||||
world.entity_mut(player).insert(TerminalInteractRequest {
|
||||
terminal_entity: terminal,
|
||||
});
|
||||
|
||||
let mut schedule = Schedule::default();
|
||||
schedule.add_systems(process_terminal_interaction);
|
||||
schedule.run(&mut world);
|
||||
|
||||
let queue = world.resource::<TerminalInteractedQueue>();
|
||||
assert_eq!(queue.events.len(), 1, "one TerminalInteracted event must be emitted");
|
||||
assert_eq!(
|
||||
queue.events.len(),
|
||||
1,
|
||||
"one TerminalInteracted event must be emitted"
|
||||
);
|
||||
assert_eq!(
|
||||
queue.events[0].terminal_id, terminal_sid,
|
||||
"terminal_id must match the interacted terminal"
|
||||
@@ -388,9 +398,9 @@ fn terminal_interact_request_consumed_after_processing() {
|
||||
|
||||
let terminal = world.spawn(TilePosition::new(5, 6, 0)).id();
|
||||
|
||||
world
|
||||
.entity_mut(player)
|
||||
.insert(TerminalInteractRequest { terminal_entity: terminal });
|
||||
world.entity_mut(player).insert(TerminalInteractRequest {
|
||||
terminal_entity: terminal,
|
||||
});
|
||||
|
||||
let mut schedule = Schedule::default();
|
||||
schedule.add_systems(process_terminal_interaction);
|
||||
|
||||
Reference in New Issue
Block a user