Refactor code for improved clarity and maintainability

- Added `#[allow(clippy::too_many_arguments)]` annotations in `change_processor.rs` and `matching.rs` to suppress warnings for functions with multiple parameters.
- Updated `serve_session.rs` to include `clippy::type_complexity` in the `#[allow(dead_code)]` annotation for better code quality.
- Simplified array initialization in `file_names.rs` for consistency.
- Enhanced texture filtering logic in `matching_fixtures.rs` by replacing `map_or` with `is_some_and` for improved readability.

These changes contribute to a cleaner codebase and address static analysis warnings, ensuring better maintainability.
This commit is contained in:
Joe 2026-02-17 20:04:52 -06:00
parent dea60eb4cf
commit df22500102
7 changed files with 24 additions and 24 deletions

View file

@ -73,6 +73,7 @@ pub struct ChangeProcessor {
impl ChangeProcessor { impl ChangeProcessor {
/// Spin up the ChangeProcessor, connecting it to the given tree, VFS, and /// Spin up the ChangeProcessor, connecting it to the given tree, VFS, and
/// outbound message queue. /// outbound message queue.
#[allow(clippy::too_many_arguments)]
pub fn start( pub fn start(
tree: Arc<Mutex<RojoTree>>, tree: Arc<Mutex<RojoTree>>,
vfs: Arc<Vfs>, vfs: Arc<Vfs>,

View file

@ -111,7 +111,7 @@ pub struct ServeSession {
/// Values are `(remove_count, create_write_count)` — each API write increments /// Values are `(remove_count, create_write_count)` — each API write increments
/// the appropriate counter, each suppressed VFS event decrements it. /// the appropriate counter, each suppressed VFS event decrements it.
/// `None` for oneshot sessions. /// `None` for oneshot sessions.
#[allow(dead_code)] #[allow(dead_code, clippy::type_complexity)]
suppressed_paths: suppressed_paths:
Option<Arc<Mutex<std::collections::HashMap<std::path::PathBuf, (usize, usize)>>>>, Option<Arc<Mutex<std::collections::HashMap<std::path::PathBuf, (usize, usize)>>>>,

View file

@ -825,7 +825,7 @@ mod tests {
.iter() .iter()
.map(|(_, face_enum)| { .map(|(_, face_enum)| {
let mut props = shared_props.clone(); let mut props = shared_props.clone();
props.push(("Face", Variant::Enum(face_enum.clone()))); props.push(("Face", Variant::Enum(*face_enum)));
make_snapshot_with_props("Texture", "Texture", props) make_snapshot_with_props("Texture", "Texture", props)
}) })
.collect(); .collect();
@ -841,13 +841,13 @@ mod tests {
.iter() .iter()
.map(|(_, face_enum)| { .map(|(_, face_enum)| {
let mut props = shared_props.clone(); let mut props = shared_props.clone();
props.push(("Face", Variant::Enum(face_enum.clone()))); props.push(("Face", Variant::Enum(*face_enum)));
make_snapshot_with_props("Texture", "Texture", props) make_snapshot_with_props("Texture", "Texture", props)
}) })
.collect(); .collect();
tree_children.push(make_snapshot_with_props("Texture", "Texture", { tree_children.push(make_snapshot_with_props("Texture", "Texture", {
let mut props = shared_props.clone(); let mut props = shared_props.clone();
props.push(("Face", Variant::Enum(face_front.clone()))); props.push(("Face", Variant::Enum(face_front)));
props props
})); }));
@ -876,7 +876,7 @@ mod tests {
None => { None => {
// Snapshot omitted Face = must match tree Face=Front (5) // Snapshot omitted Face = must match tree Face=Front (5)
assert!( assert!(
variant_eq(tree_face, &Variant::Enum(face_front.clone())), variant_eq(tree_face, &Variant::Enum(face_front)),
"Snapshot without Face should match Front, got {:?}", "Snapshot without Face should match Front, got {:?}",
tree_face tree_face
); );
@ -913,7 +913,7 @@ mod tests {
"Texture", "Texture",
vec![ vec![
("Transparency", Variant::Float32(group_transparency)), ("Transparency", Variant::Float32(group_transparency)),
("Face", Variant::Enum(face.clone())), ("Face", Variant::Enum(*face)),
], ],
)); ));
tree_children.push(make_snapshot_with_props( tree_children.push(make_snapshot_with_props(
@ -921,7 +921,7 @@ mod tests {
"Texture", "Texture",
vec![ vec![
("Transparency", Variant::Float32(group_transparency)), ("Transparency", Variant::Float32(group_transparency)),
("Face", Variant::Enum(face.clone())), ("Face", Variant::Enum(*face)),
], ],
)); ));
} }
@ -936,7 +936,7 @@ mod tests {
"Texture", "Texture",
vec![ vec![
("Transparency", Variant::Float32(group_transparency)), ("Transparency", Variant::Float32(group_transparency)),
("Face", Variant::Enum(face_front.clone())), ("Face", Variant::Enum(face_front)),
], ],
)); ));
} }
@ -974,7 +974,7 @@ mod tests {
tree_face tree_face
), ),
None => assert!( None => assert!(
variant_eq(tree_face, &Variant::Enum(face_front.clone())), variant_eq(tree_face, &Variant::Enum(face_front)),
"Omitted Face should match Front, got {:?}", "Omitted Face should match Front, got {:?}",
tree_face tree_face
), ),
@ -1123,11 +1123,11 @@ mod tests {
let mut tree_props = vec![("Transparency", Variant::Float32(group_t))]; let mut tree_props = vec![("Transparency", Variant::Float32(group_t))];
if let Some(face) = face_opt { if let Some(face) = face_opt {
snap_props.push(("Face", Variant::Enum(face.clone()))); snap_props.push(("Face", Variant::Enum(*face)));
tree_props.push(("Face", Variant::Enum(face.clone()))); tree_props.push(("Face", Variant::Enum(*face)));
} else { } else {
// Snapshot omits Face; tree has Front // Snapshot omits Face; tree has Front
tree_props.push(("Face", Variant::Enum(face_front.clone()))); tree_props.push(("Face", Variant::Enum(face_front)));
} }
snaps.push(make_snapshot_with_props("Texture", "Texture", snap_props)); snaps.push(make_snapshot_with_props("Texture", "Texture", snap_props));
@ -1169,7 +1169,7 @@ mod tests {
tree_face tree_face
), ),
None => assert!( None => assert!(
variant_eq(tree_face, &Variant::Enum(face_front.clone())), variant_eq(tree_face, &Variant::Enum(face_front)),
"Omitted Face should match Front, got {:?}", "Omitted Face should match Front, got {:?}",
tree_face tree_face
), ),

View file

@ -2495,7 +2495,7 @@ mod tests {
fn syncback_idempotency_same_input_same_output() { fn syncback_idempotency_same_input_same_output() {
// Run the same set of instances through name_for_inst twice // Run the same set of instances through name_for_inst twice
// and verify identical output (determinism). // and verify identical output (determinism).
let names = vec!["Alpha", "Beta/Gamma", "Beta:Gamma", "Delta", "CON"]; let names = ["Alpha", "Beta/Gamma", "Beta:Gamma", "Delta", "CON"];
let mw = crate::snapshot_middleware::Middleware::ModuleScript; let mw = crate::snapshot_middleware::Middleware::ModuleScript;
let mut dom = rbx_dom_weak::WeakDom::new(rbx_dom_weak::InstanceBuilder::new("Folder")); let mut dom = rbx_dom_weak::WeakDom::new(rbx_dom_weak::InstanceBuilder::new("Folder"));

View file

@ -332,6 +332,7 @@ fn match_children_for_scoring(
/// recursive subtree scoring. Hash fast-path: if hashes match, return 0. /// recursive subtree scoring. Hash fast-path: if hashes match, return 0.
/// ///
/// Mutually recursive with `match_children_for_scoring`. /// Mutually recursive with `match_children_for_scoring`.
#[allow(clippy::too_many_arguments)]
fn compute_change_count( fn compute_change_count(
new_ref: Ref, new_ref: Ref,
old_ref: Ref, old_ref: Ref,

View file

@ -134,6 +134,7 @@ impl TestServeSession {
&self.project_path &self.project_path
} }
#[allow(dead_code)]
pub fn port(&self) -> usize { pub fn port(&self) -> usize {
self.port self.port
} }
@ -516,16 +517,13 @@ pub fn fresh_rebuild_read(project_path: &Path) -> NormalizedInstance {
} }
let url = format!("http://localhost:{}/api/rojo", port); let url = format!("http://localhost:{}/api/rojo", port);
match reqwest::blocking::get(&url) { if let Ok(resp) = reqwest::blocking::get(&url) {
Ok(resp) => { if let Ok(body) = resp.bytes() {
if let Ok(body) = resp.bytes() { if let Ok(server_info) = deserialize_msgpack::<ServerInfoResponse>(&body) {
if let Ok(server_info) = deserialize_msgpack::<ServerInfoResponse>(&body) { info = Some(server_info);
info = Some(server_info); break;
break;
}
} }
} }
Err(_) => {}
} }
let retry_time_ms = BASE_DURATION_MS * (i as f32).powf(EXP_BACKOFF_FACTOR); let retry_time_ms = BASE_DURATION_MS * (i as f32).powf(EXP_BACKOFF_FACTOR);
thread::sleep(Duration::from_millis(retry_time_ms as u64)); thread::sleep(Duration::from_millis(retry_time_ms as u64));

View file

@ -134,7 +134,7 @@ fn get_texture_children(dom: &WeakDom, parent: Ref) -> Vec<Ref> {
.iter() .iter()
.filter(|&&r| { .filter(|&&r| {
dom.get_by_ref(r) dom.get_by_ref(r)
.map_or(false, |i| i.class.as_str() == "Texture") .is_some_and(|i| i.class.as_str() == "Texture")
}) })
.copied() .copied()
.collect() .collect()
@ -293,7 +293,7 @@ fn forward_matching_ufowave_textures() {
.iter() .iter()
.filter(|&&r| { .filter(|&&r| {
tree.get_instance(r) tree.get_instance(r)
.map_or(false, |i| i.class_name().as_str() == "Texture") .is_some_and(|i| i.class_name().as_str() == "Texture")
}) })
.copied() .copied()
.collect(); .collect();