Refactor code for improved readability and consistency

- Simplified function calls and removed unnecessary line breaks in `change_processor.rs`, `rojo_ref.rs`, `syncback/meta.rs`, `syncback/mod.rs`, `syncback/ref_properties.rs`, and `web/api.rs` to enhance code clarity.
- Updated test assertions in `two_way_sync.rs` for better readability by consolidating multiple lines into single assertions.

These changes improve the overall maintainability and readability of the codebase.
This commit is contained in:
Joe 2026-02-18 04:21:50 -06:00
parent b8c3520d25
commit 6f8e5a5cf2
7 changed files with 32 additions and 88 deletions

View file

@ -135,16 +135,12 @@ pub fn update_ref_paths_in_file(
let Some(path_str) = value.as_str() else {
continue;
};
let Some(resolved) =
crate::resolve_ref_path_to_absolute(path_str, source_abs)
else {
let Some(resolved) = crate::resolve_ref_path_to_absolute(path_str, source_abs) else {
continue;
};
if resolved == old_prefix || resolved.starts_with(&old_prefix_slash) {
let new_abs =
format!("{new_prefix}{}", &resolved[old_prefix.len()..]);
let new_relative =
crate::compute_relative_ref_path(source_abs, &new_abs);
let new_abs = format!("{new_prefix}{}", &resolved[old_prefix.len()..]);
let new_relative = crate::compute_relative_ref_path(source_abs, &new_abs);
*value = serde_json::Value::String(new_relative);
updated = true;
}

View file

@ -175,8 +175,7 @@ pub fn syncback_loop_with_stats(
log::debug!("Collecting referents for new DOM...");
let mut deferred_referents = collect_referents(&new_tree, &pre_prune_paths, None);
let placeholder_map =
std::mem::take(&mut deferred_referents.placeholder_to_source_and_target);
let placeholder_map = std::mem::take(&mut deferred_referents.placeholder_to_source_and_target);
// Remove any properties that are manually blocked from syncback via the
// project file.

View file

@ -494,8 +494,7 @@ mod tests {
let links = collect_referents(&dom2, &HashMap::new(), None);
let placeholders: Vec<&String> =
links.placeholder_to_source_and_target.keys().collect();
let placeholders: Vec<&String> = links.placeholder_to_source_and_target.keys().collect();
assert!(
placeholders.len() >= 2,