diff --git a/bin/gfold/Cargo.toml b/bin/gfold/Cargo.toml index e779be8..3f7cc85 100644 --- a/bin/gfold/Cargo.toml +++ b/bin/gfold/Cargo.toml @@ -27,3 +27,8 @@ serde_json = { workspace = true } termcolor = { workspace = true } thiserror = { workspace = true } toml = { workspace = true } + +[lints.clippy] +all = "warn" +pedantic = "warn" +module_name_repetitions = "allow" diff --git a/bin/gfold/src/cli.rs b/bin/gfold/src/cli.rs index 9021b48..0af70f5 100644 --- a/bin/gfold/src/cli.rs +++ b/bin/gfold/src/cli.rs @@ -89,8 +89,7 @@ impl CliHarness { let (include_email, include_submodules) = match config.display_mode { DisplayMode::Classic => (false, false), DisplayMode::Json => (true, true), - DisplayMode::Standard => (true, false), - DisplayMode::StandardAlphabetical => (true, false), + DisplayMode::Standard | DisplayMode::StandardAlphabetical => (true, false), }; let repository_collection = RepositoryCollector::run(&config.path, include_email, include_submodules)?; diff --git a/bin/gfold/src/display.rs b/bin/gfold/src/display.rs index c5f094c..54abac5 100644 --- a/bin/gfold/src/display.rs +++ b/bin/gfold/src/display.rs @@ -64,17 +64,14 @@ impl DisplayHarness { all_reports.sort_by(|a, b| a.status.as_str().cmp(b.status.as_str())); } - let color_harness = ColorHarness::new(&color_mode); + let color_harness = ColorHarness::new(color_mode); for report in all_reports { color_harness.write_bold(&report.name, false)?; - let parent = match report.parent { - Some(s) => s, - None => { - warn!("parent is empty for collector: {}", report.name); - continue; - } + let Some(parent) = report.parent else { + warn!("parent is empty for collector: {}", report.name); + continue; }; let full_path = Path::new(&parent).join(&report.name); let full_path_formatted = format!( @@ -86,7 +83,7 @@ impl DisplayHarness { color_harness.write_gray(&full_path_formatted, true)?; print!(" "); - color_harness.write_status(&report.status, PAD)?; + color_harness.write_status(report.status, PAD)?; println!(" ({})", report.branch); if let Some(url) = &report.url { println!(" {url}"); @@ -114,18 +111,17 @@ impl DisplayHarness { /// Display [`RepositoryCollection`] to `stdout` in the classic format. fn classic(reports: &RepositoryCollection, color_mode: ColorMode) -> io::Result<()> { debug!("detected classic display mode"); - let color_harness = ColorHarness::new(&color_mode); + let color_harness = ColorHarness::new(color_mode); let length = reports.keys().len(); let mut first = true; for (title, group) in reports { // FIXME(nick): make group title matching less cumbersome. if length > 1 { - match first { - true => { - first = false; - } - false => println!(), + if first { + first = false; + } else { + println!(); } color_harness.write_bold( match &title { @@ -158,7 +154,7 @@ impl DisplayHarness { for report in reports { print!("{: Self { + pub fn new(color_mode: ColorMode) -> Self { Self { color_choice: match &color_mode { ColorMode::Always => ColorChoice::Always, @@ -25,7 +25,7 @@ impl ColorHarness { } /// Writes the [`Status`] of the Git repository to `stdout`. - pub fn write_status(&self, status: &Status, status_width: usize) -> io::Result<()> { + pub fn write_status(&self, status: Status, status_width: usize) -> io::Result<()> { let mut stdout = StandardStream::stdout(self.color_choice); stdout.set_color(ColorSpec::new().set_fg(Some(match status { Status::Bare | Status::Unknown => Color::Red, @@ -68,9 +68,10 @@ impl ColorHarness { ) -> io::Result<()> { let mut stdout = StandardStream::stdout(self.color_choice); stdout.set_color(color_spec)?; - match newline { - true => writeln!(&mut stdout, "{input}")?, - false => write!(&mut stdout, "{input}")?, + if newline { + writeln!(&mut stdout, "{input}")?; + } else { + write!(&mut stdout, "{input}")?; } stdout.reset() } diff --git a/bin/gfold/src/main.rs b/bin/gfold/src/main.rs index 9ba0d25..6a82bbd 100644 --- a/bin/gfold/src/main.rs +++ b/bin/gfold/src/main.rs @@ -20,9 +20,9 @@ mod display; /// [`CliHarness::run()`]. fn main() -> anyhow::Result<()> { if env::var("RUST_LOG").is_err() { - Builder::new().filter_level(LevelFilter::Off).init() + Builder::new().filter_level(LevelFilter::Off).init(); } else { - env_logger::init() + env_logger::init(); } debug!("initialized logger");