aboutsummaryrefslogtreecommitdiffstats
path: root/format-common/src/main/kotlin/app/passwordstore/data
diff options
context:
space:
mode:
authorNewton Cesar <new123cesar@gmail.com>2022-10-08 12:03:29 -0300
committerGitHub <noreply@github.com>2022-10-08 20:33:29 +0530
commit6d73b63435a2760ec9026090ecfea4846157b6ab (patch)
treed0ebc38b48b7e56cf22bbb9acee32ed797cc16bc /format-common/src/main/kotlin/app/passwordstore/data
parent224d956e28be0e09832371c98112a5af692194e8 (diff)
downloadHardenedPass-6d73b63435a2760ec9026090ecfea4846157b6ab.tar.gz
HardenedPass-6d73b63435a2760ec9026090ecfea4846157b6ab.zip
Fix detekt warnings in format-common (#2167)
* fix warning ktlint to format-common folder * update to code review * adjusted spotless
Diffstat (limited to 'format-common/src/main/kotlin/app/passwordstore/data')
-rw-r--r--format-common/src/main/kotlin/app/passwordstore/data/passfile/PasswordEntry.kt14
1 files changed, 11 insertions, 3 deletions
diff --git a/format-common/src/main/kotlin/app/passwordstore/data/passfile/PasswordEntry.kt b/format-common/src/main/kotlin/app/passwordstore/data/passfile/PasswordEntry.kt
index 9543eb8c..38aa4a20 100644
--- a/format-common/src/main/kotlin/app/passwordstore/data/passfile/PasswordEntry.kt
+++ b/format-common/src/main/kotlin/app/passwordstore/data/passfile/PasswordEntry.kt
@@ -62,7 +62,7 @@ constructor(
do {
val otp = calculateTotp()
emit(otp)
- delay(1000L)
+ delay(ONE_SECOND.seconds)
} while (coroutineContext.isActive)
} else {
awaitCancellation()
@@ -90,6 +90,7 @@ constructor(
return totpSecret != null
}
+ @Suppress("ReturnCount")
private fun findAndStripPassword(passContent: List<String>): Pair<String?, List<String>> {
if (TotpFinder.TOTP_FIELDS.any { passContent[0].startsWith(it) }) return Pair(null, passContent)
for (line in passContent) {
@@ -180,8 +181,14 @@ constructor(
val totpAlgorithm = totpFinder.findAlgorithm(content)
val issuer = totpFinder.findIssuer(content)
val millis = clock.millis()
- val remainingTime = (totpPeriod - ((millis / 1000) % totpPeriod)).seconds
- Otp.calculateCode(totpSecret!!, millis / (1000 * totpPeriod), totpAlgorithm, digits, issuer)
+ val remainingTime = (totpPeriod - ((millis / ONE_SECOND) % totpPeriod)).seconds
+ Otp.calculateCode(
+ totpSecret!!,
+ millis / (ONE_SECOND * totpPeriod),
+ totpAlgorithm,
+ digits,
+ issuer
+ )
.mapBoth(
{ code ->
return Totp(code, remainingTime)
@@ -217,5 +224,6 @@ constructor(
"secret:",
"pass:",
)
+ private const val ONE_SECOND = 1000
}
}