Skip to content

Commit

Permalink
Fix clippies
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian committed Oct 4, 2024
1 parent b0f2283 commit 7ff97a5
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ pub struct Validate {
}

impl Validate {
#[allow(clippy::too_many_lines)]
fn run(self) -> Result<()> {
let (report, cdr, _) = self.args.load_all()?;

Expand Down Expand Up @@ -314,7 +315,7 @@ impl Validate {

table.retain_rows(|v| !v[1].is_empty() || !v[2].is_empty());

println!("{}", table);
println!("{table}");

if !is_valid {
println!(
Expand All @@ -323,13 +324,13 @@ impl Validate {
);

exit(1);
} else {
println!(
"Calculation {} all totals in the CDR.\n",
style("matches").green().bold()
);
}

println!(
"Calculation {} all totals in the CDR.\n",
style("matches").green().bold()
);

Ok(())
}
}
Expand Down Expand Up @@ -365,7 +366,7 @@ impl Analyze {
"Flat",
]);

for period in report.periods.iter() {
for period in &report.periods {
let start_time = period.start_date_time.with_timezone(&time_zone);
let dim = &period.dimensions;

Expand All @@ -379,7 +380,7 @@ impl Analyze {
]);

table.row(&[
"".to_string(),
String::new(),
"Price".to_string(),
to_string_or_default(dim.energy.price.map(|p| p.price)),
to_string_or_default(dim.time.price.map(|p| p.price)),
Expand All @@ -396,19 +397,19 @@ impl Analyze {
report.total_energy.to_string(),
report.total_time.to_string(),
report.total_parking_time.to_string(),
"".to_string(),
String::new(),
]);

table.row(&[
"".to_string(),
String::new(),
"Price".to_string(),
to_string_or_default(report.total_energy_cost.map(|p| p.excl_vat)),
to_string_or_default(report.total_time_cost.map(|p| p.excl_vat)),
to_string_or_default(report.total_parking_cost.map(|p| p.excl_vat)),
to_string_or_default(report.total_fixed_cost.map(|p| p.excl_vat)),
]);

println!("{}", table);
println!("{table}");

Ok(())
}
Expand Down Expand Up @@ -499,7 +500,7 @@ impl Display for Table {
write!(f, "|")?;

for (value, &width) in row.iter().zip(&self.widths) {
write!(f, " {0: <1$} |", value, width)?;
write!(f, " {value: <width$} |")?;
}

writeln!(f)?;
Expand Down

0 comments on commit 7ff97a5

Please sign in to comment.