Annoying. More annoying in this project.

(cherry picked from commit 777ae2461e1eb277a3aa0c998ff69e4f100387a1)
This commit is contained in:
AntsyLich 2024-08-19 12:51:37 +06:00 committed by Cuong-Tran
parent 20b02f0894
commit 335f0956b4
No known key found for this signature in database
GPG key ID: 733AA7624B9315C2
43 changed files with 5 additions and 2423 deletions

View file

@ -24,10 +24,6 @@ Before you start, please note that the ability to use following technologies is
- [Android Studio](https://developer.android.com/studio)
- Emulator or phone with developer options enabled to test changes.
## Linting
Run the `detekt` gradle task. If the build fails, a report of issues can be found in `app/build/reports/detekt/`. The report is availble in several formats and details each issue that needs attention.
## Getting help
- Join [the Discord server](https://discord.gg/85jB7V5AJR) for online help and to ask questions while developing.

View file

@ -101,7 +101,6 @@ import uy.kohesive.injekt.api.get
import java.io.File
object SettingsAdvancedScreen : SearchableSettings {
@Suppress("unused")
private fun readResolve(): Any = SettingsAdvancedScreen
@ReadOnlyComposable

View file

@ -55,7 +55,6 @@ import tachiyomi.presentation.core.i18n.stringResource
import cafe.adriel.voyager.core.screen.Screen as VoyagerScreen
object SettingsMainScreen : Screen() {
@Suppress("unused")
private fun readResolve(): Any = SettingsMainScreen
@Composable

View file

@ -25,7 +25,6 @@ import uy.kohesive.injekt.api.get
import java.text.NumberFormat
object SettingsReaderScreen : SearchableSettings {
@Suppress("unused")
private fun readResolve(): Any = SettingsReaderScreen
@ReadOnlyComposable

View file

@ -59,7 +59,6 @@ import java.time.LocalDateTime
import java.time.ZoneId
object AboutScreen : Screen() {
@Suppress("unused")
private fun readResolve(): Any = AboutScreen
@Composable

View file

@ -1,6 +1,5 @@
package eu.kanade.presentation.util
import android.annotation.SuppressLint
import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.AnimatedContentTransitionScope
import androidx.compose.animation.ContentTransform
@ -31,7 +30,6 @@ import soup.compose.material.motion.animation.rememberSlideDistance
/**
* For invoking back press to the parent activity
*/
@SuppressLint("ComposeCompositionLocalUsage")
val LocalBackPress: ProvidableCompositionLocal<(() -> Unit)?> = staticCompositionLocalOf { null }
interface Tab : cafe.adriel.voyager.navigator.tab.Tab {

View file

@ -210,7 +210,6 @@ class App : Application(), DefaultLifecycleObserver, SingletonImageLoader.Factor
)
}
@Suppress("MagicNumber")
override fun newImageLoader(context: Context): ImageLoader {
return ImageLoader.Builder(this).apply {
val callFactoryLazy = lazy { Injekt.get<NetworkHelper>().client }

View file

@ -3,7 +3,6 @@ package eu.kanade.tachiyomi.data.backup.models
import kotlinx.serialization.Serializable
import kotlinx.serialization.protobuf.ProtoNumber
@Suppress("MagicNumber")
@Serializable
data class Backup(
@ProtoNumber(1) val backupManga: List<BackupManga>,

View file

@ -4,7 +4,6 @@ import kotlinx.serialization.Serializable
import kotlinx.serialization.protobuf.ProtoNumber
import tachiyomi.domain.chapter.model.Chapter
@Suppress("MagicNumber")
@Serializable
data class BackupChapter(
// in 1.x some of these values have different names

View file

@ -4,7 +4,6 @@ import kotlinx.serialization.Serializable
import kotlinx.serialization.protobuf.ProtoNumber
import mihon.domain.extensionrepo.model.ExtensionRepo
@Suppress("MagicNumber")
@Serializable
class BackupExtensionRepos(
@ProtoNumber(1) var baseUrl: String,

View file

@ -3,13 +3,9 @@ package eu.kanade.tachiyomi.data.backup.models
import eu.kanade.tachiyomi.source.model.UpdateStrategy
import kotlinx.serialization.Serializable
import kotlinx.serialization.protobuf.ProtoNumber
import tachiyomi.domain.manga.model.CustomMangaInfo
import tachiyomi.domain.manga.model.Manga
@Suppress(
"DEPRECATION",
"MagicNumber",
)
@Suppress("DEPRECATION")
@Serializable
data class BackupManga(
// in 1.x some of these values have different names

View file

@ -53,7 +53,6 @@ import java.io.IOException
* Available request parameter:
* - [USE_CUSTOM_COVER_KEY]: Use custom cover if set by user, default is true
*/
@Suppress("LongParameterList")
class MangaCoverFetcher(
// KMK -->
private val mangaCover: MangaCover,

View file

@ -26,7 +26,6 @@ import tachiyomi.domain.source.service.SourceManager
import uy.kohesive.injekt.injectLazy
import java.io.File
import java.io.IOException
import java.net.HttpURLConnection.HTTP_NOT_MODIFIED
/**
* A [Fetcher] that fetches page preview image for [PagePreview] object.
@ -34,7 +33,6 @@ import java.net.HttpURLConnection.HTTP_NOT_MODIFIED
* Disk caching is handled by [PagePreviewCache], otherwise
* handled by Coil's [DiskCache].
*/
@Suppress("LongParameterList")
class PagePreviewFetcher(
private val page: PagePreview,
private val options: Options,

View file

@ -226,7 +226,6 @@ internal object ExtensionLoader {
* @param context The application context.
* @param extensionInfo The extension to load.
*/
@Suppress("LongMethod", "CyclomaticComplexMethod", "ReturnCount")
private suspend fun loadExtension(context: Context, extensionInfo: ExtensionInfo): LoadResult {
val pkgManager = context.packageManager
val pkgInfo = extensionInfo.packageInfo

View file

@ -63,7 +63,6 @@ import tachiyomi.presentation.core.screens.EmptyScreen
import kotlin.math.roundToInt
object DownloadQueueScreen : Screen() {
@Suppress("unused")
private fun readResolve(): Any = DownloadQueueScreen
@Composable

View file

@ -39,7 +39,6 @@ import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
object HistoryTab : Tab {
@Suppress("unused")
private fun readResolve(): Any = HistoryTab
private val snackbarHostState = SnackbarHostState()

View file

@ -65,7 +65,6 @@ import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
object HomeScreen : Screen() {
@Suppress("unused")
private fun readResolve(): Any = HomeScreen
private val librarySearchEvent = Channel<String>()

View file

@ -286,7 +286,6 @@ class LibraryScreenModel(
/**
* Applies library filters to the given map of manga.
*/
@Suppress("LongMethod", "CyclomaticComplexMethod")
private suspend fun LibraryMap.applyFilters(
trackMap: Map<Long, List<Track>>,
trackingFiler: Map<Long, TriState>,
@ -381,7 +380,6 @@ class LibraryScreenModel(
/**
* Applies library sorting to the given map of manga.
*/
@Suppress("LongMethod", "CyclomaticComplexMethod")
private fun LibraryMap.applySort(
// Map<MangaId, List<Track>>
trackMap: Map<Long, List<Track>>,

View file

@ -76,7 +76,6 @@ import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
object LibraryTab : Tab {
@Suppress("unused")
private fun readResolve(): Any = LibraryTab
override val options: TabOptions

View file

@ -43,7 +43,6 @@ import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
object MoreTab : Tab {
@Suppress("unused")
private fun readResolve(): Any = MoreTab
override val options: TabOptions

View file

@ -87,7 +87,6 @@ class PagerPageHolder(
/**
* Called when this view is detached from the window. Unsubscribes any active subscription.
*/
@SuppressLint("ClickableViewAccessibility")
override fun onDetachedFromWindow() {
super.onDetachedFromWindow()
loadJob?.cancel()

View file

@ -38,7 +38,6 @@ import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
object UpdatesTab : Tab {
@Suppress("unused")
private fun readResolve(): Any = UpdatesTab
override val options: TabOptions

View file

@ -21,6 +21,7 @@ object InternalResourceHelper {
* @param type resource type of [resName] to get
* @return 0 if not available
*/
@Suppress("SameParameterValue")
@SuppressLint("DiscouragedApi")
private fun getResourceId(resName: String, type: String): Int {
return Resources.getSystem().getIdentifier(resName, type, "android")

View file

@ -6,7 +6,6 @@ import eu.kanade.tachiyomi.network.interceptor.rateLimitHost
import eu.kanade.tachiyomi.source.model.Page
import exh.md.dto.MangaPlusPage
import exh.md.dto.MangaPlusResponse
import kotlinx.serialization.decodeFromString
import kotlinx.serialization.json.Json
import okhttp3.Headers
import okhttp3.HttpUrl.Companion.toHttpUrl

View file

@ -158,7 +158,6 @@ class SmartSearchEngine(
if (closingBracketDepthIndex != null) {
depthPairs[closingBracketDepthIndex]--
} else {
@Suppress("ControlFlowWithEmptyBody")
if (depthPairs.all { it <= 0 }) {
result.append(c)
} else {

View file

@ -92,7 +92,7 @@ object Entry {
override val key = "uh"
}
@Suppress("ktlint:standard:enum-entry-name-case")
@Suppress("EnumEntryName")
enum class ImageSize(override val value: String) : ConfigItem {
AUTO("0"),
`2400`("5"),
@ -119,7 +119,7 @@ object Entry {
override val value = "2"
}
@Suppress("ktlint:standard:enum-entry-name-case")
@Suppress("EnumEntryName")
enum class SearchResultsCount(override val value: String) : ConfigItem {
`25`("0"),
`50`("1"),
@ -130,7 +130,7 @@ object Entry {
override val key = "rc"
}
@Suppress("ktlint:standard:enum-entry-name-case")
@Suppress("EnumEntryName")
enum class ThumbnailRows(override val value: String) : ConfigItem {
`4`("0"),
`10`("1"),

View file

@ -12,7 +12,6 @@ class MigrationJobFactory(
private val scope: CoroutineScope
) {
@SuppressWarnings("MaxLineLength")
fun create(migrations: List<Migration>): Deferred<Boolean> = with(scope) {
return migrations.sortedBy { it.version }
.fold(CompletableDeferred(true)) { acc: Deferred<Boolean>, migration: Migration ->

View file

@ -6,7 +6,6 @@ dependencies {
implementation(androidx.gradle)
implementation(kotlinx.gradle)
implementation(kotlinx.compose.compiler.gradle)
implementation(libs.detekt.gradlePlugin)
implementation(gradleApi())
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))

View file

@ -3,7 +3,6 @@ import mihon.buildlogic.configureAndroid
import mihon.buildlogic.configureTest
plugins {
id("mihon.code.detekt")
id("com.android.application")
kotlin("android")
}

View file

@ -2,7 +2,6 @@ import mihon.buildlogic.configureAndroid
import mihon.buildlogic.configureTest
plugins {
id("mihon.code.detekt")
id("com.android.test")
kotlin("android")
}

View file

@ -1,59 +0,0 @@
import io.gitlab.arturbosch.detekt.Detekt
import io.gitlab.arturbosch.detekt.DetektCreateBaselineTask
import org.gradle.accessors.dm.LibrariesForLibs
plugins {
id("io.gitlab.arturbosch.detekt")
}
val libs = the<LibrariesForLibs>()
dependencies {
detektPlugins(libs.detekt.rules.formatting)
detektPlugins(libs.detekt.rules.compose)
}
private val configFile = files("$rootDir/config/detekt/detekt.yml")
private val baselineFile = file("$rootDir/config/detekt/baseline.xml")
private val kotlinFiles = "**/*.kt"
private val resourceFiles = "**/resources/**"
private val buildFiles = "**/build/**"
private val generatedFiles = "**/generated/**"
private val scriptsFiles = "**/*.kts"
detekt {
buildUponDefaultConfig = true
parallel = true
autoCorrect = false
ignoreFailures = false
config.setFrom(configFile)
baseline = file(baselineFile)
}
val detektProjectBaseline by tasks.registering(DetektCreateBaselineTask::class) {
description = "Overrides current baseline."
buildUponDefaultConfig.set(true)
ignoreFailures.set(true)
parallel.set(true)
setSource(files(rootDir))
config.setFrom(configFile)
baseline = file(baselineFile)
include(kotlinFiles)
exclude(resourceFiles, buildFiles, generatedFiles, scriptsFiles)
}
tasks.withType<Detekt>().configureEach {
include(kotlinFiles)
exclude(resourceFiles, buildFiles, generatedFiles, scriptsFiles)
reports {
html.required.set(true)
xml.required.set(false)
txt.required.set(false)
}
}
tasks.withType<Detekt>().configureEach {
jvmTarget = JavaVersion.VERSION_17.toString()
}
tasks.withType<DetektCreateBaselineTask>().configureEach {
jvmTarget = JavaVersion.VERSION_17.toString()
}

View file

@ -1,7 +1,6 @@
import mihon.buildlogic.configureCompose
plugins {
id("mihon.code.detekt")
id("com.android.library")
}

View file

@ -2,7 +2,6 @@ import mihon.buildlogic.configureAndroid
import mihon.buildlogic.configureTest
plugins {
id("mihon.code.detekt")
id("com.android.library")
}

File diff suppressed because it is too large Load diff

View file

@ -1,24 +0,0 @@
naming:
FunctionNaming:
functionPattern: '[a-z][a-zA-Z0-9]*'
ignoreAnnotated: [ 'Composable' ]
TopLevelPropertyNaming:
constantPattern: '[A-Z][A-Za-z0-9]*'
complexity:
LongMethod:
ignoreAnnotated: [ 'Composable' ]
LongParameterList:
ignoreDefaultParameters: true
ignoreAnnotated: [ 'Composable' ]
style:
MagicNumber:
ignorePropertyDeclaration: true
ignoreCompanionObjectPropertyDeclaration: true
ReturnCount:
excludeGuardClauses: true
SerialVersionUIDInSerializableClass:
active: false
UnusedPrivateMember:
ignoreAnnotated: [ 'Preview' ]

View file

@ -1,6 +1,5 @@
package eu.kanade.tachiyomi.network.interceptor
import android.annotation.SuppressLint
import android.content.Context
import android.webkit.WebResourceError
import android.webkit.WebResourceRequest
@ -57,7 +56,6 @@ class CloudflareInterceptor(
}
}
@SuppressLint("SetJavaScriptEnabled")
private fun resolveWithWebView(originalRequest: Request, oldCookie: Cookie?) {
// We need to lock this thread until the WebView finds the challenge solution url, because
// OkHttp doesn't support asynchronous interceptors.

View file

@ -51,7 +51,6 @@ fun OkHttpClient.Builder.rateLimitHost(
* @param permits [Int] Number of requests allowed within a period of units.
* @param period [Duration] The limiting duration. Defaults to 1.seconds.
*/
@Suppress("UNUSED")
fun OkHttpClient.Builder.rateLimitHost(
httpUrl: HttpUrl,
permits: Int,

View file

@ -6,7 +6,6 @@ import tachiyomi.domain.manga.model.Manga
import tachiyomi.view.LibraryView
object MangaMapper {
@Suppress("LongParameterList")
fun mapManga(
id: Long,
source: Long,
@ -65,7 +64,6 @@ object MangaMapper {
version = version,
)
@Suppress("LongParameterList")
fun mapLibraryManga(
id: Long,
source: Long,

View file

@ -75,7 +75,6 @@ class MangaRepositoryImpl(
}
}
@Suppress("MagicNumber")
override suspend fun getUpcomingManga(statuses: Set<Long>): Flow<List<Manga>> {
val epochMillis = LocalDate.now().atStartOfDay(ZoneId.systemDefault()).toEpochSecond() * 1000
return handler.subscribeToList {

View file

@ -49,7 +49,6 @@ class CreateExtensionRepo(
*
* @param repo Extension Repo holder for passing to DB/Error Dialog
*/
@Suppress("ReturnCount")
private suspend fun handleInsertionError(repo: ExtensionRepo): Result {
val repoExists = repository.getRepo(repo.baseUrl)
if (repoExists != null) {

View file

@ -17,7 +17,6 @@ class ExtensionRepoService(
) {
val client = networkHelper.client
@Suppress("TooGenericExceptionCaught")
suspend fun fetchRepoDetails(
repo: String,
): ExtensionRepo? {

View file

@ -8,8 +8,6 @@ shizuku_version = "12.2.0"
sqldelight = "2.0.2"
sqlite = "2.4.0"
voyager = "1.0.0"
detekt = "1.23.6"
detektCompose = "0.4.4"
[libraries]
desugar = "com.android.tools:desugar_jdk_libs:2.0.4"
@ -102,10 +100,6 @@ voyager-screenmodel = { module = "cafe.adriel.voyager:voyager-screenmodel", vers
voyager-tab-navigator = { module = "cafe.adriel.voyager:voyager-tab-navigator", version.ref = "voyager" }
voyager-transitions = { module = "cafe.adriel.voyager:voyager-transitions", version.ref = "voyager" }
detekt-gradlePlugin = { module = "io.gitlab.arturbosch.detekt:detekt-gradle-plugin", version.ref = "detekt" }
detekt-rules-formatting = { module = "io.gitlab.arturbosch.detekt:detekt-formatting", version.ref = "detekt" }
detekt-rules-compose = { module = "io.nlopez.compose.rules:detekt", version.ref = "detektCompose" }
[bundles]
okhttp = ["okhttp-core", "okhttp-logging", "okhttp-brotli", "okhttp-dnsoverhttps"]
js-engine = ["quickjs-android"]

View file

@ -152,7 +152,6 @@ fun Scaffold(
* @param bottomBar the content to place at the bottom of the [Scaffold], on top of the
* [content], typically a [NavigationBar].
*/
@Suppress("CyclomaticComplexMethod")
@OptIn(ExperimentalMaterial3Api::class)
@Composable
private fun ScaffoldLayout(