mirror of
https://github.com/crate-ci/typos.git
synced 2025-02-13 08:40:29 -05:00
refactor: Clarify names
This commit is contained in:
parent
692f0ac095
commit
e6a4f49eb5
3 changed files with 19 additions and 19 deletions
|
@ -5,7 +5,7 @@ extern crate test;
|
||||||
mod data;
|
mod data;
|
||||||
|
|
||||||
use assert_fs::prelude::*;
|
use assert_fs::prelude::*;
|
||||||
use typos_cli::checks::Check;
|
use typos_cli::checks::FileChecker;
|
||||||
|
|
||||||
fn bench_files(data: &str, b: &mut test::Bencher) {
|
fn bench_files(data: &str, b: &mut test::Bencher) {
|
||||||
let temp = assert_fs::TempDir::new().unwrap();
|
let temp = assert_fs::TempDir::new().unwrap();
|
||||||
|
|
|
@ -4,7 +4,7 @@ use crate::report;
|
||||||
use typos::tokens;
|
use typos::tokens;
|
||||||
use typos::Dictionary;
|
use typos::Dictionary;
|
||||||
|
|
||||||
pub trait Check: Send + Sync {
|
pub trait FileChecker: Send + Sync {
|
||||||
fn check_file(
|
fn check_file(
|
||||||
&self,
|
&self,
|
||||||
path: &std::path::Path,
|
path: &std::path::Path,
|
||||||
|
@ -106,7 +106,7 @@ pub struct Typos {
|
||||||
binary: bool,
|
binary: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Check for Typos {
|
impl FileChecker for Typos {
|
||||||
fn check_file(
|
fn check_file(
|
||||||
&self,
|
&self,
|
||||||
path: &std::path::Path,
|
path: &std::path::Path,
|
||||||
|
@ -168,7 +168,7 @@ pub struct FixTypos {
|
||||||
binary: bool,
|
binary: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Check for FixTypos {
|
impl FileChecker for FixTypos {
|
||||||
fn check_file(
|
fn check_file(
|
||||||
&self,
|
&self,
|
||||||
path: &std::path::Path,
|
path: &std::path::Path,
|
||||||
|
@ -253,7 +253,7 @@ pub struct DiffTypos {
|
||||||
binary: bool,
|
binary: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Check for DiffTypos {
|
impl FileChecker for DiffTypos {
|
||||||
fn check_file(
|
fn check_file(
|
||||||
&self,
|
&self,
|
||||||
path: &std::path::Path,
|
path: &std::path::Path,
|
||||||
|
@ -370,7 +370,7 @@ pub struct Identifiers {
|
||||||
binary: bool,
|
binary: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Check for Identifiers {
|
impl FileChecker for Identifiers {
|
||||||
fn check_file(
|
fn check_file(
|
||||||
&self,
|
&self,
|
||||||
path: &std::path::Path,
|
path: &std::path::Path,
|
||||||
|
@ -424,7 +424,7 @@ pub struct Words {
|
||||||
binary: bool,
|
binary: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Check for Words {
|
impl FileChecker for Words {
|
||||||
fn check_file(
|
fn check_file(
|
||||||
&self,
|
&self,
|
||||||
path: &std::path::Path,
|
path: &std::path::Path,
|
||||||
|
@ -476,7 +476,7 @@ pub struct FoundFiles {
|
||||||
binary: bool,
|
binary: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Check for FoundFiles {
|
impl FileChecker for FoundFiles {
|
||||||
fn check_file(
|
fn check_file(
|
||||||
&self,
|
&self,
|
||||||
path: &std::path::Path,
|
path: &std::path::Path,
|
||||||
|
@ -613,22 +613,22 @@ fn fix_buffer(mut buffer: Vec<u8>, typos: impl Iterator<Item = typos::Typo<'stat
|
||||||
buffer
|
buffer
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn check_path(
|
pub fn walk_path(
|
||||||
walk: ignore::Walk,
|
walk: ignore::Walk,
|
||||||
checks: &dyn Check,
|
checks: &dyn FileChecker,
|
||||||
parser: &typos::tokens::Tokenizer,
|
parser: &typos::tokens::Tokenizer,
|
||||||
dictionary: &dyn typos::Dictionary,
|
dictionary: &dyn typos::Dictionary,
|
||||||
reporter: &dyn report::Report,
|
reporter: &dyn report::Report,
|
||||||
) -> Result<(), ignore::Error> {
|
) -> Result<(), ignore::Error> {
|
||||||
for entry in walk {
|
for entry in walk {
|
||||||
check_entry(entry, checks, parser, dictionary, reporter)?;
|
walk_entry(entry, checks, parser, dictionary, reporter)?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn check_path_parallel(
|
pub fn walk_path_parallel(
|
||||||
walk: ignore::WalkParallel,
|
walk: ignore::WalkParallel,
|
||||||
checks: &dyn Check,
|
checks: &dyn FileChecker,
|
||||||
parser: &typos::tokens::Tokenizer,
|
parser: &typos::tokens::Tokenizer,
|
||||||
dictionary: &dyn typos::Dictionary,
|
dictionary: &dyn typos::Dictionary,
|
||||||
reporter: &dyn report::Report,
|
reporter: &dyn report::Report,
|
||||||
|
@ -636,7 +636,7 @@ pub fn check_path_parallel(
|
||||||
let error: std::sync::Mutex<Result<(), ignore::Error>> = std::sync::Mutex::new(Ok(()));
|
let error: std::sync::Mutex<Result<(), ignore::Error>> = std::sync::Mutex::new(Ok(()));
|
||||||
walk.run(|| {
|
walk.run(|| {
|
||||||
Box::new(|entry: Result<ignore::DirEntry, ignore::Error>| {
|
Box::new(|entry: Result<ignore::DirEntry, ignore::Error>| {
|
||||||
match check_entry(entry, checks, parser, dictionary, reporter) {
|
match walk_entry(entry, checks, parser, dictionary, reporter) {
|
||||||
Ok(()) => ignore::WalkState::Continue,
|
Ok(()) => ignore::WalkState::Continue,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
*error.lock().unwrap() = Err(err);
|
*error.lock().unwrap() = Err(err);
|
||||||
|
@ -649,9 +649,9 @@ pub fn check_path_parallel(
|
||||||
error.into_inner().unwrap()
|
error.into_inner().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_entry(
|
fn walk_entry(
|
||||||
entry: Result<ignore::DirEntry, ignore::Error>,
|
entry: Result<ignore::DirEntry, ignore::Error>,
|
||||||
checks: &dyn Check,
|
checks: &dyn FileChecker,
|
||||||
parser: &typos::tokens::Tokenizer,
|
parser: &typos::tokens::Tokenizer,
|
||||||
dictionary: &dyn typos::Dictionary,
|
dictionary: &dyn typos::Dictionary,
|
||||||
reporter: &dyn report::Report,
|
reporter: &dyn report::Report,
|
||||||
|
|
|
@ -101,7 +101,7 @@ fn run() -> proc_exit::ExitResult {
|
||||||
let reporter: &dyn report::Report = &status_reporter;
|
let reporter: &dyn report::Report = &status_reporter;
|
||||||
|
|
||||||
let (files, identifier_parser, word_parser, checks, fixer, differ);
|
let (files, identifier_parser, word_parser, checks, fixer, differ);
|
||||||
let selected_checks: &dyn checks::Check = if args.files {
|
let selected_checks: &dyn checks::FileChecker = if args.files {
|
||||||
files = settings.build_files();
|
files = settings.build_files();
|
||||||
&files
|
&files
|
||||||
} else if args.identifiers {
|
} else if args.identifiers {
|
||||||
|
@ -122,7 +122,7 @@ fn run() -> proc_exit::ExitResult {
|
||||||
};
|
};
|
||||||
|
|
||||||
if single_threaded {
|
if single_threaded {
|
||||||
checks::check_path(
|
checks::walk_path(
|
||||||
walk.build(),
|
walk.build(),
|
||||||
selected_checks,
|
selected_checks,
|
||||||
&parser,
|
&parser,
|
||||||
|
@ -130,7 +130,7 @@ fn run() -> proc_exit::ExitResult {
|
||||||
reporter,
|
reporter,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
checks::check_path_parallel(
|
checks::walk_path_parallel(
|
||||||
walk.build_parallel(),
|
walk.build_parallel(),
|
||||||
selected_checks,
|
selected_checks,
|
||||||
&parser,
|
&parser,
|
||||||
|
|
Loading…
Add table
Reference in a new issue