refactor(all): use let chains to flatten nested if statements

Replace nested if and if let blocks with combined if statements using let
chains. This reduces indentation and improves readability across the
project.

Co-Authored-By: fiddlerwoaroof/git-smart-commit (gemma-4-31B-it-UD-Q4_K_XL.gguf)
This commit is contained in:
Edward Langley
2026-04-13 21:58:14 -07:00
parent 6370f8b19f
commit cb35e38df9
8 changed files with 32 additions and 48 deletions

View File

@ -374,13 +374,12 @@ impl App {
}
pub fn autosave_if_needed(&mut self) {
if self.dirty && self.last_autosave.elapsed() > Duration::from_secs(30) {
if let Some(path) = &self.file_path.clone() {
if self.dirty && self.last_autosave.elapsed() > Duration::from_secs(30)
&& let Some(path) = &self.file_path.clone() {
let ap = persistence::autosave_path(path);
let _ = persistence::save(&self.model, &ap);
self.last_autosave = Instant::now();
}
}
}
pub fn start_import_wizard(&mut self, json: serde_json::Value) {

View File

@ -36,8 +36,8 @@ pub fn build_cat_tree(model: &Model, expanded: &HashSet<String>) -> Vec<CatTreeE
item_count,
expanded: is_expanded,
});
if is_expanded {
if let Some(cat) = cat {
if is_expanded
&& let Some(cat) = cat {
for item_name in cat.ordered_item_names() {
entries.push(CatTreeEntry::Item {
cat_name: cat_name.to_string(),
@ -45,7 +45,6 @@ pub fn build_cat_tree(model: &Model, expanded: &HashSet<String>) -> Vec<CatTreeE
});
}
}
}
}
entries
}

View File

@ -85,11 +85,10 @@ impl Effect for AddFormula {
// For non-_Measure targets, add the item to the category so it
// appears in the grid. _Measure targets are dynamically included
// via Model::measure_item_names().
if formula.target_category != "_Measure" {
if let Some(cat) = app.model.category_mut(&formula.target_category) {
if formula.target_category != "_Measure"
&& let Some(cat) = app.model.category_mut(&formula.target_category) {
cat.add_item(&formula.target);
}
}
app.model.add_formula(formula);
}
Err(e) => {