Skip to content

Commit

Permalink
Handle migration from detekt to spotless
Browse files Browse the repository at this point in the history
Removed Suppressions added for detekt.

Specifically removed:
- `SwallowedException` where an exception ends as a default value
- `MagicNumber`
- `CyclomaticComplexMethod`
- `TooGenericExceptionThrown`

Also ran spotlessApply which changed SMAddMangaResponse
  • Loading branch information
MajorTanya committed Aug 19, 2024
1 parent de25e8d commit 4d24dee
Show file tree
Hide file tree
Showing 11 changed files with 1 addition and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ fun Track.toApiStatus() = when (status) {

private val preferences: TrackPreferences by injectLazy()

@Suppress("MagicNumber", "CyclomaticComplexMethod")
fun DomainTrack.toApiScore(): String = when (preferences.anilistScoreType().get()) {
// 10 point
"POINT_10" -> (score.toInt() / 10).toString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ data class ALManga(
val totalChapters: Long,
val averageScore: Int,
) {
@Suppress("SwallowedException")
fun toTrack() = TrackSearch.create(TrackerManager.ANILIST).apply {
remote_id = remoteId
title = this@ALManga.title
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ class BangumiApi(
}
}

@Suppress("MagicNumber")
suspend fun search(search: String): List<TrackSearch> {
return withIOContext {
val url = "$API_URL/search/subject/${URLEncoder.encode(search, StandardCharsets.UTF_8.name())}"
Expand Down Expand Up @@ -101,7 +100,6 @@ class BangumiApi(
}
}

@Suppress("MagicNumber")
suspend fun statusLibManga(track: Track): Track? {
return withIOContext {
val urlUserRead = "$API_URL/collection/${track.remote_id}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ data class BGMOAuth(
val accessToken: String,
@SerialName("token_type")
val tokenType: String,
@Suppress("MagicNumber")
@SerialName("created_at")
val createdAt: Long = System.currentTimeMillis() / 1000,
@SerialName("expires_in")
Expand All @@ -21,5 +20,4 @@ data class BGMOAuth(
)

// Access token refresh before expired
@Suppress("MagicNumber")
fun BGMOAuth.isExpired() = (System.currentTimeMillis() / 1000) > (createdAt + expiresIn - 3600)
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package eu.kanade.tachiyomi.data.track.kitsu

import eu.kanade.tachiyomi.data.database.models.Track

@Suppress("TooGenericExceptionThrown")
fun Track.toApiStatus() = when (status) {
Kitsu.READING -> "current"
Kitsu.COMPLETED -> "completed"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ data class KitsuListSearchResult(
val data: List<KitsuListSearchItemData>,
val included: List<KitsuListSearchItemIncluded>,
) {
@Suppress("CyclomaticComplexMethod", "TooGenericExceptionThrown")
fun firstToTrack(): TrackSearch {
require(data.isNotEmpty()) { "Missing data from Kitsu" }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@ data class KitsuOAuth(
val refreshToken: String?,
)

@Suppress("MagicNumber")
fun KitsuOAuth.isExpired() = (System.currentTimeMillis() / 1000) > (createdAt + expiresIn - 3600)
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ data class KitsuAlgoliaSearchItem(
val startDate: Long?,
val endDate: Long?,
) {
@Suppress("MagicNumber")
fun toTrack(): TrackSearch {
return TrackSearch.create(TrackerManager.KITSU).apply {
remote_id = this@KitsuAlgoliaSearchItem.id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ class ShikimoriApi(
}
}

@Suppress("TooGenericExceptionThrown")
suspend fun findLibManga(track: Track, userId: String): Track? {
return withIOContext {
val urlMangas = "$API_URL/mangas".toUri().buildUpon()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import kotlinx.serialization.Serializable

@Serializable
data class SMAddMangaResponse(
val id: Long
val id: Long,
)
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ data class SMOAuth(
)

// Access token lives 1 day
@Suppress("MagicNumber")
fun SMOAuth.isExpired() = (System.currentTimeMillis() / 1000) > (createdAt + expiresIn - 3600)

0 comments on commit 4d24dee

Please sign in to comment.