Skip to content

Commit

Permalink
Fix printing possible plaintexts (#102)
Browse files Browse the repository at this point in the history
* Fix printing

* Add atty to ignore list

* Updated comment

Atty is only used in criterion now.
  • Loading branch information
SkeletalDemise authored Nov 25, 2022
1 parent 7280436 commit db297dc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ ignore = [
# ansi_term is unmaintained, but it does exactly what it needs to and no more
# so no reason to change just for the sake of it
"RUSTSEC-2021-0139",
# atty is used in criterion, ignoring it until they update
"RUSTSEC-2021-0145"
]

[licenses]
Expand Down
10 changes: 7 additions & 3 deletions src/checkers/english.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ impl Check for Checker<EnglishChecker> {
}

fn check(&self, input: &str) -> CheckResult {
let original_input = input;
// Normalise the string
let input = normalise_string(input);
trace!("Checking English for sentence {}", input);
Expand Down Expand Up @@ -65,16 +66,19 @@ impl Check for Checker<EnglishChecker> {
);
// TODO: We are also typecasting to f64 instead of usize, which costs CPU cycles.
if words_found / (input.split(' ').count()) as f64 > PLAINTEXT_DETECTION_PERCENTAGE {
debug!("Found {} words in {}", words_found, input);
debug!("Returning from English chekcer successfully with {}", input);
debug!("Found {} words in {}", words_found, original_input);
debug!(
"Returning from English chekcer successfully with {}",
original_input
);
plaintext_found = true;
break;
}
}

CheckResult {
is_identified: plaintext_found,
text: input.to_string(),
text: original_input.to_string(),
checker_name: self.name,
checker_description: self.description,
description: filename.to_string(),
Expand Down

0 comments on commit db297dc

Please sign in to comment.