mirror of
https://github.com/crate-ci/typos.git
synced 2024-12-22 23:52:12 -05:00
style: Address clippy
This commit is contained in:
parent
e6a4f49eb5
commit
67222e9338
3 changed files with 20 additions and 14 deletions
|
@ -26,14 +26,14 @@ impl<'p, 'd> ParserBuilder<'p, 'd> {
|
|||
pub fn dictionary<'d1>(self, dictionary: &'d1 dyn Dictionary) -> ParserBuilder<'p, 'd1> {
|
||||
ParserBuilder {
|
||||
tokenizer: self.tokenizer,
|
||||
dictionary: dictionary,
|
||||
dictionary,
|
||||
}
|
||||
}
|
||||
|
||||
/// Extract typos from the buffer.
|
||||
pub fn build(&self) -> TyposParser<'p, 'd> {
|
||||
TyposParser {
|
||||
tokenizer: self.tokenizer.unwrap_or_else(|| &DEFAULT_TOKENIZER),
|
||||
tokenizer: self.tokenizer.unwrap_or(&DEFAULT_TOKENIZER),
|
||||
dictionary: self.dictionary,
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ impl<'p> Default for ParserBuilder<'p, 'static> {
|
|||
}
|
||||
|
||||
static DEFAULT_TOKENIZER: once_cell::sync::Lazy<tokens::Tokenizer> =
|
||||
once_cell::sync::Lazy::new(|| tokens::Tokenizer::new());
|
||||
once_cell::sync::Lazy::new(tokens::Tokenizer::new);
|
||||
|
||||
/// Extract typos from the buffer.
|
||||
#[derive(Clone)]
|
||||
|
|
|
@ -331,12 +331,7 @@ impl FileChecker for DiffTypos {
|
|||
|
||||
if new_path.is_some() || !content.is_empty() {
|
||||
let original_path = path.display().to_string();
|
||||
let fixed_path = new_path
|
||||
.as_ref()
|
||||
.map(|p| p.as_path())
|
||||
.unwrap_or(path)
|
||||
.display()
|
||||
.to_string();
|
||||
let fixed_path = new_path.as_deref().unwrap_or(path).display().to_string();
|
||||
let original_content: Vec<_> = content
|
||||
.lines_with_terminator()
|
||||
.map(|s| String::from_utf8_lossy(s).into_owned())
|
||||
|
@ -595,7 +590,7 @@ fn extract_fix<'t>(typo: &'t typos::Typo<'t>) -> Option<&'t str> {
|
|||
}
|
||||
}
|
||||
|
||||
fn is_fixable<'t>(typo: &typos::Typo<'t>) -> bool {
|
||||
fn is_fixable(typo: &typos::Typo<'_>) -> bool {
|
||||
extract_fix(typo).is_some()
|
||||
}
|
||||
|
||||
|
|
|
@ -234,10 +234,21 @@ impl<'r> MessageStatus<'r> {
|
|||
|
||||
impl<'r> Report for MessageStatus<'r> {
|
||||
fn report(&self, msg: Message) -> Result<(), std::io::Error> {
|
||||
self.typos_found
|
||||
.compare_and_swap(false, msg.is_correction(), atomic::Ordering::Relaxed);
|
||||
self.errors_found
|
||||
.compare_and_swap(false, msg.is_error(), atomic::Ordering::Relaxed);
|
||||
let _ = self.typos_found.compare_exchange(
|
||||
false,
|
||||
msg.is_correction(),
|
||||
atomic::Ordering::Relaxed,
|
||||
atomic::Ordering::Relaxed,
|
||||
);
|
||||
let _ = self
|
||||
.errors_found
|
||||
.compare_exchange(
|
||||
false,
|
||||
msg.is_error(),
|
||||
atomic::Ordering::Relaxed,
|
||||
atomic::Ordering::Relaxed,
|
||||
)
|
||||
.unwrap();
|
||||
self.reporter.report(msg)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue