Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c2c765a0 authored by Chih-hung Hsieh's avatar Chih-hung Hsieh Committed by android-build-merger
Browse files

Merge "Add new compiler warning patterns"

am: 3a59a5f6

Change-Id: I4fdc1a183acbbf596e044cf43350f4398e97a02f
parents 7da11edb 3a59a5f6
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -426,6 +426,9 @@ patterns = [
    {'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",
+23 −3
Original line number Diff line number Diff line
@@ -42,8 +42,9 @@ def java_low(description, pattern_list):
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 @@ patterns = [
             [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 @@ patterns = [
                [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 @@ patterns = [
                [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 @@ patterns = [
                [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 @@ patterns = [
                [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 @@ patterns = [
              [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 @@ patterns = [
    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 @@ patterns = [
              [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"]),
]
+14 −10
Original line number Diff line number Diff line
@@ -39,6 +39,10 @@ def asm(description, pattern_list):
  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 @@ patterns = [
     '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',