Automatic Lint

This commit is contained in:
Syer10
2022-09-25 23:15:07 +00:00
parent 92e70bf621
commit 12c4bfdfa4
8 changed files with 39 additions and 40 deletions

View File

@@ -18,9 +18,8 @@ fun String.chop(count: Int, replacement: String = "…"): String {
} }
} }
fun String.addSuffix(char: Char): String { fun String.addSuffix(char: Char): String {
return if (endsWith(char)) { return if (endsWith(char)) {
this this
} else this + char } else this + char
} }

View File

@@ -41,4 +41,4 @@ class FlowIORequestConverter : RequestConverter {
} }
}.flowOn(Dispatchers.IO) }.flowOn(Dispatchers.IO)
} }
} }

View File

@@ -9,4 +9,4 @@ package ca.gosyer.jui.domain
import de.jensklingenberg.ktorfit.Ktorfit import de.jensklingenberg.ktorfit.Ktorfit
import de.jensklingenberg.ktorfit.create import de.jensklingenberg.ktorfit.create
inline fun <reified T> Ktorfit.createIt(): T = create() inline fun <reified T> Ktorfit.createIt(): T = create()

View File

@@ -19,7 +19,7 @@ class UpdateChapterBookmarked @Inject constructor(private val chapterRepository:
suspend fun await( suspend fun await(
mangaId: Long, mangaId: Long,
index: Int, index: Int,
bookmarked: Boolean, bookmarked: Boolean
) = asFlow(mangaId, index, bookmarked) ) = asFlow(mangaId, index, bookmarked)
.catch { log.warn(it) { "Failed to update chapter bookmark for chapter $index of $mangaId" } } .catch { log.warn(it) { "Failed to update chapter bookmark for chapter $index of $mangaId" } }
.collect() .collect()
@@ -27,14 +27,14 @@ class UpdateChapterBookmarked @Inject constructor(private val chapterRepository:
suspend fun await( suspend fun await(
manga: Manga, manga: Manga,
index: Int, index: Int,
bookmarked: Boolean, bookmarked: Boolean
) = asFlow(manga, index, bookmarked) ) = asFlow(manga, index, bookmarked)
.catch { log.warn(it) { "Failed to update chapter bookmark for chapter $index of ${manga.title}(${manga.id})" } } .catch { log.warn(it) { "Failed to update chapter bookmark for chapter $index of ${manga.title}(${manga.id})" } }
.collect() .collect()
suspend fun await( suspend fun await(
chapter: Chapter, chapter: Chapter,
bookmarked: Boolean, bookmarked: Boolean
) = asFlow(chapter, bookmarked) ) = asFlow(chapter, bookmarked)
.catch { log.warn(it) { "Failed to update chapter bookmark for chapter ${chapter.index} of ${chapter.mangaId}" } } .catch { log.warn(it) { "Failed to update chapter bookmark for chapter ${chapter.index} of ${chapter.mangaId}" } }
.collect() .collect()
@@ -42,30 +42,30 @@ class UpdateChapterBookmarked @Inject constructor(private val chapterRepository:
fun asFlow( fun asFlow(
mangaId: Long, mangaId: Long,
index: Int, index: Int,
bookmarked: Boolean, bookmarked: Boolean
) = chapterRepository.updateChapterBookmarked( ) = chapterRepository.updateChapterBookmarked(
mangaId = mangaId, mangaId = mangaId,
chapterIndex = index, chapterIndex = index,
bookmarked = bookmarked, bookmarked = bookmarked
) )
fun asFlow( fun asFlow(
manga: Manga, manga: Manga,
index: Int, index: Int,
bookmarked: Boolean, bookmarked: Boolean
) = chapterRepository.updateChapterBookmarked( ) = chapterRepository.updateChapterBookmarked(
mangaId = manga.id, mangaId = manga.id,
chapterIndex = index, chapterIndex = index,
bookmarked = bookmarked, bookmarked = bookmarked
) )
fun asFlow( fun asFlow(
chapter: Chapter, chapter: Chapter,
bookmarked: Boolean, bookmarked: Boolean
) = chapterRepository.updateChapterBookmarked( ) = chapterRepository.updateChapterBookmarked(
mangaId = chapter.mangaId, mangaId = chapter.mangaId,
chapterIndex = chapter.index, chapterIndex = chapter.index,
bookmarked = bookmarked, bookmarked = bookmarked
) )
companion object { companion object {

View File

@@ -19,7 +19,7 @@ class UpdateChapterLastPageRead @Inject constructor(private val chapterRepositor
suspend fun await( suspend fun await(
mangaId: Long, mangaId: Long,
index: Int, index: Int,
lastPageRead: Int, lastPageRead: Int
) = asFlow(mangaId, index, lastPageRead) ) = asFlow(mangaId, index, lastPageRead)
.catch { log.warn(it) { "Failed to update chapter last page read for chapter $index of $mangaId" } } .catch { log.warn(it) { "Failed to update chapter last page read for chapter $index of $mangaId" } }
.collect() .collect()
@@ -27,14 +27,14 @@ class UpdateChapterLastPageRead @Inject constructor(private val chapterRepositor
suspend fun await( suspend fun await(
manga: Manga, manga: Manga,
index: Int, index: Int,
lastPageRead: Int, lastPageRead: Int
) = asFlow(manga, index, lastPageRead) ) = asFlow(manga, index, lastPageRead)
.catch { log.warn(it) { "Failed to update chapter last page read for chapter $index of ${manga.title}(${manga.id})" } } .catch { log.warn(it) { "Failed to update chapter last page read for chapter $index of ${manga.title}(${manga.id})" } }
.collect() .collect()
suspend fun await( suspend fun await(
chapter: Chapter, chapter: Chapter,
lastPageRead: Int, lastPageRead: Int
) = asFlow(chapter, lastPageRead) ) = asFlow(chapter, lastPageRead)
.catch { log.warn(it) { "Failed to update chapter last page read for chapter ${chapter.index} of ${chapter.mangaId}" } } .catch { log.warn(it) { "Failed to update chapter last page read for chapter ${chapter.index} of ${chapter.mangaId}" } }
.collect() .collect()
@@ -42,30 +42,30 @@ class UpdateChapterLastPageRead @Inject constructor(private val chapterRepositor
fun asFlow( fun asFlow(
mangaId: Long, mangaId: Long,
index: Int, index: Int,
lastPageRead: Int, lastPageRead: Int
) = chapterRepository.updateChapterLastPageRead( ) = chapterRepository.updateChapterLastPageRead(
mangaId = mangaId, mangaId = mangaId,
chapterIndex = index, chapterIndex = index,
lastPageRead = lastPageRead, lastPageRead = lastPageRead
) )
fun asFlow( fun asFlow(
manga: Manga, manga: Manga,
index: Int, index: Int,
lastPageRead: Int, lastPageRead: Int
) = chapterRepository.updateChapterLastPageRead( ) = chapterRepository.updateChapterLastPageRead(
mangaId = manga.id, mangaId = manga.id,
chapterIndex = index, chapterIndex = index,
lastPageRead = lastPageRead, lastPageRead = lastPageRead
) )
fun asFlow( fun asFlow(
chapter: Chapter, chapter: Chapter,
lastPageRead: Int, lastPageRead: Int
) = chapterRepository.updateChapterLastPageRead( ) = chapterRepository.updateChapterLastPageRead(
mangaId = chapter.mangaId, mangaId = chapter.mangaId,
chapterIndex = chapter.index, chapterIndex = chapter.index,
lastPageRead = lastPageRead, lastPageRead = lastPageRead
) )
companion object { companion object {

View File

@@ -38,7 +38,7 @@ class UpdateChapterMarkPreviousRead @Inject constructor(private val chapterRepos
fun asFlow( fun asFlow(
mangaId: Long, mangaId: Long,
index: Int, index: Int
) = chapterRepository.updateChapterMarkPrevRead( ) = chapterRepository.updateChapterMarkPrevRead(
mangaId = mangaId, mangaId = mangaId,
chapterIndex = index chapterIndex = index
@@ -46,17 +46,17 @@ class UpdateChapterMarkPreviousRead @Inject constructor(private val chapterRepos
fun asFlow( fun asFlow(
manga: Manga, manga: Manga,
index: Int, index: Int
) = chapterRepository.updateChapterMarkPrevRead( ) = chapterRepository.updateChapterMarkPrevRead(
mangaId = manga.id, mangaId = manga.id,
chapterIndex = index, chapterIndex = index
) )
fun asFlow( fun asFlow(
chapter: Chapter, chapter: Chapter
) = chapterRepository.updateChapterMarkPrevRead( ) = chapterRepository.updateChapterMarkPrevRead(
mangaId = chapter.mangaId, mangaId = chapter.mangaId,
chapterIndex = chapter.index, chapterIndex = chapter.index
) )
companion object { companion object {

View File

@@ -19,7 +19,7 @@ class UpdateChapterRead @Inject constructor(private val chapterRepository: Chapt
suspend fun await( suspend fun await(
mangaId: Long, mangaId: Long,
index: Int, index: Int,
read: Boolean, read: Boolean
) = asFlow(mangaId, index, read) ) = asFlow(mangaId, index, read)
.catch { log.warn(it) { "Failed to update chapter read status for chapter $index of $mangaId" } } .catch { log.warn(it) { "Failed to update chapter read status for chapter $index of $mangaId" } }
.collect() .collect()
@@ -27,14 +27,14 @@ class UpdateChapterRead @Inject constructor(private val chapterRepository: Chapt
suspend fun await( suspend fun await(
manga: Manga, manga: Manga,
index: Int, index: Int,
read: Boolean, read: Boolean
) = asFlow(manga, index, read) ) = asFlow(manga, index, read)
.catch { log.warn(it) { "Failed to update chapter read status for chapter $index of ${manga.title}(${manga.id})" } } .catch { log.warn(it) { "Failed to update chapter read status for chapter $index of ${manga.title}(${manga.id})" } }
.collect() .collect()
suspend fun await( suspend fun await(
chapter: Chapter, chapter: Chapter,
read: Boolean, read: Boolean
) = asFlow(chapter, read) ) = asFlow(chapter, read)
.catch { log.warn(it) { "Failed to update chapter read status for chapter ${chapter.index} of ${chapter.mangaId}" } } .catch { log.warn(it) { "Failed to update chapter read status for chapter ${chapter.index} of ${chapter.mangaId}" } }
.collect() .collect()
@@ -42,30 +42,30 @@ class UpdateChapterRead @Inject constructor(private val chapterRepository: Chapt
fun asFlow( fun asFlow(
mangaId: Long, mangaId: Long,
index: Int, index: Int,
read: Boolean, read: Boolean
) = chapterRepository.updateChapterRead( ) = chapterRepository.updateChapterRead(
mangaId = mangaId, mangaId = mangaId,
chapterIndex = index, chapterIndex = index,
read = read, read = read
) )
fun asFlow( fun asFlow(
manga: Manga, manga: Manga,
index: Int, index: Int,
read: Boolean, read: Boolean
) = chapterRepository.updateChapterRead( ) = chapterRepository.updateChapterRead(
mangaId = manga.id, mangaId = manga.id,
chapterIndex = index, chapterIndex = index,
read = read, read = read
) )
fun asFlow( fun asFlow(
chapter: Chapter, chapter: Chapter,
read: Boolean, read: Boolean
) = chapterRepository.updateChapterRead( ) = chapterRepository.updateChapterRead(
mangaId = chapter.mangaId, mangaId = chapter.mangaId,
chapterIndex = chapter.index, chapterIndex = chapter.index,
read = read, read = read
) )
companion object { companion object {

View File

@@ -45,13 +45,13 @@ interface ChapterRepository {
@Field("markPrevRead") markPreviousRead: Boolean? = null @Field("markPrevRead") markPreviousRead: Boolean? = null
): Flow<HttpResponse>*/ ): Flow<HttpResponse>*/
//todo remove following updateChapter functions once ktorfit supports nullable parameters // todo remove following updateChapter functions once ktorfit supports nullable parameters
@FormUrlEncoded @FormUrlEncoded
@PATCH("api/v1/manga/{mangaId}/chapter/{chapterIndex}") @PATCH("api/v1/manga/{mangaId}/chapter/{chapterIndex}")
fun updateChapterRead( fun updateChapterRead(
@Path("mangaId") mangaId: Long, @Path("mangaId") mangaId: Long,
@Path("chapterIndex") chapterIndex: Int, @Path("chapterIndex") chapterIndex: Int,
@Field("read") read: Boolean, @Field("read") read: Boolean
): Flow<HttpResponse> ): Flow<HttpResponse>
@FormUrlEncoded @FormUrlEncoded
@@ -59,7 +59,7 @@ interface ChapterRepository {
fun updateChapterBookmarked( fun updateChapterBookmarked(
@Path("mangaId") mangaId: Long, @Path("mangaId") mangaId: Long,
@Path("chapterIndex") chapterIndex: Int, @Path("chapterIndex") chapterIndex: Int,
@Field("bookmarked") bookmarked: Boolean, @Field("bookmarked") bookmarked: Boolean
): Flow<HttpResponse> ): Flow<HttpResponse>
@FormUrlEncoded @FormUrlEncoded
@@ -67,7 +67,7 @@ interface ChapterRepository {
fun updateChapterLastPageRead( fun updateChapterLastPageRead(
@Path("mangaId") mangaId: Long, @Path("mangaId") mangaId: Long,
@Path("chapterIndex") chapterIndex: Int, @Path("chapterIndex") chapterIndex: Int,
@Field("lastPageRead") lastPageRead: Int, @Field("lastPageRead") lastPageRead: Int
): Flow<HttpResponse> ): Flow<HttpResponse>
@FormUrlEncoded @FormUrlEncoded