Skip to content

Commit e3e1463

Browse files
chore(deps): upgraded kotlin linter formatted code
1 parent b0cb3f5 commit e3e1463

File tree

15 files changed

+5787
-5451
lines changed

15 files changed

+5787
-5451
lines changed

.editorconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ indent_style = space
99
indent_size = 4
1010
ktlint_standard_no-wildcard-imports = disabled
1111
ktlint_standard_filename = disabled
12+
ktlint_standard_enum-entry-name-case = disabled

kotlin/src/main/com/looker/rtl/AuthSession.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import io.ktor.http.*
2929

3030
open class AuthSession(
3131
open val apiSettings: ConfigurationProvider,
32-
open val transport: Transport = Transport(apiSettings)
32+
open val transport: Transport = Transport(apiSettings),
3333
) {
3434

3535
var authToken: AuthToken = AuthToken()
@@ -148,15 +148,15 @@ open class AuthSession(
148148
Parameters.build {
149149
append(client_id, clientId)
150150
append(client_secret, clientSecret)
151-
}
151+
},
152152
)
153153
val token = ok<AuthToken>(
154154
transport.request<AuthToken>(
155155
HttpMethod.POST,
156156
"$apiPath/login",
157157
emptyMap(),
158-
body
159-
)
158+
body,
159+
),
160160
)
161161
authToken = token
162162
}
@@ -165,7 +165,7 @@ open class AuthSession(
165165
val token = activeToken()
166166
val sudoToken = transport.request<AuthToken>(
167167
HttpMethod.POST,
168-
"/login/$newId"
168+
"/login/$newId",
169169
) { requestSettings ->
170170
val headers = requestSettings.headers.toMutableMap()
171171
if (token.accessToken.isNotBlank()) {

kotlin/src/main/com/looker/rtl/AuthToken.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ data class AuthToken(
4040
@SerializedName("expires_in")
4141
var expiresIn: Long = 0L,
4242
@SerializedName("refresh_token")
43-
var refreshToken: String? = null
43+
var refreshToken: String? = null,
4444
) {
4545

4646
var expiresAt: LocalDateTime = LocalDateTime.now()
@@ -53,7 +53,7 @@ data class AuthToken(
5353
token.access_token!!,
5454
token.token_type!!,
5555
token.expires_in!!.toLong(),
56-
token.refresh_token
56+
token.refresh_token,
5757
)
5858

5959
init {

kotlin/src/main/com/looker/rtl/Constants.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ fun unQuote(value: String?): String {
9595
enum class ResponseMode {
9696
String,
9797
Binary,
98-
Unknown
98+
Unknown,
9999
}
100100

101101
fun responseMode(contentType: String): ResponseMode {

kotlin/src/main/com/looker/rtl/ErrorDoc.kt

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,21 @@ class ErrorDocItem(var url: String)
3030
/** Structure of the error code document index */
3131
typealias ErrorCodeIndex = HashMap<String, ErrorDocItem>
3232

33-
interface IErrorDocLink {
33+
interface IErrorDocLink {
3434
/** base redirector url */
3535
var redirector: String
36+
3637
/** api version of the error link */
3738
var apiVersion: String
39+
3840
/** HTTP status code */
3941
var statusCode: String
42+
4043
/** REST API Path */
4144
var apiPath: String
42-
}
45+
}
4346

44-
interface IErrorDoc {
47+
interface IErrorDoc {
4548
/** Index of all known error codes. Call load() to populate it */
4649
var index: ErrorCodeIndex?
4750

@@ -103,10 +106,10 @@ typealias ErrorCodeIndex = HashMap<String, ErrorDocItem>
103106
* @param errorMdUrl url for the error document
104107
*/
105108
fun methodName(errorMdUrl: String): String
106-
}
109+
}
107110

108111
/** Class to process Looker API error payloads and retrieve error documentation */
109-
class ErrorDoc(val sdk: APIMethods, val cdnUrl: String = ErrorCodesUrl): IErrorDoc {
112+
class ErrorDoc(val sdk: APIMethods, val cdnUrl: String = ErrorCodesUrl) : IErrorDoc {
110113
companion object {
111114
/** Location of the public CDN for Looker API Error codes */
112115
const val ErrorCodesUrl = "https://static-a.cdn.looker.app/errorcodes/"
@@ -143,7 +146,7 @@ class ErrorDoc(val sdk: APIMethods, val cdnUrl: String = ErrorCodesUrl): IErrorD
143146
match.groupValues[1],
144147
match.groupValues[2],
145148
match.groupValues[3],
146-
match.groupValues[4]
149+
match.groupValues[4],
147150
)
148151
}
149152

@@ -182,7 +185,10 @@ class ErrorDoc(val sdk: APIMethods, val cdnUrl: String = ErrorCodesUrl): IErrorD
182185

183186
override fun specPath(path: String): String {
184187
val rx = Regex("""(:\w+)""")
185-
val result = path.replace(rx) { val x = it.value.substring(1); "{$x}" }
188+
val result = path.replace(rx) {
189+
val x = it.value.substring(1)
190+
"{$x}"
191+
}
186192
return result
187193
}
188194

@@ -220,5 +226,5 @@ class ErrorDocLink(
220226
override var redirector: String = "",
221227
override var apiVersion: String = "",
222228
override var statusCode: String = "",
223-
override var apiPath: String = ""
229+
override var apiPath: String = "",
224230
) : IErrorDocLink

kotlin/src/main/com/looker/rtl/OAuthSession.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fun base64UrlEncode(bytes: ByteArray): String {
3636
@ExperimentalUnsignedTypes
3737
class OAuthSession(
3838
override val apiSettings: ConfigurationProvider,
39-
override val transport: Transport = Transport(apiSettings)
39+
override val transport: Transport = Transport(apiSettings),
4040
) :
4141
AuthSession(apiSettings, transport) {
4242
private var random = SecureRandom()
@@ -52,7 +52,7 @@ class OAuthSession(
5252
HttpMethod.POST,
5353
"/api/token",
5454
emptyMap(),
55-
body
55+
body,
5656
)
5757
val token = this.ok<AccessToken>(response)
5858
this.authToken.setToken(token)
@@ -69,8 +69,8 @@ class OAuthSession(
6969
"grant_type" to "refresh_token",
7070
"refresh_token" to this.activeToken().refreshToken,
7171
"client_id" to config["client_id"],
72-
"redirect_uri" to config["redirect_uri"]
73-
)
72+
"redirect_uri" to config["redirect_uri"],
73+
),
7474
)
7575
}
7676
}
@@ -94,8 +94,8 @@ class OAuthSession(
9494
"scope" to scope,
9595
"state" to state,
9696
"code_challenge_method" to "S256",
97-
"code_challenge" to codeChallenge
98-
)
97+
"code_challenge" to codeChallenge,
98+
),
9999
)
100100
}
101101

@@ -107,7 +107,7 @@ class OAuthSession(
107107
"code" to authCode,
108108
"code_verifier" to verifier,
109109
"client_id" to (config["client_id"] ?: error("")),
110-
"redirect_uri" to (config["redirect_uri"] ?: error(""))
110+
"redirect_uri" to (config["redirect_uri"] ?: error("")),
111111
)
112112
}
113113

kotlin/src/main/com/looker/rtl/Transport.kt

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ sealed class SDKResponse {
5757
/** A successful SDK call. */
5858
data class SDKSuccessResponse<T>(
5959
/** The object returned by the SDK call. */
60-
val value: T
60+
val value: T,
6161
) : SDKResponse() {
6262
/** Whether the SDK call was successful. */
6363
val ok: Boolean = true
@@ -66,7 +66,7 @@ sealed class SDKResponse {
6666
/** An erroring SDK call. */
6767
data class SDKErrorResponse<T>(
6868
/** The error object returned by the SDK call. */
69-
val value: T
69+
val value: T,
7070
) : SDKResponse() {
7171
/** Whether the SDK call was successful. */
7272
val ok: Boolean = false
@@ -96,14 +96,14 @@ enum class HttpMethod(val value: io.ktor.http.HttpMethod) {
9696
PUT(io.ktor.http.HttpMethod.Put),
9797
DELETE(io.ktor.http.HttpMethod.Delete),
9898
PATCH(io.ktor.http.HttpMethod.Patch),
99-
HEAD(io.ktor.http.HttpMethod.Head)
99+
HEAD(io.ktor.http.HttpMethod.Head),
100100
// TODO: Using the ktor-client-apache may support TRACE?
101101
}
102102

103103
data class RequestSettings(
104104
val method: HttpMethod,
105105
val url: String,
106-
val headers: Map<String, String> = emptyMap()
106+
val headers: Map<String, String> = emptyMap(),
107107
)
108108

109109
typealias Authenticator = (init: RequestSettings) -> RequestSettings
@@ -209,14 +209,14 @@ fun customClient(options: TransportOptions): HttpClient {
209209
@Throws(CertificateException::class)
210210
override fun checkClientTrusted(
211211
certs: Array<X509Certificate?>?,
212-
authType: String?
212+
authType: String?,
213213
) {
214214
}
215215

216216
@Throws(CertificateException::class)
217217
override fun checkServerTrusted(
218218
certs: Array<X509Certificate?>?,
219-
authType: String?
219+
authType: String?,
220220
) {
221221
}
222222
}
@@ -225,7 +225,8 @@ fun customClient(options: TransportOptions): HttpClient {
225225
sslContext.init(null, trustAllCerts, SecureRandom())
226226
val sslSocketFactory: SSLSocketFactory = sslContext.socketFactory
227227
sslSocketFactory(
228-
sslSocketFactory, tm
228+
sslSocketFactory,
229+
tm,
229230
)
230231

231232
val hostnameVerifier = HostnameVerifier { _, _ ->
@@ -252,7 +253,7 @@ class Transport(val options: TransportOptions) {
252253
fun makeUrl(
253254
path: String,
254255
queryParams: Values = emptyMap(),
255-
authenticator: Authenticator? = null // TODO figure out why ::defaultAuthenticator is matching when it shouldn't
256+
authenticator: Authenticator? = null, // TODO figure out why ::defaultAuthenticator is matching when it shouldn't
256257
): String {
257258
return if (path.startsWith("http://", true) ||
258259
path.startsWith("https://", true)
@@ -272,7 +273,7 @@ class Transport(val options: TransportOptions) {
272273
path: String,
273274
queryParams: Values = emptyMap(),
274275
body: Any? = null,
275-
noinline authenticator: Authenticator? = null
276+
noinline authenticator: Authenticator? = null,
276277
): SDKResponse {
277278
// TODO get overrides parameter to work without causing compilation errors in UserSession
278279
// overrides: TransportOptions? = null): SDKResponse {
@@ -293,7 +294,7 @@ class Transport(val options: TransportOptions) {
293294
SDKResponse.SDKSuccessResponse(
294295
client.request<HttpStatement>(builder).execute { response: HttpResponse ->
295296
response.receive<T>()
296-
}
297+
},
297298
)
298299
}
299300
} catch (e: Exception) {
@@ -310,7 +311,7 @@ class Transport(val options: TransportOptions) {
310311
path: String,
311312
queryParams: Values,
312313
authenticator: Authenticator?,
313-
body: Any?
314+
body: Any?,
314315
): HttpRequestBuilder {
315316
val builder = HttpRequestBuilder()
316317
// Set the request method
@@ -323,7 +324,8 @@ class Transport(val options: TransportOptions) {
323324

324325
var auth = authenticator ?: ::defaultAuthenticator
325326
if (path.startsWith("http://", true) ||
326-
path.startsWith("https://", true)) {
327+
path.startsWith("https://", true)
328+
) {
327329
// if a full path is passed in, this is a straight fetch, not an API call
328330
// so don't authenticate
329331
auth = ::defaultAuthenticator

0 commit comments

Comments
 (0)