Add new compiler warning patterns

* Mostly new Java and Kotlin warnings found in nightly builds.
* More clean up of Java and C++ warning patterns will follow.

Test: warn.py --url=http://cs/android --separator='?l=' build.log > warnings.html
Change-Id: I8776401d15c3a59535722d52a5eec03f954d3b15
diff --git a/tools/warn/cpp_warn_patterns.py b/tools/warn/cpp_warn_patterns.py
index 8ae0a3c..ce10693 100644
--- a/tools/warn/cpp_warn_patterns.py
+++ b/tools/warn/cpp_warn_patterns.py
@@ -426,6 +426,9 @@
     {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wnon-literal-null-conversion',
      'description': 'Zero used as null pointer',
      'patterns': [r".*: warning: expression .* zero treated as a null pointer constant"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wpointer-compare',
+     'description': 'Compare pointer to null character',
+     'patterns': [r".*: warning: comparing a pointer to a null character constant"]},
     {'category': 'C/C++', 'severity': Severity.MEDIUM,
      'description': 'Implicit conversion changes value or loses precision',
      'patterns': [r".*: warning: implicit conversion .* changes value from .* to .*-conversion",
diff --git a/tools/warn/java_warn_patterns.py b/tools/warn/java_warn_patterns.py
index 696ce9a..77b80a4 100644
--- a/tools/warn/java_warn_patterns.py
+++ b/tools/warn/java_warn_patterns.py
@@ -42,8 +42,9 @@
 patterns = [
     # pylint:disable=line-too-long,g-inconsistent-quotes
     # Warnings from Javac
-    java_medium('Use of deprecated member',
-                [r'.*: warning: \[deprecation\] .+']),
+    java_medium('Use of deprecated',
+                [r'.*: warning: \[deprecation\] .+',
+                 r'.*: warning: \[removal\] .+ has been deprecated and marked for removal$']),
     java_medium('Unchecked conversion',
                 [r'.*: warning: \[unchecked\] .+']),
     # Warnings generated by Error Prone
@@ -125,6 +126,8 @@
              [r".*: warning: \[UseBinds\] .+"]),
     java_low('Wildcard imports, static or otherwise, should not be used',
              [r".*: warning: \[WildcardImport\] .+"]),
+    java_medium('AcronymName',
+                [r".*\.java:.*: warning: .+ \[AcronymName\]$"]),
     java_medium('Method reference is ambiguous',
                 [r".*: warning: \[AmbiguousMethodReference\] .+"]),
     java_medium('This method passes a pair of parameters through to String.format, but the enclosing method wasn\'t annotated @FormatMethod. Doing so gives compile-time rather than run-time protection against malformed format strings.',
@@ -265,6 +268,8 @@
                 [r".*: warning: \[InstanceOfAndCastMatchWrongType\] .+"]),
     java_medium('Expression of type int may overflow before being assigned to a long',
                 [r".*: warning: \[IntLongMath\] .+"]),
+    java_medium('IntentBuilderName',
+                [r".*\.java:.*: warning: .+ \[IntentBuilderName\]$"]),
     java_medium('This @param tag doesn\'t refer to a parameter of the method.',
                 [r".*: warning: \[InvalidParam\] .+"]),
     java_medium('This tag is invalid.',
@@ -319,6 +324,8 @@
                 [r".*: warning: \[NonCanonicalStaticMemberImport\] .+"]),
     java_medium('equals method doesn\'t override Object.equals',
                 [r".*: warning: \[NonOverridingEquals\] .+"]),
+    java_medium('Not closeable',
+                [r".*\.java:.*: warning: .+ \[NotCloseable\]$"]),
     java_medium('Constructors should not be annotated with @Nullable since they cannot return null',
                 [r".*: warning: \[NullableConstructor\] .+"]),
     java_medium('Dereference of possibly-null value',
@@ -369,6 +376,8 @@
                 [r".*: warning: \[RequiredModifiers\] .+"]),
     java_medium('Void methods should not have a @return tag.',
                 [r".*: warning: \[ReturnFromVoid\] .+"]),
+    java_medium('SAM-compatible parameters should be last',
+                [r".*\.java:.*: warning: .+ \[SamShouldBeLast\]$"]),
     java_medium(u'Prefer the short-circuiting boolean operators \u0026\u0026 and || to \u0026 and |.',
                 [r".*: warning: \[ShortCircuitBoolean\] .+"]),
     java_medium('Writes to static fields should not be guarded by instance locks',
@@ -431,6 +440,10 @@
                 [r".*: warning: \[UnusedException\] .+"]),
     java_medium('Java assert is used in test. For testing purposes Assert.* matchers should be used.',
                 [r".*: warning: \[UseCorrectAssertInTests\] .+"]),
+    java_medium('UserHandle',
+                [r".*\.java:.*: warning: .+ \[UserHandle\]$"]),
+    java_medium('UserHandleName',
+                [r".*\.java:.*: warning: .+ \[UserHandleName\]$"]),
     java_medium('Non-constant variable missing @Var annotation',
                 [r".*: warning: \[Var\] .+"]),
     java_medium('variableName and type with the same name would refer to the static field instead of the class',
@@ -449,6 +462,8 @@
               [r".*: warning: \[ArrayFillIncompatibleType\] .+"]),
     java_high('hashcode method on array does not hash array contents',
               [r".*: warning: \[ArrayHashCode\] .+"]),
+    java_high('ArrayReturn',
+              [r".*\.java:.*: warning: .+ \[ArrayReturn\]$"]),
     java_high('Calling toString on an array does not provide useful information',
               [r".*: warning: \[ArrayToString\] .+"]),
     java_high('Arrays.asList does not autobox primitive arrays, as one might expect.',
@@ -500,7 +515,7 @@
     java_high('Thread created but not started',
               [r".*: warning: \[DeadThread\] .+"]),
     java_high('Deprecated item is not annotated with @Deprecated',
-              [r".*: warning: \[DepAnn\] .+"]),
+              [r".*\.java:.*: warning: \[.*\] .+ is not annotated with @Deprecated$"]),
     java_high('Division by integer literal zero',
               [r".*: warning: \[DivZero\] .+"]),
     java_high('This method should not be called.',
@@ -721,4 +736,9 @@
               [r".*: warning: \[UnusedCollectionModifiedInPlace\] .+"]),
     java_high('`var` should not be used as a type name.',
               [r".*: warning: \[VarTypeName\] .+"]),
+    # Other javac tool warnings
+    java_medium('addNdkApiCoverage failed to getPackage',
+                [r".*: warning: addNdkApiCoverage failed to getPackage"]),
+    java_medium('Supported version from annotation processor',
+                [r".*: warning: Supported source version .+ from annotation processor"]),
 ]
diff --git a/tools/warn/other_warn_patterns.py b/tools/warn/other_warn_patterns.py
index 45d14dc..524673e 100644
--- a/tools/warn/other_warn_patterns.py
+++ b/tools/warn/other_warn_patterns.py
@@ -39,6 +39,10 @@
   return warn('asm', Severity.MEDIUM, description, pattern_list)
 
 
+def kotlin(description, pattern_list):
+  return warn('Kotlin', Severity.MEDIUM, description, pattern_list)
+
+
 patterns = [
     # pylint:disable=line-too-long,g-inconsistent-quotes
     # aapt warnings
@@ -96,16 +100,16 @@
      'description': 'Proto: Import not used',
      'patterns': [r".*: warning: Import .*/.*\.proto but not used.$"]},
     # Kotlin warnings
-    {'category': 'Kotlin', 'severity': Severity.MEDIUM,
-     'description': 'Kotlin: never used parameter or variable',
-     'patterns': [r".*: warning: (parameter|variable) '.*' is never used$"]},
-    {'category': 'Kotlin', 'severity': Severity.MEDIUM,
-     'description': 'Kotlin: Deprecated in Java',
-     'patterns': [r".*: warning: '.*' is deprecated. Deprecated in Java"]},
-    {'category': 'Kotlin', 'severity': Severity.MEDIUM,
-     'description': 'Kotlin: library has Kotlin runtime',
-     'patterns': [r".*: warning: library has Kotlin runtime bundled into it",
-                  r".*: warning: some JAR files .* have the Kotlin Runtime library"]},
+    kotlin('never used parameter or variable',
+           [r".*\.kt:.*: warning: (parameter|variable) '.*' is never used$",
+            r".*\.kt:.*: warning: (parameter|variable) '.*' is never used, could be renamed to _$"]),
+    kotlin('unchecked cast',
+           [r".*\.kt:.*: warning: unchecked cast: .* to .*$"]),
+    kotlin('Deprecated in Java',
+           [r".*\.kt:.*: warning: '.*' is deprecated. Deprecated in Java"]),
+    kotlin('library has Kotlin runtime',
+           [r".*: warning: library has Kotlin runtime bundled into it",
+            r".*: warning: some JAR files .* have the Kotlin Runtime library"]),
     # Rust warnings
     {'category': 'Rust', 'severity': Severity.HIGH,
      'description': 'Rust: Does not derive Copy',