Skip to content

Commit

Permalink
Merge pull request #143 from grab/use-path-variables-and-use-latest-l…
Browse files Browse the repository at this point in the history
…int-tool

use --path-variables to make the lint (full/partial) results cacheable.
  • Loading branch information
mohammadkahelghi-grabtaxi authored Mar 4, 2024
2 parents 4eabb7f + 8ce7583 commit 1e751cf
Show file tree
Hide file tree
Showing 9 changed files with 2,143 additions and 2,071 deletions.
4,110 changes: 2,126 additions & 1,984 deletions bazel_common_maven_install.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion rules/setup.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def bazel_common_setup(
maven_install(
name = repo_name,
artifacts = DAGGER_ARTIFACTS + [
"com.android.tools.lint:lint:31.0.2",
"com.android.tools.lint:lint:31.4.0-alpha09",
"com.google.guava:guava:29.0-jre",
"com.google.auto:auto-common:0.10",
"com.google.auto.service:auto-service:1.0-rc6",
Expand Down
10 changes: 1 addition & 9 deletions tests/android/library/lint_baseline.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="5" by="lint 8.0.2" client="" dependencies="true" name="" type="baseline" variant="all" version="8.0.2">

<issue
id="LongLogTag"
message="The logging tag can be at most 23 characters, was 39 (SomeReallyLongTagForLintToDetectAndWarn)">
<location
file="tests/android/src/main/java/com/grab/test/TestActivity.kt"
line="13"/>
</issue>
<issues format="6" by="lint 8.4.0-alpha09" type="baseline" client="" dependencies="true" name="" variant="all" version="8.4.0-alpha09">

</issues>
4 changes: 2 additions & 2 deletions tools/lint/src/main/java/com/grab/lint/LintAnalyzeCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ class LintAnalyzeCommand : LintBaseCommand() {
.forEach { path ->
if ("lint-definite-all.xml" in path.name) {
Files.delete(path)
} else {
} /*else {
Sanitizer(tmpPath = workingDir).sanitize(path.toFile())
}
}*/
}
}
}
8 changes: 8 additions & 0 deletions tools/lint/src/main/java/com/grab/lint/LintBaseCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ abstract class LintBaseCommand : CliktCommand() {
"--compile-sdk-version",
)

protected val pathVariables by option(
"--path-variables"
).default("${PWD}=${System.getenv(PWD)}")

override fun run() {
preRun()
prepareJdk()
Expand Down Expand Up @@ -197,4 +201,8 @@ abstract class LintBaseCommand : CliktCommand() {
}
}
}

companion object {
private const val PWD = "PWD"
}
}
3 changes: 2 additions & 1 deletion tools/lint/src/main/java/com/grab/lint/LintReportCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class LintReportCommand : LintBaseCommand() {
tmpBaseline: File,
) {
val newBaseline = runLint(workingDir, projectXml, tmpBaseline)
Sanitizer(tmpPath = workingDir).sanitize(newBaseline, updatedBaseline)
newBaseline.copyTo(updatedBaseline)
LintResults(
resultCodeFile = resultCode,
lintResultsFile = outputXml
Expand All @@ -52,6 +52,7 @@ class LintReportCommand : LintBaseCommand() {
"--project", projectXml.toString(),
"--xml", outputXml.toString(),
"--baseline", tmpBaseline.absolutePath,
"--path-variables", pathVariables,
"--cache-dir", workingDir.resolve("cache").pathString,
"--update-baseline", // Always update the baseline, so we can copy later if needed
"--report-only" // Only do reporting
Expand Down
70 changes: 0 additions & 70 deletions tools/lint/src/main/java/com/grab/lint/Sanitizer.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.grab.test.BaseTest
import org.junit.Before
import org.junit.Test
import java.io.File
import kotlin.test.assertEquals
import kotlin.test.assertTrue

class LintAnalyzeCommandTest : BaseTest() {
Expand Down Expand Up @@ -82,10 +81,10 @@ class LintAnalyzeCommandTest : BaseTest() {
)
)
val partialResults = partialResults.walkTopDown().filter { it.isFile }.toList()
assertEquals(1, partialResults.size, "Partial results are generated")
assertEquals("lint-partial-all.xml", partialResults.first().name, "Partial all file is generated")
assertTrue(partialResults.isNotEmpty(), "Partial results are generated")
assertTrue(partialResults.any { it.name == "lint-partial.xml" }, "Partial all file is generated")
assertTrue {
partialResults.first().readText().contains("id=\"UnusedResources\"")
partialResults.first { it.name == "lint-partial.xml" }.readText().contains("id=\"UnusedResources\"")
}
assertTrue("Project XML is generated") {
projectXml.exists()
Expand Down

0 comments on commit 1e751cf

Please sign in to comment.