style: add braces to if statements for consistency
Consolidate if-let chain formatting by adding missing braces throughout the project. This improves readability and ensures consistency across the codebase. Co-Authored-By: fiddlerwoaroof/git-smart-commit (gemma-4-31B-it-UD-Q4_K_XL.gguf)
This commit is contained in:
@ -168,9 +168,10 @@ fn draw(f: &mut Frame, app: &App) {
|
||||
f.render_widget(HelpWidget::new(app.help_page), size);
|
||||
}
|
||||
if matches!(app.mode, AppMode::ImportWizard)
|
||||
&& let Some(wizard) = &app.wizard {
|
||||
f.render_widget(ImportWizardWidget::new(wizard), size);
|
||||
}
|
||||
&& let Some(wizard) = &app.wizard
|
||||
{
|
||||
f.render_widget(ImportWizardWidget::new(wizard), size);
|
||||
}
|
||||
// ExportPrompt now uses the minibuffer at the bottom bar.
|
||||
if app.is_empty_model() && matches!(app.mode, AppMode::Normal | AppMode::CommandMode { .. }) {
|
||||
draw_welcome(f, main_chunks[1]);
|
||||
|
||||
@ -150,11 +150,12 @@ impl ImportPipeline {
|
||||
}
|
||||
|
||||
if !measures.is_empty()
|
||||
&& let Some(cat) = model.category_mut("_Measure") {
|
||||
for m in &measures {
|
||||
cat.add_item(&m.field);
|
||||
}
|
||||
&& let Some(cat) = model.category_mut("_Measure")
|
||||
{
|
||||
for m in &measures {
|
||||
cat.add_item(&m.field);
|
||||
}
|
||||
}
|
||||
|
||||
for record in &self.records {
|
||||
if let Value::Object(map) = record {
|
||||
@ -177,12 +178,13 @@ impl ImportPipeline {
|
||||
// Extract date components from this field's value
|
||||
for (field, fmt, comp, derived_name) in &date_extractions {
|
||||
if *field == cat_proposal.field
|
||||
&& let Some(derived_val) = extract_date_component(&v, fmt, *comp) {
|
||||
if let Some(cat) = model.category_mut(derived_name) {
|
||||
cat.add_item(&derived_val);
|
||||
}
|
||||
coords.push((derived_name.clone(), derived_val));
|
||||
&& let Some(derived_val) = extract_date_component(&v, fmt, *comp)
|
||||
{
|
||||
if let Some(cat) = model.category_mut(derived_name) {
|
||||
cat.add_item(&derived_val);
|
||||
}
|
||||
coords.push((derived_name.clone(), derived_val));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
valid = false;
|
||||
|
||||
@ -185,9 +185,10 @@ impl Model {
|
||||
// so it appears in the grid. _Measure targets are dynamically included
|
||||
// via measure_item_names().
|
||||
if formula.target_category != "_Measure"
|
||||
&& let Some(cat) = self.categories.get_mut(&formula.target_category) {
|
||||
cat.add_item(&formula.target);
|
||||
}
|
||||
&& 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,9 +332,10 @@ impl Model {
|
||||
}
|
||||
for formula in &self.formulas {
|
||||
if let Some(item_val) = key.get(&formula.target_category)
|
||||
&& item_val == formula.target {
|
||||
return self.eval_formula_depth(formula, key, depth - 1);
|
||||
}
|
||||
&& item_val == formula.target
|
||||
{
|
||||
return self.eval_formula_depth(formula, key, depth - 1);
|
||||
}
|
||||
}
|
||||
self.data.get(key).cloned()
|
||||
}
|
||||
@ -456,9 +458,10 @@ impl Model {
|
||||
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)
|
||||
&& item_val == formula.target {
|
||||
return self.eval_formula_with_cache(formula, key, none_cats);
|
||||
}
|
||||
&& item_val == formula.target
|
||||
{
|
||||
return self.eval_formula_with_cache(formula, key, none_cats);
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
@ -560,9 +563,10 @@ impl Model {
|
||||
use crate::formula::AggFunc;
|
||||
let mut partial = context.without(target_category);
|
||||
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());
|
||||
}
|
||||
&& 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);
|
||||
}
|
||||
@ -753,9 +757,10 @@ impl Model {
|
||||
Expr::Agg(func, inner, agg_filter) => {
|
||||
let mut partial = context.without(target_category);
|
||||
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());
|
||||
}
|
||||
&& 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);
|
||||
}
|
||||
|
||||
@ -171,10 +171,11 @@ pub fn format_md(model: &Model) -> String {
|
||||
for (cat, axis) in &view.category_axes {
|
||||
let qcat = quote_name(cat);
|
||||
if *axis == Axis::Page
|
||||
&& let Some(sel) = view.page_selections.get(cat) {
|
||||
w!(out, "{qcat}: page, {}", quote_name(sel));
|
||||
continue;
|
||||
}
|
||||
&& let Some(sel) = view.page_selections.get(cat)
|
||||
{
|
||||
w!(out, "{qcat}: page, {}", quote_name(sel));
|
||||
continue;
|
||||
}
|
||||
let axis_str = match axis {
|
||||
Axis::Row => "row",
|
||||
Axis::Column => "column",
|
||||
@ -398,13 +399,14 @@ pub fn parse_md(text: &str) -> Result<Model> {
|
||||
if fl.as_rule() == Rule::formula_line {
|
||||
let raw = first_str(fl)?;
|
||||
if let Some(i) = raw.rfind(" [")
|
||||
&& raw.ends_with(']') {
|
||||
formulas.push((
|
||||
raw[..i].to_string(),
|
||||
raw[i + 2..raw.len() - 1].to_string(),
|
||||
));
|
||||
continue;
|
||||
}
|
||||
&& raw.ends_with(']')
|
||||
{
|
||||
formulas.push((
|
||||
raw[..i].to_string(),
|
||||
raw[i + 2..raw.len() - 1].to_string(),
|
||||
));
|
||||
continue;
|
||||
}
|
||||
// No [Category] suffix — default to _Measure
|
||||
if !raw.is_empty() && raw.contains('=') {
|
||||
formulas.push((raw, "_Measure".to_string()));
|
||||
@ -475,9 +477,10 @@ pub fn parse_md(text: &str) -> Result<Model> {
|
||||
};
|
||||
pv.axes.push((cat.clone(), axis));
|
||||
if axis == Axis::Page
|
||||
&& let Some(sel_pair) = parts.next() {
|
||||
pv.page_selections.push((cat, extract_name(sel_pair)?));
|
||||
}
|
||||
&& let Some(sel_pair) = parts.next()
|
||||
{
|
||||
pv.page_selections.push((cat, extract_name(sel_pair)?));
|
||||
}
|
||||
}
|
||||
Rule::format_line => pv.format = first_str(entry)?,
|
||||
Rule::hidden_line => pv.hidden.push(extract_name_pair(entry)?),
|
||||
@ -548,9 +551,10 @@ pub fn parse_md(text: &str) -> Result<Model> {
|
||||
}
|
||||
|
||||
if let Some(iv) = &initial_view
|
||||
&& m.views.contains_key(iv) {
|
||||
m.active_view = iv.clone();
|
||||
}
|
||||
&& m.views.contains_key(iv)
|
||||
{
|
||||
m.active_view = iv.clone();
|
||||
}
|
||||
|
||||
for (raw, cat_name) in &formulas {
|
||||
m.add_formula(parse_formula(raw, cat_name).with_context(|| format!("Formula: {raw}"))?);
|
||||
|
||||
@ -374,12 +374,14 @@ impl App {
|
||||
}
|
||||
|
||||
pub fn autosave_if_needed(&mut self) {
|
||||
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();
|
||||
}
|
||||
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) {
|
||||
|
||||
@ -36,15 +36,14 @@ pub fn build_cat_tree(model: &Model, expanded: &HashSet<String>) -> Vec<CatTreeE
|
||||
item_count,
|
||||
expanded: is_expanded,
|
||||
});
|
||||
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(),
|
||||
item_name: item_name.to_string(),
|
||||
});
|
||||
}
|
||||
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(),
|
||||
item_name: item_name.to_string(),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
entries
|
||||
}
|
||||
|
||||
@ -86,9 +86,10 @@ impl Effect for AddFormula {
|
||||
// appears in the grid. _Measure targets are dynamically included
|
||||
// via Model::measure_item_names().
|
||||
if formula.target_category != "_Measure"
|
||||
&& let Some(cat) = app.model.category_mut(&formula.target_category) {
|
||||
cat.add_item(&formula.target);
|
||||
}
|
||||
&& let Some(cat) = app.model.category_mut(&formula.target_category)
|
||||
{
|
||||
cat.add_item(&formula.target);
|
||||
}
|
||||
app.model.add_formula(formula);
|
||||
}
|
||||
Err(e) => {
|
||||
|
||||
@ -54,13 +54,14 @@ impl GridLayout {
|
||||
) -> Self {
|
||||
let mut layout = Self::new(model, view);
|
||||
if layout.is_records_mode()
|
||||
&& let Some(records) = frozen_records {
|
||||
let row_items: Vec<AxisEntry> = (0..records.len())
|
||||
.map(|i| AxisEntry::DataItem(vec![i.to_string()]))
|
||||
.collect();
|
||||
layout.row_items = row_items;
|
||||
layout.records = Some(records);
|
||||
}
|
||||
&& let Some(records) = frozen_records
|
||||
{
|
||||
let row_items: Vec<AxisEntry> = (0..records.len())
|
||||
.map(|i| AxisEntry::DataItem(vec![i.to_string()]))
|
||||
.collect();
|
||||
layout.row_items = row_items;
|
||||
layout.records = Some(records);
|
||||
}
|
||||
if view.prune_empty {
|
||||
layout.prune_empty(model);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user