diff --git a/app-check/app-check-sdk/src/commonMain/kotlin/io/ashdavies/check/FirebaseApp.kt b/app-check/app-check-sdk/src/commonMain/kotlin/io/ashdavies/check/FirebaseApp.kt index d3c44abdc..80dd5000c 100644 --- a/app-check/app-check-sdk/src/commonMain/kotlin/io/ashdavies/check/FirebaseApp.kt +++ b/app-check/app-check-sdk/src/commonMain/kotlin/io/ashdavies/check/FirebaseApp.kt @@ -17,41 +17,34 @@ public fun FirebaseApp.appCheck(httpClient: HttpClient): AppCheck = AppCheck( httpClient = httpClient, ) -internal fun getProjectId(firebaseApp: FirebaseApp): String = - requireNotNull(findExplicitProjectId(firebaseApp)) { - "Failed to determine project ID. Initialize the " + - "SDK with service account credentials or set project ID as an app option. " + - "Alternatively, set the GOOGLE_CLOUD_PROJECT environment variable." - } +internal fun getProjectId(firebaseApp: FirebaseApp): String = requireNotNull(findExplicitProjectId(firebaseApp)) { + "Failed to determine project ID. Initialize the " + + "SDK with service account credentials or set project ID as an app option. " + + "Alternatively, set the GOOGLE_CLOUD_PROJECT environment variable." +} -internal fun getProjectNumber(): String = - requireNotNull(findExplicitProjectNumber()) { - "Failed to determine project number. Make sure to initialize " + - "the SDK on a Google Cloud Compute Engine with default VM metadata. " + - "Alternatively, set the GCP_PROJECT_NUMBER environment variable." - } +internal fun getProjectNumber(): String = requireNotNull(findExplicitProjectNumber()) { + "Failed to determine project number. Make sure to initialize " + + "the SDK on a Google Cloud Compute Engine with default VM metadata. " + + "Alternatively, set the GCP_PROJECT_NUMBER environment variable." +} -private fun findExplicitProjectId(firebaseApp: FirebaseApp): String? = - firebaseApp.options.projectId - ?: googleCredentials { it.projectId } - ?: BuildConfig.GOOGLE_CLOUD_PROJECT - ?: BuildConfig.GCLOUD_PROJECT - ?: BuildConfig.GCP_PROJECT - ?: fetchProjectId() +private fun findExplicitProjectId(firebaseApp: FirebaseApp): String? = firebaseApp.options.projectId + ?: googleCredentials { it.projectId } + ?: BuildConfig.GOOGLE_CLOUD_PROJECT + ?: BuildConfig.GCLOUD_PROJECT + ?: BuildConfig.GCP_PROJECT + ?: fetchProjectId() -private fun findExplicitProjectNumber(): String? = - BuildConfig.FIREBASE_ANDROID_APP_ID - ?.let { it.split(":")[1] } - ?: fetchProjectNumber() +private fun findExplicitProjectNumber(): String? = BuildConfig.FIREBASE_ANDROID_APP_ID + ?.let { it.split(":")[1] } + ?: fetchProjectNumber() -private inline fun googleCredentials(transform: (T) -> R): R? = - (GoogleCredentials.getApplicationDefault() as? T)?.let(transform) +private inline fun googleCredentials(transform: (T) -> R): R? = (GoogleCredentials.getApplicationDefault() as? T)?.let(transform) -private fun fetchProjectId(): String? = - fetchComputeMetadataBlocking(path = "project/project-id") +private fun fetchProjectId(): String? = fetchComputeMetadataBlocking(path = "project/project-id") -private fun fetchProjectNumber(): String? = - fetchComputeMetadataBlocking(path = "project/numeric-project-id") +private fun fetchProjectNumber(): String? = fetchComputeMetadataBlocking(path = "project/numeric-project-id") private inline fun fetchComputeMetadataBlocking( httpClient: HttpClient = HttpClient(), diff --git a/cloud-run/src/commonMain/kotlin/io/ashdavies/cloud/Cloud.kt b/cloud-run/src/commonMain/kotlin/io/ashdavies/cloud/Cloud.kt index 0c3d9da68..4888a66a8 100644 --- a/cloud-run/src/commonMain/kotlin/io/ashdavies/cloud/Cloud.kt +++ b/cloud-run/src/commonMain/kotlin/io/ashdavies/cloud/Cloud.kt @@ -7,8 +7,9 @@ import com.google.cloud.firestore.FirestoreOptions import com.google.cloud.storage.Storage import com.google.cloud.storage.StorageOptions -private fun , O : ServiceOptions> service(options: () -> O) = - lazy(LazyThreadSafetyMode.NONE) { options().service } +private fun , O : ServiceOptions> service(options: () -> O): Lazy { + return lazy(LazyThreadSafetyMode.NONE) { options().service } +} internal val firestore: Firestore by service(FirestoreOptions::getDefaultInstance) diff --git a/dominion-app/src/commonMain/kotlin/io/ashdavies/dominion/HttpClient.kt b/dominion-app/src/commonMain/kotlin/io/ashdavies/dominion/HttpClient.kt index f9ce1f3e0..f668b901d 100644 --- a/dominion-app/src/commonMain/kotlin/io/ashdavies/dominion/HttpClient.kt +++ b/dominion-app/src/commonMain/kotlin/io/ashdavies/dominion/HttpClient.kt @@ -99,8 +99,10 @@ internal data class ImageInfo( ) } -private fun JsonElement.getContentAsString(key: String): String = - jsonObject.getValue(key).jsonPrimitive.content +private fun JsonElement.getContentAsString(key: String): String { + return jsonObject.getValue(key).jsonPrimitive.content +} -private inline fun JsonElement.getOrThrow(key: String): T = - jsonObject.getValue(key) as? T ?: error(T::class.simpleName ?: error(T::class)) +private inline fun JsonElement.getOrThrow(key: String): T { + return jsonObject.getValue(key) as? T ?: error(T::class.simpleName ?: error(T::class)) +} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e05089370..b1e582728 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -104,7 +104,7 @@ ktor-server-host-common = { module = "io.ktor:ktor-server-host-common", version. ktor-server-test-host = { module = "io.ktor:ktor-server-test-host", version.ref = "ktor" } mosaic-runtime = "com.jakewharton.mosaic:mosaic-runtime:0.14.0" -pinterest-ktlint-bom = "com.pinterest.ktlint:ktlint-bom:1.3.1" +pinterest-ktlint-bom = "com.pinterest.ktlint:ktlint-bom:1.4.0" slack-circuit-foundation = { module = "com.slack.circuit:circuit-foundation", version.ref = "slack-circuit" } slack-circuit-runtime = { module = "com.slack.circuit:circuit-runtime", version.ref = "slack-circuit" } diff --git a/map-routes/src/androidMain/kotlin/io/ashdavies/routes/LocationPermissionState.android.kt b/map-routes/src/androidMain/kotlin/io/ashdavies/routes/LocationPermissionState.android.kt index b317920ca..7730c117a 100644 --- a/map-routes/src/androidMain/kotlin/io/ashdavies/routes/LocationPermissionState.android.kt +++ b/map-routes/src/androidMain/kotlin/io/ashdavies/routes/LocationPermissionState.android.kt @@ -24,8 +24,9 @@ internal actual fun rememberLocationPermissionState(): LocationPermissionState { override val shouldShowRationale: Boolean = multiplePermissionState.shouldShowRationale - override fun launchMultiplePermissionRequest() = + override fun launchMultiplePermissionRequest() { multiplePermissionState.launchMultiplePermissionRequest() + } } } }