mirror of
https://github.com/crate-ci/typos.git
synced 2024-11-25 10:31:02 -05:00
refactor(cli): Clarify role of checks
This commit is contained in:
parent
b5f606f201
commit
0ea6de6019
4 changed files with 20 additions and 21 deletions
|
@ -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,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
pub mod checks;
|
||||
pub mod config;
|
||||
pub mod dict;
|
||||
pub mod file;
|
||||
pub mod report;
|
||||
|
|
21
src/main.rs
21
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,
|
||||
|
|
Loading…
Reference in a new issue