Skip to content

Commit

Permalink
🚨 Fix various detekt warnings and enable type resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxr1998 committed Jan 13, 2024
1 parent 5090b4c commit 9fb12d9
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bot-detekt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Setup Gradle
uses: gradle/gradle-build-action@842c587ad8aa4c68eeba24c396e15af4c2e9f30a # v2.9.0
- name: Run detekt task
run: ./gradlew detekt
run: ./gradlew detekt detektMain
- name: Upload SARIF files
uses: github/codeql-action/upload-sarif@74483a38d39275f33fcff5f35b679b5ca4a26a99 # v2.22.5
if: ${{ always() }}
Expand Down
4 changes: 4 additions & 0 deletions detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ complexity:
thresholdInEnums: 8
ignoreDeprecated: true

coroutines:
InjectDispatcher:
active: false

exceptions:
SwallowedException:
active: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ class WeiboImageSource(
val renderDataString = body.substring(startIndex, endIndex)
val renderData: JsonObject = json.parseToJsonElement(renderDataString).jsonObject

val status = renderData["status"]!!.jsonObject
val picIds = status["pic_ids"]!!.jsonArray.map { element -> element.jsonPrimitive.content }
val status = requireNotNull(renderData["status"]).jsonObject
val picIds = requireNotNull(status["pic_ids"]).jsonArray.map { element -> element.jsonPrimitive.content }
picIds.map { id ->
val imageUrl = "https://wx4.sinaimg.cn/original/$id.jpg"
CommandEntryEntity.image(imageUrl, normalizedUrl)
}
} catch (e: NullPointerException) {
} catch (e: IllegalArgumentException) {
logger.error("Couldn't parse response")
return ImageResolver.Status.ParsingFailed()
} catch (e: Exception) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/de/maxr1998/diskord/util/exposed/Batch.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ suspend fun FieldSet.processBatches(

if (batch.size < batchSize) break

lastOffset = toLong(batch.last()[autoIncColumn]!!)
lastOffset = toLong(checkNotNull(batch.last()[autoIncColumn]) { "Batch element autoIncColumn is null" })
}
}

Expand Down

0 comments on commit 9fb12d9

Please sign in to comment.