From e7bf1abcf8dec14823bb5265740d153f8ab0bd96 Mon Sep 17 00:00:00 2001 From: Naveen Singh <36371707+naveensingh@users.noreply.github.com> Date: Thu, 3 Jul 2025 21:16:51 +0530 Subject: [PATCH] chore: ignore extra translations and update detekt rules * chore: ignore extra translations in lint Extra translations are removed automatically by Weblate * chore: update detekt rules More compose-friendly * chore: update lint baselines --- app/build.gradle.kts | 4 +++ app/detekt-baseline.xml | 14 ---------- app/lint-baseline.xml | 14 +++++----- detekt.yml | 58 +++++++++++++++++++++++++++++++++++++++ gradle/libs.versions.toml | 3 ++ lint.xml | 1 + 6 files changed, 73 insertions(+), 21 deletions(-) create mode 100644 detekt.yml diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 3a21366b..09ee282b 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -129,6 +129,9 @@ android { detekt { baseline = file("detekt-baseline.xml") + config.setFrom("$rootDir/detekt.yml") + buildUponDefaultConfig = true + allRules = false } dependencies { @@ -139,4 +142,5 @@ dependencies { implementation(libs.eventbus) implementation(libs.libphonenumber) implementation(libs.geocoder) + detektPlugins(libs.compose.detekt) } diff --git a/app/detekt-baseline.xml b/app/detekt-baseline.xml index 7fecfd55..9be3c9de 100644 --- a/app/detekt-baseline.xml +++ b/app/detekt-baseline.xml @@ -24,33 +24,19 @@ ExplicitItLambdaParameter:FavoritesFragment.kt$FavoritesFragment${ it -> if (context.config.showCallConfirmation) { CallConfirmationDialog(activity as SimpleActivity, (it as Contact).getNameToDisplay()) { activity?.apply { initiateCall(it) { launchCallIntent(it) } } } } else { activity?.apply { initiateCall(it as Contact) { launchCallIntent(it) } } } } LargeClass:CallActivity.kt$CallActivity : SimpleActivity LongMethod:CallActivity.kt$CallActivity$@SuppressLint("ClickableViewAccessibility") private fun handleSwipe() - LongMethod:CallActivity.kt$CallActivity$private fun initButtons() - LongMethod:CallNotificationManager.kt$CallNotificationManager$@SuppressLint("NewApi") fun setupNotification(forceLowPriority: Boolean = false) - LongMethod:ContactsAdapter.kt$ContactsAdapter$@SuppressLint("ClickableViewAccessibility") private fun setupView(binding: ItemViewBinding, contact: Contact, holder: ViewHolder) - LongMethod:DialpadActivity.kt$DialpadActivity$override fun onCreate(savedInstanceState: Bundle?) - LongMethod:RecentCallsAdapter.kt$RecentCallsAdapter$private fun showPopupMenu(view: View, call: RecentCall) LongMethod:RecentCallsAdapter.kt$RecentCallsAdapter.RecentCallViewHolder$fun bind(call: RecentCall) LongMethod:RecentsHelper.kt$RecentsHelper$@SuppressLint("NewApi") private fun getRecents( contacts: List<Contact>, selection: String? = null, selectionParams: Array<String>? = null, ): List<RecentCall> - LongParameterList:ContactsAdapter.kt$ContactsAdapter$( activity: SimpleActivity, var contacts: MutableList<Contact>, recyclerView: MyRecyclerView, highlightText: String = "", private val refreshItemsListener: RefreshItemsListener? = null, var viewType: Int = VIEW_TYPE_LIST, private val showDeleteButton: Boolean = true, private val enableDrag: Boolean = false, private val allowLongClick: Boolean = true, itemClick: (Any) -> Unit, val profileIconClick: ((Any) -> Unit)? = null ) - LongParameterList:RecentCallsAdapter.kt$RecentCallsAdapter$( activity: SimpleActivity, recyclerView: MyRecyclerView, private val refreshItemsListener: RefreshItemsListener?, private val showOverflowMenu: Boolean, private val itemDelete: (List<RecentCall>) -> Unit = {}, itemClick: (Any) -> Unit, val profileIconClick: ((Any) -> Unit)? = null ) MagicNumber:Activity.kt$1000000 - MagicNumber:Call.kt$1000 MagicNumber:CallActivity.kt$CallActivity$0.10f MagicNumber:CallActivity.kt$CallActivity$0.2f MagicNumber:CallActivity.kt$CallActivity$0.5f - MagicNumber:CallActivity.kt$CallActivity$1000 - MagicNumber:CallActivity.kt$CallActivity$1000L MagicNumber:CallActivity.kt$CallActivity$200L MagicNumber:CallActivity.kt$CallActivity$250L MagicNumber:CallActivity.kt$CallActivity$3000 MagicNumber:CallActivity.kt$CallActivity$5 MagicNumber:CallActivity.kt$CallActivity$50f MagicNumber:CallActivity.kt$CallActivity$60 - MagicNumber:CallActivity.kt$CallActivity.<no name provided>$1000 - MagicNumber:CallLogItem.kt$CallLogItem$1000L - MagicNumber:CallNotificationManager.kt$CallNotificationManager$42 MagicNumber:Config.kt$Config$9 - MagicNumber:DialpadActivity.kt$DialpadActivity$1000 MagicNumber:DialpadActivity.kt$DialpadActivity$3 MagicNumber:DialpadActivity.kt$DialpadActivity$4 MagicNumber:DialpadActivity.kt$DialpadActivity$5 diff --git a/app/lint-baseline.xml b/app/lint-baseline.xml index ba070c1a..17c57d7a 100644 --- a/app/lint-baseline.xml +++ b/app/lint-baseline.xml @@ -51,8 +51,8 @@ errorLine1="app-build-targetSDK = "34"" errorLine2=" ~~~~"> @@ -84,7 +84,7 @@ errorLine1="distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip" errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -95,8 +95,8 @@ errorLine1="gradlePlugins-agp = "8.10.1"" errorLine2=" ~~~~~~~~"> @@ -106,8 +106,8 @@ errorLine1="app-build-compileSDKVersion = "34"" errorLine2=" ~~~~"> diff --git a/detekt.yml b/detekt.yml new file mode 100644 index 00000000..6472c5a3 --- /dev/null +++ b/detekt.yml @@ -0,0 +1,58 @@ +build: + maxIssues: 0 + weights: + complexity: 2 + LongParameterList: 2 + style: 1 + +processors: + active: true + exclude: + - "FunctionCountProcessor" + - "PropertyCountProcessor" + +config: + validation: true + +complexity: + LongParameterList: + active: true + functionThreshold: 10 + constructorThreshold: 8 + ignoreDefaultParameters: true + ignoreAnnotated: + - "Composable" + LongMethod: + active: true + threshold: 120 + ignoreAnnotated: + - "Composable" + - "Preview" + +style: + MagicNumber: + active: true + ignoreAnnotated: ["Composable"] + ignoreEnums: true + ignoreNumbers: ["-1", "0", "1", "2", "42", "1000"] + MaxLineLength: + active: true + maxLineLength: 120 + excludePackageStatements: true + excludeImportStatements: true + +naming: + FunctionNaming: + active: true + ignoreAnnotated: ["Composable", "Preview"] + functionPattern: "[a-z][A-Za-z0-9]*" + +Compose: # io.nlopez.compose.rules + ComposableParametersOrdering: + active: true + ModifierDefaultValue: + active: true + MissingModifierDefaultValue: + active: true + PublicComposablePreview: + active: true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 4ec79617..f1122df8 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -5,6 +5,7 @@ kotlin = "2.2.0" kotlinxSerializationJson = "1.8.1" #Detekt detekt = "1.23.8" +detektCompose = "0.4.22" #Eventbus eventbus = "3.3.1" #Fossify @@ -22,6 +23,8 @@ app-build-minimumSDK = "26" app-build-javaVersion = "VERSION_17" app-build-kotlinJVMTarget = "17" [libraries] +#Compose +compose-detekt = { module = "io.nlopez.compose.rules:detekt", version.ref = "detektCompose" } #Fossify fossify-commons = { module = "org.fossify:commons", version.ref = "commons" } #EventBus diff --git a/lint.xml b/lint.xml index 05685cd8..4b4a7825 100644 --- a/lint.xml +++ b/lint.xml @@ -31,4 +31,5 @@ +