build: add lint-baseline.xml

This commit is contained in:
oxy
2023-10-10 16:44:47 +08:00
parent 77dd3030a0
commit 91f7e0cebe
33 changed files with 401 additions and 25 deletions

View File

@ -49,6 +49,10 @@ android {
composeOptions {
kotlinCompilerExtensionVersion = libs.versions.compose.compiler.get()
}
lint {
baseline = file("lint-baseline.xml")
}
}
hilt {

View File

@ -0,0 +1,20 @@
{
"version": 3,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "com.m3u.androidApp",
"variantName": "debug",
"elements": [
{
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 67,
"versionName": "1.12.1",
"outputFile": "androidApp-debug.apk"
}
],
"elementType": "File"
}

View File

@ -0,0 +1,224 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 8.1.0" type="baseline" client="gradle" dependencies="false" name="AGP (8.1.0)" variant="all" version="8.1.0">
<issue
id="GradleDependency"
message="A newer version of androidx.activity:activity-compose than 1.8.0-rc01 is available: 1.8.0"
errorLine1="androidx-activity = &quot;1.8.0-rc01&quot;"
errorLine2=" ~~~~~~~~~~~~">
<location
file="$HOME/StudioProjects/M3UAndroid/gradle/libs.versions.toml"
line="5"
column="21"/>
</issue>
<issue
id="GradleDependency"
message="A newer version of androidx.compose.animation:animation than 1.6.0-alpha06 is available: 1.6.0-alpha07"
errorLine1="androidx-compose = &quot;1.6.0-alpha06&quot;"
errorLine2=" ~~~~~~~~~~~~~~~">
<location
file="$HOME/StudioProjects/M3UAndroid/gradle/libs.versions.toml"
line="7"
column="20"/>
</issue>
<issue
id="GradleDependency"
message="A newer version of androidx.compose.material:material than 1.6.0-alpha06 is available: 1.6.0-alpha07"
errorLine1="androidx-compose = &quot;1.6.0-alpha06&quot;"
errorLine2=" ~~~~~~~~~~~~~~~">
<location
file="$HOME/StudioProjects/M3UAndroid/gradle/libs.versions.toml"
line="7"
column="20"/>
</issue>
<issue
id="GradleDependency"
message="A newer version of androidx.compose.material:material-icons-extended than 1.6.0-alpha06 is available: 1.6.0-alpha07"
errorLine1="androidx-compose = &quot;1.6.0-alpha06&quot;"
errorLine2=" ~~~~~~~~~~~~~~~">
<location
file="$HOME/StudioProjects/M3UAndroid/gradle/libs.versions.toml"
line="7"
column="20"/>
</issue>
<issue
id="GradleDependency"
message="A newer version of androidx.compose.runtime:runtime than 1.6.0-alpha06 is available: 1.6.0-alpha07"
errorLine1="androidx-compose = &quot;1.6.0-alpha06&quot;"
errorLine2=" ~~~~~~~~~~~~~~~">
<location
file="$HOME/StudioProjects/M3UAndroid/gradle/libs.versions.toml"
line="7"
column="20"/>
</issue>
<issue
id="GradleDependency"
message="A newer version of androidx.compose.ui:ui than 1.6.0-alpha06 is available: 1.6.0-alpha07"
errorLine1="androidx-compose = &quot;1.6.0-alpha06&quot;"
errorLine2=" ~~~~~~~~~~~~~~~">
<location
file="$HOME/StudioProjects/M3UAndroid/gradle/libs.versions.toml"
line="7"
column="20"/>
</issue>
<issue
id="GradleDependency"
message="A newer version of androidx.compose.ui:ui-tooling than 1.6.0-alpha06 is available: 1.6.0-alpha07"
errorLine1="androidx-compose = &quot;1.6.0-alpha06&quot;"
errorLine2=" ~~~~~~~~~~~~~~~">
<location
file="$HOME/StudioProjects/M3UAndroid/gradle/libs.versions.toml"
line="7"
column="20"/>
</issue>
<issue
id="GradleDependency"
message="A newer version of androidx.compose.ui:ui-tooling-preview than 1.6.0-alpha06 is available: 1.6.0-alpha07"
errorLine1="androidx-compose = &quot;1.6.0-alpha06&quot;"
errorLine2=" ~~~~~~~~~~~~~~~">
<location
file="$HOME/StudioProjects/M3UAndroid/gradle/libs.versions.toml"
line="7"
column="20"/>
</issue>
<issue
id="GradleDependency"
message="A newer version of androidx.compose.ui:ui-util than 1.6.0-alpha06 is available: 1.6.0-alpha07"
errorLine1="androidx-compose = &quot;1.6.0-alpha06&quot;"
errorLine2=" ~~~~~~~~~~~~~~~">
<location
file="$HOME/StudioProjects/M3UAndroid/gradle/libs.versions.toml"
line="7"
column="20"/>
</issue>
<issue
id="GradleDependency"
message="Upgrade `androidx.compose.foundation` for keyboard and mouse support"
errorLine1="androidx-compose = &quot;1.6.0-alpha06&quot;"
errorLine2=" ~~~~~~~~~~~~~~~">
<location
file="$HOME/StudioProjects/M3UAndroid/gradle/libs.versions.toml"
line="7"
column="20"/>
</issue>
<issue
id="GradleDependency"
message="A newer version of androidx.compose.material3:material3 than 1.2.0-alpha08 is available: 1.2.0-alpha09"
errorLine1="androidx-compose-material3 = &quot;1.2.0-alpha08&quot;"
errorLine2=" ~~~~~~~~~~~~~~~">
<location
file="$HOME/StudioProjects/M3UAndroid/gradle/libs.versions.toml"
line="8"
column="30"/>
</issue>
<issue
id="GradleDependency"
message="A newer version of androidx.navigation:navigation-compose than 2.7.3 is available: 2.7.4"
errorLine1="androidx-navigation = &quot;2.7.3&quot;"
errorLine2=" ~~~~~~~">
<location
file="$HOME/StudioProjects/M3UAndroid/gradle/libs.versions.toml"
line="9"
column="23"/>
</issue>
<issue
id="GradleDependency"
message="A newer version of androidx.hilt:hilt-compiler than 1.1.0-alpha01 is available: 1.1.0-beta01"
errorLine1="androidx-hilt-compiler = &quot;1.1.0-alpha01&quot;"
errorLine2=" ~~~~~~~~~~~~~~~">
<location
file="$HOME/StudioProjects/M3UAndroid/gradle/libs.versions.toml"
line="12"
column="26"/>
</issue>
<issue
id="GradleDependency"
message="A newer version of androidx.hilt:hilt-work than 1.1.0-alpha01 is available: 1.1.0-beta01"
errorLine1="androidx-hilt-work = &quot;1.1.0-alpha01&quot;"
errorLine2=" ~~~~~~~~~~~~~~~">
<location
file="$HOME/StudioProjects/M3UAndroid/gradle/libs.versions.toml"
line="13"
column="22"/>
</issue>
<issue
id="GradleDependency"
message="A newer version of androidx.hilt:hilt-navigation-compose than 1.1.0-alpha01 is available: 1.1.0-beta01"
errorLine1="androidx-hilt-navigation-compose = &quot;1.1.0-alpha01&quot;"
errorLine2=" ~~~~~~~~~~~~~~~">
<location
file="$HOME/StudioProjects/M3UAndroid/gradle/libs.versions.toml"
line="14"
column="36"/>
</issue>
<issue
id="GradleDependency"
message="A newer version of androidx.tv:tv-foundation than 1.0.0-alpha09 is available: 1.0.0-alpha10"
errorLine1="androidx-tv = &quot;1.0.0-alpha09&quot;"
errorLine2=" ~~~~~~~~~~~~~~~">
<location
file="$HOME/StudioProjects/M3UAndroid/gradle/libs.versions.toml"
line="15"
column="15"/>
</issue>
<issue
id="GradleDependency"
message="A newer version of androidx.tv:tv-material than 1.0.0-alpha09 is available: 1.0.0-alpha10"
errorLine1="androidx-tv = &quot;1.0.0-alpha09&quot;"
errorLine2=" ~~~~~~~~~~~~~~~">
<location
file="$HOME/StudioProjects/M3UAndroid/gradle/libs.versions.toml"
line="15"
column="15"/>
</issue>
<issue
id="GradleDependency"
message="A newer version of org.jetbrains.kotlin:kotlin-serialization than 1.9.0 is available: 1.9.10"
errorLine1="kotlin = &quot;1.9.0&quot;"
errorLine2=" ~~~~~~~">
<location
file="$HOME/StudioProjects/M3UAndroid/gradle/libs.versions.toml"
line="29"
column="10"/>
</issue>
<issue
id="GradleDependency"
message="A newer version of com.google.android.material:material than 1.9.0 is available: 1.10.0"
errorLine1="com-google-android-material = &quot;1.9.0&quot;"
errorLine2=" ~~~~~~~">
<location
file="$HOME/StudioProjects/M3UAndroid/gradle/libs.versions.toml"
line="38"
column="31"/>
</issue>
<issue
id="UnusedResources"
message="The resource `R.string.features_scheme_import` appears to be unused"
errorLine1=" &lt;string name=&quot;features_scheme_import&quot;>Import as live&lt;/string>"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/values/strings.xml"
line="4"
column="13"/>
</issue>
</issues>

View File

@ -1,5 +1,8 @@
@file:SuppressLint("UseHelperIssue")
package com.m3u.androidApp
import android.annotation.SuppressLint
import android.app.PictureInPictureParams
import android.content.res.Configuration
import android.graphics.Color
@ -40,7 +43,7 @@ class MainActivity : ComponentActivity() {
private var actualOnPipModeChanged: OnPipModeChanged? = null
private val viewModel: AppViewModel by viewModels()
private val helper by lazy {
createHelper(
helper(
title = viewModel.title::value,
actions = viewModel.actions::value,
fob = viewModel.fob::value
@ -64,7 +67,7 @@ class MainActivity : ComponentActivity() {
applyConfiguration()
}
private fun createHelper(
private fun helper(
title: Method<String>,
actions: Method<List<Action>>,
fob: Method<Fob?>
@ -104,7 +107,9 @@ class MainActivity : ComponentActivity() {
get() = actualOnPipModeChanged
set(value) {
if (value != null) addOnPictureInPictureModeChangedListener(value)
else actualOnPipModeChanged?.let { removeOnPictureInPictureModeChangedListener(it) }
else actualOnPipModeChanged?.let {
removeOnPictureInPictureModeChangedListener(it)
}
}
}
@ -118,7 +123,6 @@ class MainActivity : ComponentActivity() {
applyConfiguration()
}
@Helper.WindowInsetsAllowed
private fun applyConfiguration() {
val navigationBarsVisibility = helper.navigationBarsVisibility
val statusBarsVisibility = helper.statusBarsVisibility
@ -137,7 +141,6 @@ class MainActivity : ComponentActivity() {
}
}
@Helper.WindowInsetsAllowed
private fun WindowInsetsControllerCompat.default(@InsetsType types: Int) {
when (types) {
WindowInsetsCompat.Type.navigationBars() -> {

View File

@ -29,6 +29,10 @@ android {
kotlinOptions {
jvmTarget = "17"
}
lint {
baseline = file("lint-baseline.xml")
}
}
dependencies {

4
core/lint-baseline.xml Normal file
View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 8.1.0" type="baseline" client="gradle" dependencies="false" name="AGP (8.1.0)" variant="all" version="8.1.0">
</issues>

View File

@ -33,6 +33,9 @@ android {
arg("room.schemaLocation", "${projectDir}/schemas")
arg("ksp.incremental", "true")
}
lint {
baseline = file("lint-baseline.xml")
}
}
dependencies {
@ -67,5 +70,5 @@ dependencies {
implementation(libs.androidx.hilt.hilt.work)
ksp(libs.androidx.hilt.hilt.compiler)
implementation("com.github.bjoernpetersen:m3u-parser:1.3.0")
implementation(libs.parser.m3u)
}

15
data/lint-baseline.xml Normal file
View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 8.1.0" type="baseline" client="gradle" dependencies="false" name="AGP (8.1.0)" variant="all" version="8.1.0">
<issue
id="UseTomlInstead"
message="Use version catalog instead"
errorLine1=" implementation(libs.androidx.hilt.hilt.work)"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="build.gradle.kts"
line="70"
column="21"/>
</issue>
</issues>

View File

@ -35,6 +35,9 @@ android {
composeOptions {
kotlinCompilerExtensionVersion = libs.versions.compose.compiler.get()
}
lint {
baseline = file("lint-baseline.xml")
}
}
dependencies {

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 8.1.0" type="baseline" client="gradle" dependencies="false" name="AGP (8.1.0)" variant="all" version="8.1.0">
</issues>

View File

@ -35,6 +35,9 @@ android {
composeOptions {
kotlinCompilerExtensionVersion = libs.versions.compose.compiler.get()
}
lint {
baseline = file("lint-baseline.xml")
}
}
dependencies {

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 8.1.0" type="baseline" client="gradle" dependencies="false" name="AGP (8.1.0)" variant="all" version="8.1.0">
</issues>

View File

@ -35,6 +35,9 @@ android {
composeOptions {
kotlinCompilerExtensionVersion = libs.versions.compose.compiler.get()
}
lint {
baseline = file("lint-baseline.xml")
}
}
dependencies {

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 8.1.0" type="baseline" client="gradle" dependencies="false" name="AGP (8.1.0)" variant="all" version="8.1.0">
</issues>

View File

@ -35,6 +35,9 @@ android {
composeOptions {
kotlinCompilerExtensionVersion = libs.versions.compose.compiler.get()
}
lint {
baseline = file("lint-baseline.xml")
}
}
dependencies {

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 8.1.0" type="baseline" client="gradle" dependencies="false" name="AGP (8.1.0)" variant="all" version="8.1.0">
</issues>

View File

@ -35,6 +35,9 @@ android {
composeOptions {
kotlinCompilerExtensionVersion = libs.versions.compose.compiler.get()
}
lint {
baseline = file("lint-baseline.xml")
}
}
dependencies {

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 8.1.0" type="baseline" client="gradle" dependencies="false" name="AGP (8.1.0)" variant="all" version="8.1.0">
<issue
id="AutoboxingStateCreation"
message="Prefer `mutableLongStateOf` instead of `mutableStateOf`"
errorLine1=" var lastClick by remember { mutableStateOf(0L) }"
errorLine2=" ~~~~~~~~~~~~~~">
<location
file="src/main/java/com/m3u/features/feed/components/LiveItem.kt"
line="72"
column="37"/>
</issue>
</issues>

View File

@ -35,6 +35,9 @@ android {
composeOptions {
kotlinCompilerExtensionVersion = libs.versions.compose.compiler.get()
}
lint {
baseline = file("lint-baseline.xml")
}
}
dependencies {

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 8.1.0" type="baseline" client="gradle" dependencies="false" name="AGP (8.1.0)" variant="all" version="8.1.0">
</issues>

View File

@ -35,6 +35,9 @@ android {
composeOptions {
kotlinCompilerExtensionVersion = libs.versions.compose.compiler.get()
}
lint {
baseline = file("lint-baseline.xml")
}
}
dependencies {

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 8.1.0" type="baseline" client="gradle" dependencies="false" name="AGP (8.1.0)" variant="all" version="8.1.0">
</issues>

View File

@ -35,6 +35,9 @@ android {
composeOptions {
kotlinCompilerExtensionVersion = libs.versions.compose.compiler.get()
}
lint {
baseline = file("lint-baseline.xml")
}
}
dependencies {

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 8.1.0" type="baseline" client="gradle" dependencies="false" name="AGP (8.1.0)" variant="all" version="8.1.0">
</issues>

View File

@ -232,6 +232,7 @@ private fun LocalStorageButton(
horizontal = spacing.medium,
vertical = 12.5.dp
)
.then(modifier)
) {
Text(
text = text.uppercase(),

View File

@ -40,6 +40,7 @@ androidx-test-uiautomator = "2.2.0"
androidx-benchmark = "1.1.1"
lint = "31.1.2"
parser-m3u = "1.3.0"
[libraries]
androidx-core-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "androidx-core" }
@ -111,6 +112,8 @@ androidx-benchmark-benchmark-macro-junit4 = { group = "androidx.benchmark", name
com-android-tools-lint-lint-api = { group = "com.android.tools.lint", name = "lint-api", version.ref = "lint" }
parser-m3u = { group = "com.github.bjoernpetersen", name = "m3u-parser", version.ref = "parser-m3u" }
[plugins]
com-android-application = { id = "com.android.application", version.ref = "android-gradle-plugin" }
com-android-library = { id = "com.android.library", version.ref = "android-gradle-plugin" }

View File

@ -5,5 +5,5 @@ plugins {
}
dependencies {
compileOnly("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
compileOnly(libs.com.android.tools.lint.lint.api)
compileOnly("com.android.tools.lint:lint:31.1.2")
}

View File

@ -0,0 +1 @@
-keepattributes *Annotation*

View File

@ -11,18 +11,12 @@ import com.android.tools.lint.detector.api.Severity
import com.android.tools.lint.detector.api.SourceCodeScanner
import com.intellij.psi.PsiMethod
import org.jetbrains.uast.UCallExpression
import org.jetbrains.uast.getContainingUMethod
class HelperDetector : Detector(), SourceCodeScanner {
override fun getApplicableMethodNames(): List<String> = listOf("show", "hide")
override fun visitMethodCall(context: JavaContext, node: UCallExpression, method: PsiMethod) {
val evaluator = context.evaluator
val marked =
node.getContainingUMethod()
?.uAnnotations
?.find { it.qualifiedName == ANNOTATION_NAME } != null
if (marked) return
if (evaluator.isMemberInClass(method, "androidx.core.view.WindowInsetsControllerCompat")) {
val isStatusBars = node.getArgumentForParameter(0)?.evaluate() == 1
val visible = node.methodName == "show"
@ -58,11 +52,6 @@ class HelperDetector : Detector(), SourceCodeScanner {
)
.with(expression)
.autoFix(robot = true, independent = true)
.build(),
LintFix.create()
.name("Marked with @$CHILD_ANNOTATION_NAME annotation")
.annotate("@$ANNOTATION_NAME")
.autoFix(robot = true, independent = false)
.build()
)
)
@ -76,8 +65,6 @@ class HelperDetector : Detector(), SourceCodeScanner {
}
companion object {
private const val CHILD_ANNOTATION_NAME = "WindowInsetsAllowed"
private const val ANNOTATION_NAME = "com.m3u.ui.model.Helper.${CHILD_ANNOTATION_NAME}"
private const val BRIEF_DESCRIPTION = "Helper instead of WindowInsetsControllerCompat"
val EXPLANATION = """
Usage of WindowInsetsControllerCompat to control the system bars is not allowed in this project.

View File

@ -33,6 +33,9 @@ android {
composeOptions {
kotlinCompilerExtensionVersion = libs.versions.compose.compiler.get()
}
lint {
baseline = file("lint-baseline.xml")
}
}
dependencies {

26
ui/lint-baseline.xml Normal file
View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 8.1.0" type="baseline" client="gradle" dependencies="false" name="AGP (8.1.0)" variant="all" version="8.1.0">
<issue
id="StaredImportsIssue"
message="Using special import instead of star-import."
errorLine1="import androidx.compose.foundation.layout.*"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/com/m3u/ui/components/ThemeSelection.kt"
line="9"
column="8"/>
</issue>
<issue
id="StaredImportsIssue"
message="Using special import instead of star-import."
errorLine1="import androidx.compose.material3.*"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/com/m3u/ui/components/ThemeSelection.kt"
line="15"
column="8"/>
</issue>
</issues>

View File

@ -6,13 +6,27 @@ import androidx.compose.animation.core.animateIntAsState
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.Add
import androidx.compose.material.icons.rounded.DarkMode
import androidx.compose.material.icons.rounded.LightMode
import androidx.compose.material3.*
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.ElevatedCard
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedCard
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment

View File

@ -20,9 +20,6 @@ typealias OnPipModeChanged = Consumer<PictureInPictureModeChangedInfo>
@Stable
interface Helper {
@Retention(AnnotationRetention.SOURCE)
annotation class WindowInsetsAllowed
var title: String
var actions: List<Action>
var fob: Fob?