From 8cfe6ec84c1bd8119fd59fbb76d729da284ced27 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Mon, 19 Dec 2022 16:47:17 +0530 Subject: [PATCH] refactor: merge format-common-impl into format-common Also converts the format-common module into an Android library since UriTotpFinder requires the Android SDK. --- app/build.gradle.kts | 2 +- detekt-baselines/format-common-impl.xml | 8 ------- detekt-baselines/format-common.xml | 9 +++++--- format-common-impl/build.gradle.kts | 23 ------------------- format-common/build.gradle.kts | 18 ++++++++++++--- .../passwordstore/util/totp/UriTotpFinder.kt | 0 .../data/passfile/PasswordEntryTest.kt | 2 +- .../passwordstore/util/time/TestUserClock.kt | 0 .../app/passwordstore/util/totp/OtpTest.kt | 0 .../util/totp/UriTotpFinderTest.kt | 0 settings.gradle.kts | 2 -- 11 files changed, 23 insertions(+), 41 deletions(-) delete mode 100644 detekt-baselines/format-common-impl.xml delete mode 100644 format-common-impl/build.gradle.kts rename {format-common-impl => format-common}/src/main/kotlin/app/passwordstore/util/totp/UriTotpFinder.kt (100%) rename {format-common-impl => format-common}/src/test/kotlin/app/passwordstore/data/passfile/PasswordEntryTest.kt (98%) rename {format-common-impl => format-common}/src/test/kotlin/app/passwordstore/util/time/TestUserClock.kt (100%) rename {format-common-impl => format-common}/src/test/kotlin/app/passwordstore/util/totp/OtpTest.kt (100%) rename {format-common-impl => format-common}/src/test/kotlin/app/passwordstore/util/totp/UriTotpFinderTest.kt (100%) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 62e1f857..c4d1cff5 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -58,7 +58,7 @@ dependencies { implementation(projects.autofillParser) implementation(projects.coroutineUtils) implementation(projects.cryptoPgpainless) - implementation(projects.formatCommonImpl) + implementation(projects.formatCommon) implementation(projects.passgen.diceware) implementation(projects.passgen.random) implementation(projects.uiCompose) diff --git a/detekt-baselines/format-common-impl.xml b/detekt-baselines/format-common-impl.xml deleted file mode 100644 index 1d731d42..00000000 --- a/detekt-baselines/format-common-impl.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - MaxLineLength:UriTotpFinderTest.kt$UriTotpFinderTest.Companion$"otpauth://totp/ACME%20Co:john@example.com?secret=HXDMVJECJJWSRB3HWIZR4IFUGFTMXBOZ&issuer=ACME%20Co&algorithm=SHA256&digits=12&period=25" - ReturnCount:UriTotpFinder.kt$UriTotpFinder$override fun findSecret(content: String): String? - - diff --git a/detekt-baselines/format-common.xml b/detekt-baselines/format-common.xml index c373eea4..1d731d42 100644 --- a/detekt-baselines/format-common.xml +++ b/detekt-baselines/format-common.xml @@ -1,5 +1,8 @@ - + - - + + + MaxLineLength:UriTotpFinderTest.kt$UriTotpFinderTest.Companion$"otpauth://totp/ACME%20Co:john@example.com?secret=HXDMVJECJJWSRB3HWIZR4IFUGFTMXBOZ&issuer=ACME%20Co&algorithm=SHA256&digits=12&period=25" + ReturnCount:UriTotpFinder.kt$UriTotpFinder$override fun findSecret(content: String): String? + diff --git a/format-common-impl/build.gradle.kts b/format-common-impl/build.gradle.kts deleted file mode 100644 index f9bd7628..00000000 --- a/format-common-impl/build.gradle.kts +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved. - * SPDX-License-Identifier: GPL-3.0-only - */ -@file:Suppress("DSL_SCOPE_VIOLATION", "UnstableApiUsage") - -plugins { - id("com.github.android-password-store.android-library") - id("com.github.android-password-store.kotlin-android") - id("com.github.android-password-store.kotlin-library") -} - -android { namespace = "app.passwordstore.format.common.impl" } - -dependencies { - api(projects.formatCommon) - implementation(libs.dagger.hilt.core) - testImplementation(projects.coroutineUtilsTesting) - testImplementation(libs.bundles.testDependencies) - testImplementation(libs.kotlin.coroutines.test) - testImplementation(libs.testing.robolectric) - testImplementation(libs.testing.turbine) -} diff --git a/format-common/build.gradle.kts b/format-common/build.gradle.kts index a42a2404..34b5c69e 100644 --- a/format-common/build.gradle.kts +++ b/format-common/build.gradle.kts @@ -5,15 +5,27 @@ @file:Suppress("DSL_SCOPE_VIOLATION", "UnstableApiUsage") plugins { - kotlin("jvm") + id("com.github.android-password-store.android-library") + id("com.github.android-password-store.kotlin-android") id("com.github.android-password-store.kotlin-library") } +android { + namespace = "app.passwordstore.format.common" + compileOptions { isCoreLibraryDesugaringEnabled = true } +} + dependencies { + api(libs.kotlin.coroutines.core) api(libs.thirdparty.kotlinResult) + compileOnly(libs.androidx.annotation) + coreLibraryDesugaring(libs.android.desugarJdkLibs) implementation(projects.coroutineUtils) - implementation(libs.androidx.annotation) implementation(libs.dagger.hilt.core) implementation(libs.thirdparty.commons.codec) - implementation(libs.kotlin.coroutines.core) + testImplementation(projects.coroutineUtilsTesting) + testImplementation(libs.bundles.testDependencies) + testImplementation(libs.kotlin.coroutines.test) + testImplementation(libs.testing.robolectric) + testImplementation(libs.testing.turbine) } diff --git a/format-common-impl/src/main/kotlin/app/passwordstore/util/totp/UriTotpFinder.kt b/format-common/src/main/kotlin/app/passwordstore/util/totp/UriTotpFinder.kt similarity index 100% rename from format-common-impl/src/main/kotlin/app/passwordstore/util/totp/UriTotpFinder.kt rename to format-common/src/main/kotlin/app/passwordstore/util/totp/UriTotpFinder.kt diff --git a/format-common-impl/src/test/kotlin/app/passwordstore/data/passfile/PasswordEntryTest.kt b/format-common/src/test/kotlin/app/passwordstore/data/passfile/PasswordEntryTest.kt similarity index 98% rename from format-common-impl/src/test/kotlin/app/passwordstore/data/passfile/PasswordEntryTest.kt rename to format-common/src/test/kotlin/app/passwordstore/data/passfile/PasswordEntryTest.kt index 0d77cfe2..31ced9f3 100644 --- a/format-common-impl/src/test/kotlin/app/passwordstore/data/passfile/PasswordEntryTest.kt +++ b/format-common/src/test/kotlin/app/passwordstore/data/passfile/PasswordEntryTest.kt @@ -153,7 +153,7 @@ class PasswordEntryTest { /** * Same as [generatesOtpFromTotpUri], but advances the clock by 5 seconds. This exercises the * [Totp.remainingTime] calculation logic, and acts as a regression test to resolve the bug which - * blocked https://msfjarvis.dev/aps/issue/1550. + * blocked https://github.com/Android-Password-Store/Android-Password-Store/issues/1550. */ @Test fun generatedOtpHasCorrectRemainingTime() = runTest { diff --git a/format-common-impl/src/test/kotlin/app/passwordstore/util/time/TestUserClock.kt b/format-common/src/test/kotlin/app/passwordstore/util/time/TestUserClock.kt similarity index 100% rename from format-common-impl/src/test/kotlin/app/passwordstore/util/time/TestUserClock.kt rename to format-common/src/test/kotlin/app/passwordstore/util/time/TestUserClock.kt diff --git a/format-common-impl/src/test/kotlin/app/passwordstore/util/totp/OtpTest.kt b/format-common/src/test/kotlin/app/passwordstore/util/totp/OtpTest.kt similarity index 100% rename from format-common-impl/src/test/kotlin/app/passwordstore/util/totp/OtpTest.kt rename to format-common/src/test/kotlin/app/passwordstore/util/totp/OtpTest.kt diff --git a/format-common-impl/src/test/kotlin/app/passwordstore/util/totp/UriTotpFinderTest.kt b/format-common/src/test/kotlin/app/passwordstore/util/totp/UriTotpFinderTest.kt similarity index 100% rename from format-common-impl/src/test/kotlin/app/passwordstore/util/totp/UriTotpFinderTest.kt rename to format-common/src/test/kotlin/app/passwordstore/util/totp/UriTotpFinderTest.kt diff --git a/settings.gradle.kts b/settings.gradle.kts index e051f053..f0df8965 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -179,8 +179,6 @@ include("crypto-pgpainless") include("format-common") -include("format-common-impl") - include("passgen:diceware") include("passgen:random")