fix(api): fix AvoidUsingNotNullOperator lint

This commit is contained in:
Harsh Shandilya 2024-10-04 12:25:54 +05:30
parent c72ba1ab97
commit 62ac78bad6
2 changed files with 8 additions and 5 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright © 2023 Harsh Shandilya.
* Copyright © 2023-2024 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
@ -19,8 +19,9 @@ object CSRFTokenConverter : Converter<ResponseBody, CSRFToken> {
val token =
Jsoup.parse(value.string(), LobstersApi.BASE_URL)
.select("meta[name=\"csrf-token\"]")
.first()!!
.attr("content")
.firstOrNull()
?.attr("content")
.orEmpty()
return CSRFToken(token)
}

View file

@ -1,5 +1,5 @@
/*
* Copyright © 2021-2023 Harsh Shandilya.
* Copyright © 2021-2024 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
@ -15,7 +15,9 @@ import kotlin.contracts.contract
object TestUtils {
fun getResource(path: String): String {
// Load the JSON response
val uri = javaClass.classLoader!!.getResource(path)
val uri =
requireNotNull(javaClass.classLoader) { "if this is null something has gone very wrong" }
.getResource(path)
val file = File(uri.path)
return String(file.readBytes())
}