From 39f3782b53c05967385b1b8a26af34f46436d5b9 Mon Sep 17 00:00:00 2001 From: Naveen Singh <36371707+naveensingh@users.noreply.github.com> Date: Tue, 24 Jun 2025 16:09:59 +0530 Subject: [PATCH] chore: update lint rules and baselines (#183) --- .github/workflows/update-lint-baselines.yml | 11 + .gitignore | 1 + app/build.gradle.kts | 8 +- app/detekt-baseline.xml | 40 +- app/lint-baseline.xml | 567 +++++++++++++++----- lint.xml | 34 ++ 6 files changed, 498 insertions(+), 163 deletions(-) create mode 100644 .github/workflows/update-lint-baselines.yml create mode 100644 lint.xml diff --git a/.github/workflows/update-lint-baselines.yml b/.github/workflows/update-lint-baselines.yml new file mode 100644 index 00000000..17043a58 --- /dev/null +++ b/.github/workflows/update-lint-baselines.yml @@ -0,0 +1,11 @@ +name: Update lint baselines + +on: + workflow_dispatch: + schedule: + - cron: "0 0 1 * *" + +jobs: + update-lint-baselines: + uses: FossifyOrg/.github/.github/workflows/update-lint-baselines.yml@main + secrets: inherit diff --git a/.gitignore b/.gitignore index d209458c..72ae8c3b 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ keystore.jks keystore.properties fastlane/fastlane.json fastlane/report.xml +.kotlin/ diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 62927a17..444440a1 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,3 +1,4 @@ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import org.jetbrains.kotlin.konan.properties.Properties import java.io.FileInputStream @@ -103,7 +104,9 @@ android { } tasks.withType { - kotlinOptions.jvmTarget = project.libs.versions.app.build.kotlinJVMTarget.get() + compilerOptions.jvmTarget.set( + JvmTarget.fromTarget(project.libs.versions.app.build.kotlinJVMTarget.get()) + ) } namespace = project.property("APP_ID").toString() @@ -111,8 +114,9 @@ android { lint { checkReleaseBuilds = false abortOnError = true - warningsAsErrors = true + warningsAsErrors = false baseline = file("lint-baseline.xml") + lintConfig = rootProject.file("lint.xml") } bundle { diff --git a/app/detekt-baseline.xml b/app/detekt-baseline.xml index 98878198..99ae383f 100644 --- a/app/detekt-baseline.xml +++ b/app/detekt-baseline.xml @@ -1,6 +1,6 @@ - + ComplexCondition:ManageClipboardItemsActivity.kt$ManageClipboardItemsActivity$requestCode == PICK_EXPORT_CLIPS_INTENT && resultCode == Activity.RESULT_OK && resultData != null && resultData.data != null ComplexCondition:ManageClipboardItemsActivity.kt$ManageClipboardItemsActivity$requestCode == PICK_IMPORT_CLIPS_SOURCE_INTENT && resultCode == Activity.RESULT_OK && resultData != null && resultData.data != null @@ -63,16 +63,11 @@ MaxLineLength:ClipsActivityAdapter.kt$ClipsActivityAdapter$override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) MaxLineLength:ClipsKeyboardAdapter.kt$ClipsKeyboardAdapter$layerDrawable.findDrawableByLayerId(R.id.clipboard_background_stroke).applyColorFilter(context.getStrokeColor()) MaxLineLength:Config.kt$Config$set(lastExportedClipsFolder) = prefs.edit().putString(LAST_EXPORTED_CLIPS_FOLDER, lastExportedClipsFolder).apply() - MaxLineLength:Context.kt$baseConfig.isUsingSystemTheme -> ResourcesCompat.getDrawable(resources, R.drawable.dialog_you_background, theme) MaxLineLength:Context.kt$fun - MaxLineLength:Context.kt$isBlackAndWhiteTheme() -> ResourcesCompat.getDrawable(resources, R.drawable.black_dialog_background, theme) MaxLineLength:EmojisAdapter.kt$EmojisAdapter.EmojiCategoryViewHolder$inner MaxLineLength:ExportClipsDialog.kt$ExportClipsDialog$exportClipsFilename.setText("${activity.getString(R.string.app_launcher_name)}_${activity.getCurrentFormattedDateTime()}") MaxLineLength:ExportClipsDialog.kt$ExportClipsDialog$val activity: BaseSimpleActivity MaxLineLength:ExportClipsDialog.kt$ExportClipsDialog$val title = String.format(activity.getString(R.string.file_already_exists_overwrite), newPath.getFilenameFromPath()) - MaxLineLength:MainActivity.kt$MainActivity$(applyBackground as LayerDrawable).findDrawableByLayerId(R.id.button_background_holder).applyColorFilter(getProperPrimaryColor()) - MaxLineLength:MainActivity.kt$MainActivity$ConfirmationAdvancedDialog - MaxLineLength:MainActivity.kt$MainActivity$updateMaterialActivityViews(mainCoordinator, mainHolder, useTransparentNavigation = false, useTopSearchMenu = false) MaxLineLength:ManageClipboardItemsActivity.kt$ManageClipboardItemsActivity$clipboardItemsPlaceholder.text = "${getText(R.string.manage_clipboard_empty)}\n\n${getText(R.string.manage_clips)}" MaxLineLength:ManageClipboardItemsActivity.kt$ManageClipboardItemsActivity$if MaxLineLength:ManageClipboardItemsActivity.kt$ManageClipboardItemsActivity$updateMaterialActivityViews(clipboardCoordinator, clipboardItemsList, useTransparentNavigation = true, useTopSearchMenu = false) @@ -93,37 +88,11 @@ MaxLineLength:MyKeyboardView.kt$MyKeyboardView$// For 'number' and 'phone' keyboards the count of popup keys might be bigger than count of keys in the main keyboard. MaxLineLength:MyKeyboardView.kt$MyKeyboardView$// if the user presses a key while still holding down the previous, type in both chars and ignore the later gestures MaxLineLength:MyKeyboardView.kt$MyKeyboardView$// make sure we highlight the proper key right after long pressing it, before any ACTION_MOVE event occurs - MaxLineLength:MyKeyboardView.kt$MyKeyboardView$MeasureSpec.makeMeasureSpec(width, MeasureSpec.AT_MOST) - MaxLineLength:MyKeyboardView.kt$MyKeyboardView$class MaxLineLength:MyKeyboardView.kt$MyKeyboardView$if - MaxLineLength:MyKeyboardView.kt$MyKeyboardView$keyboardViewBinding!!.emojiPaletteTopBar.elevation = if (offset > 4) context.resources.getDimensionPixelSize(R.dimen.one_dp).toFloat() else 0f - MaxLineLength:MyKeyboardView.kt$MyKeyboardView$keyboardViewBinding?.emojiCategoriesStrip?.children?.filterIsInstance<ImageButton>() - MaxLineLength:MyKeyboardView.kt$MyKeyboardView$layerDrawable.findDrawableByLayerId(R.id.clipboard_background_shape).applyColorFilter(mBackgroundColor) - MaxLineLength:MyKeyboardView.kt$MyKeyboardView$mMiniKeyboard = mMiniKeyboardCache[popupKey]?.let(KeyboardPopupKeyboardBinding::bind)?.miniKeyboardView - MaxLineLength:MyKeyboardView.kt$MyKeyboardView$mPreviewText!!.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)) MaxLineLength:MyKeyboardView.kt$MyKeyboardView$me.x - (coords[0] + mMiniKeyboard!!.measuredWidth) > mPopupMaxMoveDistance - MaxLineLength:MyKeyboardView.kt$MyKeyboardView$setupEmojiPalette(toolbarColor = mKeyboardBackgroundColor, backgroundColor = mBackgroundColor, textColor = mTextColor) MaxLineLength:MyKeyboardView.kt$MyKeyboardView$systemFontPaint.hasGlyph(emoji.emoji) - MaxLineLength:MyKeyboardView.kt$MyKeyboardView$val - MaxLineLength:MyKeyboardView.kt$MyKeyboardView$val clipboardClearAnimation = ObjectAnimator.ofFloat(keyboardViewBinding!!.clipboardClear, "alpha", newAlpha) - MaxLineLength:MyKeyboardView.kt$MyKeyboardView$val clipboardValueAnimation = ObjectAnimator.ofFloat(keyboardViewBinding!!.clipboardValue, "alpha", newAlpha) - MaxLineLength:MyKeyboardView.kt$MyKeyboardView$val id = emojiCategoryIds.entries.first { it.value == (activeCategory.value as EmojisAdapter.Item.Category).value }.key - MaxLineLength:MyKeyboardView.kt$MyKeyboardView$val isCurrentClipPinnedToo = pinnedClips.any { clipboardContent?.isNotEmpty() == true && it.value.trim() == clipboardContent } - MaxLineLength:MyKeyboardView.kt$MyKeyboardView$val layerDrawable = (this as RippleDrawable).findDrawableByLayerId(R.id.clipboard_background_holder) as LayerDrawable - MaxLineLength:MyKeyboardView.kt$MyKeyboardView$val popupKeyWidth = popupKey.calcKeyWidth(containerWidth = mMiniKeyboardContainer?.measuredWidth ?: width) - MaxLineLength:MyKeyboardView.kt$MyKeyboardView$val startY = (key.height / 2f) + ((textSize - paint.descent()) / 2f) - ((textSize / 2f) * (rows.size - 1)) - MaxLineLength:MyKeyboardView.kt$MyKeyboardView$val widthToUse = mMiniKeyboardContainer!!.measuredWidth - (popupKey.popupCharacters!!.length / 2) * popupKeyWidth - MaxLineLength:MyKeyboardView.kt$MyKeyboardView.<no name provided>$override MaxLineLength:OnKeyboardActionListener.kt$OnKeyboardActionListener$* - MaxLineLength:SettingsActivity.kt$SettingsActivity$RadioItem(KEYBOARD_HEIGHT_100_PERCENT, getKeyboardHeightPercentageText(KEYBOARD_HEIGHT_100_PERCENT)) - MaxLineLength:SettingsActivity.kt$SettingsActivity$RadioItem(KEYBOARD_HEIGHT_120_PERCENT, getKeyboardHeightPercentageText(KEYBOARD_HEIGHT_120_PERCENT)) - MaxLineLength:SettingsActivity.kt$SettingsActivity$RadioItem(KEYBOARD_HEIGHT_140_PERCENT, getKeyboardHeightPercentageText(KEYBOARD_HEIGHT_140_PERCENT)) - MaxLineLength:SettingsActivity.kt$SettingsActivity$RadioItem(KEYBOARD_HEIGHT_160_PERCENT, getKeyboardHeightPercentageText(KEYBOARD_HEIGHT_160_PERCENT)) - MaxLineLength:SettingsActivity.kt$SettingsActivity$settingsKeyboardHeightMultiplier.text = getKeyboardHeightPercentageText(config.keyboardHeightPercentage) MaxLineLength:SettingsActivity.kt$SettingsActivity$settingsUseEnglishHolder.beVisibleIf((config.wasUseEnglishToggled || Locale.getDefault().language != "en") && !isTiramisuPlus()) - MaxLineLength:SettingsActivity.kt$SettingsActivity$settingsVoiceInputMethodValue.text = getCurrentVoiceInputMethod()?.first?.loadLabel(packageManager) ?: getString(R.string.none) - MaxLineLength:SettingsActivity.kt$SettingsActivity$settingsVoiceInputMethodValue.text = getCurrentVoiceInputMethod(inputMethods)?.first?.loadLabel(packageManager) ?: getString(R.string.none) - MaxLineLength:SettingsActivity.kt$SettingsActivity$updateMaterialActivityViews(settingsCoordinator, settingsHolder, useTransparentNavigation = true, useTopSearchMenu = false) MaxLineLength:SimpleKeyboardIME.kt$SimpleKeyboardIME$// If the keyboard is set to symbols and the user presses space, we usually should switch back to the letters keyboard. MaxLineLength:SimpleKeyboardIME.kt$SimpleKeyboardIME$System.currentTimeMillis() - lastShiftPressTS < SHIFT_PERM_TOGGLE_SPEED -> keyboard!!.mShiftState = ShiftState.ON_PERMANENT MaxLineLength:SimpleKeyboardIME.kt$SimpleKeyboardIME$class @@ -158,11 +127,7 @@ TooManyFunctions:SettingsActivity.kt$SettingsActivity : SimpleActivity TooManyFunctions:SimpleKeyboardIME.kt$SimpleKeyboardIME : InputMethodServiceOnKeyboardActionListenerOnSharedPreferenceChangeListener WildcardImport:ClipsKeyboardAdapter.kt$import org.fossify.commons.extensions.* - WildcardImport:Context.kt$import android.view.* - WildcardImport:Context.kt$import org.fossify.commons.extensions.* - WildcardImport:Context.kt$import org.fossify.keyboard.helpers.* WildcardImport:ExportClipsDialog.kt$import org.fossify.commons.extensions.* - WildcardImport:MainActivity.kt$import org.fossify.commons.extensions.* WildcardImport:ManageClipboardItemsActivity.kt$import org.fossify.commons.extensions.* WildcardImport:ManageClipboardItemsActivity.kt$import org.fossify.commons.helpers.* WildcardImport:MyKeyboardView.kt$import android.graphics.* @@ -172,9 +137,6 @@ WildcardImport:MyKeyboardView.kt$import org.fossify.commons.extensions.* WildcardImport:MyKeyboardView.kt$import org.fossify.keyboard.extensions.* WildcardImport:MyKeyboardView.kt$import org.fossify.keyboard.helpers.* - WildcardImport:SettingsActivity.kt$import org.fossify.commons.extensions.* - WildcardImport:SettingsActivity.kt$import org.fossify.keyboard.extensions.* - WildcardImport:SettingsActivity.kt$import org.fossify.keyboard.helpers.* WildcardImport:SimpleKeyboardIME.kt$import android.text.InputType.* WildcardImport:SimpleKeyboardIME.kt$import android.view.inputmethod.* WildcardImport:SimpleKeyboardIME.kt$import org.fossify.commons.extensions.* diff --git a/app/lint-baseline.xml b/app/lint-baseline.xml index 5caa24cf..32d4e4d3 100644 --- a/app/lint-baseline.xml +++ b/app/lint-baseline.xml @@ -1,21 +1,14 @@ - - - - - + @@ -27,19 +20,19 @@ + id="OldTargetApi" + message="Not targeting the latest versions of Android; compatibility modes apply. Consider testing and updating this version. Consult the `android.os.Build.VERSION_CODES` javadoc for details." + errorLine1="app-build-targetSDK = "34"" + errorLine2=" ~~~~"> + file="$HOME/Projects/Fossify/FossifyOrg/Keyboard/gradle/libs.versions.toml" + line="19" + column="23"/> - - - - + id="AndroidGradlePluginVersion" + message="A newer version of Gradle than 8.11.1 is available: 8.14.2" + errorLine1="distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip" + errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> + column="17"/> + message="A newer version of androidx.room:room-compiler than 2.7.1 is available: 2.7.2" + errorLine1="room = "2.7.1"" + errorLine2=" ~~~~~~~"> + file="$HOME/Projects/Fossify/FossifyOrg/Keyboard/gradle/libs.versions.toml" + line="12" + column="8"/> + message="A newer version of androidx.room:room-ktx than 2.7.1 is available: 2.7.2" + errorLine1="room = "2.7.1"" + errorLine2=" ~~~~~~~"> + file="$HOME/Projects/Fossify/FossifyOrg/Keyboard/gradle/libs.versions.toml" + line="12" + column="8"/> + message="A newer version of androidx.room:room-runtime than 2.7.1 is available: 2.7.2" + errorLine1="room = "2.7.1"" + errorLine2=" ~~~~~~~"> + file="$HOME/Projects/Fossify/FossifyOrg/Keyboard/gradle/libs.versions.toml" + line="12" + column="8"/> + + + + + + + + + errorLine1=" resources.getDrawable(R.drawable.button_background_rounded, theme) as RippleDrawable" + errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> + line="113" + column="13"/> + + + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +