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) // See https://kotlinlang.org/docs/reference/experimental.html#experimental-status-of-experimental-api(-markers)
withType<KotlinCompile> { withType<KotlinCompile> {
kotlinOptions.freeCompilerArgs += listOf( kotlinOptions.freeCompilerArgs += listOf(
@ -321,7 +325,8 @@ tasks {
} }
preBuild { preBuild {
dependsOn(formatKotlin, copyHebrewStrings, localesConfigTask) val ktlintTask = if (System.getenv("GITHUB_BASE_REF") == null) formatKotlin else lintKotlin
dependsOn(ktlintTask, copyHebrewStrings, localesConfigTask)
} }
} }

View File

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

View File

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

View File

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

View File

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

View File

@ -14,12 +14,8 @@ data class BackupSavedSearch(
@ProtoNumber(4) val source: Long = 0, @ProtoNumber(4) val source: Long = 0,
) )
val backupSavedSearchMapper = { val backupSavedSearchMapper =
_: Long, { _: Long, source: Long, name: String, query: String?, filtersJson: String? ->
source: Long,
name: String,
query: String?,
filtersJson: String?, ->
BackupSavedSearch( BackupSavedSearch(
source = source, source = source,
name = name, name = name,

View File

@ -51,19 +51,7 @@ data class BackupTracking(
} }
val backupTrackMapper = { val backupTrackMapper = {
_id: 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 ->
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, ->
BackupTracking( BackupTracking(
syncId = syncId.toInt(), syncId = syncId.toInt(),
mediaId = mediaId, mediaId = mediaId,

View File

@ -19,11 +19,13 @@ object PreferenceValues {
/* ktlint-disable experimental:enum-entry-name-case */ /* ktlint-disable experimental:enum-entry-name-case */
// Keys are lowercase to match legacy string values // Keys are lowercase to match legacy string values
/* ktlint-disable enum-entry-name-case */
enum class ThemeMode { enum class ThemeMode {
light, light,
dark, dark,
system, system,
} }
/* ktlint-enable enum-entry-name-case */
/* ktlint-enable experimental: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 Format.Webp -> type.isAnimated && Build.VERSION.SDK_INT >= Build.VERSION_CODES.P
else -> false else -> false
} }
} catch (e: Exception) { /* Do Nothing */ } } catch (e: Exception) {
/* Do Nothing */
}
return false return false
} }

View File

@ -87,7 +87,7 @@ object Entry {
override val key = "uh" 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 { enum class ImageSize(override val value: String) : ConfigItem {
AUTO("0"), AUTO("0"),
`2400`("5"), `2400`("5"),
@ -131,7 +131,7 @@ object Entry {
override val key = "tr" 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 { enum class UseOriginalImages(override val value: String) : ConfigItem {
NO("0"), NO("0"),

View File

@ -27,8 +27,12 @@ subprojects {
kotlinter { kotlinter {
experimentalRules = true 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
)
} }
} }