Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
kenny-statsig committed Sep 13, 2023
1 parent d421b69 commit 1206826
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 25 deletions.
5 changes: 2 additions & 3 deletions src/main/java/com/statsig/androidsdk/HttpUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import okhttp3.Response
import okhttp3.ResponseBody.Companion.toResponseBody
import java.net.HttpURLConnection


private val RETRY_CODES: IntArray = intArrayOf(
HttpURLConnection.HTTP_CLIENT_TIMEOUT,
HttpURLConnection.HTTP_INTERNAL_ERROR,
Expand All @@ -26,7 +25,7 @@ private const val STATSIG_SDK_TYPE_KEY = "STATSIG-SDK-TYPE"
private const val STATSIG_SDK_VERSION_KEY = "STATSIG-SDK-VERSION"
private const val ACCEPT_HEADER_KEY = "Accept"
private const val ACCEPT_HEADER_VALUE = "application/json"
internal val JSON: MediaType = "application/json; charset=utf-8".toMediaType();
internal val JSON: MediaType = "application/json; charset=utf-8".toMediaType()

class RequestHeaderInterceptor(private val sdkKey: String) : Interceptor {
@Throws(Exception::class)
Expand Down Expand Up @@ -70,4 +69,4 @@ class ResponseInterceptor : Interceptor {
.addHeader("attempt", attempt.toString())
.build()
}
}
}
5 changes: 1 addition & 4 deletions src/main/java/com/statsig/androidsdk/InitializeResponse.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package com.statsig.androidsdk

import com.google.gson.JsonObject
import com.google.gson.JsonSerializer
import com.google.gson.annotations.SerializedName


enum class InitializeFailReason {
CoroutineTimeout,
NetworkTimeout,
Expand Down Expand Up @@ -35,7 +32,7 @@ internal data class APIFeatureGate(
@SerializedName("secondary_exposures") val secondaryExposures: Array<Map<String, String>> = arrayOf(),
)

internal data class APIDynamicConfig (
internal data class APIDynamicConfig(
@SerializedName("name") val name: String,
@SerializedName("value") val value: Map<String, Any>,
@SerializedName("rule_id") val ruleID: String?,
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/statsig/androidsdk/StatsigClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ internal class StatsigClient() {

@VisibleForTesting
internal lateinit var statsigNetwork: StatsigNetwork

@VisibleForTesting
internal lateinit var options: StatsigOptions

Expand Down
10 changes: 7 additions & 3 deletions src/main/java/com/statsig/androidsdk/StatsigNetwork.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import java.net.ConnectException
import java.net.SocketTimeoutException
import java.util.concurrent.TimeUnit


// Constants
private val MAX_LOG_PERIOD = TimeUnit.DAYS.toMillis(3)
private const val POLLING_INTERVAL_MS: Long = 10000
Expand Down Expand Up @@ -213,8 +212,13 @@ internal class StatsigNetwork(
}
var response = client.newCall(request).execute()
var code = response.code
endDiagnostics(diagnostics, contextType, code,
response.headers["x-statsig-region"], response.headers["attempt"]?.toInt())
endDiagnostics(
diagnostics,
contextType,
code,
response.headers["x-statsig-region"],
response.headers["attempt"]?.toInt(),
)
when (code) {
in 200..299 -> {
if (code == 204 && endpoint == INITIALIZE_ENDPOINT) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import io.mockk.coEvery
import io.mockk.mockk
import io.mockk.spyk
import kotlinx.coroutines.*
import okhttp3.mockwebserver.MockWebServer
import org.junit.Assert.assertEquals
import org.junit.Before
import org.junit.Test
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/statsig/androidsdk/ErrorBoundaryTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class ErrorBoundaryTest {
app,
"client-key",
null,
options = StatsigOptions(disableDiagnosticsLogging = true)
options = StatsigOptions(disableDiagnosticsLogging = true),
)
Statsig.shutdown()
}
Expand Down Expand Up @@ -132,7 +132,7 @@ class ErrorBoundaryTest {
app,
"client-key",
null,
options = StatsigOptions(disableDiagnosticsLogging = true)
options = StatsigOptions(disableDiagnosticsLogging = true),
)
Statsig.shutdown()
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/statsig/androidsdk/LayerExposureTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ class LayerExposureTest {
// filter out diagnostics data
val events = result.events.filter { event -> event.eventName != "statsig::diagnostics" }
logs = if (events.isEmpty())null else LogEventData(events as ArrayList<LogEvent>, result.statsigMetadata)
}
},
)
initTime = System.currentTimeMillis()
TestUtil.startStatsigAndWait(app, user = user, server = server)
Expand Down
1 change: 0 additions & 1 deletion src/test/java/com/statsig/androidsdk/StatsigTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.statsig.androidsdk

import android.app.Application
import com.google.gson.Gson
import io.mockk.coEvery
import io.mockk.mockk
import io.mockk.unmockkAll
import kotlinx.coroutines.runBlocking
Expand Down
1 change: 0 additions & 1 deletion src/test/java/com/statsig/androidsdk/StoreTest.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.statsig.androidsdk

import android.app.Application
import io.mockk.coVerify
import io.mockk.every
import io.mockk.mockk
import io.mockk.mockkObject
Expand Down
12 changes: 3 additions & 9 deletions src/test/java/com/statsig/androidsdk/TestUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@ import com.google.gson.JsonObject
import com.google.gson.JsonPrimitive
import com.google.gson.JsonSerializationContext
import com.google.gson.JsonSerializer
import com.google.gson.TypeAdapter
import com.google.gson.TypeAdapterFactory
import com.google.gson.annotations.SerializedName
import com.google.gson.reflect.TypeToken
import com.google.gson.stream.JsonReader
import com.google.gson.stream.JsonWriter
import io.mockk.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
Expand All @@ -31,7 +26,6 @@ import java.lang.reflect.Type
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit


@OptIn(ExperimentalCoroutinesApi::class)
class TestUtil {
companion object {
Expand Down Expand Up @@ -325,7 +319,7 @@ class TestUtil {
time: Long? = null,
hasUpdates: Boolean = true,
onLog: ((LogEventData) -> Unit)? = null,
getInitializeResponse: ((InitializeRequestBody) -> InitializeResponse)? = null
getInitializeResponse: ((InitializeRequestBody) -> InitializeResponse)? = null,
): MockWebServer {
var server = MockWebServer()
server.apply {
Expand All @@ -341,7 +335,7 @@ class TestUtil {
}
val type = object : TypeToken<MutableMap<String, Any>>() {}.type
val gson = GsonBuilder().registerTypeAdapter(
type, PolymorphicSerializer()
type, PolymorphicSerializer(),
).create()
var stringified = gson.toJson(response)
return MockResponse().setResponseCode(200).setBody(stringified)
Expand Down Expand Up @@ -380,7 +374,7 @@ class TestUtil {
override fun serialize(
src: Any?,
typeOfSrc: Type?,
context: JsonSerializationContext?
context: JsonSerializationContext?,
): JsonElement {
return src.let {
if (it is Map<*, *>) {
Expand Down

0 comments on commit 1206826

Please sign in to comment.