Skip to content

Commit

Permalink
fix(deps): update dependency com.pinterest.ktlint:ktlint-bom to v1.4.0 (
Browse files Browse the repository at this point in the history
#1271)

* fix(deps): update dependency com.pinterest.ktlint:ktlint-bom to v1.4.0

* Apply ktlint style fixes

---------

Co-authored-by: playground-manager[bot] <126197455+playground-manager[bot]@users.noreply.github.com>
Co-authored-by: Ashley Davies <[email protected]>
  • Loading branch information
playground-manager[bot] and ashdavies authored Oct 25, 2024
1 parent ba8f986 commit fde4203
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<ServiceAccountCredentials, String?> { it.projectId }
?: BuildConfig.GOOGLE_CLOUD_PROJECT
?: BuildConfig.GCLOUD_PROJECT
?: BuildConfig.GCP_PROJECT
?: fetchProjectId()
private fun findExplicitProjectId(firebaseApp: FirebaseApp): String? = firebaseApp.options.projectId
?: googleCredentials<ServiceAccountCredentials, String?> { 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 <reified T : GoogleCredentials, R> googleCredentials(transform: (T) -> R): R? =
(GoogleCredentials.getApplicationDefault() as? T)?.let(transform)
private inline fun <reified T : GoogleCredentials, R> 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 <reified T> fetchComputeMetadataBlocking(
httpClient: HttpClient = HttpClient(),
Expand Down
5 changes: 3 additions & 2 deletions cloud-run/src/commonMain/kotlin/io/ashdavies/cloud/Cloud.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import com.google.cloud.firestore.FirestoreOptions
import com.google.cloud.storage.Storage
import com.google.cloud.storage.StorageOptions

private fun <S : Service<O>, O : ServiceOptions<S, O>> service(options: () -> O) =
lazy(LazyThreadSafetyMode.NONE) { options().service }
private fun <S : Service<O>, O : ServiceOptions<S, O>> service(options: () -> O): Lazy<S> {
return lazy(LazyThreadSafetyMode.NONE) { options().service }
}

internal val firestore: Firestore
by service(FirestoreOptions::getDefaultInstance)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <reified T : JsonElement> JsonElement.getOrThrow(key: String): T =
jsonObject.getValue(key) as? T ?: error(T::class.simpleName ?: error(T::class))
private inline fun <reified T : JsonElement> JsonElement.getOrThrow(key: String): T {
return jsonObject.getValue(key) as? T ?: error(T::class.simpleName ?: error(T::class))
}
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ internal actual fun rememberLocationPermissionState(): LocationPermissionState {
override val shouldShowRationale: Boolean =
multiplePermissionState.shouldShowRationale

override fun launchMultiplePermissionRequest() =
override fun launchMultiplePermissionRequest() {
multiplePermissionState.launchMultiplePermissionRequest()
}
}
}
}

0 comments on commit fde4203

Please sign in to comment.