Apply lint dedicated module.

Change-Id: I654a8663af53819d08cd3d7d82c839536904b1bb
pull/2106/head
Jaehwa Noh 2 months ago
parent 7912c71332
commit 281ef8750a

@ -86,6 +86,7 @@ dependencies {
implementation(projects.core.data)
implementation(projects.core.model)
implementation(projects.core.analytics)
implementation(projects.lint)
implementation(projects.sync.work)
implementation(libs.androidx.activity.compose)

@ -55,11 +55,13 @@ abstract class AndroidLibraryConventionPlugin : Plugin<Project> {
}
configureSpotlessForAndroid()
dependencies {
"androidTestImplementation"(libs.findLibrary("kotlin.test").get())
if (project.name != "lint") "implementation"(project(":lint"))
"implementation"(libs.findLibrary("androidx.tracing.ktx").get())
"testImplementation"(libs.findLibrary("kotlin.test").get())
"testImplementation"(libs.findLibrary("junit").get())
"implementation"(libs.findLibrary("androidx.tracing.ktx").get())
"androidTestImplementation"(libs.findLibrary("kotlin.test").get())
}
}
}

@ -44,6 +44,5 @@ class AndroidLintConventionPlugin : Plugin<Project> {
private fun Lint.configure() {
xmlReport = true
sarifReport = true
checkDependencies = true
disable += "GradleDependency"
}

@ -26,8 +26,6 @@ android {
}
dependencies {
lintPublish(projects.lint)
api(libs.androidx.compose.foundation)
api(libs.androidx.compose.foundation.layout)
api(libs.androidx.compose.material.iconsExtended)

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2022 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<lint>
<!--
Lint crashes when it tries to analyse a file without a package name:
java.lang.IllegalStateException: () -> kotlin.String at org.jetbrains.kotlin.asJava.classes.KtLightClassForFacadeImpl$Companion.createForFacadeNoCache
-->
<issue id="DesignSystem" severity="ignore"/>
</lint>

@ -42,7 +42,7 @@ class GetFollowableTopicsUseCaseTest {
)
@Test
fun test_whenNoParams_followableTopicsAreReturnedWithNoSorting() = runTest {
fun whenNoParams_followableTopicsAreReturnedWithNoSorting() = runTest {
// Obtain a stream of followable topics.
val followableTopics = useCase()
@ -62,7 +62,7 @@ class GetFollowableTopicsUseCaseTest {
}
@Test
fun test_whenSortOrderIsByName_topicsSortedByNameAreReturned() = runTest {
fun whenSortOrderIsByName_topicsSortedByNameAreReturned() = runTest {
// Obtain a stream of followable topics, sorted by name.
val followableTopics = useCase(
sortBy = NAME,

@ -14,31 +14,14 @@
* limitations under the License.
*/
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
plugins {
`java-library`
kotlin("jvm")
alias(libs.plugins.nowinandroid.android.lint)
}
java {
// Up to Java 11 APIs are available through desugaring
// https://developer.android.com/studio/write/java11-minimal-support-table
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
alias(libs.plugins.nowinandroid.android.library)
}
kotlin {
compilerOptions {
jvmTarget = JvmTarget.JVM_11
}
android {
namespace = "com.google.samples.apps.nowinandroid.lint"
}
dependencies {
compileOnly(libs.kotlin.stdlib)
compileOnly(libs.lint.api)
testImplementation(libs.kotlin.test)
testImplementation(libs.lint.checks)
testImplementation(libs.lint.tests)
lintPublish(projects.lint.impl)
}

@ -17,8 +17,8 @@
package com.google.samples.apps.nowinandroid.lint.impl.designsystem
import com.android.tools.lint.checks.infrastructure.TestFile
import com.android.tools.lint.checks.infrastructure.TestFiles
import com.android.tools.lint.checks.infrastructure.TestLintTask
import com.android.tools.lint.checks.infrastructure.TestFiles.kotlin
import com.android.tools.lint.checks.infrastructure.TestLintTask.lint
import com.google.samples.apps.nowinandroid.lint.impl.TestMethodNameDetector.Companion.FORMAT
import com.google.samples.apps.nowinandroid.lint.impl.TestMethodNameDetector.Companion.PREFIX
import org.junit.Test
@ -27,10 +27,10 @@ class TestMethodNameDetectorTest {
@Test
fun `detect prefix`() {
TestLintTask.lint().issues(PREFIX)
lint().issues(PREFIX)
.files(
JUNIT_TEST_STUB,
TestFiles.kotlin(
kotlin(
"""
import org.junit.Test
class Test {
@ -72,10 +72,10 @@ class TestMethodNameDetectorTest {
@Test
fun `detect format`() {
TestLintTask.lint().issues(FORMAT)
lint().issues(FORMAT)
.files(
JUNIT_TEST_STUB,
TestFiles.kotlin(
kotlin(
"src/androidTest/com/example/Test.kt",
"""
import org.junit.Test
@ -113,7 +113,7 @@ class TestMethodNameDetectorTest {
}
private companion object {
private val JUNIT_TEST_STUB: TestFile = TestFiles.kotlin(
private val JUNIT_TEST_STUB: TestFile = kotlin(
"""
package org.junit
annotation class Test

Loading…
Cancel
Save