From 6d73b63435a2760ec9026090ecfea4846157b6ab Mon Sep 17 00:00:00 2001 From: Newton Cesar Date: Sat, 8 Oct 2022 12:03:29 -0300 Subject: Fix detekt warnings in format-common (#2167) * fix warning ktlint to format-common folder * update to code review * adjusted spotless --- .../data/passfile/PasswordEntryTest.kt | 1 + .../app/passwordstore/util/time/TestClocks.kt | 33 ---------------------- .../app/passwordstore/util/time/TestUserClock.kt | 33 ++++++++++++++++++++++ 3 files changed, 34 insertions(+), 33 deletions(-) delete mode 100644 format-common/src/test/kotlin/app/passwordstore/util/time/TestClocks.kt create mode 100644 format-common/src/test/kotlin/app/passwordstore/util/time/TestUserClock.kt (limited to 'format-common/src/test') diff --git a/format-common/src/test/kotlin/app/passwordstore/data/passfile/PasswordEntryTest.kt b/format-common/src/test/kotlin/app/passwordstore/data/passfile/PasswordEntryTest.kt index f492604d..2022d968 100644 --- a/format-common/src/test/kotlin/app/passwordstore/data/passfile/PasswordEntryTest.kt +++ b/format-common/src/test/kotlin/app/passwordstore/data/passfile/PasswordEntryTest.kt @@ -194,6 +194,7 @@ class PasswordEntryTest { companion object { + @Suppress("MaxLineLength") const val TOTP_URI = "otpauth://totp/ACME%20Co:john@example.com?secret=HXDMVJECJJWSRB3HWIZR4IFUGFTMXBOZ&issuer=ACME%20Co&algorithm=SHA1&digits=6&period=30" diff --git a/format-common/src/test/kotlin/app/passwordstore/util/time/TestClocks.kt b/format-common/src/test/kotlin/app/passwordstore/util/time/TestClocks.kt deleted file mode 100644 index 8a860a39..00000000 --- a/format-common/src/test/kotlin/app/passwordstore/util/time/TestClocks.kt +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved. - * SPDX-License-Identifier: GPL-3.0-only - */ - -package app.passwordstore.util.time - -import java.time.Clock -import java.time.Instant -import java.time.ZoneId -import java.time.ZoneOffset.UTC - -/** - * Implementation of [UserClock] that is fixed to [Instant.EPOCH] for deterministic time-based tests - */ -class TestUserClock(instant: Instant) : UserClock() { - - constructor() : this(Instant.EPOCH) - - private var clock = fixed(instant, UTC) - - override fun withZone(zone: ZoneId): Clock = clock.withZone(zone) - - override fun getZone(): ZoneId = UTC - - override fun instant(): Instant = clock.instant() - - companion object { - fun withAddedSeconds(secondsToAdd: Long): TestUserClock { - return TestUserClock(Instant.EPOCH.plusSeconds(secondsToAdd)) - } - } -} diff --git a/format-common/src/test/kotlin/app/passwordstore/util/time/TestUserClock.kt b/format-common/src/test/kotlin/app/passwordstore/util/time/TestUserClock.kt new file mode 100644 index 00000000..8a860a39 --- /dev/null +++ b/format-common/src/test/kotlin/app/passwordstore/util/time/TestUserClock.kt @@ -0,0 +1,33 @@ +/* + * Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved. + * SPDX-License-Identifier: GPL-3.0-only + */ + +package app.passwordstore.util.time + +import java.time.Clock +import java.time.Instant +import java.time.ZoneId +import java.time.ZoneOffset.UTC + +/** + * Implementation of [UserClock] that is fixed to [Instant.EPOCH] for deterministic time-based tests + */ +class TestUserClock(instant: Instant) : UserClock() { + + constructor() : this(Instant.EPOCH) + + private var clock = fixed(instant, UTC) + + override fun withZone(zone: ZoneId): Clock = clock.withZone(zone) + + override fun getZone(): ZoneId = UTC + + override fun instant(): Instant = clock.instant() + + companion object { + fun withAddedSeconds(secondsToAdd: Long): TestUserClock { + return TestUserClock(Instant.EPOCH.plusSeconds(secondsToAdd)) + } + } +} -- cgit v1.2.3