From 0ea6de601917aac94f2094b34af1db6f925ec209 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Thu, 11 Feb 2021 21:27:33 -0600 Subject: [PATCH] refactor(cli): Clarify role of checks --- benches/checks.rs | 18 +++++++++--------- src/{checks.rs => file.rs} | 0 src/lib.rs | 2 +- src/main.rs | 21 ++++++++++----------- 4 files changed, 20 insertions(+), 21 deletions(-) rename src/{checks.rs => file.rs} (100%) diff --git a/benches/checks.rs b/benches/checks.rs index 1877d72..9c6a540 100644 --- a/benches/checks.rs +++ b/benches/checks.rs @@ -2,7 +2,7 @@ mod data; use assert_fs::prelude::*; use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion}; -use typos_cli::checks::FileChecker; +use typos_cli::file::FileChecker; fn bench_checks(c: &mut Criterion) { let mut group = c.benchmark_group("checks"); @@ -15,9 +15,9 @@ fn bench_checks(c: &mut Criterion) { let corrections = typos_cli::dict::BuiltIn::new(Default::default()); let parser = typos::tokens::Tokenizer::new(); - let settings = typos_cli::checks::CheckSettings::new(); + let settings = typos_cli::file::CheckSettings::new(); b.iter(|| { - typos_cli::checks::FoundFiles.check_file( + typos_cli::file::FoundFiles.check_file( sample_path.path(), true, &settings, @@ -36,9 +36,9 @@ fn bench_checks(c: &mut Criterion) { let corrections = typos_cli::dict::BuiltIn::new(Default::default()); let parser = typos::tokens::Tokenizer::new(); - let settings = typos_cli::checks::CheckSettings::new(); + let settings = typos_cli::file::CheckSettings::new(); b.iter(|| { - typos_cli::checks::Identifiers.check_file( + typos_cli::file::Identifiers.check_file( sample_path.path(), true, &settings, @@ -57,9 +57,9 @@ fn bench_checks(c: &mut Criterion) { let corrections = typos_cli::dict::BuiltIn::new(Default::default()); let parser = typos::tokens::Tokenizer::new(); - let settings = typos_cli::checks::CheckSettings::new(); + let settings = typos_cli::file::CheckSettings::new(); b.iter(|| { - typos_cli::checks::Words.check_file( + typos_cli::file::Words.check_file( sample_path.path(), true, &settings, @@ -78,9 +78,9 @@ fn bench_checks(c: &mut Criterion) { let corrections = typos_cli::dict::BuiltIn::new(Default::default()); let parser = typos::tokens::Tokenizer::new(); - let settings = typos_cli::checks::CheckSettings::new(); + let settings = typos_cli::file::CheckSettings::new(); b.iter(|| { - typos_cli::checks::Typos.check_file( + typos_cli::file::Typos.check_file( sample_path.path(), true, &settings, diff --git a/src/checks.rs b/src/file.rs similarity index 100% rename from src/checks.rs rename to src/file.rs diff --git a/src/lib.rs b/src/lib.rs index 4d0e01e..bc10a10 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -pub mod checks; pub mod config; pub mod dict; +pub mod file; pub mod report; diff --git a/src/main.rs b/src/main.rs index ec4edcc..cfd035e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,7 +7,6 @@ use std::io::Write; use structopt::StructOpt; mod args; -use typos_cli::checks; use typos_cli::config; use typos_cli::dict; use typos_cli::report; @@ -105,7 +104,7 @@ fn run_checks(args: &args::Args) -> proc_exit::ExitResult { dictionary.identifiers(config.default.extend_identifiers()); dictionary.words(config.default.extend_words()); - let mut settings = checks::CheckSettings::new(); + let mut settings = typos_cli::file::CheckSettings::new(); settings .check_filenames(config.default.check_filename()) .check_files(config.default.check_file()) @@ -132,22 +131,22 @@ fn run_checks(args: &args::Args) -> proc_exit::ExitResult { let status_reporter = report::MessageStatus::new(output_reporter); let reporter: &dyn report::Report = &status_reporter; - let selected_checks: &dyn checks::FileChecker = if args.files { - &checks::FoundFiles + let selected_checks: &dyn typos_cli::file::FileChecker = if args.files { + &typos_cli::file::FoundFiles } else if args.identifiers { - &checks::Identifiers + &typos_cli::file::Identifiers } else if args.words { - &checks::Words + &typos_cli::file::Words } else if args.write_changes { - &checks::FixTypos + &typos_cli::file::FixTypos } else if args.diff { - &checks::DiffTypos + &typos_cli::file::DiffTypos } else { - &checks::Typos + &typos_cli::file::Typos }; if single_threaded { - checks::walk_path( + typos_cli::file::walk_path( walk.build(), selected_checks, &settings, @@ -156,7 +155,7 @@ fn run_checks(args: &args::Args) -> proc_exit::ExitResult { reporter, ) } else { - checks::walk_path_parallel( + typos_cli::file::walk_path_parallel( walk.build_parallel(), selected_checks, &settings,