Skip to content

Commit

Permalink
Fix many lints and prepare for version 2.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
shssoichiro committed Mar 19, 2023
1 parent c2129e4 commit 958c5da
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 24 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,10 @@
**Version 2.2.2**
- Fix a possible panic in spatial pattern checker (https://github.com/shssoichiro/zxcvbn-rs/issues/70)[#70]
- Update several dependencies
- Fix several new clippy lints
- Officially specify minimum Rust version requirement
- The version has not changed, but the requirement has now been added to Cargo.toml

**Version 2.2.1**
- Fixes for building on WASM targets

Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Expand Up @@ -6,11 +6,11 @@ homepage = "https://github.com/shssoichiro/zxcvbn-rs"
license = "MIT"
name = "zxcvbn"
repository = "https://github.com/shssoichiro/zxcvbn-rs"
version = "2.2.1"
version = "2.2.2"
edition = "2021"
rust-version = "1.63"

[badges]
travis-ci = { repository = "shssoichiro/zxcvbn-rs", branch = "master" }
maintenance = { status = "passively-maintained" }

[dependencies]
Expand Down
1 change: 0 additions & 1 deletion README.md
@@ -1,6 +1,5 @@
# zxcvbn

[![Build Status](https://travis-ci.org/shssoichiro/zxcvbn-rs.svg?branch=master)](https://travis-ci.org/shssoichiro/zxcvbn-rs)
[![Version](https://img.shields.io/crates/v/zxcvbn.svg)](https://crates.io/crates/zxcvbn)
[![License](https://img.shields.io/crates/l/zxcvbn.svg)](https://github.com/shssoichiro/zxcvbn-rs/blob/master/LICENSE)

Expand Down
1 change: 1 addition & 0 deletions clippy.toml
@@ -0,0 +1 @@
msrv = "1.63"
9 changes: 2 additions & 7 deletions src/frequency_lists.rs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/matching/mod.rs
Expand Up @@ -509,7 +509,7 @@ impl Matcher for SequenceMatch {
("lower", 26)
} else if first_chr.is_uppercase() {
("upper", 26)
} else if first_chr.is_digit(10) {
} else if first_chr.is_ascii_digit() {
("digits", 10)
} else {
// conservatively stick with roman alphabet size.
Expand Down
9 changes: 2 additions & 7 deletions src/matching/patterns.rs
Expand Up @@ -3,7 +3,7 @@ use crate::matching::Match;
use std::collections::HashMap;

/// Pattern type used to detect a match
#[derive(Debug, Clone, PartialEq)]
#[derive(Debug, Clone, PartialEq, Default)]
#[cfg_attr(feature = "ser", derive(Serialize))]
#[cfg_attr(feature = "ser", serde(tag = "pattern"))]
#[cfg_attr(feature = "ser", serde(rename_all = "lowercase"))]
Expand All @@ -21,6 +21,7 @@ pub enum MatchPattern {
/// A match based on date patterns
Date(DatePattern),
/// A match based on bruteforce attempting to guess a password
#[default]
BruteForce,
}

Expand All @@ -39,12 +40,6 @@ impl MatchPattern {
}
}

impl Default for MatchPattern {
fn default() -> Self {
MatchPattern::BruteForce
}
}

/// A match based on a word in a dictionary
#[derive(Debug, Clone, PartialEq, Default)]
#[cfg_attr(feature = "builder", derive(Builder))]
Expand Down
12 changes: 6 additions & 6 deletions src/scoring.rs
Expand Up @@ -106,7 +106,7 @@ pub fn most_guessable_match_sequence(
if competing_l > len {
continue;
}
if competing_guesses <= guesses as u64 {
if competing_guesses <= guesses {
return;
}
}
Expand Down Expand Up @@ -202,7 +202,7 @@ pub fn most_guessable_match_sequence(
};

GuessCalculation {
guesses: guesses as u64,
guesses,
guesses_log10: (guesses as f64).log10(),
sequence: optimal_match_sequence,
}
Expand Down Expand Up @@ -326,7 +326,7 @@ fn l33t_variations(pattern: &DictionaryPattern, token: &str) -> u64 {
variations *= possibilities;
}
}
variations as u64
variations
}

fn n_ck(n: usize, k: usize) -> u64 {
Expand Down Expand Up @@ -362,7 +362,7 @@ impl Estimator for SpatialPattern {
for j in 1..=possible_turns {
guesses = guesses.saturating_add(
n_ck(i - 1, j - 1)
.saturating_mul(starts as u64)
.saturating_mul(starts)
.saturating_mul(degree.pow(j as u32)),
);
}
Expand Down Expand Up @@ -413,7 +413,7 @@ impl Estimator for SequencePattern {
// lower guesses for obvious starting points
let mut base_guesses = if ['a', 'A', 'z', 'Z', '0', '1', '9'].contains(&first_chr) {
4
} else if first_chr.is_digit(10) {
} else if first_chr.is_ascii_digit() {
10
} else {
// could give a higher base for uppercase,
Expand Down Expand Up @@ -468,7 +468,7 @@ impl Estimator for DatePattern {
if !self.separator.is_empty() {
guesses *= 4;
}
guesses as u64
guesses
}
}

Expand Down

0 comments on commit 958c5da

Please sign in to comment.