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:
@ -184,11 +184,10 @@ impl Model {
|
||||
// For non-_Measure target categories, add the target as a category item
|
||||
// so it appears in the grid. _Measure targets are dynamically included
|
||||
// via measure_item_names().
|
||||
if formula.target_category != "_Measure" {
|
||||
if let Some(cat) = self.categories.get_mut(&formula.target_category) {
|
||||
if formula.target_category != "_Measure"
|
||||
&& let Some(cat) = self.categories.get_mut(&formula.target_category) {
|
||||
cat.add_item(&formula.target);
|
||||
}
|
||||
}
|
||||
// Replace if same target within the same category
|
||||
if let Some(pos) = self.formulas.iter().position(|f| {
|
||||
f.target == formula.target && f.target_category == formula.target_category
|
||||
@ -331,11 +330,10 @@ impl Model {
|
||||
return Some(CellValue::Error("circular".into()));
|
||||
}
|
||||
for formula in &self.formulas {
|
||||
if let Some(item_val) = key.get(&formula.target_category) {
|
||||
if item_val == formula.target {
|
||||
if let Some(item_val) = key.get(&formula.target_category)
|
||||
&& item_val == formula.target {
|
||||
return self.eval_formula_depth(formula, key, depth - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
self.data.get(key).cloned()
|
||||
}
|
||||
@ -457,11 +455,10 @@ impl Model {
|
||||
/// Uses raw data aggregation for non-formula refs and the cache for formula refs.
|
||||
fn evaluate_formula_cell(&self, key: &CellKey, none_cats: &[String]) -> Option<CellValue> {
|
||||
for formula in &self.formulas {
|
||||
if let Some(item_val) = key.get(&formula.target_category) {
|
||||
if item_val == formula.target {
|
||||
if let Some(item_val) = key.get(&formula.target_category)
|
||||
&& item_val == formula.target {
|
||||
return self.eval_formula_with_cache(formula, key, none_cats);
|
||||
}
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
@ -562,11 +559,10 @@ impl Model {
|
||||
Expr::Agg(func, inner, agg_filter) => {
|
||||
use crate::formula::AggFunc;
|
||||
let mut partial = context.without(target_category);
|
||||
if let Expr::Ref(item_name) = inner.as_ref() {
|
||||
if let Some(cat) = find_item_category(model, item_name) {
|
||||
if let Expr::Ref(item_name) = inner.as_ref()
|
||||
&& let Some(cat) = find_item_category(model, item_name) {
|
||||
partial = partial.with(cat, item_name.as_str());
|
||||
}
|
||||
}
|
||||
if let Some(f) = agg_filter {
|
||||
partial = partial.with(&f.category, &f.item);
|
||||
}
|
||||
@ -756,11 +752,10 @@ impl Model {
|
||||
Expr::UnaryMinus(e) => Ok(-eval_expr(e, context, model, target_category, depth)?),
|
||||
Expr::Agg(func, inner, agg_filter) => {
|
||||
let mut partial = context.without(target_category);
|
||||
if let Expr::Ref(item_name) = inner.as_ref() {
|
||||
if let Some(cat) = find_item_category(model, item_name) {
|
||||
if let Expr::Ref(item_name) = inner.as_ref()
|
||||
&& let Some(cat) = find_item_category(model, item_name) {
|
||||
partial = partial.with(cat, item_name.as_str());
|
||||
}
|
||||
}
|
||||
if let Some(f) = agg_filter {
|
||||
partial = partial.with(&f.category, &f.item);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user