Skip to content

Commit

Permalink
Merge pull request #159 from nulab/fix-sonarcloud-reliability
Browse files Browse the repository at this point in the history
fix: Fix sonarcloud reliability
  • Loading branch information
vvatanabe authored Aug 28, 2023
2 parents f4b34cf + c1a1331 commit 3d29dbd
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/nulabinc/zxcvbn/Scoring.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ private static double calculateMetrics(int l, double guesses, boolean excludeAdd
metrics = handleInfinity(metrics);

if (!excludeAdditive) {
metrics += Math.pow(MIN_GUESSES_BEFORE_GROWING_SEQUENCE, l - 1);
metrics += Math.pow(MIN_GUESSES_BEFORE_GROWING_SEQUENCE, (double) l - 1);
metrics = handleInfinity(metrics);
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/nulabinc/zxcvbn/TimeEstimates.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ private static String format(double number, String text) {
}

private static double divide(double dividend, double divisor) {
BigDecimal dividendDecimal = new BigDecimal(dividend);
BigDecimal divisorDecimal = new BigDecimal(divisor);
BigDecimal dividendDecimal = BigDecimal.valueOf(dividend);
BigDecimal divisorDecimal = BigDecimal.valueOf(divisor);
return dividendDecimal.divide(divisorDecimal, RoundingMode.HALF_DOWN).doubleValue();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public double exec(Match match) {
int uppercaseVariations = uppercaseVariations(match);
int l33tVariations = l33tVariations(match);
int reversedVariations = match.reversed ? 2 : 1;
return match.rank * uppercaseVariations * l33tVariations * reversedVariations;
return (double) match.rank * uppercaseVariations * l33tVariations * reversedVariations;
}

public int uppercaseVariations(Match match) {
Expand Down
36 changes: 18 additions & 18 deletions src/main/java/com/nulabinc/zxcvbn/matchers/L33tMatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,24 @@
public class L33tMatcher extends BaseMatcher {

private final Map<String, Map<String, Integer>> rankedDictionaries;
private static final Map<Character, List<Character>> L33T_TABLE =
Collections.unmodifiableMap(
new HashMap<Character, List<Character>>() {
{
put('a', Arrays.asList('4', '@'));
put('b', Collections.singletonList('8'));
put('c', Arrays.asList('(', '{', '[', '<'));
put('e', Collections.singletonList('3'));
put('g', Arrays.asList('6', '9'));
put('i', Arrays.asList('1', '!', '|'));
put('l', Arrays.asList('1', '|', '7'));
put('o', Collections.singletonList('0'));
put('s', Arrays.asList('$', '5'));
put('t', Arrays.asList('+', '7'));
put('x', Collections.singletonList('%'));
put('z', Collections.singletonList('2'));
}
});
private static final Map<Character, List<Character>> L33T_TABLE;

static {
Map<Character, List<Character>> table = new HashMap<>();
table.put('a', Arrays.asList('4', '@'));
table.put('b', Collections.singletonList('8'));
table.put('c', Arrays.asList('(', '{', '[', '<'));
table.put('e', Collections.singletonList('3'));
table.put('g', Arrays.asList('6', '9'));
table.put('i', Arrays.asList('1', '!', '|'));
table.put('l', Arrays.asList('1', '|', '7'));
table.put('o', Collections.singletonList('0'));
table.put('s', Arrays.asList('$', '5'));
table.put('t', Arrays.asList('+', '7'));
table.put('x', Collections.singletonList('%'));
table.put('z', Collections.singletonList('2'));
L33T_TABLE = Collections.unmodifiableMap(table);
}

public L33tMatcher(Context context, Map<String, Map<String, Integer>> rankedDictionaries) {
super(context);
Expand Down

0 comments on commit 3d29dbd

Please sign in to comment.