Skip to content

Commit 3f0a988

Browse files
committed
style: fix formatting in CLI
1 parent 5e8b1c7 commit 3f0a988

1 file changed

Lines changed: 27 additions & 23 deletions

File tree

src/bin/cli.rs

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,9 @@ fn main() -> Result<()> {
176176
output,
177177
format,
178178
} => report_command(&path, output, format)?,
179-
Commands::Compare {
180-
path1,
181-
path2,
182-
diff,
183-
} => compare_command(&path1, &path2, diff, cli.format)?,
179+
Commands::Compare { path1, path2, diff } => {
180+
compare_command(&path1, &path2, diff, cli.format)?
181+
}
184182
}
185183

186184
Ok(())
@@ -341,7 +339,13 @@ fn complexity_command(
341339
OutputFormat::Table | OutputFormat::Pretty => {
342340
let mut table = Table::new();
343341
table.load_preset(UTF8_FULL);
344-
table.set_header(vec!["File", "Function", "Cyclomatic", "Cognitive", "Status"]);
342+
table.set_header(vec![
343+
"File",
344+
"Function",
345+
"Cyclomatic",
346+
"Cognitive",
347+
"Status",
348+
]);
345349

346350
for item in &complexities {
347351
let status = if item.cyclomatic > threshold {
@@ -387,7 +391,11 @@ fn report_command(path: &Path, output: Option<PathBuf>, format: ReportFormat) ->
387391
anyhow::bail!("Path must be a valid directory: {}", path.display());
388392
}
389393

390-
log::info!("Generating {} report for: {}", format_name(format), path.display());
394+
log::info!(
395+
"Generating {} report for: {}",
396+
format_name(format),
397+
path.display()
398+
);
391399

392400
let spinner = ProgressBar::new_spinner();
393401
spinner.set_message("Generating report...");
@@ -411,17 +419,16 @@ fn report_command(path: &Path, output: Option<PathBuf>, format: ReportFormat) ->
411419
Ok(())
412420
}
413421

414-
fn compare_command(
415-
path1: &Path,
416-
path2: &Path,
417-
_diff: bool,
418-
format: OutputFormat,
419-
) -> Result<()> {
422+
fn compare_command(path1: &Path, path2: &Path, _diff: bool, format: OutputFormat) -> Result<()> {
420423
if !path1.exists() || !path2.exists() {
421424
anyhow::bail!("Both paths must exist");
422425
}
423426

424-
log::info!("Comparing:\n {} vs\n {}", path1.display(), path2.display());
427+
log::info!(
428+
"Comparing:\n {} vs\n {}",
429+
path1.display(),
430+
path2.display()
431+
);
425432

426433
// TODO: Implement actual comparison
427434
let comparison = mock_comparison(path1, path2);
@@ -612,10 +619,7 @@ fn generate_mock_report(_path: &Path, format: ReportFormat) -> String {
612619
}
613620
}
614621

615-
fn mock_comparison(
616-
_path1: &Path,
617-
_path2: &Path,
618-
) -> Vec<(String, String, String, String)> {
622+
fn mock_comparison(_path1: &Path, _path2: &Path) -> Vec<(String, String, String, String)> {
619623
vec![
620624
(
621625
"Cyclomatic Complexity".to_string(),
@@ -690,7 +694,10 @@ fn display_metrics_table(metrics: &MetricsData, filter: Option<MetricType>) {
690694
let show_all = filter.is_none() || matches!(filter, Some(MetricType::All));
691695

692696
if show_all || matches!(filter, Some(MetricType::Cyclomatic)) {
693-
table.add_row(vec!["Cyclomatic Complexity", &metrics.cyclomatic.to_string()]);
697+
table.add_row(vec![
698+
"Cyclomatic Complexity",
699+
&metrics.cyclomatic.to_string(),
700+
]);
694701
}
695702
if show_all || matches!(filter, Some(MetricType::Cognitive)) {
696703
table.add_row(vec!["Cognitive Complexity", &metrics.cognitive.to_string()]);
@@ -728,10 +735,7 @@ fn display_metrics_pretty(metrics: &MetricsData, filter: Option<MetricType>) {
728735
println!(" Lines of Code: {}", metrics.loc);
729736
}
730737
if show_all || matches!(filter, Some(MetricType::Maintainability)) {
731-
println!(
732-
" Maintainability Index: {:.1}",
733-
metrics.maintainability
734-
);
738+
println!(" Maintainability Index: {:.1}", metrics.maintainability);
735739
}
736740
}
737741

0 commit comments

Comments
 (0)