summaryrefslogtreecommitdiff
path: root/java/lint.go
diff options
context:
space:
mode:
author Cole Faust <colefaust@google.com> 2024-01-04 10:29:27 -0800
committer Cole Faust <colefaust@google.com> 2024-01-04 10:39:33 -0800
commitb765d6bd460dba905ada40be8e89db699232d569 (patch)
treefd089339ab4de6be3667611cb033bbd6911ef91c /java/lint.go
parent36ce95848b0e3da31d379086b7a55cd1ba1d31da (diff)
Don't implicitly pick up lint-baseline.xml
lintable modules currently pick up files named "lint-baseline.xml" to use as the lint baseline implicitly. This is confusing because you could end up using the baseline files in more modules than intended. Lint also has a feature where it requests you remove unnecessary findings from the baseline file, so something could be necessary for one module, but unnecessary for another that accidentally picked up the baseline. All modules that used to pick up the baseline implicitly have been fixed to specify it explicitly already. Fixes: 272769514 Test: Presubmits Change-Id: Id17202e2d119b87ab82c18cb35410b93ed8d5071
Diffstat (limited to 'java/lint.go')
-rw-r--r--java/lint.go21
1 files changed, 4 insertions, 17 deletions
diff --git a/java/lint.go b/java/lint.go
index 5a684a8c0..39f9df273 100644
--- a/java/lint.go
+++ b/java/lint.go
@@ -56,7 +56,8 @@ type LintProperties struct {
// Modules that provide extra lint checks
Extra_check_modules []string
- // Name of the file that lint uses as the baseline. Defaults to "lint-baseline.xml".
+ // The lint baseline file to use. If specified, lint warnings listed in this file will be
+ // suppressed during lint checks.
Baseline_filename *string
// If true, baselining updatability lint checks (e.g. NewApi) is prohibited. Defaults to false.
@@ -365,19 +366,6 @@ func (l *linter) generateManifest(ctx android.ModuleContext, rule *android.RuleB
return manifestPath
}
-func (l *linter) getBaselineFilepath(ctx android.ModuleContext) android.OptionalPath {
- var lintBaseline android.OptionalPath
- if lintFilename := proptools.StringDefault(l.properties.Lint.Baseline_filename, "lint-baseline.xml"); lintFilename != "" {
- if String(l.properties.Lint.Baseline_filename) != "" {
- // if manually specified, we require the file to exist
- lintBaseline = android.OptionalPathForPath(android.PathForModuleSrc(ctx, lintFilename))
- } else {
- lintBaseline = android.ExistentPathForSource(ctx, ctx.ModuleDir(), lintFilename)
- }
- }
- return lintBaseline
-}
-
func (l *linter) lint(ctx android.ModuleContext) {
if !l.enabled() {
return
@@ -518,9 +506,8 @@ func (l *linter) lint(ctx android.ModuleContext) {
cmd.FlagWithArg("--check ", checkOnly)
}
- lintBaseline := l.getBaselineFilepath(ctx)
- if lintBaseline.Valid() {
- cmd.FlagWithInput("--baseline ", lintBaseline.Path())
+ if l.properties.Lint.Baseline_filename != nil {
+ cmd.FlagWithInput("--baseline ", android.PathForModuleSrc(ctx, *l.properties.Lint.Baseline_filename))
}
cmd.FlagWithOutput("--write-reference-baseline ", referenceBaseline)