Skip to content

Commit 3d4bd02

Browse files
Remove watchosDeviceArm64 (#33)
* kotlin/ktor/gradle/APG update * Fix gradle version. * Remove deprecated build conf * Update versions and dependencies * Lint fixes * build.gradle.kts update * build.gradle.kts update. convert dawinMain to appleMain * workflow updates. java version to 17. deploy fixed on macos-latest * Remove todo * Detekt fix. SonarQube updated to 5.0.0 * AppleMain fix * rework appleMain and dependent sources * Revert "rework appleMain and dependent sources" This reverts commit f1d7d5a. * rework nativeMain to nativeRestMain * rework nativeTest to nativeRestTest * Fix sonar report link. Added missing watchosDeviceArm64() Added fetch-depth: 0 to yml report uploads * Update version and readme * Fix version format. Remove watchosDeviceArm64 (no ktpr support) * Using random SDK keys in tests * Small changes * Update ConfigCatClientTests.kt * Fix tests * Fixup sonar issues * Fix lint * Fixup tests * Update ConfigService.kt --------- Co-authored-by: Peter Csajtai <[email protected]>
1 parent 5444e9c commit 3d4bd02

27 files changed

+153
-159
lines changed

.editorconfig

Lines changed: 0 additions & 2 deletions
This file was deleted.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ ConfigCat is a <a href="https://configcat.com" target="_blank">hosted feature fl
2020

2121
### 1. Install the ConfigCat SDK
2222
```kotlin
23-
val CONFIGCAT_VERSION: String by project
23+
val configcatVersion: String by project
2424

2525
kotlin {
2626
sourceSets {
2727
val commonMain by getting {
2828
dependencies {
29-
implementation("com.configcat:configcat-kotlin-client:$CONFIGCAT_VERSION")
29+
implementation("com.configcat:configcat-kotlin-client:$configcatVersion")
3030
}
3131
}
3232
}

build.gradle.kts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ kotlin {
8888
watchosArm64()
8989
watchosX64()
9090
watchosSimulatorArm64()
91-
watchosDeviceArm64()
9291

9392
tvosArm64()
9493
tvosX64()
@@ -219,8 +218,13 @@ detekt {
219218
}
220219

221220
ktlint {
221+
additionalEditorconfig.set(
222+
mapOf(
223+
"max_line_length" to "120"
224+
)
225+
)
222226
filter {
223-
exclude { element -> element.file.path.contains("build.gradle.kts") }
227+
exclude { element -> element.file.path.contains("build.gradle.kts") || element.file.path.contains("Test") }
224228
}
225229
}
226230

detekt.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ complexity:
1515
thresholdInClasses: 22
1616
thresholdInInterfaces: 17
1717
LongMethod:
18-
threshold: 70
18+
threshold: 80
1919
LongParameterList:
2020
constructorThreshold: 10
2121
functionThreshold: 7

src/appleTest/kotlin/com/configcat/DarwinEvaluationTests.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@ import io.ktor.client.engine.mock.MockEngine
1111
import io.ktor.client.engine.mock.respond
1212
import io.ktor.http.HttpStatusCode
1313
import io.ktor.http.headersOf
14-
import kotlinx.coroutines.ExperimentalCoroutinesApi
1514
import kotlinx.coroutines.test.runTest
1615
import kotlin.test.Test
1716
import kotlin.test.fail
1817

19-
@OptIn(ExperimentalCoroutinesApi::class)
2018
class DarwinEvaluationTests {
2119
@Test
2220
fun testComparators() =
@@ -68,7 +66,10 @@ class DarwinEvaluationTests {
6866

6967
val result: Any? = client.getAnyValue(settingKey, test.defaultValue, test.user)
7068
if (test.returnValue != result) {
71-
errors.add("Return value mismatch for test: %s Test Key: $settingKey Expected: ${test.returnValue}, Result: $result \n")
69+
errors.add(
70+
"Return value mismatch for test: %s Test Key: " +
71+
"$settingKey Expected: ${test.returnValue}, Result: $result \n",
72+
)
7273
}
7374
val expectedLog = test.expectedLog
7475
val logResultBuilder = StringBuilder()
@@ -82,7 +83,9 @@ class DarwinEvaluationTests {
8283
}
8384
val logResult: String = logResultBuilder.toString()
8485
if (expectedLog != logResult) {
85-
errors.add("Log mismatch for test: %s Test Key: $settingKey Expected:\n$expectedLog\nResult:\n$logResult\n")
86+
errors.add(
87+
"Log mismatch for test: %s Test Key: $settingKey Expected:\n$expectedLog\nResult:\n$logResult\n",
88+
)
8689
}
8790
evaluationTestLogger.resetLogList()
8891
}

src/commonMain/kotlin/com/configcat/ConfigCatClient.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,6 @@ internal class Client private constructor(
797797
}
798798

799799
internal object SettingTypeHelper {
800-
fun Int.toSettingTypeOrNull(): SettingType? = SettingType.values().firstOrNull { it.id == this }
800+
fun Int.toSettingTypeOrNull(): SettingType? = SettingType.entries.firstOrNull { it.id == this }
801801
}
802802
}

src/commonMain/kotlin/com/configcat/ConfigService.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import com.configcat.model.Entry
88
import com.configcat.model.Setting
99
import korlibs.crypto.sha1
1010
import korlibs.time.DateTime
11+
import kotlinx.atomicfu.AtomicRef
1112
import kotlinx.atomicfu.atomic
1213
import kotlinx.atomicfu.locks.reentrantLock
1314
import kotlinx.atomicfu.locks.withLock
@@ -47,10 +48,10 @@ internal class ConfigService(
4748
private val initialized = atomic(false)
4849
private val offline = atomic(options.offline)
4950
private val mode = options.pollingMode
51+
private val fetchJob: AtomicRef<Deferred<Pair<Entry, String?>>?> = atomic(null)
5052
private var pollingJob: Job? = null
5153
private var cachedEntry = Entry.empty
5254
private var cachedJsonString = ""
53-
private var fetchJob: Deferred<Pair<Entry, String?>>? = null
5455
private var fetching = false
5556

5657
val isOffline: Boolean get() = offline.value
@@ -140,12 +141,11 @@ internal class ConfigService(
140141
return Pair(cachedEntry, null)
141142
}
142143

143-
val runningJob = fetchJob
144-
if (runningJob == null || !fetching) {
144+
if (fetchJob.value == null || !fetching) {
145145
// No fetch is running, initiate a new one.
146146
fetching = true
147147
val eTag = cachedEntry.eTag
148-
fetchJob =
148+
fetchJob.value =
149149
coroutineScope.async {
150150
if (mode is AutoPollMode && !initialized.value) {
151151
// Waiting for the client initialization.
@@ -174,7 +174,7 @@ internal class ConfigService(
174174
}
175175
}
176176
// Await the fetch routine.
177-
val result = fetchJob?.await()
177+
val result = fetchJob.value?.await()
178178

179179
mutex.withLock {
180180
return result?.let { value ->

src/commonMain/kotlin/com/configcat/Evaluator.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,16 @@ internal data class EvaluationContext(
4444
)
4545

4646
internal object ComparatorHelp {
47-
fun Int.toComparatorOrNull(): Evaluator.UserComparator? = Evaluator.UserComparator.values().firstOrNull { it.id == this }
47+
fun Int.toComparatorOrNull(): Evaluator.UserComparator? =
48+
Evaluator.UserComparator.entries.firstOrNull { it.id == this }
4849

4950
fun Int.toPrerequisiteComparatorOrNull(): Evaluator.PrerequisiteComparator? =
50-
Evaluator.PrerequisiteComparator.values().firstOrNull { it.id == this }
51+
Evaluator.PrerequisiteComparator.entries.firstOrNull { it.id == this }
5152

52-
fun Int.toSegmentComparatorOrNull(): Evaluator.SegmentComparator? = Evaluator.SegmentComparator.values().firstOrNull { it.id == this }
53+
fun Int.toSegmentComparatorOrNull(): Evaluator.SegmentComparator? =
54+
Evaluator.SegmentComparator.entries.firstOrNull {
55+
it.id == this
56+
}
5357
}
5458

5559
private const val USER_OBJECT_IS_MISSING = "cannot evaluate, User Object is missing"

src/commonMain/kotlin/com/configcat/PollingModes.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,21 @@ public data class LazyLoadConfiguration(
4141
/**
4242
* Creates an auto polling configuration.
4343
*/
44-
public fun autoPoll(block: AutoPollConfiguration.() -> Unit = {}): PollingMode = AutoPollMode(AutoPollConfiguration().apply(block))
44+
public fun autoPoll(block: AutoPollConfiguration.() -> Unit = {}): PollingMode =
45+
AutoPollMode(AutoPollConfiguration().apply(block))
4546

4647
/**
4748
* Creates a lazy load polling configuration.
4849
*/
49-
public fun lazyLoad(block: LazyLoadConfiguration.() -> Unit = {}): PollingMode = LazyLoadMode(LazyLoadConfiguration().apply(block))
50+
public fun lazyLoad(block: LazyLoadConfiguration.() -> Unit = {}): PollingMode =
51+
LazyLoadMode(LazyLoadConfiguration().apply(block))
5052

5153
/**
5254
* Creates a manual polling configuration.
5355
*/
5456
public fun manualPoll(): PollingMode = ManualPollMode()
5557

56-
internal class AutoPollMode constructor(val configuration: AutoPollConfiguration) : PollingMode {
58+
internal class AutoPollMode(val configuration: AutoPollConfiguration) : PollingMode {
5759
override val identifier: String = "a"
5860

5961
init {
@@ -62,7 +64,7 @@ internal class AutoPollMode constructor(val configuration: AutoPollConfiguration
6264
}
6365
}
6466

65-
internal class LazyLoadMode constructor(val configuration: LazyLoadConfiguration) : PollingMode {
67+
internal class LazyLoadMode(val configuration: LazyLoadConfiguration) : PollingMode {
6668
override val identifier: String = "l"
6769

6870
init {

src/commonTest/kotlin/com/configcat/CommonUtilsTests.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import com.configcat.model.Preferences
55
import com.configcat.model.Segment
66
import com.configcat.model.Setting
77
import com.configcat.model.SettingValue
8-
import kotlinx.coroutines.ExperimentalCoroutinesApi
98
import kotlinx.coroutines.test.runTest
109
import kotlinx.serialization.Serializable
1110
import kotlinx.serialization.encodeToString
@@ -16,7 +15,6 @@ import kotlin.test.assertEquals
1615
import kotlin.test.assertFailsWith
1716
import kotlin.test.assertNotNull
1817

19-
@OptIn(ExperimentalCoroutinesApi::class)
2018
class CommonUtilsTests {
2119
@Test
2220
fun testValidateSettingValueType() =

0 commit comments

Comments
 (0)