1*9e94795aSAndroid Build Coastguard Worker# python3 2*9e94795aSAndroid Build Coastguard Worker# Copyright (C) 2019 The Android Open Source Project 3*9e94795aSAndroid Build Coastguard Worker# 4*9e94795aSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License"); 5*9e94795aSAndroid Build Coastguard Worker# you may not use this file except in compliance with the License. 6*9e94795aSAndroid Build Coastguard Worker# You may obtain a copy of the License at 7*9e94795aSAndroid Build Coastguard Worker# 8*9e94795aSAndroid Build Coastguard Worker# http://www.apache.org/licenses/LICENSE-2.0 9*9e94795aSAndroid Build Coastguard Worker# 10*9e94795aSAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software 11*9e94795aSAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS, 12*9e94795aSAndroid Build Coastguard Worker# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*9e94795aSAndroid Build Coastguard Worker# See the License for the specific language governing permissions and 14*9e94795aSAndroid Build Coastguard Worker# limitations under the License. 15*9e94795aSAndroid Build Coastguard Worker 16*9e94795aSAndroid Build Coastguard Worker"""Warning patterns for Java compiler tools.""" 17*9e94795aSAndroid Build Coastguard Worker 18*9e94795aSAndroid Build Coastguard Worker# No need of doc strings for trivial small functions. 19*9e94795aSAndroid Build Coastguard Worker# pylint:disable=missing-function-docstring 20*9e94795aSAndroid Build Coastguard Worker 21*9e94795aSAndroid Build Coastguard Worker# pylint:disable=relative-beyond-top-level 22*9e94795aSAndroid Build Coastguard Workerfrom .cpp_warn_patterns import compile_patterns 23*9e94795aSAndroid Build Coastguard Workerfrom .severity import Severity 24*9e94795aSAndroid Build Coastguard Worker 25*9e94795aSAndroid Build Coastguard Worker 26*9e94795aSAndroid Build Coastguard Workerdef java_warn(severity, description, pattern_list): 27*9e94795aSAndroid Build Coastguard Worker return { 28*9e94795aSAndroid Build Coastguard Worker 'category': 'Java', 29*9e94795aSAndroid Build Coastguard Worker 'severity': severity, 30*9e94795aSAndroid Build Coastguard Worker 'description': 'Java: ' + description, 31*9e94795aSAndroid Build Coastguard Worker 'patterns': pattern_list 32*9e94795aSAndroid Build Coastguard Worker } 33*9e94795aSAndroid Build Coastguard Worker 34*9e94795aSAndroid Build Coastguard Worker 35*9e94795aSAndroid Build Coastguard Workerdef java_high(description, pattern_list): 36*9e94795aSAndroid Build Coastguard Worker return java_warn(Severity.HIGH, description, pattern_list) 37*9e94795aSAndroid Build Coastguard Worker 38*9e94795aSAndroid Build Coastguard Worker 39*9e94795aSAndroid Build Coastguard Workerdef java_medium(description, pattern_list): 40*9e94795aSAndroid Build Coastguard Worker return java_warn(Severity.MEDIUM, description, pattern_list) 41*9e94795aSAndroid Build Coastguard Worker 42*9e94795aSAndroid Build Coastguard Worker 43*9e94795aSAndroid Build Coastguard Workerdef warn_with_name(name, severity, description=None): 44*9e94795aSAndroid Build Coastguard Worker if description is None: 45*9e94795aSAndroid Build Coastguard Worker description = name 46*9e94795aSAndroid Build Coastguard Worker return java_warn(severity, description, 47*9e94795aSAndroid Build Coastguard Worker [r'.*\.java:.*: warning: .+ \[' + name + r'\]$', 48*9e94795aSAndroid Build Coastguard Worker r'.*\.java:.*: warning: \[' + name + r'\] .+']) 49*9e94795aSAndroid Build Coastguard Worker 50*9e94795aSAndroid Build Coastguard Worker 51*9e94795aSAndroid Build Coastguard Workerdef high(name, description=None): 52*9e94795aSAndroid Build Coastguard Worker return warn_with_name(name, Severity.HIGH, description) 53*9e94795aSAndroid Build Coastguard Worker 54*9e94795aSAndroid Build Coastguard Worker 55*9e94795aSAndroid Build Coastguard Workerdef medium(name, description=None): 56*9e94795aSAndroid Build Coastguard Worker return warn_with_name(name, Severity.MEDIUM, description) 57*9e94795aSAndroid Build Coastguard Worker 58*9e94795aSAndroid Build Coastguard Worker 59*9e94795aSAndroid Build Coastguard Workerdef low(name, description=None): 60*9e94795aSAndroid Build Coastguard Worker return warn_with_name(name, Severity.LOW, description) 61*9e94795aSAndroid Build Coastguard Worker 62*9e94795aSAndroid Build Coastguard Worker 63*9e94795aSAndroid Build Coastguard Workerwarn_patterns = [ 64*9e94795aSAndroid Build Coastguard Worker # pylint does not recognize g-inconsistent-quotes 65*9e94795aSAndroid Build Coastguard Worker # pylint:disable=line-too-long,bad-option-value,g-inconsistent-quotes 66*9e94795aSAndroid Build Coastguard Worker # Warnings from Javac 67*9e94795aSAndroid Build Coastguard Worker java_medium('Use of deprecated', 68*9e94795aSAndroid Build Coastguard Worker [r'.*: warning: \[deprecation\] .+', 69*9e94795aSAndroid Build Coastguard Worker r'.*: warning: \[removal\] .+ has been deprecated and marked for removal$']), 70*9e94795aSAndroid Build Coastguard Worker java_medium('Incompatible SDK implementation', 71*9e94795aSAndroid Build Coastguard Worker [r'.*\.java:.*: warning: @Implementation .+ has .+ not .+ as in the SDK ']), 72*9e94795aSAndroid Build Coastguard Worker medium('unchecked', 'Unchecked conversion'), 73*9e94795aSAndroid Build Coastguard Worker java_medium('No annotation method', 74*9e94795aSAndroid Build Coastguard Worker [r'.*\.class\): warning: Cannot find annotation method .+ in']), 75*9e94795aSAndroid Build Coastguard Worker java_medium('No class/method in SDK ...', 76*9e94795aSAndroid Build Coastguard Worker [r'.*\.java:.*: warning: No such (class|method) .* for SDK']), 77*9e94795aSAndroid Build Coastguard Worker java_medium('Unknown enum constant', 78*9e94795aSAndroid Build Coastguard Worker [r'unknown_source_file: warning: unknown enum constant .+']), 79*9e94795aSAndroid Build Coastguard Worker # Warnings generated by Error Prone 80*9e94795aSAndroid Build Coastguard Worker java_medium('Non-ascii characters used, but ascii encoding specified', 81*9e94795aSAndroid Build Coastguard Worker [r".*: warning: unmappable character for encoding ascii"]), 82*9e94795aSAndroid Build Coastguard Worker java_medium('Non-varargs call of varargs method with inexact argument type for last parameter', 83*9e94795aSAndroid Build Coastguard Worker [r".*: warning: non-varargs call of varargs method with inexact argument type for last parameter"]), 84*9e94795aSAndroid Build Coastguard Worker java_medium('Unchecked method invocation', 85*9e94795aSAndroid Build Coastguard Worker [r".*: warning: \[unchecked\] unchecked method invocation: .+ in class .+"]), 86*9e94795aSAndroid Build Coastguard Worker java_medium('Unchecked conversion', 87*9e94795aSAndroid Build Coastguard Worker [r".*: warning: \[unchecked\] unchecked conversion"]), 88*9e94795aSAndroid Build Coastguard Worker java_medium('_ used as an identifier', 89*9e94795aSAndroid Build Coastguard Worker [r".*: warning: '_' used as an identifier"]), 90*9e94795aSAndroid Build Coastguard Worker java_medium('hidden superclass', 91*9e94795aSAndroid Build Coastguard Worker [r".*: warning: .* stripped of .* superclass .* \[HiddenSuperclass\]"]), 92*9e94795aSAndroid Build Coastguard Worker java_high('Use of internal proprietary API', 93*9e94795aSAndroid Build Coastguard Worker [r".*: warning: .* is internal proprietary API and may be removed"]), 94*9e94795aSAndroid Build Coastguard Worker low('BooleanParameter', 95*9e94795aSAndroid Build Coastguard Worker 'Use parameter comments to document ambiguous literals'), 96*9e94795aSAndroid Build Coastguard Worker low('ClassNamedLikeTypeParameter', 97*9e94795aSAndroid Build Coastguard Worker 'This class\'s name looks like a Type Parameter.'), 98*9e94795aSAndroid Build Coastguard Worker low('ConstantField', 99*9e94795aSAndroid Build Coastguard Worker 'Field name is CONSTANT_CASE, but field is not static and final'), 100*9e94795aSAndroid Build Coastguard Worker low('EmptySetMultibindingContributions', 101*9e94795aSAndroid Build Coastguard Worker '@Multibinds is a more efficient and declarative mechanism for ensuring that a set multibinding is present in the graph.'), 102*9e94795aSAndroid Build Coastguard Worker low('ExpectedExceptionRefactoring', 103*9e94795aSAndroid Build Coastguard Worker 'Prefer assertThrows to ExpectedException'), 104*9e94795aSAndroid Build Coastguard Worker low('FieldCanBeFinal', 105*9e94795aSAndroid Build Coastguard Worker 'This field is only assigned during initialization; consider making it final'), 106*9e94795aSAndroid Build Coastguard Worker low('FieldMissingNullable', 107*9e94795aSAndroid Build Coastguard Worker 'Fields that can be null should be annotated @Nullable'), 108*9e94795aSAndroid Build Coastguard Worker low('ImmutableRefactoring', 109*9e94795aSAndroid Build Coastguard Worker 'Refactors uses of the JSR 305 @Immutable to Error Prone\'s annotation'), 110*9e94795aSAndroid Build Coastguard Worker low('LambdaFunctionalInterface', 111*9e94795aSAndroid Build Coastguard Worker u'Use Java\'s utility functional interfaces instead of Function\u003cA, B> for primitive types.'), 112*9e94795aSAndroid Build Coastguard Worker low('MethodCanBeStatic', 113*9e94795aSAndroid Build Coastguard Worker 'A private method that does not reference the enclosing instance can be static'), 114*9e94795aSAndroid Build Coastguard Worker low('MixedArrayDimensions', 115*9e94795aSAndroid Build Coastguard Worker 'C-style array declarations should not be used'), 116*9e94795aSAndroid Build Coastguard Worker low('MultiVariableDeclaration', 117*9e94795aSAndroid Build Coastguard Worker 'Variable declarations should declare only one variable'), 118*9e94795aSAndroid Build Coastguard Worker low('MultipleTopLevelClasses', 119*9e94795aSAndroid Build Coastguard Worker 'Source files should not contain multiple top-level class declarations'), 120*9e94795aSAndroid Build Coastguard Worker low('MultipleUnaryOperatorsInMethodCall', 121*9e94795aSAndroid Build Coastguard Worker 'Avoid having multiple unary operators acting on the same variable in a method call'), 122*9e94795aSAndroid Build Coastguard Worker low('OnNameExpected', 123*9e94795aSAndroid Build Coastguard Worker 'OnNameExpected naming style'), 124*9e94795aSAndroid Build Coastguard Worker low('PackageLocation', 125*9e94795aSAndroid Build Coastguard Worker 'Package names should match the directory they are declared in'), 126*9e94795aSAndroid Build Coastguard Worker low('ParameterComment', 127*9e94795aSAndroid Build Coastguard Worker 'Non-standard parameter comment; prefer `/* paramName= */ arg`'), 128*9e94795aSAndroid Build Coastguard Worker low('ParameterNotNullable', 129*9e94795aSAndroid Build Coastguard Worker 'Method parameters that aren\'t checked for null shouldn\'t be annotated @Nullable'), 130*9e94795aSAndroid Build Coastguard Worker low('PrivateConstructorForNoninstantiableModule', 131*9e94795aSAndroid Build Coastguard Worker 'Add a private constructor to modules that will not be instantiated by Dagger.'), 132*9e94795aSAndroid Build Coastguard Worker low('PrivateConstructorForUtilityClass', 133*9e94795aSAndroid Build Coastguard Worker 'Utility classes (only static members) are not designed to be instantiated and should be made noninstantiable with a default constructor.'), 134*9e94795aSAndroid Build Coastguard Worker low('RemoveUnusedImports', 135*9e94795aSAndroid Build Coastguard Worker 'Unused imports'), 136*9e94795aSAndroid Build Coastguard Worker low('ReturnMissingNullable', 137*9e94795aSAndroid Build Coastguard Worker 'Methods that can return null should be annotated @Nullable'), 138*9e94795aSAndroid Build Coastguard Worker low('ScopeOnModule', 139*9e94795aSAndroid Build Coastguard Worker 'Scopes on modules have no function and will soon be an error.'), 140*9e94795aSAndroid Build Coastguard Worker low('SwitchDefault', 141*9e94795aSAndroid Build Coastguard Worker 'The default case of a switch should appear at the end of the last statement group'), 142*9e94795aSAndroid Build Coastguard Worker low('TestExceptionRefactoring', 143*9e94795aSAndroid Build Coastguard Worker 'Prefer assertThrows to @Test(expected=...)'), 144*9e94795aSAndroid Build Coastguard Worker low('ThrowsUncheckedException', 145*9e94795aSAndroid Build Coastguard Worker 'Unchecked exceptions do not need to be declared in the method signature.'), 146*9e94795aSAndroid Build Coastguard Worker low('TryFailRefactoring', 147*9e94795aSAndroid Build Coastguard Worker 'Prefer assertThrows to try/fail'), 148*9e94795aSAndroid Build Coastguard Worker low('TypeParameterNaming', 149*9e94795aSAndroid Build Coastguard Worker 'Type parameters must be a single letter with an optional numeric suffix, or an UpperCamelCase name followed by the letter \'T\'.'), 150*9e94795aSAndroid Build Coastguard Worker low('UngroupedOverloads', 151*9e94795aSAndroid Build Coastguard Worker 'Constructors and methods with the same name should appear sequentially with no other code in between. Please re-order or re-name methods.'), 152*9e94795aSAndroid Build Coastguard Worker low('UnnecessarySetDefault', 153*9e94795aSAndroid Build Coastguard Worker 'Unnecessary call to NullPointerTester#setDefault'), 154*9e94795aSAndroid Build Coastguard Worker low('UnnecessaryStaticImport', 155*9e94795aSAndroid Build Coastguard Worker 'Using static imports for types is unnecessary'), 156*9e94795aSAndroid Build Coastguard Worker low('UseBinds', 157*9e94795aSAndroid Build Coastguard Worker '@Binds is a more efficient and declarative mechanism for delegating a binding.'), 158*9e94795aSAndroid Build Coastguard Worker low('WildcardImport', 159*9e94795aSAndroid Build Coastguard Worker 'Wildcard imports, static or otherwise, should not be used'), 160*9e94795aSAndroid Build Coastguard Worker medium('AcronymName', 161*9e94795aSAndroid Build Coastguard Worker 'AcronymName'), 162*9e94795aSAndroid Build Coastguard Worker medium('AmbiguousMethodReference', 163*9e94795aSAndroid Build Coastguard Worker 'Method reference is ambiguous'), 164*9e94795aSAndroid Build Coastguard Worker medium('AnnotateFormatMethod', 165*9e94795aSAndroid Build Coastguard Worker '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.'), 166*9e94795aSAndroid Build Coastguard Worker medium('AnnotationPosition', 167*9e94795aSAndroid Build Coastguard Worker 'Annotations should be positioned after Javadocs, but before modifiers..'), 168*9e94795aSAndroid Build Coastguard Worker medium('ArgumentSelectionDefectChecker', 169*9e94795aSAndroid Build Coastguard Worker 'Arguments are in the wrong order or could be commented for clarity.'), 170*9e94795aSAndroid Build Coastguard Worker medium('ArrayAsKeyOfSetOrMap', 171*9e94795aSAndroid Build Coastguard Worker 'Arrays do not override equals() or hashCode, so comparisons will be done on reference equality only. If neither deduplication nor lookup are needed, consider using a List instead. Otherwise, use IdentityHashMap/Set, a Map from a library that handles object arrays, or an Iterable/List of pairs.'), 172*9e94795aSAndroid Build Coastguard Worker medium('AssertEqualsArgumentOrderChecker', 173*9e94795aSAndroid Build Coastguard Worker 'Arguments are swapped in assertEquals-like call'), 174*9e94795aSAndroid Build Coastguard Worker medium('AssertFalse', 175*9e94795aSAndroid Build Coastguard Worker 'Assertions may be disabled at runtime and do not guarantee that execution will halt here; consider throwing an exception instead'), 176*9e94795aSAndroid Build Coastguard Worker medium('AssertThrowsMultipleStatements', 177*9e94795aSAndroid Build Coastguard Worker 'The lambda passed to assertThrows should contain exactly one statement'), 178*9e94795aSAndroid Build Coastguard Worker medium('AssertionFailureIgnored', 179*9e94795aSAndroid Build Coastguard Worker 'This assertion throws an AssertionError if it fails, which will be caught by an enclosing try block.'), 180*9e94795aSAndroid Build Coastguard Worker medium('AssistedInjectAndInjectOnConstructors', 181*9e94795aSAndroid Build Coastguard Worker '@AssistedInject and @Inject should not be used on different constructors in the same class.'), 182*9e94795aSAndroid Build Coastguard Worker medium('AutoValueFinalMethods', 183*9e94795aSAndroid Build Coastguard Worker 'Make toString(), hashCode() and equals() final in AutoValue classes, so it is clear to readers that AutoValue is not overriding them'), 184*9e94795aSAndroid Build Coastguard Worker medium('BadAnnotationImplementation', 185*9e94795aSAndroid Build Coastguard Worker 'Classes that implement Annotation must override equals and hashCode. Consider using AutoAnnotation instead of implementing Annotation by hand.'), 186*9e94795aSAndroid Build Coastguard Worker medium('BadComparable', 187*9e94795aSAndroid Build Coastguard Worker 'Possible sign flip from narrowing conversion'), 188*9e94795aSAndroid Build Coastguard Worker medium('BadImport', 189*9e94795aSAndroid Build Coastguard Worker 'Importing nested classes/static methods/static fields with commonly-used names can make code harder to read, because it may not be clear from the context exactly which type is being referred to. Qualifying the name with that of the containing class can make the code clearer.'), 190*9e94795aSAndroid Build Coastguard Worker medium('BadInstanceof', 191*9e94795aSAndroid Build Coastguard Worker 'instanceof used in a way that is equivalent to a null check.'), 192*9e94795aSAndroid Build Coastguard Worker medium('BigDecimalEquals', 193*9e94795aSAndroid Build Coastguard Worker 'BigDecimal#equals has surprising behavior: it also compares scale.'), 194*9e94795aSAndroid Build Coastguard Worker medium('BigDecimalLiteralDouble', 195*9e94795aSAndroid Build Coastguard Worker 'new BigDecimal(double) loses precision in this case.'), 196*9e94795aSAndroid Build Coastguard Worker medium('BinderIdentityRestoredDangerously', 197*9e94795aSAndroid Build Coastguard Worker 'A call to Binder.clearCallingIdentity() should be followed by Binder.restoreCallingIdentity() in a finally block. Otherwise the wrong Binder identity may be used by subsequent code.'), 198*9e94795aSAndroid Build Coastguard Worker medium('BindingToUnqualifiedCommonType', 199*9e94795aSAndroid Build Coastguard Worker 'This code declares a binding for a common value type without a Qualifier annotation.'), 200*9e94795aSAndroid Build Coastguard Worker medium('BoxedPrimitiveConstructor', 201*9e94795aSAndroid Build Coastguard Worker 'valueOf or autoboxing provides better time and space performance'), 202*9e94795aSAndroid Build Coastguard Worker medium('ByteBufferBackingArray', 203*9e94795aSAndroid Build Coastguard Worker 'ByteBuffer.array() shouldn\'t be called unless ByteBuffer.arrayOffset() is used or if the ByteBuffer was initialized using ByteBuffer.wrap() or ByteBuffer.allocate().'), 204*9e94795aSAndroid Build Coastguard Worker medium('CannotMockFinalClass', 205*9e94795aSAndroid Build Coastguard Worker 'Mockito cannot mock final classes'), 206*9e94795aSAndroid Build Coastguard Worker medium('CanonicalDuration', 207*9e94795aSAndroid Build Coastguard Worker 'Duration can be expressed more clearly with different units'), 208*9e94795aSAndroid Build Coastguard Worker medium('CatchAndPrintStackTrace', 209*9e94795aSAndroid Build Coastguard Worker 'Logging or rethrowing exceptions should usually be preferred to catching and calling printStackTrace'), 210*9e94795aSAndroid Build Coastguard Worker medium('CatchFail', 211*9e94795aSAndroid Build Coastguard Worker 'Ignoring exceptions and calling fail() is unnecessary, and makes test output less useful'), 212*9e94795aSAndroid Build Coastguard Worker medium('ChangedAbstract', 213*9e94795aSAndroid Build Coastguard Worker 'Method has changed \'abstract\' qualifier'), 214*9e94795aSAndroid Build Coastguard Worker medium('ClassCanBeStatic', 215*9e94795aSAndroid Build Coastguard Worker 'Inner class is non-static but does not reference enclosing class'), 216*9e94795aSAndroid Build Coastguard Worker medium('ClassNewInstance', 217*9e94795aSAndroid Build Coastguard Worker 'Class.newInstance() bypasses exception checking; prefer getDeclaredConstructor().newInstance()'), 218*9e94795aSAndroid Build Coastguard Worker medium('CloseableProvides', 219*9e94795aSAndroid Build Coastguard Worker 'Providing Closeable resources makes their lifecycle unclear'), 220*9e94795aSAndroid Build Coastguard Worker medium('CollectionToArraySafeParameter', 221*9e94795aSAndroid Build Coastguard Worker 'The type of the array parameter of Collection.toArray needs to be compatible with the array type'), 222*9e94795aSAndroid Build Coastguard Worker medium('CollectorShouldNotUseState', 223*9e94795aSAndroid Build Coastguard Worker 'Collector.of() should not use state'), 224*9e94795aSAndroid Build Coastguard Worker medium('ComparableAndComparator', 225*9e94795aSAndroid Build Coastguard Worker 'Class should not implement both `Comparable` and `Comparator`'), 226*9e94795aSAndroid Build Coastguard Worker medium('ConstructorInvokesOverridable', 227*9e94795aSAndroid Build Coastguard Worker 'Constructors should not invoke overridable methods.'), 228*9e94795aSAndroid Build Coastguard Worker medium('ConstructorLeaksThis', 229*9e94795aSAndroid Build Coastguard Worker 'Constructors should not pass the \'this\' reference out in method invocations, since the object may not be fully constructed.'), 230*9e94795aSAndroid Build Coastguard Worker medium('DateFormatConstant', 231*9e94795aSAndroid Build Coastguard Worker 'DateFormat is not thread-safe, and should not be used as a constant field.'), 232*9e94795aSAndroid Build Coastguard Worker medium('DefaultCharset', 233*9e94795aSAndroid Build Coastguard Worker 'Implicit use of the platform default charset, which can result in differing behaviour between JVM executions or incorrect behavior if the encoding of the data source doesn\'t match expectations.'), 234*9e94795aSAndroid Build Coastguard Worker medium('DeprecatedThreadMethods', 235*9e94795aSAndroid Build Coastguard Worker 'Avoid deprecated Thread methods; read the method\'s javadoc for details.'), 236*9e94795aSAndroid Build Coastguard Worker medium('DoubleBraceInitialization', 237*9e94795aSAndroid Build Coastguard Worker 'Prefer collection factory methods or builders to the double-brace initialization pattern.'), 238*9e94795aSAndroid Build Coastguard Worker medium('DoubleCheckedLocking', 239*9e94795aSAndroid Build Coastguard Worker 'Double-checked locking on non-volatile fields is unsafe'), 240*9e94795aSAndroid Build Coastguard Worker medium('EmptyTopLevelDeclaration', 241*9e94795aSAndroid Build Coastguard Worker 'Empty top-level type declaration'), 242*9e94795aSAndroid Build Coastguard Worker medium('EqualsBrokenForNull', 243*9e94795aSAndroid Build Coastguard Worker 'equals() implementation may throw NullPointerException when given null'), 244*9e94795aSAndroid Build Coastguard Worker medium('EqualsGetClass', 245*9e94795aSAndroid Build Coastguard Worker 'Overriding Object#equals in a non-final class by using getClass rather than instanceof breaks substitutability of subclasses.'), 246*9e94795aSAndroid Build Coastguard Worker medium('EqualsHashCode', 247*9e94795aSAndroid Build Coastguard Worker 'Classes that override equals should also override hashCode.'), 248*9e94795aSAndroid Build Coastguard Worker medium('EqualsIncompatibleType', 249*9e94795aSAndroid Build Coastguard Worker 'An equality test between objects with incompatible types always returns false'), 250*9e94795aSAndroid Build Coastguard Worker medium('EqualsUnsafeCast', 251*9e94795aSAndroid Build Coastguard Worker 'The contract of #equals states that it should return false for incompatible types, while this implementation may throw ClassCastException.'), 252*9e94795aSAndroid Build Coastguard Worker medium('EqualsUsingHashCode', 253*9e94795aSAndroid Build Coastguard Worker 'Implementing #equals by just comparing hashCodes is fragile. Hashes collide frequently, and this will lead to false positives in #equals.'), 254*9e94795aSAndroid Build Coastguard Worker medium('ExpectedExceptionChecker', 255*9e94795aSAndroid Build Coastguard Worker 'Calls to ExpectedException#expect should always be followed by exactly one statement.'), 256*9e94795aSAndroid Build Coastguard Worker medium('ExtendingJUnitAssert', 257*9e94795aSAndroid Build Coastguard Worker 'When only using JUnit Assert\'s static methods, you should import statically instead of extending.'), 258*9e94795aSAndroid Build Coastguard Worker medium('FallThrough', 259*9e94795aSAndroid Build Coastguard Worker 'Switch case may fall through'), 260*9e94795aSAndroid Build Coastguard Worker medium('Finally', 261*9e94795aSAndroid Build Coastguard Worker 'If you return or throw from a finally, then values returned or thrown from the try-catch block will be ignored. Consider using try-with-resources instead.'), 262*9e94795aSAndroid Build Coastguard Worker medium('FloatCast', 263*9e94795aSAndroid Build Coastguard Worker 'Use parentheses to make the precedence explicit'), 264*9e94795aSAndroid Build Coastguard Worker medium('FloatingPointAssertionWithinEpsilon', 265*9e94795aSAndroid Build Coastguard Worker 'This fuzzy equality check is using a tolerance less than the gap to the next number. You may want a less restrictive tolerance, or to assert equality.'), 266*9e94795aSAndroid Build Coastguard Worker medium('FloatingPointLiteralPrecision', 267*9e94795aSAndroid Build Coastguard Worker 'Floating point literal loses precision'), 268*9e94795aSAndroid Build Coastguard Worker medium('FragmentInjection', 269*9e94795aSAndroid Build Coastguard Worker 'Classes extending PreferenceActivity must implement isValidFragment such that it does not unconditionally return true to prevent vulnerability to fragment injection attacks.'), 270*9e94795aSAndroid Build Coastguard Worker medium('FragmentNotInstantiable', 271*9e94795aSAndroid Build Coastguard Worker 'Subclasses of Fragment must be instantiable via Class#newInstance(): the class must be public, static and have a public nullary constructor'), 272*9e94795aSAndroid Build Coastguard Worker medium('FunctionalInterfaceClash', 273*9e94795aSAndroid Build Coastguard Worker 'Overloads will be ambiguous when passing lambda arguments'), 274*9e94795aSAndroid Build Coastguard Worker medium('FutureReturnValueIgnored', 275*9e94795aSAndroid Build Coastguard Worker 'Return value of methods returning Future must be checked. Ignoring returned Futures suppresses exceptions thrown from the code that completes the Future.'), 276*9e94795aSAndroid Build Coastguard Worker medium('GetClassOnEnum', 277*9e94795aSAndroid Build Coastguard Worker 'Calling getClass() on an enum may return a subclass of the enum type'), 278*9e94795aSAndroid Build Coastguard Worker medium('HardCodedSdCardPath', 279*9e94795aSAndroid Build Coastguard Worker 'Hardcoded reference to /sdcard'), 280*9e94795aSAndroid Build Coastguard Worker medium('HidingField', 281*9e94795aSAndroid Build Coastguard Worker 'Hiding fields of superclasses may cause confusion and errors'), 282*9e94795aSAndroid Build Coastguard Worker medium('ImmutableAnnotationChecker', 283*9e94795aSAndroid Build Coastguard Worker 'Annotations should always be immutable'), 284*9e94795aSAndroid Build Coastguard Worker medium('ImmutableEnumChecker', 285*9e94795aSAndroid Build Coastguard Worker 'Enums should always be immutable'), 286*9e94795aSAndroid Build Coastguard Worker medium('IncompatibleModifiers', 287*9e94795aSAndroid Build Coastguard Worker 'This annotation has incompatible modifiers as specified by its @IncompatibleModifiers annotation'), 288*9e94795aSAndroid Build Coastguard Worker medium('InconsistentCapitalization', 289*9e94795aSAndroid Build Coastguard Worker 'It is confusing to have a field and a parameter under the same scope that differ only in capitalization.'), 290*9e94795aSAndroid Build Coastguard Worker medium('InconsistentHashCode', 291*9e94795aSAndroid Build Coastguard Worker 'Including fields in hashCode which are not compared in equals violates the contract of hashCode.'), 292*9e94795aSAndroid Build Coastguard Worker medium('InconsistentOverloads', 293*9e94795aSAndroid Build Coastguard Worker 'The ordering of parameters in overloaded methods should be as consistent as possible (when viewed from left to right)'), 294*9e94795aSAndroid Build Coastguard Worker medium('IncrementInForLoopAndHeader', 295*9e94795aSAndroid Build Coastguard Worker 'This for loop increments the same variable in the header and in the body'), 296*9e94795aSAndroid Build Coastguard Worker medium('InjectOnConstructorOfAbstractClass', 297*9e94795aSAndroid Build Coastguard Worker 'Constructors on abstract classes are never directly @Injected, only the constructors of their subclasses can be @Inject\'ed.'), 298*9e94795aSAndroid Build Coastguard Worker medium('InputStreamSlowMultibyteRead', 299*9e94795aSAndroid Build Coastguard Worker 'Please also override int read(byte[], int, int), otherwise multi-byte reads from this input stream are likely to be slow.'), 300*9e94795aSAndroid Build Coastguard Worker medium('InstanceOfAndCastMatchWrongType', 301*9e94795aSAndroid Build Coastguard Worker 'Casting inside an if block should be plausibly consistent with the instanceof type'), 302*9e94795aSAndroid Build Coastguard Worker medium('IntLongMath', 303*9e94795aSAndroid Build Coastguard Worker 'Expression of type int may overflow before being assigned to a long'), 304*9e94795aSAndroid Build Coastguard Worker medium('IntentBuilderName', 305*9e94795aSAndroid Build Coastguard Worker 'IntentBuilderName'), 306*9e94795aSAndroid Build Coastguard Worker medium('InvalidParam', 307*9e94795aSAndroid Build Coastguard Worker 'This @param tag doesn\'t refer to a parameter of the method.'), 308*9e94795aSAndroid Build Coastguard Worker medium('InvalidTag', 309*9e94795aSAndroid Build Coastguard Worker 'This tag is invalid.'), 310*9e94795aSAndroid Build Coastguard Worker medium('InvalidThrows', 311*9e94795aSAndroid Build Coastguard Worker 'The documented method doesn\'t actually throw this checked exception.'), 312*9e94795aSAndroid Build Coastguard Worker medium('IterableAndIterator', 313*9e94795aSAndroid Build Coastguard Worker 'Class should not implement both `Iterable` and `Iterator`'), 314*9e94795aSAndroid Build Coastguard Worker medium('JUnit3FloatingPointComparisonWithoutDelta', 315*9e94795aSAndroid Build Coastguard Worker 'Floating-point comparison without error tolerance'), 316*9e94795aSAndroid Build Coastguard Worker medium('JUnit4ClassUsedInJUnit3', 317*9e94795aSAndroid Build Coastguard Worker 'Some JUnit4 construct cannot be used in a JUnit3 context. Convert your class to JUnit4 style to use them.'), 318*9e94795aSAndroid Build Coastguard Worker medium('JUnitAmbiguousTestClass', 319*9e94795aSAndroid Build Coastguard Worker 'Test class inherits from JUnit 3\'s TestCase but has JUnit 4 @Test annotations.'), 320*9e94795aSAndroid Build Coastguard Worker medium('JavaLangClash', 321*9e94795aSAndroid Build Coastguard Worker 'Never reuse class names from java.lang'), 322*9e94795aSAndroid Build Coastguard Worker medium('JdkObsolete', 323*9e94795aSAndroid Build Coastguard Worker 'Suggests alternatives to obsolete JDK classes.'), 324*9e94795aSAndroid Build Coastguard Worker medium('LockNotBeforeTry', 325*9e94795aSAndroid Build Coastguard Worker 'Calls to Lock#lock should be immediately followed by a try block which releases the lock.'), 326*9e94795aSAndroid Build Coastguard Worker medium('LogicalAssignment', 327*9e94795aSAndroid Build Coastguard Worker 'Assignment where a boolean expression was expected; use == if this assignment wasn\'t expected or add parentheses for clarity.'), 328*9e94795aSAndroid Build Coastguard Worker medium('MathAbsoluteRandom', 329*9e94795aSAndroid Build Coastguard Worker 'Math.abs does not always give a positive result. Please consider other methods for positive random numbers.'), 330*9e94795aSAndroid Build Coastguard Worker medium('MissingCasesInEnumSwitch', 331*9e94795aSAndroid Build Coastguard Worker 'Switches on enum types should either handle all values, or have a default case.'), 332*9e94795aSAndroid Build Coastguard Worker medium('MissingDefault', 333*9e94795aSAndroid Build Coastguard Worker 'The Google Java Style Guide requires that each switch statement includes a default statement group, even if it contains no code. (This requirement is lifted for any switch statement that covers all values of an enum.)'), 334*9e94795aSAndroid Build Coastguard Worker medium('MissingFail', 335*9e94795aSAndroid Build Coastguard Worker 'Not calling fail() when expecting an exception masks bugs'), 336*9e94795aSAndroid Build Coastguard Worker medium('MissingOverride', 337*9e94795aSAndroid Build Coastguard Worker 'method overrides method in supertype; expected @Override'), 338*9e94795aSAndroid Build Coastguard Worker medium('ModifiedButNotUsed', 339*9e94795aSAndroid Build Coastguard Worker 'A collection or proto builder was created, but its values were never accessed.'), 340*9e94795aSAndroid Build Coastguard Worker medium('ModifyCollectionInEnhancedForLoop', 341*9e94795aSAndroid Build Coastguard Worker 'Modifying a collection while iterating over it in a loop may cause a ConcurrentModificationException to be thrown.'), 342*9e94795aSAndroid Build Coastguard Worker medium('MultipleParallelOrSequentialCalls', 343*9e94795aSAndroid Build Coastguard Worker 'Multiple calls to either parallel or sequential are unnecessary and cause confusion.'), 344*9e94795aSAndroid Build Coastguard Worker medium('MutableConstantField', 345*9e94795aSAndroid Build Coastguard Worker 'Constant field declarations should use the immutable type (such as ImmutableList) instead of the general collection interface type (such as List)'), 346*9e94795aSAndroid Build Coastguard Worker medium('MutableMethodReturnType', 347*9e94795aSAndroid Build Coastguard Worker 'Method return type should use the immutable type (such as ImmutableList) instead of the general collection interface type (such as List)'), 348*9e94795aSAndroid Build Coastguard Worker medium('NarrowingCompoundAssignment', 349*9e94795aSAndroid Build Coastguard Worker 'Compound assignments may hide dangerous casts'), 350*9e94795aSAndroid Build Coastguard Worker medium('NestedInstanceOfConditions', 351*9e94795aSAndroid Build Coastguard Worker 'Nested instanceOf conditions of disjoint types create blocks of code that never execute'), 352*9e94795aSAndroid Build Coastguard Worker medium('NoFunctionalReturnType', 353*9e94795aSAndroid Build Coastguard Worker 'Instead of returning a functional type, return the actual type that the returned function would return and use lambdas at use site.'), 354*9e94795aSAndroid Build Coastguard Worker medium('NonAtomicVolatileUpdate', 355*9e94795aSAndroid Build Coastguard Worker 'This update of a volatile variable is non-atomic'), 356*9e94795aSAndroid Build Coastguard Worker medium('NonCanonicalStaticMemberImport', 357*9e94795aSAndroid Build Coastguard Worker 'Static import of member uses non-canonical name'), 358*9e94795aSAndroid Build Coastguard Worker medium('NonOverridingEquals', 359*9e94795aSAndroid Build Coastguard Worker 'equals method doesn\'t override Object.equals'), 360*9e94795aSAndroid Build Coastguard Worker medium('NotCloseable', 361*9e94795aSAndroid Build Coastguard Worker 'Not closeable'), 362*9e94795aSAndroid Build Coastguard Worker medium('NullableCollection', 363*9e94795aSAndroid Build Coastguard Worker 'Method should not return a nullable collection'), 364*9e94795aSAndroid Build Coastguard Worker medium('NullableConstructor', 365*9e94795aSAndroid Build Coastguard Worker 'Constructors should not be annotated with @Nullable since they cannot return null'), 366*9e94795aSAndroid Build Coastguard Worker medium('NullableDereference', 367*9e94795aSAndroid Build Coastguard Worker 'Dereference of possibly-null value'), 368*9e94795aSAndroid Build Coastguard Worker medium('NullablePrimitive', 369*9e94795aSAndroid Build Coastguard Worker '@Nullable should not be used for primitive types since they cannot be null'), 370*9e94795aSAndroid Build Coastguard Worker medium('NullableVoid', 371*9e94795aSAndroid Build Coastguard Worker 'void-returning methods should not be annotated with @Nullable, since they cannot return null'), 372*9e94795aSAndroid Build Coastguard Worker medium('ObjectToString', 373*9e94795aSAndroid Build Coastguard Worker 'Calling toString on Objects that don\'t override toString() doesn\'t provide useful information'), 374*9e94795aSAndroid Build Coastguard Worker medium('ObjectsHashCodePrimitive', 375*9e94795aSAndroid Build Coastguard Worker 'Objects.hashCode(Object o) should not be passed a primitive value'), 376*9e94795aSAndroid Build Coastguard Worker medium('OperatorPrecedence', 377*9e94795aSAndroid Build Coastguard Worker 'Use grouping parenthesis to make the operator precedence explicit'), 378*9e94795aSAndroid Build Coastguard Worker medium('OptionalNotPresent', 379*9e94795aSAndroid Build Coastguard Worker 'One should not call optional.get() inside an if statement that checks !optional.isPresent'), 380*9e94795aSAndroid Build Coastguard Worker medium('OrphanedFormatString', 381*9e94795aSAndroid Build Coastguard Worker 'String literal contains format specifiers, but is not passed to a format method'), 382*9e94795aSAndroid Build Coastguard Worker medium('OverrideThrowableToString', 383*9e94795aSAndroid Build Coastguard Worker 'To return a custom message with a Throwable class, one should override getMessage() instead of toString() for Throwable.'), 384*9e94795aSAndroid Build Coastguard Worker medium('Overrides', 385*9e94795aSAndroid Build Coastguard Worker 'Varargs doesn\'t agree for overridden method'), 386*9e94795aSAndroid Build Coastguard Worker medium('OverridesGuiceInjectableMethod', 387*9e94795aSAndroid Build Coastguard Worker 'This method is not annotated with @Inject, but it overrides a method that is annotated with @com.google.inject.Inject. Guice will inject this method, and it is recommended to annotate it explicitly.'), 388*9e94795aSAndroid Build Coastguard Worker medium('ParameterName', 389*9e94795aSAndroid Build Coastguard Worker 'Detects `/* name= */`-style comments on actual parameters where the name doesn\'t match the formal parameter'), 390*9e94795aSAndroid Build Coastguard Worker medium('PreconditionsInvalidPlaceholder', 391*9e94795aSAndroid Build Coastguard Worker 'Preconditions only accepts the %s placeholder in error message strings'), 392*9e94795aSAndroid Build Coastguard Worker medium('PrimitiveArrayPassedToVarargsMethod', 393*9e94795aSAndroid Build Coastguard Worker 'Passing a primitive array to a varargs method is usually wrong'), 394*9e94795aSAndroid Build Coastguard Worker medium('ProtoRedundantSet', 395*9e94795aSAndroid Build Coastguard Worker 'A field on a protocol buffer was set twice in the same chained expression.'), 396*9e94795aSAndroid Build Coastguard Worker medium('ProtosAsKeyOfSetOrMap', 397*9e94795aSAndroid Build Coastguard Worker 'Protos should not be used as a key to a map, in a set, or in a contains method on a descendant of a collection. Protos have non deterministic ordering and proto equality is deep, which is a performance issue.'), 398*9e94795aSAndroid Build Coastguard Worker medium('ProvidesFix', 399*9e94795aSAndroid Build Coastguard Worker 'BugChecker has incorrect ProvidesFix tag, please update'), 400*9e94795aSAndroid Build Coastguard Worker medium('QualifierOrScopeOnInjectMethod', 401*9e94795aSAndroid Build Coastguard Worker 'Qualifiers/Scope annotations on @Inject methods don\'t have any effect. Move the qualifier annotation to the binding location.'), 402*9e94795aSAndroid Build Coastguard Worker medium('QualifierWithTypeUse', 403*9e94795aSAndroid Build Coastguard Worker 'Injection frameworks currently don\'t understand Qualifiers in TYPE_PARAMETER or TYPE_USE contexts.'), 404*9e94795aSAndroid Build Coastguard Worker medium('ReachabilityFenceUsage', 405*9e94795aSAndroid Build Coastguard Worker 'reachabilityFence should always be called inside a finally block'), 406*9e94795aSAndroid Build Coastguard Worker medium('RedundantThrows', 407*9e94795aSAndroid Build Coastguard Worker 'Thrown exception is a subtype of another'), 408*9e94795aSAndroid Build Coastguard Worker medium('ReferenceEquality', 409*9e94795aSAndroid Build Coastguard Worker 'Comparison using reference equality instead of value equality'), 410*9e94795aSAndroid Build Coastguard Worker medium('RequiredModifiers', 411*9e94795aSAndroid Build Coastguard Worker 'This annotation is missing required modifiers as specified by its @RequiredModifiers annotation'), 412*9e94795aSAndroid Build Coastguard Worker medium('ReturnFromVoid', 413*9e94795aSAndroid Build Coastguard Worker 'Void methods should not have a @return tag.'), 414*9e94795aSAndroid Build Coastguard Worker medium('SamShouldBeLast', 415*9e94795aSAndroid Build Coastguard Worker 'SAM-compatible parameters should be last'), 416*9e94795aSAndroid Build Coastguard Worker medium('ShortCircuitBoolean', 417*9e94795aSAndroid Build Coastguard Worker u'Prefer the short-circuiting boolean operators \u0026\u0026 and || to \u0026 and |.'), 418*9e94795aSAndroid Build Coastguard Worker medium('StaticGuardedByInstance', 419*9e94795aSAndroid Build Coastguard Worker 'Writes to static fields should not be guarded by instance locks'), 420*9e94795aSAndroid Build Coastguard Worker medium('StaticQualifiedUsingExpression', 421*9e94795aSAndroid Build Coastguard Worker 'A static variable or method should be qualified with a class name, not expression'), 422*9e94795aSAndroid Build Coastguard Worker medium('StreamResourceLeak', 423*9e94795aSAndroid Build Coastguard Worker 'Streams that encapsulate a closeable resource should be closed using try-with-resources'), 424*9e94795aSAndroid Build Coastguard Worker medium('StringEquality', 425*9e94795aSAndroid Build Coastguard Worker 'String comparison using reference equality instead of value equality'), 426*9e94795aSAndroid Build Coastguard Worker medium('StringSplitter', 427*9e94795aSAndroid Build Coastguard Worker 'String.split(String) has surprising behavior'), 428*9e94795aSAndroid Build Coastguard Worker medium('SwigMemoryLeak', 429*9e94795aSAndroid Build Coastguard Worker 'SWIG generated code that can\'t call a C++ destructor will leak memory'), 430*9e94795aSAndroid Build Coastguard Worker medium('SynchronizeOnNonFinalField', 431*9e94795aSAndroid Build Coastguard Worker 'Synchronizing on non-final fields is not safe: if the field is ever updated, different threads may end up locking on different objects.'), 432*9e94795aSAndroid Build Coastguard Worker medium('SystemExitOutsideMain', 433*9e94795aSAndroid Build Coastguard Worker 'Code that contains System.exit() is untestable.'), 434*9e94795aSAndroid Build Coastguard Worker medium('TestExceptionChecker', 435*9e94795aSAndroid Build Coastguard Worker 'Using @Test(expected=...) is discouraged, since the test will pass if *any* statement in the test method throws the expected exception'), 436*9e94795aSAndroid Build Coastguard Worker medium('ThreadJoinLoop', 437*9e94795aSAndroid Build Coastguard Worker 'Thread.join needs to be surrounded by a loop until it succeeds, as in Uninterruptibles.joinUninterruptibly.'), 438*9e94795aSAndroid Build Coastguard Worker medium('ThreadLocalUsage', 439*9e94795aSAndroid Build Coastguard Worker 'ThreadLocals should be stored in static fields'), 440*9e94795aSAndroid Build Coastguard Worker medium('ThreadPriorityCheck', 441*9e94795aSAndroid Build Coastguard Worker 'Relying on the thread scheduler is discouraged; see Effective Java Item 72 (2nd edition) / 84 (3rd edition).'), 442*9e94795aSAndroid Build Coastguard Worker medium('ThreeLetterTimeZoneID', 443*9e94795aSAndroid Build Coastguard Worker 'Three-letter time zone identifiers are deprecated, may be ambiguous, and might not do what you intend; the full IANA time zone ID should be used instead.'), 444*9e94795aSAndroid Build Coastguard Worker medium('ToStringReturnsNull', 445*9e94795aSAndroid Build Coastguard Worker 'An implementation of Object.toString() should never return null.'), 446*9e94795aSAndroid Build Coastguard Worker medium('TruthAssertExpected', 447*9e94795aSAndroid Build Coastguard Worker 'The actual and expected values appear to be swapped, which results in poor assertion failure messages. The actual value should come first.'), 448*9e94795aSAndroid Build Coastguard Worker medium('TruthConstantAsserts', 449*9e94795aSAndroid Build Coastguard Worker 'Truth Library assert is called on a constant.'), 450*9e94795aSAndroid Build Coastguard Worker medium('TruthIncompatibleType', 451*9e94795aSAndroid Build Coastguard Worker 'Argument is not compatible with the subject\'s type.'), 452*9e94795aSAndroid Build Coastguard Worker medium('TypeNameShadowing', 453*9e94795aSAndroid Build Coastguard Worker 'Type parameter declaration shadows another named type'), 454*9e94795aSAndroid Build Coastguard Worker medium('TypeParameterShadowing', 455*9e94795aSAndroid Build Coastguard Worker 'Type parameter declaration overrides another type parameter already declared'), 456*9e94795aSAndroid Build Coastguard Worker medium('TypeParameterUnusedInFormals', 457*9e94795aSAndroid Build Coastguard Worker 'Declaring a type parameter that is only used in the return type is a misuse of generics: operations on the type parameter are unchecked, it hides unsafe casts at invocations of the method, and it interacts badly with method overload resolution.'), 458*9e94795aSAndroid Build Coastguard Worker medium('URLEqualsHashCode', 459*9e94795aSAndroid Build Coastguard Worker 'Avoid hash-based containers of java.net.URL--the containers rely on equals() and hashCode(), which cause java.net.URL to make blocking internet connections.'), 460*9e94795aSAndroid Build Coastguard Worker medium('UndefinedEquals', 461*9e94795aSAndroid Build Coastguard Worker 'Collection, Iterable, Multimap, and Queue do not have well-defined equals behavior'), 462*9e94795aSAndroid Build Coastguard Worker medium('UnnecessaryDefaultInEnumSwitch', 463*9e94795aSAndroid Build Coastguard Worker 'Switch handles all enum values: an explicit default case is unnecessary and defeats error checking for non-exhaustive switches.'), 464*9e94795aSAndroid Build Coastguard Worker medium('UnnecessaryParentheses', 465*9e94795aSAndroid Build Coastguard Worker 'Unnecessary use of grouping parentheses'), 466*9e94795aSAndroid Build Coastguard Worker medium('UnsafeFinalization', 467*9e94795aSAndroid Build Coastguard Worker 'Finalizer may run before native code finishes execution'), 468*9e94795aSAndroid Build Coastguard Worker medium('UnsafeReflectiveConstructionCast', 469*9e94795aSAndroid Build Coastguard Worker 'Prefer `asSubclass` instead of casting the result of `newInstance`, to detect classes of incorrect type before invoking their constructors.This way, if the class is of the incorrect type,it will throw an exception before invoking its constructor.'), 470*9e94795aSAndroid Build Coastguard Worker medium('UnsynchronizedOverridesSynchronized', 471*9e94795aSAndroid Build Coastguard Worker 'Unsynchronized method overrides a synchronized method.'), 472*9e94795aSAndroid Build Coastguard Worker medium('Unused', 473*9e94795aSAndroid Build Coastguard Worker 'Unused.'), 474*9e94795aSAndroid Build Coastguard Worker medium('UnusedException', 475*9e94795aSAndroid Build Coastguard Worker 'This catch block catches an exception and re-throws another, but swallows the caught exception rather than setting it as a cause. This can make debugging harder.'), 476*9e94795aSAndroid Build Coastguard Worker medium('UseCorrectAssertInTests', 477*9e94795aSAndroid Build Coastguard Worker 'Java assert is used in test. For testing purposes Assert.* matchers should be used.'), 478*9e94795aSAndroid Build Coastguard Worker medium('UserHandle', 479*9e94795aSAndroid Build Coastguard Worker 'UserHandle'), 480*9e94795aSAndroid Build Coastguard Worker medium('UserHandleName', 481*9e94795aSAndroid Build Coastguard Worker 'UserHandleName'), 482*9e94795aSAndroid Build Coastguard Worker medium('Var', 483*9e94795aSAndroid Build Coastguard Worker 'Non-constant variable missing @Var annotation'), 484*9e94795aSAndroid Build Coastguard Worker medium('VariableNameSameAsType', 485*9e94795aSAndroid Build Coastguard Worker 'variableName and type with the same name would refer to the static field instead of the class'), 486*9e94795aSAndroid Build Coastguard Worker medium('WaitNotInLoop', 487*9e94795aSAndroid Build Coastguard Worker 'Because of spurious wakeups, Object.wait() and Condition.await() must always be called in a loop'), 488*9e94795aSAndroid Build Coastguard Worker medium('WakelockReleasedDangerously', 489*9e94795aSAndroid Build Coastguard Worker 'A wakelock acquired with a timeout may be released by the system before calling `release`, even after checking `isHeld()`. If so, it will throw a RuntimeException. Please wrap in a try/catch block.'), 490*9e94795aSAndroid Build Coastguard Worker java_medium('Found raw type', 491*9e94795aSAndroid Build Coastguard Worker [r'.*\.java:.*: warning: \[rawtypes\] found raw type']), 492*9e94795aSAndroid Build Coastguard Worker java_medium('Redundant cast', 493*9e94795aSAndroid Build Coastguard Worker [r'.*\.java:.*: warning: \[cast\] redundant cast to']), 494*9e94795aSAndroid Build Coastguard Worker java_medium('Static method should be qualified', 495*9e94795aSAndroid Build Coastguard Worker [r'.*\.java:.*: warning: \[static\] static method should be qualified']), 496*9e94795aSAndroid Build Coastguard Worker medium('AbstractInner'), 497*9e94795aSAndroid Build Coastguard Worker medium('BothPackageInfoAndHtml'), 498*9e94795aSAndroid Build Coastguard Worker medium('BuilderSetStyle'), 499*9e94795aSAndroid Build Coastguard Worker medium('CallbackName'), 500*9e94795aSAndroid Build Coastguard Worker medium('ExecutorRegistration'), 501*9e94795aSAndroid Build Coastguard Worker medium('HiddenTypeParameter'), 502*9e94795aSAndroid Build Coastguard Worker medium('JavaApiUsedByMainlineModule'), 503*9e94795aSAndroid Build Coastguard Worker medium('ListenerLast'), 504*9e94795aSAndroid Build Coastguard Worker medium('MinMaxConstant'), 505*9e94795aSAndroid Build Coastguard Worker medium('MissingBuildMethod'), 506*9e94795aSAndroid Build Coastguard Worker medium('MissingGetterMatchingBuilder'), 507*9e94795aSAndroid Build Coastguard Worker medium('NoByteOrShort'), 508*9e94795aSAndroid Build Coastguard Worker medium('OverlappingConstants'), 509*9e94795aSAndroid Build Coastguard Worker medium('SetterReturnsThis'), 510*9e94795aSAndroid Build Coastguard Worker medium('StaticFinalBuilder'), 511*9e94795aSAndroid Build Coastguard Worker medium('StreamFiles'), 512*9e94795aSAndroid Build Coastguard Worker medium('Typo'), 513*9e94795aSAndroid Build Coastguard Worker medium('UseIcu'), 514*9e94795aSAndroid Build Coastguard Worker medium('fallthrough'), 515*9e94795aSAndroid Build Coastguard Worker medium('overrides'), 516*9e94795aSAndroid Build Coastguard Worker medium('serial'), 517*9e94795aSAndroid Build Coastguard Worker medium('try'), 518*9e94795aSAndroid Build Coastguard Worker high('AndroidInjectionBeforeSuper', 519*9e94795aSAndroid Build Coastguard Worker 'AndroidInjection.inject() should always be invoked before calling super.lifecycleMethod()'), 520*9e94795aSAndroid Build Coastguard Worker high('AndroidJdkLibsChecker', 521*9e94795aSAndroid Build Coastguard Worker 'Use of class, field, or method that is not compatible with legacy Android devices'), 522*9e94795aSAndroid Build Coastguard Worker high('ArrayEquals', 523*9e94795aSAndroid Build Coastguard Worker 'Reference equality used to compare arrays'), 524*9e94795aSAndroid Build Coastguard Worker high('ArrayFillIncompatibleType', 525*9e94795aSAndroid Build Coastguard Worker 'Arrays.fill(Object[], Object) called with incompatible types.'), 526*9e94795aSAndroid Build Coastguard Worker high('ArrayHashCode', 527*9e94795aSAndroid Build Coastguard Worker 'hashcode method on array does not hash array contents'), 528*9e94795aSAndroid Build Coastguard Worker high('ArrayReturn', 529*9e94795aSAndroid Build Coastguard Worker 'ArrayReturn'), 530*9e94795aSAndroid Build Coastguard Worker high('ArrayToString', 531*9e94795aSAndroid Build Coastguard Worker 'Calling toString on an array does not provide useful information'), 532*9e94795aSAndroid Build Coastguard Worker high('ArraysAsListPrimitiveArray', 533*9e94795aSAndroid Build Coastguard Worker 'Arrays.asList does not autobox primitive arrays, as one might expect.'), 534*9e94795aSAndroid Build Coastguard Worker high('AssistedInjectAndInjectOnSameConstructor', 535*9e94795aSAndroid Build Coastguard Worker '@AssistedInject and @Inject cannot be used on the same constructor.'), 536*9e94795aSAndroid Build Coastguard Worker high('AsyncCallableReturnsNull', 537*9e94795aSAndroid Build Coastguard Worker 'AsyncCallable should not return a null Future, only a Future whose result is null.'), 538*9e94795aSAndroid Build Coastguard Worker high('AsyncFunctionReturnsNull', 539*9e94795aSAndroid Build Coastguard Worker 'AsyncFunction should not return a null Future, only a Future whose result is null.'), 540*9e94795aSAndroid Build Coastguard Worker high('AutoFactoryAtInject', 541*9e94795aSAndroid Build Coastguard Worker '@AutoFactory and @Inject should not be used in the same type.'), 542*9e94795aSAndroid Build Coastguard Worker high('AutoValueConstructorOrderChecker', 543*9e94795aSAndroid Build Coastguard Worker 'Arguments to AutoValue constructor are in the wrong order'), 544*9e94795aSAndroid Build Coastguard Worker high('BadShiftAmount', 545*9e94795aSAndroid Build Coastguard Worker 'Shift by an amount that is out of range'), 546*9e94795aSAndroid Build Coastguard Worker high('BundleDeserializationCast', 547*9e94795aSAndroid Build Coastguard Worker 'Object serialized in Bundle may have been flattened to base type.'), 548*9e94795aSAndroid Build Coastguard Worker high('ChainingConstructorIgnoresParameter', 549*9e94795aSAndroid Build Coastguard Worker 'The called constructor accepts a parameter with the same name and type as one of its caller\'s parameters, but its caller doesn\'t pass that parameter to it. It\'s likely that it was intended to.'), 550*9e94795aSAndroid Build Coastguard Worker high('CheckReturnValue', 551*9e94795aSAndroid Build Coastguard Worker 'Ignored return value of method that is annotated with @CheckReturnValue'), 552*9e94795aSAndroid Build Coastguard Worker high('ClassName', 553*9e94795aSAndroid Build Coastguard Worker 'The source file name should match the name of the top-level class it contains'), 554*9e94795aSAndroid Build Coastguard Worker high('CollectionIncompatibleType', 555*9e94795aSAndroid Build Coastguard Worker 'Incompatible type as argument to Object-accepting Java collections method'), 556*9e94795aSAndroid Build Coastguard Worker high('ComparableType', 557*9e94795aSAndroid Build Coastguard Worker u'Implementing \'Comparable\u003cT>\' where T is not compatible with the implementing class.'), 558*9e94795aSAndroid Build Coastguard Worker high('ComparingThisWithNull', 559*9e94795aSAndroid Build Coastguard Worker 'this == null is always false, this != null is always true'), 560*9e94795aSAndroid Build Coastguard Worker high('ComparisonContractViolated', 561*9e94795aSAndroid Build Coastguard Worker 'This comparison method violates the contract'), 562*9e94795aSAndroid Build Coastguard Worker high('ComparisonOutOfRange', 563*9e94795aSAndroid Build Coastguard Worker 'Comparison to value that is out of range for the compared type'), 564*9e94795aSAndroid Build Coastguard Worker high('CompatibleWithAnnotationMisuse', 565*9e94795aSAndroid Build Coastguard Worker '@CompatibleWith\'s value is not a type argument.'), 566*9e94795aSAndroid Build Coastguard Worker high('CompileTimeConstant', 567*9e94795aSAndroid Build Coastguard Worker 'Non-compile-time constant expression passed to parameter with @CompileTimeConstant type annotation.'), 568*9e94795aSAndroid Build Coastguard Worker high('ComplexBooleanConstant', 569*9e94795aSAndroid Build Coastguard Worker 'Non-trivial compile time constant boolean expressions shouldn\'t be used.'), 570*9e94795aSAndroid Build Coastguard Worker high('ConditionalExpressionNumericPromotion', 571*9e94795aSAndroid Build Coastguard Worker 'A conditional expression with numeric operands of differing types will perform binary numeric promotion of the operands; when these operands are of reference types, the expression\'s result may not be of the expected type.'), 572*9e94795aSAndroid Build Coastguard Worker high('ConstantOverflow', 573*9e94795aSAndroid Build Coastguard Worker 'Compile-time constant expression overflows'), 574*9e94795aSAndroid Build Coastguard Worker high('DaggerProvidesNull', 575*9e94795aSAndroid Build Coastguard Worker 'Dagger @Provides methods may not return null unless annotated with @Nullable'), 576*9e94795aSAndroid Build Coastguard Worker high('DeadException', 577*9e94795aSAndroid Build Coastguard Worker 'Exception created but not thrown'), 578*9e94795aSAndroid Build Coastguard Worker high('DeadThread', 579*9e94795aSAndroid Build Coastguard Worker 'Thread created but not started'), 580*9e94795aSAndroid Build Coastguard Worker java_high('Deprecated item is not annotated with @Deprecated', 581*9e94795aSAndroid Build Coastguard Worker [r".*\.java:.*: warning: \[.*\] .+ is not annotated with @Deprecated$"]), 582*9e94795aSAndroid Build Coastguard Worker high('DivZero', 583*9e94795aSAndroid Build Coastguard Worker 'Division by integer literal zero'), 584*9e94795aSAndroid Build Coastguard Worker high('DoNotCall', 585*9e94795aSAndroid Build Coastguard Worker 'This method should not be called.'), 586*9e94795aSAndroid Build Coastguard Worker high('EmptyIf', 587*9e94795aSAndroid Build Coastguard Worker 'Empty statement after if'), 588*9e94795aSAndroid Build Coastguard Worker high('EqualsNaN', 589*9e94795aSAndroid Build Coastguard Worker '== NaN always returns false; use the isNaN methods instead'), 590*9e94795aSAndroid Build Coastguard Worker high('EqualsReference', 591*9e94795aSAndroid Build Coastguard Worker '== must be used in equals method to check equality to itself or an infinite loop will occur.'), 592*9e94795aSAndroid Build Coastguard Worker high('EqualsWrongThing', 593*9e94795aSAndroid Build Coastguard Worker 'Comparing different pairs of fields/getters in an equals implementation is probably a mistake.'), 594*9e94795aSAndroid Build Coastguard Worker high('ForOverride', 595*9e94795aSAndroid Build Coastguard Worker 'Method annotated @ForOverride must be protected or package-private and only invoked from declaring class, or from an override of the method'), 596*9e94795aSAndroid Build Coastguard Worker high('FormatString', 597*9e94795aSAndroid Build Coastguard Worker 'Invalid printf-style format string'), 598*9e94795aSAndroid Build Coastguard Worker high('FormatStringAnnotation', 599*9e94795aSAndroid Build Coastguard Worker 'Invalid format string passed to formatting method.'), 600*9e94795aSAndroid Build Coastguard Worker high('FunctionalInterfaceMethodChanged', 601*9e94795aSAndroid Build Coastguard Worker 'Casting a lambda to this @FunctionalInterface can cause a behavior change from casting to a functional superinterface, which is surprising to users. Prefer decorator methods to this surprising behavior.'), 602*9e94795aSAndroid Build Coastguard Worker high('FuturesGetCheckedIllegalExceptionType', 603*9e94795aSAndroid Build Coastguard Worker 'Futures.getChecked requires a checked exception type with a standard constructor.'), 604*9e94795aSAndroid Build Coastguard Worker high('FuzzyEqualsShouldNotBeUsedInEqualsMethod', 605*9e94795aSAndroid Build Coastguard Worker 'DoubleMath.fuzzyEquals should never be used in an Object.equals() method'), 606*9e94795aSAndroid Build Coastguard Worker high('GetClassOnAnnotation', 607*9e94795aSAndroid Build Coastguard Worker 'Calling getClass() on an annotation may return a proxy class'), 608*9e94795aSAndroid Build Coastguard Worker high('GetClassOnClass', 609*9e94795aSAndroid Build Coastguard Worker 'Calling getClass() on an object of type Class returns the Class object for java.lang.Class; you probably meant to operate on the object directly'), 610*9e94795aSAndroid Build Coastguard Worker high('GuardedBy', 611*9e94795aSAndroid Build Coastguard Worker 'Checks for unguarded accesses to fields and methods with @GuardedBy annotations'), 612*9e94795aSAndroid Build Coastguard Worker high('GuiceAssistedInjectScoping', 613*9e94795aSAndroid Build Coastguard Worker 'Scope annotation on implementation class of AssistedInject factory is not allowed'), 614*9e94795aSAndroid Build Coastguard Worker high('GuiceAssistedParameters', 615*9e94795aSAndroid Build Coastguard Worker 'A constructor cannot have two @Assisted parameters of the same type unless they are disambiguated with named @Assisted annotations.'), 616*9e94795aSAndroid Build Coastguard Worker high('GuiceInjectOnFinalField', 617*9e94795aSAndroid Build Coastguard Worker 'Although Guice allows injecting final fields, doing so is disallowed because the injected value may not be visible to other threads.'), 618*9e94795aSAndroid Build Coastguard Worker high('HashtableContains', 619*9e94795aSAndroid Build Coastguard Worker 'contains() is a legacy method that is equivalent to containsValue()'), 620*9e94795aSAndroid Build Coastguard Worker high('IdentityBinaryExpression', 621*9e94795aSAndroid Build Coastguard Worker 'A binary expression where both operands are the same is usually incorrect.'), 622*9e94795aSAndroid Build Coastguard Worker high('Immutable', 623*9e94795aSAndroid Build Coastguard Worker 'Type declaration annotated with @Immutable is not immutable'), 624*9e94795aSAndroid Build Coastguard Worker high('ImmutableModification', 625*9e94795aSAndroid Build Coastguard Worker 'Modifying an immutable collection is guaranteed to throw an exception and leave the collection unmodified'), 626*9e94795aSAndroid Build Coastguard Worker high('IncompatibleArgumentType', 627*9e94795aSAndroid Build Coastguard Worker 'Passing argument to a generic method with an incompatible type.'), 628*9e94795aSAndroid Build Coastguard Worker high('IndexOfChar', 629*9e94795aSAndroid Build Coastguard Worker 'The first argument to indexOf is a Unicode code point, and the second is the index to start the search from'), 630*9e94795aSAndroid Build Coastguard Worker high('InexactVarargsConditional', 631*9e94795aSAndroid Build Coastguard Worker 'Conditional expression in varargs call contains array and non-array arguments'), 632*9e94795aSAndroid Build Coastguard Worker high('InfiniteRecursion', 633*9e94795aSAndroid Build Coastguard Worker 'This method always recurses, and will cause a StackOverflowError'), 634*9e94795aSAndroid Build Coastguard Worker high('InjectInvalidTargetingOnScopingAnnotation', 635*9e94795aSAndroid Build Coastguard Worker 'A scoping annotation\'s Target should include TYPE and METHOD.'), 636*9e94795aSAndroid Build Coastguard Worker high('InjectMoreThanOneQualifier', 637*9e94795aSAndroid Build Coastguard Worker 'Using more than one qualifier annotation on the same element is not allowed.'), 638*9e94795aSAndroid Build Coastguard Worker high('InjectMoreThanOneScopeAnnotationOnClass', 639*9e94795aSAndroid Build Coastguard Worker 'A class can be annotated with at most one scope annotation.'), 640*9e94795aSAndroid Build Coastguard Worker high('InjectOnMemberAndConstructor', 641*9e94795aSAndroid Build Coastguard Worker 'Members shouldn\'t be annotated with @Inject if constructor is already annotated @Inject'), 642*9e94795aSAndroid Build Coastguard Worker high('InjectScopeAnnotationOnInterfaceOrAbstractClass', 643*9e94795aSAndroid Build Coastguard Worker 'Scope annotation on an interface or abstact class is not allowed'), 644*9e94795aSAndroid Build Coastguard Worker high('InjectScopeOrQualifierAnnotationRetention', 645*9e94795aSAndroid Build Coastguard Worker 'Scoping and qualifier annotations must have runtime retention.'), 646*9e94795aSAndroid Build Coastguard Worker high('InjectedConstructorAnnotations', 647*9e94795aSAndroid Build Coastguard Worker 'Injected constructors cannot be optional nor have binding annotations'), 648*9e94795aSAndroid Build Coastguard Worker high('InsecureCryptoUsage', 649*9e94795aSAndroid Build Coastguard Worker 'A standard cryptographic operation is used in a mode that is prone to vulnerabilities'), 650*9e94795aSAndroid Build Coastguard Worker high('InvalidPatternSyntax', 651*9e94795aSAndroid Build Coastguard Worker 'Invalid syntax used for a regular expression'), 652*9e94795aSAndroid Build Coastguard Worker high('InvalidTimeZoneID', 653*9e94795aSAndroid Build Coastguard Worker 'Invalid time zone identifier. TimeZone.getTimeZone(String) will silently return GMT instead of the time zone you intended.'), 654*9e94795aSAndroid Build Coastguard Worker high('IsInstanceOfClass', 655*9e94795aSAndroid Build Coastguard Worker 'The argument to Class#isInstance(Object) should not be a Class'), 656*9e94795aSAndroid Build Coastguard Worker high('IsLoggableTagLength', 657*9e94795aSAndroid Build Coastguard Worker 'Log tag too long, cannot exceed 23 characters.'), 658*9e94795aSAndroid Build Coastguard Worker high('IterablePathParameter', 659*9e94795aSAndroid Build Coastguard Worker u'Path implements Iterable\u003cPath>; prefer Collection\u003cPath> for clarity'), 660*9e94795aSAndroid Build Coastguard Worker high('JMockTestWithoutRunWithOrRuleAnnotation', 661*9e94795aSAndroid Build Coastguard Worker 'jMock tests must have a @RunWith(JMock.class) annotation, or the Mockery field must have a @Rule JUnit annotation'), 662*9e94795aSAndroid Build Coastguard Worker high('JUnit3TestNotRun', 663*9e94795aSAndroid Build Coastguard Worker 'Test method will not be run; please correct method signature (Should be public, non-static, and method name should begin with "test").'), 664*9e94795aSAndroid Build Coastguard Worker high('JUnit4ClassAnnotationNonStatic', 665*9e94795aSAndroid Build Coastguard Worker 'This method should be static'), 666*9e94795aSAndroid Build Coastguard Worker high('JUnit4SetUpNotRun', 667*9e94795aSAndroid Build Coastguard Worker 'setUp() method will not be run; please add JUnit\'s @Before annotation'), 668*9e94795aSAndroid Build Coastguard Worker high('JUnit4TearDownNotRun', 669*9e94795aSAndroid Build Coastguard Worker 'tearDown() method will not be run; please add JUnit\'s @After annotation'), 670*9e94795aSAndroid Build Coastguard Worker high('JUnit4TestNotRun', 671*9e94795aSAndroid Build Coastguard Worker 'This looks like a test method but is not run; please add @Test and @Ignore, or, if this is a helper method, reduce its visibility.'), 672*9e94795aSAndroid Build Coastguard Worker high('JUnitAssertSameCheck', 673*9e94795aSAndroid Build Coastguard Worker 'An object is tested for reference equality to itself using JUnit library.'), 674*9e94795aSAndroid Build Coastguard Worker high('Java7ApiChecker', 675*9e94795aSAndroid Build Coastguard Worker 'Use of class, field, or method that is not compatible with JDK 7'), 676*9e94795aSAndroid Build Coastguard Worker high('JavaxInjectOnAbstractMethod', 677*9e94795aSAndroid Build Coastguard Worker 'Abstract and default methods are not injectable with javax.inject.Inject'), 678*9e94795aSAndroid Build Coastguard Worker high('JavaxInjectOnFinalField', 679*9e94795aSAndroid Build Coastguard Worker '@javax.inject.Inject cannot be put on a final field.'), 680*9e94795aSAndroid Build Coastguard Worker high('LiteByteStringUtf8', 681*9e94795aSAndroid Build Coastguard Worker 'This pattern will silently corrupt certain byte sequences from the serialized protocol message. Use ByteString or byte[] directly'), 682*9e94795aSAndroid Build Coastguard Worker high('LockMethodChecker', 683*9e94795aSAndroid Build Coastguard Worker 'This method does not acquire the locks specified by its @LockMethod annotation'), 684*9e94795aSAndroid Build Coastguard Worker high('LongLiteralLowerCaseSuffix', 685*9e94795aSAndroid Build Coastguard Worker 'Prefer \'L\' to \'l\' for the suffix to long literals'), 686*9e94795aSAndroid Build Coastguard Worker high('LoopConditionChecker', 687*9e94795aSAndroid Build Coastguard Worker 'Loop condition is never modified in loop body.'), 688*9e94795aSAndroid Build Coastguard Worker high('MathRoundIntLong', 689*9e94795aSAndroid Build Coastguard Worker 'Math.round(Integer) results in truncation'), 690*9e94795aSAndroid Build Coastguard Worker high('MislabeledAndroidString', 691*9e94795aSAndroid Build Coastguard Worker 'Certain resources in `android.R.string` have names that do not match their content'), 692*9e94795aSAndroid Build Coastguard Worker high('MissingSuperCall', 693*9e94795aSAndroid Build Coastguard Worker 'Overriding method is missing a call to overridden super method'), 694*9e94795aSAndroid Build Coastguard Worker high('MissingTestCall', 695*9e94795aSAndroid Build Coastguard Worker 'A terminating method call is required for a test helper to have any effect.'), 696*9e94795aSAndroid Build Coastguard Worker high('MisusedWeekYear', 697*9e94795aSAndroid Build Coastguard Worker 'Use of "YYYY" (week year) in a date pattern without "ww" (week in year). You probably meant to use "yyyy" (year) instead.'), 698*9e94795aSAndroid Build Coastguard Worker high('MockitoCast', 699*9e94795aSAndroid Build Coastguard Worker 'A bug in Mockito will cause this test to fail at runtime with a ClassCastException'), 700*9e94795aSAndroid Build Coastguard Worker high('MockitoUsage', 701*9e94795aSAndroid Build Coastguard Worker 'Missing method call for verify(mock) here'), 702*9e94795aSAndroid Build Coastguard Worker high('ModifyingCollectionWithItself', 703*9e94795aSAndroid Build Coastguard Worker 'Using a collection function with itself as the argument.'), 704*9e94795aSAndroid Build Coastguard Worker high('MoreThanOneInjectableConstructor', 705*9e94795aSAndroid Build Coastguard Worker 'This class has more than one @Inject-annotated constructor. Please remove the @Inject annotation from all but one of them.'), 706*9e94795aSAndroid Build Coastguard Worker high('MustBeClosedChecker', 707*9e94795aSAndroid Build Coastguard Worker 'The result of this method must be closed.'), 708*9e94795aSAndroid Build Coastguard Worker high('NCopiesOfChar', 709*9e94795aSAndroid Build Coastguard Worker 'The first argument to nCopies is the number of copies, and the second is the item to copy'), 710*9e94795aSAndroid Build Coastguard Worker high('NoAllocation', 711*9e94795aSAndroid Build Coastguard Worker '@NoAllocation was specified on this method, but something was found that would trigger an allocation'), 712*9e94795aSAndroid Build Coastguard Worker high('NonCanonicalStaticImport', 713*9e94795aSAndroid Build Coastguard Worker 'Static import of type uses non-canonical name'), 714*9e94795aSAndroid Build Coastguard Worker high('NonFinalCompileTimeConstant', 715*9e94795aSAndroid Build Coastguard Worker '@CompileTimeConstant parameters should be final or effectively final'), 716*9e94795aSAndroid Build Coastguard Worker high('NonRuntimeAnnotation', 717*9e94795aSAndroid Build Coastguard Worker 'Calling getAnnotation on an annotation that is not retained at runtime.'), 718*9e94795aSAndroid Build Coastguard Worker high('NullTernary', 719*9e94795aSAndroid Build Coastguard Worker 'This conditional expression may evaluate to null, which will result in an NPE when the result is unboxed.'), 720*9e94795aSAndroid Build Coastguard Worker high('NumericEquality', 721*9e94795aSAndroid Build Coastguard Worker 'Numeric comparison using reference equality instead of value equality'), 722*9e94795aSAndroid Build Coastguard Worker high('OptionalEquality', 723*9e94795aSAndroid Build Coastguard Worker 'Comparison using reference equality instead of value equality'), 724*9e94795aSAndroid Build Coastguard Worker high('OverlappingQualifierAndScopeAnnotation', 725*9e94795aSAndroid Build Coastguard Worker 'Annotations cannot be both Scope annotations and Qualifier annotations: this causes confusion when trying to use them.'), 726*9e94795aSAndroid Build Coastguard Worker high('OverridesJavaxInjectableMethod', 727*9e94795aSAndroid Build Coastguard Worker 'This method is not annotated with @Inject, but it overrides a method that is annotated with @javax.inject.Inject. The method will not be Injected.'), 728*9e94795aSAndroid Build Coastguard Worker high('PackageInfo', 729*9e94795aSAndroid Build Coastguard Worker 'Declaring types inside package-info.java files is very bad form'), 730*9e94795aSAndroid Build Coastguard Worker high('ParameterPackage', 731*9e94795aSAndroid Build Coastguard Worker 'Method parameter has wrong package'), 732*9e94795aSAndroid Build Coastguard Worker high('ParcelableCreator', 733*9e94795aSAndroid Build Coastguard Worker 'Detects classes which implement Parcelable but don\'t have CREATOR'), 734*9e94795aSAndroid Build Coastguard Worker high('PreconditionsCheckNotNull', 735*9e94795aSAndroid Build Coastguard Worker 'Literal passed as first argument to Preconditions.checkNotNull() can never be null'), 736*9e94795aSAndroid Build Coastguard Worker high('PreconditionsCheckNotNullPrimitive', 737*9e94795aSAndroid Build Coastguard Worker 'First argument to `Preconditions.checkNotNull()` is a primitive rather than an object reference'), 738*9e94795aSAndroid Build Coastguard Worker high('PredicateIncompatibleType', 739*9e94795aSAndroid Build Coastguard Worker 'Using ::equals or ::isInstance as an incompatible Predicate; the predicate will always return false'), 740*9e94795aSAndroid Build Coastguard Worker high('PrivateSecurityContractProtoAccess', 741*9e94795aSAndroid Build Coastguard Worker 'Access to a private protocol buffer field is forbidden. This protocol buffer carries a security contract, and can only be created using an approved library. Direct access to the fields is forbidden.'), 742*9e94795aSAndroid Build Coastguard Worker high('ProtoFieldNullComparison', 743*9e94795aSAndroid Build Coastguard Worker 'Protobuf fields cannot be null.'), 744*9e94795aSAndroid Build Coastguard Worker high('ProtoStringFieldReferenceEquality', 745*9e94795aSAndroid Build Coastguard Worker 'Comparing protobuf fields of type String using reference equality'), 746*9e94795aSAndroid Build Coastguard Worker high('ProtocolBufferOrdinal', 747*9e94795aSAndroid Build Coastguard Worker 'To get the tag number of a protocol buffer enum, use getNumber() instead.'), 748*9e94795aSAndroid Build Coastguard Worker high('ProvidesMethodOutsideOfModule', 749*9e94795aSAndroid Build Coastguard Worker '@Provides methods need to be declared in a Module to have any effect.'), 750*9e94795aSAndroid Build Coastguard Worker high('RandomCast', 751*9e94795aSAndroid Build Coastguard Worker 'Casting a random number in the range [0.0, 1.0) to an integer or long always results in 0.'), 752*9e94795aSAndroid Build Coastguard Worker high('RandomModInteger', 753*9e94795aSAndroid Build Coastguard Worker 'Use Random.nextInt(int). Random.nextInt() % n can have negative results'), 754*9e94795aSAndroid Build Coastguard Worker high('RectIntersectReturnValueIgnored', 755*9e94795aSAndroid Build Coastguard Worker 'Return value of android.graphics.Rect.intersect() must be checked'), 756*9e94795aSAndroid Build Coastguard Worker high('RestrictTo', 757*9e94795aSAndroid Build Coastguard Worker 'Use of method or class annotated with @RestrictTo'), 758*9e94795aSAndroid Build Coastguard Worker high('RestrictedApiChecker', 759*9e94795aSAndroid Build Coastguard Worker ' Check for non-whitelisted callers to RestrictedApiChecker.'), 760*9e94795aSAndroid Build Coastguard Worker high('ReturnValueIgnored', 761*9e94795aSAndroid Build Coastguard Worker 'Return value of this method must be used'), 762*9e94795aSAndroid Build Coastguard Worker high('SelfAssignment', 763*9e94795aSAndroid Build Coastguard Worker 'Variable assigned to itself'), 764*9e94795aSAndroid Build Coastguard Worker high('SelfComparison', 765*9e94795aSAndroid Build Coastguard Worker 'An object is compared to itself'), 766*9e94795aSAndroid Build Coastguard Worker high('SelfEquals', 767*9e94795aSAndroid Build Coastguard Worker 'Testing an object for equality with itself will always be true.'), 768*9e94795aSAndroid Build Coastguard Worker high('ShouldHaveEvenArgs', 769*9e94795aSAndroid Build Coastguard Worker 'This method must be called with an even number of arguments.'), 770*9e94795aSAndroid Build Coastguard Worker high('SizeGreaterThanOrEqualsZero', 771*9e94795aSAndroid Build Coastguard Worker 'Comparison of a size >= 0 is always true, did you intend to check for non-emptiness?'), 772*9e94795aSAndroid Build Coastguard Worker high('StaticOrDefaultInterfaceMethod', 773*9e94795aSAndroid Build Coastguard Worker 'Static and default interface methods are not natively supported on older Android devices. '), 774*9e94795aSAndroid Build Coastguard Worker high('StreamToString', 775*9e94795aSAndroid Build Coastguard Worker 'Calling toString on a Stream does not provide useful information'), 776*9e94795aSAndroid Build Coastguard Worker high('StringBuilderInitWithChar', 777*9e94795aSAndroid Build Coastguard Worker 'StringBuilder does not have a char constructor; this invokes the int constructor.'), 778*9e94795aSAndroid Build Coastguard Worker high('SubstringOfZero', 779*9e94795aSAndroid Build Coastguard Worker 'String.substring(0) returns the original String'), 780*9e94795aSAndroid Build Coastguard Worker high('SuppressWarningsDeprecated', 781*9e94795aSAndroid Build Coastguard Worker 'Suppressing "deprecated" is probably a typo for "deprecation"'), 782*9e94795aSAndroid Build Coastguard Worker high('ThrowIfUncheckedKnownChecked', 783*9e94795aSAndroid Build Coastguard Worker 'throwIfUnchecked(knownCheckedException) is a no-op.'), 784*9e94795aSAndroid Build Coastguard Worker high('ThrowNull', 785*9e94795aSAndroid Build Coastguard Worker 'Throwing \'null\' always results in a NullPointerException being thrown.'), 786*9e94795aSAndroid Build Coastguard Worker high('TruthSelfEquals', 787*9e94795aSAndroid Build Coastguard Worker 'isEqualTo should not be used to test an object for equality with itself; the assertion will never fail.'), 788*9e94795aSAndroid Build Coastguard Worker high('TryFailThrowable', 789*9e94795aSAndroid Build Coastguard Worker 'Catching Throwable/Error masks failures from fail() or assert*() in the try block'), 790*9e94795aSAndroid Build Coastguard Worker high('TypeParameterQualifier', 791*9e94795aSAndroid Build Coastguard Worker 'Type parameter used as type qualifier'), 792*9e94795aSAndroid Build Coastguard Worker high('UnlockMethod', 793*9e94795aSAndroid Build Coastguard Worker 'This method does not acquire the locks specified by its @UnlockMethod annotation'), 794*9e94795aSAndroid Build Coastguard Worker high('UnnecessaryTypeArgument', 795*9e94795aSAndroid Build Coastguard Worker 'Non-generic methods should not be invoked with type arguments'), 796*9e94795aSAndroid Build Coastguard Worker high('UnusedAnonymousClass', 797*9e94795aSAndroid Build Coastguard Worker 'Instance created but never used'), 798*9e94795aSAndroid Build Coastguard Worker high('UnusedCollectionModifiedInPlace', 799*9e94795aSAndroid Build Coastguard Worker 'Collection is modified in place, but the result is not used'), 800*9e94795aSAndroid Build Coastguard Worker high('VarTypeName', 801*9e94795aSAndroid Build Coastguard Worker '`var` should not be used as a type name.'), 802*9e94795aSAndroid Build Coastguard Worker 803*9e94795aSAndroid Build Coastguard Worker # Other javac tool warnings 804*9e94795aSAndroid Build Coastguard Worker java_medium('addNdkApiCoverage failed to getPackage', 805*9e94795aSAndroid Build Coastguard Worker [r".*: warning: addNdkApiCoverage failed to getPackage"]), 806*9e94795aSAndroid Build Coastguard Worker java_medium('bad path element', 807*9e94795aSAndroid Build Coastguard Worker [r".*: warning: \[path\] bad path element .*\.jar"]), 808*9e94795aSAndroid Build Coastguard Worker java_medium('Supported version from annotation processor', 809*9e94795aSAndroid Build Coastguard Worker [r".*: warning: Supported source version .+ from annotation processor"]), 810*9e94795aSAndroid Build Coastguard Worker java_medium('Schema export directory is not provided', 811*9e94795aSAndroid Build Coastguard Worker [r".*\.(java|kt):.*: warning: Schema export directory is not provided"]), 812*9e94795aSAndroid Build Coastguard Worker] 813*9e94795aSAndroid Build Coastguard Worker 814*9e94795aSAndroid Build Coastguard Workercompile_patterns(warn_patterns) 815