summaryrefslogtreecommitdiff
path: root/java/lint.go
diff options
context:
space:
mode:
author Jaewoong Jung <jungjw@google.com> 2021-04-21 14:01:55 -0700
committer Jaewoong Jung <jungjw@google.com> 2021-04-21 16:56:19 -0700
commit79e6f6bfccbc2f7209e8e3ce1872951be64a41d5 (patch)
tree53078730bdac4493dc45bbfbb4deb9d6c44490bc /java/lint.go
parent4949557d507ee5cf5f56a5c92bbda5f8e5da4254 (diff)
Forbid bypassing updatability lint checks.
Test: lint_test.go Bug: 182349282 Change-Id: Iac7c01493b449c2ddd6df6c68f8a74dfe72dfd7a
Diffstat (limited to 'java/lint.go')
-rw-r--r--java/lint.go16
1 files changed, 15 insertions, 1 deletions
diff --git a/java/lint.go b/java/lint.go
index a77daa85d..0618cbf6d 100644
--- a/java/lint.go
+++ b/java/lint.go
@@ -26,6 +26,10 @@ import (
"android/soong/remoteexec"
)
+// lint checks automatically enforced for modules that have different min_sdk_version than
+// sdk_version
+var updatabilityChecks = []string{"NewApi"}
+
type LintProperties struct {
// Controls for running Android Lint on the module.
Lint struct {
@@ -298,7 +302,17 @@ func (l *linter) lint(ctx android.ModuleContext) {
}
if l.minSdkVersion != l.compileSdkVersion {
- l.extraMainlineLintErrors = append(l.extraMainlineLintErrors, "NewApi")
+ l.extraMainlineLintErrors = append(l.extraMainlineLintErrors, updatabilityChecks...)
+ _, filtered := android.FilterList(l.properties.Lint.Warning_checks, updatabilityChecks)
+ if len(filtered) != 0 {
+ ctx.PropertyErrorf("lint.warning_checks",
+ "Can't treat %v checks as warnings if min_sdk_version is different from sdk_version.", filtered)
+ }
+ _, filtered = android.FilterList(l.properties.Lint.Disabled_checks, updatabilityChecks)
+ if len(filtered) != 0 {
+ ctx.PropertyErrorf("lint.disabled_checks",
+ "Can't disable %v checks if min_sdk_version is different from sdk_version.", filtered)
+ }
}
extraLintCheckModules := ctx.GetDirectDepsWithTag(extraLintCheckTag)