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:
@@ -197,8 +197,7 @@ pub fn process_knowledge_events(
|
||||
match event.event_type {
|
||||
KnowledgeEventType::DirectObservation { target, position } => {
|
||||
if let Some(stable_id) = registry.to_stable(target) {
|
||||
if let Some(claim) =
|
||||
observer_kg.observe_entity(stable_id, position, event.tick)
|
||||
if let Some(claim) = observer_kg.observe_entity(stable_id, position, event.tick)
|
||||
{
|
||||
// StableId is Copy — capture before moving claim into event.
|
||||
let told_by = claim.told_by;
|
||||
|
||||
@@ -622,7 +622,12 @@ mod tests {
|
||||
);
|
||||
|
||||
// Public is symmetric — even self-observation passes
|
||||
assert!(filter_by_access(observer, observer, &ObserverAccess::Public, &kg));
|
||||
assert!(filter_by_access(
|
||||
observer,
|
||||
observer,
|
||||
&ObserverAccess::Public,
|
||||
&kg
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -630,7 +635,7 @@ mod tests {
|
||||
// THE critical negative test (Sprint 12 joint briefing).
|
||||
// A non-owner observer must NOT get access to OwnerOnly data.
|
||||
let observer = StableId(1); // some other entity
|
||||
let target = StableId(2); // owns the component
|
||||
let target = StableId(2); // owns the component
|
||||
let kg = KnowledgeGraph::new();
|
||||
|
||||
assert!(
|
||||
@@ -657,8 +662,14 @@ mod tests {
|
||||
let kg = KnowledgeGraph::new();
|
||||
for id in 1u64..=10 {
|
||||
assert!(
|
||||
!filter_by_access(StableId(id), StableId(id + 1), &ObserverAccess::OwnerOnly, &kg),
|
||||
"StableId({id}) should not match StableId({})", id + 1
|
||||
!filter_by_access(
|
||||
StableId(id),
|
||||
StableId(id + 1),
|
||||
&ObserverAccess::OwnerOnly,
|
||||
&kg
|
||||
),
|
||||
"StableId({id}) should not match StableId({})",
|
||||
id + 1
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -886,7 +897,10 @@ mod tests {
|
||||
|
||||
// Observe at SAME position — no contradiction
|
||||
let result = g.observe_entity(target, make_position(10, 10), 200);
|
||||
assert!(result.is_none(), "Same position should not be a contradiction");
|
||||
assert!(
|
||||
result.is_none(),
|
||||
"Same position should not be a contradiction"
|
||||
);
|
||||
let entry = g.entity_knowledge(&target).unwrap();
|
||||
assert_eq!(entry.state, KnowledgeState::Active);
|
||||
assert!(entry.contradicted_claim.is_none());
|
||||
@@ -1067,7 +1081,10 @@ mod tests {
|
||||
.expect("contradiction should be detected");
|
||||
|
||||
let entry = g.entity_knowledge(&target).unwrap();
|
||||
let stored = entry.contradicted_claim.as_ref().expect("field should be populated");
|
||||
let stored = entry
|
||||
.contradicted_claim
|
||||
.as_ref()
|
||||
.expect("field should be populated");
|
||||
|
||||
assert_eq!(stored.told_by, returned.told_by);
|
||||
assert_eq!(stored.told_tick, returned.told_tick);
|
||||
@@ -1114,7 +1131,10 @@ mod tests {
|
||||
// Second observation (now source is DirectObservation, different position):
|
||||
// state must stay Contradicted — contradiction is still unresolved.
|
||||
let claim2 = g.observe_entity(target, make_position(11, 3), 300);
|
||||
assert!(claim2.is_none(), "no new contradiction: DirectObservation source");
|
||||
assert!(
|
||||
claim2.is_none(),
|
||||
"no new contradiction: DirectObservation source"
|
||||
);
|
||||
assert_eq!(
|
||||
g.entity_knowledge(&target).unwrap().state,
|
||||
KnowledgeState::Contradicted,
|
||||
@@ -1158,8 +1178,14 @@ mod tests {
|
||||
let a_result = g.observe_entity(entity_a, make_position(8, 1), 200);
|
||||
let b_result = g.observe_entity(entity_b, make_position(9, 5), 200);
|
||||
|
||||
assert!(a_result.is_some(), "Entity A (ToldBy source) should contradict");
|
||||
assert!(b_result.is_none(), "Entity B (DirectObservation) should not contradict");
|
||||
assert!(
|
||||
a_result.is_some(),
|
||||
"Entity A (ToldBy source) should contradict"
|
||||
);
|
||||
assert!(
|
||||
b_result.is_none(),
|
||||
"Entity B (DirectObservation) should not contradict"
|
||||
);
|
||||
assert_eq!(
|
||||
g.entity_knowledge(&entity_a).unwrap().state,
|
||||
KnowledgeState::Contradicted
|
||||
|
||||
@@ -279,9 +279,10 @@ impl Default for DecayThresholds {
|
||||
///
|
||||
/// Design: coarse-grained component-level tags rather than per-field.
|
||||
/// A component either passes or fails its access check as a whole.
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
|
||||
pub enum ObserverAccess {
|
||||
/// Anyone can observe this data. Default for non-sensitive components.
|
||||
#[default]
|
||||
Public,
|
||||
/// Only the entity that owns this component (e.g. player's own inventory).
|
||||
OwnerOnly,
|
||||
@@ -295,12 +296,6 @@ pub enum ObserverAccess {
|
||||
KnowledgeGated(String),
|
||||
}
|
||||
|
||||
impl Default for ObserverAccess {
|
||||
fn default() -> Self {
|
||||
Self::Public
|
||||
}
|
||||
}
|
||||
|
||||
/// Component that attaches an access rule to an entity's sensitive data.
|
||||
///
|
||||
/// When an observer snapshot is built, `filter_by_access` (implemented in
|
||||
|
||||
Reference in New Issue
Block a user