Modern Apps git

← Modern-Apps.git

avatar: clippy hygiene in engine and renderer tests

Commit
2f06b21270852f5270d5347f5bb93d6c9afbc575
Author
Vayun Mathur <[email protected]>
When
2026-12-01 21:58 UTC (4 days ago)
Parents
abf02fb
Workspace clippy flagged: get(&id).is_none() on the surfaces
map (now !contains_key, matching the assertion below it), an
index loop over the flattened identity matrix (now enumerate),
and a field assignment right after Default::default() in the
traits endpoint test (now a struct literal with the field set).
Two constant assertions (MAX_BONES >= JOINT_COUNT, the SUN_DIR
sign) relate consts by design and guard retunes: they stay
under per-test allows with comments.

Verified: cargo clippy -p yuu_avatar --all-targets clean,
cargo test -p yuu_avatar (90 passed), fmt clean.

Diff

library/avatar/src/main/rust/src/avatar.rs
diff --git a/library/avatar/src/main/rust/src/avatar.rs b/library/avatar/src/main/rust/src/avatar.rsindex ecf61b2ac3..f4a973894e 100644--- a/library/avatar/src/main/rust/src/avatar.rs+++ b/library/avatar/src/main/rust/src/avatar.rs@@ -377,6 +377,10 @@ mod tests_extra {         YuuPose { id: "idle".into(), name: "Idle".into(), joints: HashMap::new() }     } +    // `MAX_BONES >= JOINT_COUNT` relates two consts: it is an+    // invariant guard that fires if either is retuned, so the+    // constant assertion is intentional.+    #[allow(clippy::assertions_on_constants)]     #[test]     fn name_roundtrip_and_discriminants_match_ubo_order() {         for (i, joint) in ALL_JOINTS.iter().copied().enumerate() {
library/avatar/src/main/rust/src/engine_config.rs
diff --git a/library/avatar/src/main/rust/src/engine_config.rs b/library/avatar/src/main/rust/src/engine_config.rsindex 50dc34ccca..ff8df2afe2 100644--- a/library/avatar/src/main/rust/src/engine_config.rs+++ b/library/avatar/src/main/rust/src/engine_config.rs@@ -174,7 +174,7 @@ mod tests_extra {         cleanup(id);         // set_paused on an unknown surface is a no-op and creates nothing.         set_paused(id, true);-        assert!(engine().lock().expect("engine").surfaces.get(&id).is_none());+        assert!(!engine().lock().expect("engine").surfaces.contains_key(&id));         // set_auto_rotate records prefs without creating a phantom surface.         set_auto_rotate(id, false);         {
library/avatar/src/main/rust/src/gles/renderer.rs
diff --git a/library/avatar/src/main/rust/src/gles/renderer.rs b/library/avatar/src/main/rust/src/gles/renderer.rsindex 0153ed539b..743fdca195 100644--- a/library/avatar/src/main/rust/src/gles/renderer.rs+++ b/library/avatar/src/main/rust/src/gles/renderer.rs@@ -334,11 +334,14 @@ mod tests {         // Identity stays identity under flatten (GL transpose=false path).         let id = glam::Mat4::IDENTITY.to_cols_array_2d();         let flat = flatten(&id);-        for i in 0..16 {-            assert_eq!(flat[i], if i % 5 == 0 { 1.0 } else { 0.0 }, "index {i}");+        for (i, v) in flat.iter().enumerate() {+            assert_eq!(*v, if i % 5 == 0 { 1.0 } else { 0.0 }, "index {i}");         }     } +    // `SUN_DIR[1] < 0.0` asserts on a const lighting direction: an+    // invariant guard if the constant is ever retuned.+    #[allow(clippy::assertions_on_constants)]     #[test]     fn normalize_and_fixed_lighting_constants() {         assert_eq!(normalize([0.0, 0.0, 0.0]), [0.0, 0.0, 0.0], "zero vector guarded, not NaN");
library/avatar/src/main/rust/src/traits.rs
diff --git a/library/avatar/src/main/rust/src/traits.rs b/library/avatar/src/main/rust/src/traits.rsindex b520bd3591..2e008bfd39 100644--- a/library/avatar/src/main/rust/src/traits.rs+++ b/library/avatar/src/main/rust/src/traits.rs@@ -223,8 +223,7 @@ mod tests {      #[test]     fn height_and_weight_scales_hit_endpoints_and_clamp() {-        let mut t = YuuTraits::default();-        t.body_height = 0.0;+        let mut t = YuuTraits { body_height: 0.0, ..Default::default() };         assert!((t.height_scale() - 0.9).abs() < 1e-6);         t.body_height = 1.0;         assert!((t.height_scale() - 1.1).abs() < 1e-6);