summaryrefslogtreecommitdiff
path: root/java/lint.go
diff options
context:
space:
mode:
author Jaewoong Jung <jungjw@google.com> 2021-04-19 08:54:36 -0700
committer Jaewoong Jung <jungjw@google.com> 2021-04-19 08:54:36 -0700
commit302c5b8d80fb8b850d33a831b2a4b221c743bbee (patch)
tree80a8598498a36afcbe689bdf4942b6a3ee16def2 /java/lint.go
parent731bb91b8e65c57ec0a55e2ed11abb9910a89c6b (diff)
Extract getBaselineFilepath method.
Test: m nothing Bug: 182349282 Change-Id: Id3ab0f3b7d398af9dcfd66ee3c0bda64d999178d
Diffstat (limited to 'java/lint.go')
-rw-r--r--java/lint.go27
1 files changed, 16 insertions, 11 deletions
diff --git a/java/lint.go b/java/lint.go
index aa308e669..b8ce2a4e5 100644
--- a/java/lint.go
+++ b/java/lint.go
@@ -279,6 +279,19 @@ 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
@@ -381,17 +394,9 @@ func (l *linter) lint(ctx android.ModuleContext) {
cmd.FlagWithArg("--check ", checkOnly)
}
- if lintFilename := proptools.StringDefault(l.properties.Lint.Baseline_filename, "lint-baseline.xml"); lintFilename != "" {
- var lintBaseline android.OptionalPath
- 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)
- }
- if lintBaseline.Valid() {
- cmd.FlagWithInput("--baseline ", lintBaseline.Path())
- }
+ lintBaseline := l.getBaselineFilepath(ctx)
+ if lintBaseline.Valid() {
+ cmd.FlagWithInput("--baseline ", lintBaseline.Path())
}
cmd.Text("|| (").Text("if [ -e").Input(text).Text("]; then cat").Input(text).Text("; fi; exit 7)")