Lint changes (#7802)

- Fixes current lint issues
- Changes lint task to lintKotlin on PRs

(cherry picked from commit 09abfc7843ef69d65cb4f1a3459ff8ee2718e4f7)

# Conflicts:
#	app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt
#	build.gradle.kts
This commit is contained in:
Andreas 2022-08-18 20:06:32 +02:00 committed by Jobobby04
parent 128a868ffb
commit b9db59fa45
12 changed files with 64 additions and 97 deletions

View File

@ -296,6 +296,10 @@ tasks {
}
}
withType<org.jmailen.gradle.kotlinter.tasks.LintTask>().configureEach {
exclude { it.file.path.contains("generated[\\\\/]".toRegex())}
}
// See https://kotlinlang.org/docs/reference/experimental.html#experimental-status-of-experimental-api(-markers)
withType<KotlinCompile> {
kotlinOptions.freeCompilerArgs += listOf(
@ -321,7 +325,8 @@ tasks {
}
preBuild {
dependsOn(formatKotlin, copyHebrewStrings, localesConfigTask)
val ktlintTask = if (System.getenv("GITHUB_BASE_REF") == null) formatKotlin else lintKotlin
dependsOn(ktlintTask, copyHebrewStrings, localesConfigTask)
}
}

View File

@ -2,29 +2,19 @@ package eu.kanade.data.exh
import exh.merged.sql.models.MergedMangaReference
val mergedMangaReferenceMapper = {
id: Long,
isInfoManga: Boolean,
getChapterUpdates: Boolean,
chapterSortMode: Long,
chapterPriority: Long,
downloadChapters: Boolean,
mergeId: Long,
mergeUrl: String,
mangaId: Long?,
mangaUrl: String,
mangaSourceId: Long, ->
MergedMangaReference(
id = id,
isInfoManga = isInfoManga,
getChapterUpdates = getChapterUpdates,
chapterSortMode = chapterSortMode.toInt(),
chapterPriority = chapterPriority.toInt(),
downloadChapters = downloadChapters,
mergeId = mergeId,
mergeUrl = mergeUrl,
mangaId = mangaId,
mangaUrl = mangaUrl,
mangaSourceId = mangaSourceId,
)
}
val mergedMangaReferenceMapper =
{ id: Long, isInfoManga: Boolean, getChapterUpdates: Boolean, chapterSortMode: Long, chapterPriority: Long, downloadChapters: Boolean, mergeId: Long, mergeUrl: String, mangaId: Long?, mangaUrl: String, mangaSourceId: Long ->
MergedMangaReference(
id = id,
isInfoManga = isInfoManga,
getChapterUpdates = getChapterUpdates,
chapterSortMode = chapterSortMode.toInt(),
chapterPriority = chapterPriority.toInt(),
downloadChapters = downloadChapters,
mergeId = mergeId,
mergeUrl = mergeUrl,
mangaId = mangaId,
mangaUrl = mangaUrl,
mangaSourceId = mangaSourceId,
)
}

View File

@ -105,9 +105,9 @@ object Migrations {
// Reset sorting preference if using removed sort by source
val oldSortingMode = prefs.getInt(PreferenceKeys.librarySortingMode, 0)
if (oldSortingMode == 5 /* SOURCE */) {
if (oldSortingMode == 5) { // SOURCE = 5
prefs.edit {
putInt(PreferenceKeys.librarySortingMode, 0 /* ALPHABETICAL */)
putInt(PreferenceKeys.librarySortingMode, 0) // ALPHABETICAL = 0
}
}
}

View File

@ -37,19 +37,7 @@ data class BackupChapter(
}
}
val backupChapterMapper = {
_: Long,
_: Long,
url: String,
name: String,
scanlator: String?,
read: Boolean,
bookmark: Boolean,
lastPageRead: Long,
chapterNumber: Float,
source_order: Long,
dateFetch: Long,
dateUpload: Long, ->
val backupChapterMapper = { _: Long, _: Long, url: String, name: String, scanlator: String?, read: Boolean, bookmark: Boolean, lastPageRead: Long, chapterNumber: Float, source_order: Long, dateFetch: Long, dateUpload: Long ->
BackupChapter(
url = url,
name = name,

View File

@ -35,26 +35,16 @@ data class BackupMergedMangaReference(
}
}
val backupMergedMangaReferenceMapper = {
_: Long,
isInfoManga: Boolean,
getChapterUpdates: Boolean,
chapterSortMode: Long,
chapterPriority: Long,
downloadChapters: Boolean,
_: Long,
mergeUrl: String,
_: Long?,
mangaUrl: String,
mangaSourceId: Long, ->
BackupMergedMangaReference(
isInfoManga = isInfoManga,
getChapterUpdates = getChapterUpdates,
chapterSortMode = chapterSortMode.toInt(),
chapterPriority = chapterPriority.toInt(),
downloadChapters = downloadChapters,
mergeUrl = mergeUrl,
mangaUrl = mangaUrl,
mangaSourceId = mangaSourceId,
)
}
val backupMergedMangaReferenceMapper =
{ _: Long, isInfoManga: Boolean, getChapterUpdates: Boolean, chapterSortMode: Long, chapterPriority: Long, downloadChapters: Boolean, _: Long, mergeUrl: String, _: Long?, mangaUrl: String, mangaSourceId: Long ->
BackupMergedMangaReference(
isInfoManga = isInfoManga,
getChapterUpdates = getChapterUpdates,
chapterSortMode = chapterSortMode.toInt(),
chapterPriority = chapterPriority.toInt(),
downloadChapters = downloadChapters,
mergeUrl = mergeUrl,
mangaUrl = mangaUrl,
mangaSourceId = mangaSourceId,
)
}

View File

@ -14,16 +14,12 @@ data class BackupSavedSearch(
@ProtoNumber(4) val source: Long = 0,
)
val backupSavedSearchMapper = {
_: Long,
source: Long,
name: String,
query: String?,
filtersJson: String?, ->
BackupSavedSearch(
source = source,
name = name,
query = query.orEmpty(),
filterList = filtersJson ?: "[]",
)
}
val backupSavedSearchMapper =
{ _: Long, source: Long, name: String, query: String?, filtersJson: String? ->
BackupSavedSearch(
source = source,
name = name,
query = query.orEmpty(),
filterList = filtersJson ?: "[]",
)
}

View File

@ -51,19 +51,7 @@ data class BackupTracking(
}
val backupTrackMapper = {
_id: Long,
manga_id: Long,
syncId: Long,
mediaId: Long,
libraryId: Long?,
title: String,
lastChapterRead: Double,
totalChapters: Long,
status: Long,
score: Float,
remoteUrl: String,
startDate: Long,
finishDate: Long, ->
_: Long, _: Long, syncId: Long, mediaId: Long, libraryId: Long?, title: String, lastChapterRead: Double, totalChapters: Long, status: Long, score: Float, remoteUrl: String, startDate: Long, finishDate: Long ->
BackupTracking(
syncId = syncId.toInt(),
mediaId = mediaId,

View File

@ -19,11 +19,13 @@ object PreferenceValues {
/* ktlint-disable experimental:enum-entry-name-case */
// Keys are lowercase to match legacy string values
/* ktlint-disable enum-entry-name-case */
enum class ThemeMode {
light,
dark,
system,
}
/* ktlint-enable enum-entry-name-case */
/* ktlint-enable experimental:enum-entry-name-case */

View File

@ -103,7 +103,9 @@ class LocalSource(
}
}
else -> { /* Do nothing */ }
else -> {
/* Do nothing */
}
}
}

View File

@ -83,7 +83,9 @@ object ImageUtil {
Format.Webp -> type.isAnimated && Build.VERSION.SDK_INT >= Build.VERSION_CODES.P
else -> false
}
} catch (e: Exception) { /* Do Nothing */ }
} catch (e: Exception) {
/* Do Nothing */
}
return false
}

View File

@ -87,7 +87,7 @@ object Entry {
override val key = "uh"
}
/* ktlint-disable experimental:enum-entry-name-case */
/* ktlint-disable enum-entry-name-case */
enum class ImageSize(override val value: String) : ConfigItem {
AUTO("0"),
`2400`("5"),
@ -131,7 +131,7 @@ object Entry {
override val key = "tr"
}
/* ktlint-enable experimental:enum-entry-name-case */
/* ktlint-enable enum-entry-name-case */
enum class UseOriginalImages(override val value: String) : ConfigItem {
NO("0"),

View File

@ -27,8 +27,12 @@ subprojects {
kotlinter {
experimentalRules = true
// Doesn't play well with Android Studio
disabledRules = arrayOf("experimental:argument-list-wrapping", "experimental:comment-wrapping")
disabledRules = arrayOf(
"experimental:argument-list-wrapping", // Doesn't play well with Android Studio
"experimental:comment-wrapping", // Doesn't play nice with SY specifiers
"filename", // Often broken to give a more general name
)
}
}