diff options
author | Harsh Shandilya <me@msfjarvis.dev> | 2022-06-09 13:51:29 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-09 13:51:29 +0530 |
commit | 426fc924fba28ec898681ad7f7010456554f061e (patch) | |
tree | 195eac25c605a89f4e239578d685928a64675ee0 /passgen | |
parent | f968b21bf665975e17ad9b03bcff652000e96ec4 (diff) |
Upgrade ktfmt (#1942)
* build-logic: upgrade ktfmt
* all: reformat
Diffstat (limited to 'passgen')
2 files changed, 18 insertions, 13 deletions
diff --git a/passgen/random/src/main/kotlin/dev/msfjarvis/aps/passgen/random/RandomPasswordGenerator.kt b/passgen/random/src/main/kotlin/dev/msfjarvis/aps/passgen/random/RandomPasswordGenerator.kt index 32d3ff49..dcc79ac9 100644 --- a/passgen/random/src/main/kotlin/dev/msfjarvis/aps/passgen/random/RandomPasswordGenerator.kt +++ b/passgen/random/src/main/kotlin/dev/msfjarvis/aps/passgen/random/RandomPasswordGenerator.kt @@ -36,7 +36,8 @@ internal object RandomPasswordGenerator { var password = "" while (password.length < targetLength) { val candidate = bank.secureRandomCharacter() - if (pwFlags hasFlag PasswordGenerator.NO_AMBIGUOUS && + if ( + pwFlags hasFlag PasswordGenerator.NO_AMBIGUOUS && candidate in PasswordGenerator.AMBIGUOUS_STR ) { continue diff --git a/passgen/random/src/main/kotlin/dev/msfjarvis/aps/passgen/random/RandomPhonemesGenerator.kt b/passgen/random/src/main/kotlin/dev/msfjarvis/aps/passgen/random/RandomPhonemesGenerator.kt index b9df4324..57dfc1e1 100644 --- a/passgen/random/src/main/kotlin/dev/msfjarvis/aps/passgen/random/RandomPhonemesGenerator.kt +++ b/passgen/random/src/main/kotlin/dev/msfjarvis/aps/passgen/random/RandomPhonemesGenerator.kt @@ -97,7 +97,8 @@ internal object RandomPhonemesGenerator { val candidate = elements.secureRandomElement() // Reroll if the candidate does not fulfill the current requirements. - if (!candidate.flags.hasFlag(nextBasicType) || + if ( + !candidate.flags.hasFlag(nextBasicType) || (isStartOfPart && candidate.flags hasFlag NOT_FIRST) || // Don't let a diphthong that starts with a vowel follow a vowel. (previousFlags hasFlag VOWEL && @@ -116,7 +117,8 @@ internal object RandomPhonemesGenerator { val useUpperIfBothCasesAllowed = (isStartOfPart || candidate.flags hasFlag CONSONANT) && secureRandomBiasedBoolean(20) password += - if (pwFlags hasFlag PasswordGenerator.UPPERS && + if ( + pwFlags hasFlag PasswordGenerator.UPPERS && (!(pwFlags hasFlag PasswordGenerator.LOWERS) || useUpperIfBothCasesAllowed) ) { candidate.upperCase @@ -131,15 +133,16 @@ internal object RandomPhonemesGenerator { // Second part: Add digits and symbols with a certain probability (if requested) if // they would not directly follow the first character in a pronounceable part. - if (!isStartOfPart && - pwFlags hasFlag PasswordGenerator.DIGITS && - secureRandomBiasedBoolean(30) + if ( + !isStartOfPart && pwFlags hasFlag PasswordGenerator.DIGITS && secureRandomBiasedBoolean(30) ) { var randomDigit: Char do { randomDigit = secureRandomNumber(10).toString(10).first() - } while (pwFlags hasFlag PasswordGenerator.NO_AMBIGUOUS && - randomDigit in PasswordGenerator.AMBIGUOUS_STR) + } while ( + pwFlags hasFlag PasswordGenerator.NO_AMBIGUOUS && + randomDigit in PasswordGenerator.AMBIGUOUS_STR + ) password += randomDigit // Begin a new pronounceable part after every digit. @@ -149,15 +152,16 @@ internal object RandomPhonemesGenerator { continue } - if (!isStartOfPart && - pwFlags hasFlag PasswordGenerator.SYMBOLS && - secureRandomBiasedBoolean(20) + if ( + !isStartOfPart && pwFlags hasFlag PasswordGenerator.SYMBOLS && secureRandomBiasedBoolean(20) ) { var randomSymbol: Char do { randomSymbol = PasswordGenerator.SYMBOLS_STR.secureRandomCharacter() - } while (pwFlags hasFlag PasswordGenerator.NO_AMBIGUOUS && - randomSymbol in PasswordGenerator.AMBIGUOUS_STR) + } while ( + pwFlags hasFlag PasswordGenerator.NO_AMBIGUOUS && + randomSymbol in PasswordGenerator.AMBIGUOUS_STR + ) password += randomSymbol // Continue the password generation as if nothing was added. } |