From 09abfc7843ef69d65cb4f1a3459ff8ee2718e4f7 Mon Sep 17 00:00:00 2001 From: Andreas Date: Thu, 18 Aug 2022 20:06:32 +0200 Subject: [PATCH] Lint changes (#7802) - Fixes current lint issues - Changes lint task to lintKotlin on PRs --- app/build.gradle.kts | 7 ++++++- .../main/java/eu/kanade/tachiyomi/Migrations.kt | 4 ++-- .../tachiyomi/data/backup/models/BackupChapter.kt | 14 +------------- .../tachiyomi/data/backup/models/BackupTracking.kt | 14 +------------- .../tachiyomi/data/preference/PreferenceValues.kt | 2 ++ .../java/eu/kanade/tachiyomi/source/LocalSource.kt | 4 +++- .../ui/setting/SettingsAdvancedController.kt | 2 +- .../eu/kanade/tachiyomi/util/system/ImageUtil.kt | 4 +++- build.gradle.kts | 7 +++++-- 9 files changed, 24 insertions(+), 34 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 8a2b1ba0bb..8f96c39770 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -290,6 +290,10 @@ tasks { } } + withType().configureEach { + exclude { it.file.path.contains("generated[\\\\/]".toRegex())} + } + // See https://kotlinlang.org/docs/reference/experimental.html#experimental-status-of-experimental-api(-markers) withType { kotlinOptions.freeCompilerArgs += listOf( @@ -315,7 +319,8 @@ tasks { } preBuild { - dependsOn(formatKotlin, copyHebrewStrings, localesConfigTask) + val ktlintTask = if (System.getenv("GITHUB_BASE_REF") == null) formatKotlin else lintKotlin + dependsOn(ktlintTask, copyHebrewStrings, localesConfigTask) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt b/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt index 10bdd4ce42..2b5320897c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt @@ -103,9 +103,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 } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/models/BackupChapter.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/models/BackupChapter.kt index 9170140803..19a81fc601 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/models/BackupChapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/models/BackupChapter.kt @@ -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, diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/models/BackupTracking.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/models/BackupTracking.kt index 8a04f8796b..a9cf7e57a9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/models/BackupTracking.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/models/BackupTracking.kt @@ -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, diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceValues.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceValues.kt index c5965588e3..7b35fefe7b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceValues.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceValues.kt @@ -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 */ diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt b/app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt index 1f6764c388..75c4720690 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt @@ -98,7 +98,9 @@ class LocalSource( } } - else -> { /* Do nothing */ } + else -> { + /* Do nothing */ + } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt index ab7f4b55b6..0c34cf1d36 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt @@ -21,12 +21,12 @@ import eu.kanade.tachiyomi.network.PREF_DOH_360 import eu.kanade.tachiyomi.network.PREF_DOH_ADGUARD import eu.kanade.tachiyomi.network.PREF_DOH_ALIDNS import eu.kanade.tachiyomi.network.PREF_DOH_CLOUDFLARE +import eu.kanade.tachiyomi.network.PREF_DOH_CONTROLD import eu.kanade.tachiyomi.network.PREF_DOH_DNSPOD import eu.kanade.tachiyomi.network.PREF_DOH_GOOGLE import eu.kanade.tachiyomi.network.PREF_DOH_MULLVAD import eu.kanade.tachiyomi.network.PREF_DOH_QUAD101 import eu.kanade.tachiyomi.network.PREF_DOH_QUAD9 -import eu.kanade.tachiyomi.network.PREF_DOH_CONTROLD import eu.kanade.tachiyomi.ui.base.controller.openInBrowser import eu.kanade.tachiyomi.ui.base.controller.pushController import eu.kanade.tachiyomi.ui.setting.database.ClearDatabaseController diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/system/ImageUtil.kt b/app/src/main/java/eu/kanade/tachiyomi/util/system/ImageUtil.kt index 2d9bec7183..2f1d995cbd 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/system/ImageUtil.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/system/ImageUtil.kt @@ -82,7 +82,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 } diff --git a/build.gradle.kts b/build.gradle.kts index 1bb42db5ef..56f7124c1f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -26,8 +26,11 @@ subprojects { kotlinter { experimentalRules = true - // Doesn't play well with Android Studio - disabledRules = arrayOf("experimental:argument-list-wrapping") + + disabledRules = arrayOf( + "experimental:argument-list-wrapping", // Doesn't play well with Android Studio + "filename", // Often broken to give a more general name + ) } }