Switch to a new Ktlint Formatter (#705)

* Switch to new Ktlint plugin

* Add ktlintCheck to PR builds

* Run formatter

* Put ktlint version in libs toml

* Fix lint

* Use Zip4Java from libs.toml
This commit is contained in:
Mitchell Syer
2023-10-06 23:38:39 -04:00
committed by GitHub
parent 3cd3cb0186
commit 849acfca3d
277 changed files with 6709 additions and 5090 deletions

View File

@@ -9,8 +9,13 @@ import com.fasterxml.jackson.annotation.JsonValue
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
enum class IncludeInUpdate(@JsonValue val value: Int) {
EXCLUDE(0), INCLUDE(1), UNSET(-1);
enum class IncludeInUpdate(
@JsonValue val value: Int,
) {
EXCLUDE(0),
INCLUDE(1),
UNSET(-1),
;
companion object {
fun fromValue(value: Int) = IncludeInUpdate.values().find { it.value == value } ?: UNSET
@@ -24,5 +29,5 @@ data class CategoryDataClass(
val default: Boolean,
val size: Int,
val includeInUpdate: IncludeInUpdate,
val meta: Map<String, String> = emptyMap()
val meta: Map<String, String> = emptyMap(),
)

View File

@@ -15,38 +15,27 @@ data class ChapterDataClass(
val chapterNumber: Float,
val scanlator: String?,
val mangaId: Int,
/** chapter is read */
val read: Boolean,
/** chapter is bookmarked */
val bookmarked: Boolean,
/** last read page, zero means not read/no data */
val lastPageRead: Int,
/** last read page, zero means not read/no data */
val lastReadAt: Long,
// TODO(v0.6.0): rename to sourceOrder
/** this chapter's index, starts with 1 */
val index: Int,
/** the date we fist saw this chapter*/
val fetchedAt: Long,
/** the website url of this chapter*/
val realUrl: String? = null,
/** is chapter downloaded */
val downloaded: Boolean,
/** used to construct pages in the front-end */
val pageCount: Int = -1,
/** total chapter count, used to calculate if there's a next and prev chapter */
val chapterCount: Int? = null,
/** used to store client specific values */
val meta: Map<String, String> = emptyMap()
val meta: Map<String, String> = emptyMap(),
)

View File

@@ -10,15 +10,13 @@ package suwayomi.tachidesk.manga.model.dataclass
data class ExtensionDataClass(
val apkName: String,
val iconUrl: String,
val name: String,
val pkgName: String,
val versionName: String,
val versionCode: Int,
val lang: String,
val isNsfw: Boolean,
val installed: Boolean,
val hasUpdate: Boolean,
val obsolete: Boolean
val obsolete: Boolean,
)

View File

@@ -9,5 +9,5 @@ package suwayomi.tachidesk.manga.model.dataclass
data class MangaChapterDataClass(
val manga: MangaDataClass,
val chapter: ChapterDataClass
val chapter: ChapterDataClass,
)

View File

@@ -15,14 +15,11 @@ import java.time.Instant
data class MangaDataClass(
val id: Int,
val sourceId: String,
val url: String,
val title: String,
val thumbnailUrl: String? = null,
val thumbnailUrlLastFetched: Long = 0,
val initialized: Boolean = false,
val artist: String? = null,
val author: String? = null,
val description: String? = null,
@@ -31,30 +28,25 @@ data class MangaDataClass(
val inLibrary: Boolean = false,
val inLibraryAt: Long = 0,
val source: SourceDataClass? = null,
/** meta data for clients */
val meta: Map<String, String> = emptyMap(),
val realUrl: String? = null,
var lastFetchedAt: Long? = 0,
var chaptersLastFetchedAt: Long? = 0,
var updateStrategy: UpdateStrategy = UpdateStrategy.ALWAYS_UPDATE,
val freshData: Boolean = false,
var unreadCount: Long? = null,
var downloadCount: Long? = null,
var chapterCount: Long? = null,
var lastReadAt: Long? = null,
var lastChapterRead: ChapterDataClass? = null,
val age: Long? = if (lastFetchedAt == null) 0 else Instant.now().epochSecond.minus(lastFetchedAt),
val chaptersAge: Long? = if (chaptersLastFetchedAt == null) null else Instant.now().epochSecond.minus(chaptersLastFetchedAt)
val chaptersAge: Long? = if (chaptersLastFetchedAt == null) null else Instant.now().epochSecond.minus(chaptersLastFetchedAt),
)
data class PagedMangaListDataClass(
val mangaList: List<MangaDataClass>,
val hasNextPage: Boolean
val hasNextPage: Boolean,
)
internal fun String?.toGenreList() = this?.split(",")?.trimAll().orEmpty()

View File

@@ -9,5 +9,5 @@ package suwayomi.tachidesk.manga.model.dataclass
data class PageDataClass(
val index: Int,
var imageUrl: String
var imageUrl: String,
)

View File

@@ -11,15 +11,15 @@ import kotlin.math.min
open class PaginatedList<T>(
val page: List<T>,
val hasNextPage: Boolean
val hasNextPage: Boolean,
)
const val PaginationFactor = 50
const val PAGINATION_FACTOR = 50
fun <T> paginatedFrom(
pageNum: Int,
paginationFactor: Int = PaginationFactor,
lister: () -> List<T>
paginationFactor: Int = PAGINATION_FACTOR,
lister: () -> List<T>,
): PaginatedList<T> {
val list = lister()
val lastIndex = list.size - 1
@@ -35,6 +35,6 @@ fun <T> paginatedFrom(
return PaginatedList(
sliced,
higherIndex < lastIndex
higherIndex < lastIndex,
)
}

View File

@@ -14,16 +14,12 @@ data class SourceDataClass(
val name: String,
val lang: String,
val iconUrl: String,
/** The Source provides a latest listing */
val supportsLatest: Boolean,
/** The Source implements [ConfigurableSource] */
val isConfigurable: Boolean,
/** The Source class has a @Nsfw annotation */
val isNsfw: Boolean,
/** A nicer version of [name] */
val displayName: String
val displayName: String,
)

View File

@@ -20,12 +20,13 @@ object CategoryTable : IntIdTable() {
val includeInUpdate = integer("include_in_update").default(IncludeInUpdate.UNSET.value)
}
fun CategoryTable.toDataClass(categoryEntry: ResultRow) = CategoryDataClass(
categoryEntry[id].value,
categoryEntry[order],
categoryEntry[name],
categoryEntry[isDefault],
Category.getCategorySize(categoryEntry[id].value),
IncludeInUpdate.fromValue(categoryEntry[includeInUpdate]),
Category.getCategoryMetaMap(categoryEntry[id].value)
)
fun CategoryTable.toDataClass(categoryEntry: ResultRow) =
CategoryDataClass(
categoryEntry[id].value,
categoryEntry[order],
categoryEntry[name],
categoryEntry[isDefault],
Category.getCategorySize(categoryEntry[id].value),
IncludeInUpdate.fromValue(categoryEntry[includeInUpdate]),
Category.getCategoryMetaMap(categoryEntry[id].value),
)

View File

@@ -60,5 +60,5 @@ fun ChapterTable.toDataClass(chapterEntry: ResultRow) =
downloaded = chapterEntry[isDownloaded],
pageCount = chapterEntry[pageCount],
chapterCount = transaction { ChapterTable.select { manga eq chapterEntry[manga].value }.count().toInt() },
meta = getChapterMetaMap(chapterEntry[id])
meta = getChapterMetaMap(chapterEntry[id]),
)

View File

@@ -13,8 +13,12 @@ object ExtensionTable : IntIdTable() {
val apkName = varchar("apk_name", 1024)
// default is the local source icon from tachiyomi
val iconUrl = varchar("icon_url", 2048)
.default("https://raw.githubusercontent.com/tachiyomiorg/tachiyomi/64ba127e7d43b1d7e6d58a6f5c9b2bd5fe0543f7/app/src/main/res/mipmap-xxxhdpi/ic_local_source.webp")
@Suppress("ktlint:standard:max-line-length")
val iconUrl =
varchar("icon_url", 2048)
.default(
"https://raw.githubusercontent.com/tachiyomiorg/tachiyomi/64ba127e7d43b1d7e6d58a6f5c9b2bd5fe0543f7/app/src/main/res/mipmap-xxxhdpi/ic_local_source.webp",
)
val name = varchar("name", 128)
val pkgName = varchar("pkg_name", 128)

View File

@@ -50,14 +50,11 @@ fun MangaTable.toDataClass(mangaEntry: ResultRow) =
MangaDataClass(
id = mangaEntry[this.id].value,
sourceId = mangaEntry[sourceReference].toString(),
url = mangaEntry[url],
title = mangaEntry[title],
thumbnailUrl = proxyThumbnailUrl(mangaEntry[this.id].value),
thumbnailUrlLastFetched = mangaEntry[thumbnailUrlLastFetched],
initialized = mangaEntry[initialized],
artist = mangaEntry[artist],
author = mangaEntry[author],
description = mangaEntry[description],
@@ -69,7 +66,7 @@ fun MangaTable.toDataClass(mangaEntry: ResultRow) =
realUrl = mangaEntry[realUrl],
lastFetchedAt = mangaEntry[lastFetchedAt],
chaptersLastFetchedAt = mangaEntry[chaptersLastFetchedAt],
updateStrategy = UpdateStrategy.valueOf(mangaEntry[updateStrategy])
updateStrategy = UpdateStrategy.valueOf(mangaEntry[updateStrategy]),
)
enum class MangaStatus(val value: Int) {
@@ -79,7 +76,8 @@ enum class MangaStatus(val value: Int) {
LICENSED(3),
PUBLISHING_FINISHED(4),
CANCELLED(5),
ON_HIATUS(6);
ON_HIATUS(6),
;
companion object {
fun valueOf(value: Int): MangaStatus = values().find { it.value == value } ?: UNKNOWN