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:
@@ -562,7 +562,8 @@ impl FullTemplateDef {
|
||||
|
||||
// 2 — each role validates
|
||||
for role in &self.roles {
|
||||
role.validate().map_err(|e| format!("role '{}': {}", role.role_id.0, e))?;
|
||||
role.validate()
|
||||
.map_err(|e| format!("role '{}': {}", role.role_id.0, e))?;
|
||||
}
|
||||
|
||||
// 3 — space spec
|
||||
@@ -854,7 +855,7 @@ impl std::fmt::Display for ValidationError {
|
||||
/// divergence).
|
||||
pub fn validate_triangle_def(def: &TriangleDef) -> Result<(), ValidationError> {
|
||||
// 1. Conflict viability: at least one Want axis
|
||||
if !def.interest_axes.iter().any(|a| *a == NpcAxis::Want) {
|
||||
if !def.interest_axes.contains(&NpcAxis::Want) {
|
||||
return Err(ValidationError::ConflictViability {
|
||||
triangle_id: def.triangle_id,
|
||||
});
|
||||
@@ -1104,7 +1105,7 @@ pub fn tick_triangle_escalation(
|
||||
thresholds: Query<&ToleranceThreshold>,
|
||||
) {
|
||||
// Only process on game-minute boundaries (every 10 ticks, D-031)
|
||||
if time.tick % TICKS_PER_GAME_MINUTE != 0 {
|
||||
if !time.tick.is_multiple_of(TICKS_PER_GAME_MINUTE) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1178,7 +1179,7 @@ pub fn apply_resolve_triangle(
|
||||
// Avoids O(N*M) full scan when multiple resolves fire in one tick.
|
||||
let id_to_entity: BTreeMap<TriangleId, Entity> = triangles
|
||||
.iter()
|
||||
.map(|(entity, state)| (state.triangle_id.clone(), entity))
|
||||
.map(|(entity, state)| (state.triangle_id, entity))
|
||||
.collect();
|
||||
|
||||
for cmd in commands {
|
||||
@@ -1347,7 +1348,11 @@ mod tests {
|
||||
RoleId::new("supervisor"),
|
||||
],
|
||||
conflict_type: ConflictType::LatentTension,
|
||||
interest_axes: [NpcAxis::Contentment, NpcAxis::Contentment, NpcAxis::Tolerance],
|
||||
interest_axes: [
|
||||
NpcAxis::Contentment,
|
||||
NpcAxis::Contentment,
|
||||
NpcAxis::Tolerance,
|
||||
],
|
||||
relationship_constraints: vec![],
|
||||
};
|
||||
|
||||
@@ -1438,7 +1443,11 @@ mod tests {
|
||||
let result = generate_intra_template_triangles(&mut world, tid, &defs, &mut rng);
|
||||
|
||||
assert_eq!(result.triangles.len(), 2, "should generate 2 triangles");
|
||||
assert!(result.warnings.is_empty(), "no warnings expected: {:?}", result.warnings);
|
||||
assert!(
|
||||
result.warnings.is_empty(),
|
||||
"no warnings expected: {:?}",
|
||||
result.warnings
|
||||
);
|
||||
|
||||
// Verify role assignments
|
||||
let t1 = &result.triangles[0];
|
||||
@@ -1511,7 +1520,10 @@ mod tests {
|
||||
|
||||
// Actually with only 2 NPCs, both are already assigned before we need a 3rd.
|
||||
// The triangle should be skipped with a warning.
|
||||
assert!(!result.warnings.is_empty(), "should have warnings about missing roles");
|
||||
assert!(
|
||||
!result.warnings.is_empty(),
|
||||
"should have warnings about missing roles"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -1553,11 +1565,7 @@ mod tests {
|
||||
let defs = vec![
|
||||
TriangleDef {
|
||||
triangle_id: TriangleId(300),
|
||||
roles: [
|
||||
RoleId::new("a"),
|
||||
RoleId::new("b"),
|
||||
RoleId::new("c"),
|
||||
],
|
||||
roles: [RoleId::new("a"), RoleId::new("b"), RoleId::new("c")],
|
||||
conflict_type: ConflictType::LoyaltyConflict,
|
||||
interest_axes: [NpcAxis::Want, NpcAxis::Secret, NpcAxis::Relationships],
|
||||
relationship_constraints: vec![RelationshipConstraint {
|
||||
@@ -1568,11 +1576,7 @@ mod tests {
|
||||
},
|
||||
TriangleDef {
|
||||
triangle_id: TriangleId(301),
|
||||
roles: [
|
||||
RoleId::new("a"),
|
||||
RoleId::new("c"),
|
||||
RoleId::new("d"),
|
||||
],
|
||||
roles: [RoleId::new("a"), RoleId::new("c"), RoleId::new("d")],
|
||||
conflict_type: ConflictType::LatentTension,
|
||||
interest_axes: [NpcAxis::Want, NpcAxis::Contentment, NpcAxis::Tolerance],
|
||||
relationship_constraints: vec![RelationshipConstraint {
|
||||
@@ -1603,7 +1607,10 @@ mod tests {
|
||||
assert_eq!(result1.triangles.len(), result2.triangles.len());
|
||||
for (t1, t2) in result1.triangles.iter().zip(result2.triangles.iter()) {
|
||||
assert_eq!(t1.tension, t2.tension, "tension must be deterministic");
|
||||
assert_eq!(t1.tension_rate, t2.tension_rate, "tension_rate must be deterministic");
|
||||
assert_eq!(
|
||||
t1.tension_rate, t2.tension_rate,
|
||||
"tension_rate must be deterministic"
|
||||
);
|
||||
assert_eq!(t1.role_assignments, t2.role_assignments);
|
||||
}
|
||||
}
|
||||
@@ -1681,7 +1688,10 @@ mod tests {
|
||||
schedule.run(&mut world);
|
||||
|
||||
let state = world.get::<TriangleState>(triangle).unwrap();
|
||||
assert_eq!(state.tension, 60, "Active triangle should gain +5 per game-minute × 2");
|
||||
assert_eq!(
|
||||
state.tension, 60,
|
||||
"Active triangle should gain +5 per game-minute × 2"
|
||||
);
|
||||
assert_eq!(
|
||||
state.phase,
|
||||
TrianglePhase::Active,
|
||||
@@ -1721,7 +1731,10 @@ mod tests {
|
||||
schedule.run(&mut world);
|
||||
|
||||
let state = world.get::<TriangleState>(triangle).unwrap();
|
||||
assert_eq!(state.tension, 255, "tension should saturate at u8::MAX (255)");
|
||||
assert_eq!(
|
||||
state.tension, 255,
|
||||
"tension should saturate at u8::MAX (255)"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user