blob: 980065a5d449da2829071f1b4a01a1430f2cbf41 [file] [log] [blame]
// Copyright 2017 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package error_prone
import (
"android/soong/java/config"
)
func init() {
// These values are set into build/soong/java/config/config.go so that soong doesn't have any
// references to external/error_prone, which may not always exist.
config.ErrorProneClasspath = []string{
"external/error_prone/error_prone/error_prone_core-2.3.2-with-dependencies.jar",
"external/error_prone/error_prone/error_prone_annotations-2.3.2.jar",
"external/error_prone/error_prone/error_prone_type_annotations-2.3.2.jar",
"external/error_prone/checkerframework/dataflow-2.5.3.jar",
"external/error_prone/checkerframework/javacutil-2.5.3.jar",
"external/error_prone/jFormatString/jFormatString-3.0.0.jar",
}
// The checks that are fatal to the build.
config.ErrorProneChecksError = []string{
// Errorprone default severity ERROR
"-Xep:AndroidInjectionBeforeSuper:ERROR",
"-Xep:ArrayFillIncompatibleType:ERROR",
"-Xep:AsyncCallableReturnsNull:ERROR",
"-Xep:AsyncFunctionReturnsNull:ERROR",
"-Xep:AutoValueConstructorOrderChecker:ERROR",
"-Xep:BundleDeserializationCast:ERROR",
"-Xep:ChainingConstructorIgnoresParameter:ERROR",
"-Xep:CheckReturnValue:ERROR",
"-Xep:CollectionIncompatibleType:ERROR",
"-Xep:ComparingThisWithNull:ERROR",
"-Xep:ComparisonOutOfRange:ERROR",
"-Xep:CompatibleWithAnnotationMisuse:ERROR",
"-Xep:CompileTimeConstant:ERROR",
"-Xep:ConstantOverflow:ERROR",
"-Xep:DaggerProvidesNull:ERROR",
"-Xep:DeadException:ERROR",
"-Xep:DeadThread:ERROR",
"-Xep:DoNotCall:ERROR",
"-Xep:EqualsNaN:ERROR",
"-Xep:EqualsWrongThing:ERROR",
"-Xep:ForOverride:ERROR",
"-Xep:FormatStringAnnotation:ERROR",
"-Xep:FunctionalInterfaceMethodChanged:ERROR",
"-Xep:FuturesGetCheckedIllegalExceptionType:ERROR",
"-Xep:GuiceAssistedInjectScoping:ERROR",
"-Xep:GuiceAssistedParameters:ERROR",
"-Xep:GuiceInjectOnFinalField:ERROR",
"-Xep:Immutable:ERROR",
"-Xep:ImmutableModification:ERROR",
"-Xep:IncompatibleArgumentType:ERROR",
"-Xep:IndexOfChar:ERROR",
"-Xep:InexactVarargsConditional:ERROR",
"-Xep:InfiniteRecursion:ERROR",
"-Xep:InjectMoreThanOneScopeAnnotationOnClass:ERROR",
"-Xep:InjectOnMemberAndConstructor:ERROR",
"-Xep:InvalidPatternSyntax:ERROR",
"-Xep:IsInstanceOfClass:ERROR",
"-Xep:JUnit3TestNotRun:ERROR",
"-Xep:JUnit4ClassAnnotationNonStatic:ERROR",
"-Xep:JUnit4SetUpNotRun:ERROR",
"-Xep:JUnit4TearDownNotRun:ERROR",
"-Xep:JUnit4TestNotRun:ERROR",
"-Xep:JUnitAssertSameCheck:ERROR",
"-Xep:JavaxInjectOnAbstractMethod:ERROR",
"-Xep:LiteByteStringUtf8:ERROR",
"-Xep:LoopConditionChecker:ERROR",
"-Xep:MissingTestCall:ERROR",
"-Xep:MockitoCast:ERROR",
"-Xep:MockitoUsage:ERROR",
"-Xep:MoreThanOneInjectableConstructor:ERROR",
"-Xep:MustBeClosedChecker:ERROR",
"-Xep:NCopiesOfChar:ERROR",
"-Xep:NonCanonicalStaticImport:ERROR",
"-Xep:NonFinalCompileTimeConstant:ERROR",
"-Xep:OptionalEquality:ERROR",
"-Xep:OverlappingQualifierAndScopeAnnotation:ERROR",
"-Xep:PackageInfo:ERROR",
"-Xep:PreconditionsCheckNotNull:ERROR",
"-Xep:PreconditionsCheckNotNullPrimitive:ERROR",
"-Xep:PredicateIncompatibleType:ERROR",
"-Xep:PrivateSecurityContractProtoAccess:ERROR",
"-Xep:ProtoFieldNullComparison:ERROR",
"-Xep:ProtoStringFieldReferenceEquality:ERROR",
"-Xep:ProvidesMethodOutsideOfModule:ERROR",
"-Xep:RandomCast:ERROR",
"-Xep:RestrictedApiChecker:ERROR",
"-Xep:SelfAssignment:ERROR",
"-Xep:ShouldHaveEvenArgs:ERROR",
"-Xep:StreamToString:ERROR",
"-Xep:SubstringOfZero:ERROR",
"-Xep:SuppressWarningsDeprecated:ERROR",
"-Xep:ThrowIfUncheckedKnownChecked:ERROR",
"-Xep:ThrowNull:ERROR",
"-Xep:TruthSelfEquals:ERROR",
"-Xep:TypeParameterQualifier:ERROR",
"-Xep:UnnecessaryTypeArgument:ERROR",
"-Xep:UnusedAnonymousClass:ERROR",
"-Xep:VarTypeName:ERROR",
// Errorprone default severity WARNING
// Errorprone default severity SUGGESTION
}
// The checks that are not fatal to the build.
config.ErrorProneChecksWarning = []string{
// Errorprone default severity ERROR
"-Xep:ArrayEquals:WARN",
"-Xep:ArrayHashCode:WARN",
"-Xep:ArrayToString:WARN",
"-Xep:ArraysAsListPrimitiveArray:WARN",
"-Xep:BadShiftAmount:WARN",
"-Xep:ComparableType:WARN",
"-Xep:ComplexBooleanConstant:WARN",
"-Xep:ConditionalExpressionNumericPromotion:WARN",
"-Xep:EqualsReference:WARN",
"-Xep:FormatString:WARN",
"-Xep:GetClassOnAnnotation:WARN",
"-Xep:GetClassOnClass:WARN",
"-Xep:GuardedBy:WARN",
"-Xep:HashtableContains:WARN",
"-Xep:IdentityBinaryExpression:WARN",
"-Xep:InvalidTimeZoneID:WARN",
"-Xep:IsLoggableTagLength:WARN",
"-Xep:MathRoundIntLong:WARN",
"-Xep:MislabeledAndroidString:WARN",
"-Xep:MissingSuperCall:WARN",
"-Xep:MisusedWeekYear:WARN",
"-Xep:ModifyingCollectionWithItself:WARN",
"-Xep:NonRuntimeAnnotation:WARN",
"-Xep:NullTernary:WARN",
"-Xep:OverridesJavaxInjectableMethod:WARN",
"-Xep:ParcelableCreator:WARN",
"-Xep:ProtocolBufferOrdinal:WARN",
"-Xep:RandomModInteger:WARN",
"-Xep:RectIntersectReturnValueIgnored:WARN",
"-Xep:ReturnValueIgnored:WARN",
"-Xep:SelfComparison:WARN",
"-Xep:SelfEquals:WARN",
"-Xep:SizeGreaterThanOrEqualsZero:WARN",
"-Xep:StringBuilderInitWithChar:WARN",
"-Xep:TryFailThrowable:WARN",
"-Xep:UnusedCollectionModifiedInPlace:WARN",
// Errorprone default severity WARNING
// "-Xep:AmbiguousMethodReference:WARN",
// "-Xep:ArgumentSelectionDefectChecker:WARN",
// "-Xep:ArrayAsKeyOfSetOrMap:WARN",
// "-Xep:AssertEqualsArgumentOrderChecker:WARN",
// "-Xep:AssertThrowsMultipleStatements:WARN",
// "-Xep:AssertionFailureIgnored:WARN",
// "-Xep:AutoValueFinalMethods:WARN",
// "-Xep:BadAnnotationImplementation:WARN",
// "-Xep:BadComparable:WARN",
// "-Xep:BadImport:WARN",
// "-Xep:BadInstanceof:WARN",
// "-Xep:BigDecimalEquals:WARN",
// "-Xep:BigDecimalLiteralDouble:WARN",
// "-Xep:BoxedPrimitiveConstructor:WARN",
// "-Xep:ByteBufferBackingArray:WARN",
// "-Xep:CannotMockFinalClass:WARN",
// "-Xep:CanonicalDuration:WARN",
// "-Xep:CatchAndPrintStackTrace:WARN",
// "-Xep:CatchFail:WARN",
// "-Xep:ClassCanBeStatic:WARN",
// "-Xep:ClassNewInstance:WARN",
// "-Xep:CloseableProvides:WARN",
// "-Xep:CollectionToArraySafeParameter:WARN",
// "-Xep:CollectorShouldNotUseState:WARN",
// "-Xep:ComparableAndComparator:WARN",
// "-Xep:DateFormatConstant:WARN",
// "-Xep:DefaultCharset:WARN",
// "-Xep:DeprecatedThreadMethods:WARN",
// "-Xep:DoubleBraceInitialization:WARN",
// "-Xep:DoubleCheckedLocking:WARN",
// "-Xep:EqualsGetClass:WARN",
// "-Xep:EqualsHashCode:WARN",
// "-Xep:EqualsIncompatibleType:WARN",
// "-Xep:EqualsUnsafeCast:WARN",
// "-Xep:EqualsUsingHashCode:WARN",
// "-Xep:ExtendingJUnitAssert:WARN",
// "-Xep:FallThrough:WARN",
// "-Xep:Finally:WARN",
// "-Xep:FloatCast:WARN",
// "-Xep:FloatingPointAssertionWithinEpsilon:WARN",
// "-Xep:FloatingPointLiteralPrecision:WARN",
// "-Xep:FragmentInjection:WARN",
// "-Xep:FragmentNotInstantiable:WARN",
// "-Xep:FutureReturnValueIgnored:WARN",
// "-Xep:GetClassOnEnum:WARN",
// "-Xep:HidingField:WARN",
// "-Xep:ImmutableAnnotationChecker:WARN",
// "-Xep:ImmutableEnumChecker:WARN",
// "-Xep:IncompatibleModifiers:WARN",
// "-Xep:InconsistentCapitalization:WARN",
// "-Xep:InconsistentHashCode:WARN",
// "-Xep:IncrementInForLoopAndHeader:WARN",
// "-Xep:InjectOnConstructorOfAbstractClass:WARN",
// "-Xep:InputStreamSlowMultibyteRead:WARN",
// "-Xep:InstanceOfAndCastMatchWrongType:WARN",
// "-Xep:IntLongMath:WARN",
// "-Xep:IterableAndIterator:WARN",
// "-Xep:JUnit3FloatingPointComparisonWithoutDelta:WARN",
// "-Xep:JUnit4ClassUsedInJUnit3:WARN",
// "-Xep:JUnitAmbiguousTestClass:WARN",
// "-Xep:JavaLangClash:WARN",
// "-Xep:JdkObsolete:WARN",
// "-Xep:LockNotBeforeTry:WARN",
// "-Xep:LogicalAssignment:WARN",
// "-Xep:MathAbsoluteRandom:WARN",
// "-Xep:MissingCasesInEnumSwitch:WARN",
// "-Xep:MissingFail:WARN",
// "-Xep:MissingOverride:WARN",
// "-Xep:ModifiedButNotUsed:WARN",
// "-Xep:ModifyCollectionInEnhancedForLoop:WARN",
// "-Xep:MultipleParallelOrSequentialCalls:WARN",
// "-Xep:MutableConstantField:WARN",
// "-Xep:NarrowingCompoundAssignment:WARN",
// "-Xep:NestedInstanceOfConditions:WARN",
// "-Xep:NonAtomicVolatileUpdate:WARN",
// "-Xep:NonOverridingEquals:WARN",
// "-Xep:NullableConstructor:WARN",
// "-Xep:NullablePrimitive:WARN",
// "-Xep:NullableVoid:WARN",
// "-Xep:ObjectToString:WARN",
// "-Xep:ObjectsHashCodePrimitive:WARN",
// "-Xep:OperatorPrecedence:WARN",
// "-Xep:OptionalNotPresent:WARN",
// "-Xep:OrphanedFormatString:WARN",
// "-Xep:OverrideThrowableToString:WARN",
// "-Xep:Overrides:WARN",
// "-Xep:OverridesGuiceInjectableMethod:WARN",
// "-Xep:ParameterName:WARN",
// "-Xep:PreconditionsInvalidPlaceholder:WARN",
// "-Xep:ProtoRedundantSet:WARN",
// "-Xep:QualifierOrScopeOnInjectMethod:WARN",
// "-Xep:ReachabilityFenceUsage:WARN",
// "-Xep:ReferenceEquality:WARN",
// "-Xep:RequiredModifiers:WARN",
// "-Xep:ShortCircuitBoolean:WARN",
// "-Xep:StaticGuardedByInstance:WARN",
// "-Xep:StreamResourceLeak:WARN",
// "-Xep:StringSplitter:WARN",
// "-Xep:SwigMemoryLeak:WARN",
// "-Xep:SynchronizeOnNonFinalField:WARN",
// "-Xep:ThreadJoinLoop:WARN",
// "-Xep:ThreadLocalUsage:WARN",
// "-Xep:ThreadPriorityCheck:WARN",
// "-Xep:ThreeLetterTimeZoneID:WARN",
// "-Xep:ToStringReturnsNull:WARN",
// "-Xep:TruthAssertExpected:WARN",
// "-Xep:TruthConstantAsserts:WARN",
// "-Xep:TruthIncompatibleType:WARN",
// "-Xep:TypeNameShadowing:WARN",
// "-Xep:TypeParameterShadowing:WARN",
// "-Xep:TypeParameterUnusedInFormals:WARN",
// "-Xep:URLEqualsHashCode:WARN",
// "-Xep:UndefinedEquals:WARN",
// "-Xep:UnnecessaryParentheses:WARN",
// "-Xep:UnsafeFinalization:WARN",
// "-Xep:UnsafeReflectiveConstructionCast:WARN",
// "-Xep:UnsynchronizedOverridesSynchronized:WARN",
// "-Xep:UseCorrectAssertInTests:WARN",
// "-Xep:VariableNameSameAsType:WARN",
// "-Xep:WaitNotInLoop:WARN",
// "-Xep:WakelockReleasedDangerously:WARN",
// Errorprone default severity SUGGESTION
}
// The checks that are default-disabled and listed for completeness
// and simple experiments.
config.ErrorProneChecksDefaultDisabled = []string{
// Errorprone default severity ERROR
// "-Xep:AndroidJdkLibsChecker:ERROR",
// "-Xep:AssistedInjectAndInjectOnSameConstructor:ERROR",
// "-Xep:AutoFactoryAtInject:ERROR",
// "-Xep:ClassName:ERROR",
// "-Xep:ComparisonContractViolated:ERROR",
// "-Xep:DepAnn:ERROR",
// "-Xep:DivZero:ERROR",
// "-Xep:EmptyIf:ERROR",
// "-Xep:FuzzyEqualsShouldNotBeUsedInEqualsMethod:ERROR",
// "-Xep:InjectInvalidTargetingOnScopingAnnotation:ERROR",
// "-Xep:InjectMoreThanOneQualifier:ERROR",
// "-Xep:InjectScopeAnnotationOnInterfaceOrAbstractClass:ERROR",
// "-Xep:InjectScopeOrQualifierAnnotationRetention:ERROR",
// "-Xep:InjectedConstructorAnnotations:ERROR",
// "-Xep:InsecureCryptoUsage:ERROR",
// "-Xep:IterablePathParameter:ERROR",
// "-Xep:JMockTestWithoutRunWithOrRuleAnnotation:ERROR",
// "-Xep:Java7ApiChecker:ERROR",
// "-Xep:JavaxInjectOnFinalField:ERROR",
// "-Xep:LockMethodChecker:ERROR",
// "-Xep:LongLiteralLowerCaseSuffix:ERROR",
// "-Xep:NoAllocation:ERROR",
// "-Xep:NumericEquality:ERROR",
// "-Xep:ParameterPackage:ERROR",
// "-Xep:RestrictTo:ERROR",
// "-Xep:StaticOrDefaultInterfaceMethod:ERROR",
// "-Xep:UnlockMethod:ERROR",
// Errorprone default severity WARNING
// "-Xep:AnnotateFormatMethod:WARN",
// "-Xep:AnnotationPosition:WARN",
// "-Xep:AssertFalse:WARN",
// "-Xep:AssistedInjectAndInjectOnConstructors:WARN",
// "-Xep:BinderIdentityRestoredDangerously:WARN",
// "-Xep:BindingToUnqualifiedCommonType:WARN",
// "-Xep:ConstructorInvokesOverridable:WARN",
// "-Xep:ConstructorLeaksThis:WARN",
// "-Xep:EmptyTopLevelDeclaration:WARN",
// "-Xep:EqualsBrokenForNull:WARN",
// "-Xep:ExpectedExceptionChecker:WARN",
// "-Xep:FunctionalInterfaceClash:WARN",
// "-Xep:HardCodedSdCardPath:WARN",
// "-Xep:InconsistentOverloads:WARN",
// "-Xep:InvalidParam:WARN",
// "-Xep:InvalidTag:WARN",
// "-Xep:InvalidThrows:WARN",
// "-Xep:MissingDefault:WARN",
// "-Xep:MutableMethodReturnType:WARN",
// "-Xep:NoFunctionalReturnType:WARN",
// "-Xep:NonCanonicalStaticMemberImport:WARN",
// "-Xep:NullableDereference:WARN",
// "-Xep:PrimitiveArrayPassedToVarargsMethod:WARN",
// "-Xep:ProtosAsKeyOfSetOrMap:WARN",
// "-Xep:ProvidesFix:WARN",
// "-Xep:QualifierWithTypeUse:WARN",
// "-Xep:RedundantThrows:WARN",
// "-Xep:ReturnFromVoid:WARN",
// "-Xep:StaticQualifiedUsingExpression:WARN",
// "-Xep:StringEquality:WARN",
// "-Xep:SystemExitOutsideMain:WARN",
// "-Xep:TestExceptionChecker:WARN",
// "-Xep:UnnecessaryDefaultInEnumSwitch:WARN",
// "-Xep:Unused:WARN",
// "-Xep:UnusedException:WARN",
// "-Xep:Var:WARN",
// Errorprone default severity SUGGESTION
// "-Xep:BooleanParameter:SUGGESTION",
// "-Xep:ClassNamedLikeTypeParameter:SUGGESTION",
// "-Xep:ConstantField:SUGGESTION",
// "-Xep:EmptySetMultibindingContributions:SUGGESTION",
// "-Xep:ExpectedExceptionRefactoring:SUGGESTION",
// "-Xep:FieldCanBeFinal:SUGGESTION",
// "-Xep:FieldMissingNullable:SUGGESTION",
// "-Xep:ImmutableRefactoring:SUGGESTION",
// "-Xep:LambdaFunctionalInterface:SUGGESTION",
// "-Xep:MethodCanBeStatic:SUGGESTION",
// "-Xep:MixedArrayDimensions:SUGGESTION",
// "-Xep:MultiVariableDeclaration:SUGGESTION",
// "-Xep:MultipleTopLevelClasses:SUGGESTION",
// "-Xep:MultipleUnaryOperatorsInMethodCall:SUGGESTION",
// "-Xep:PackageLocation:SUGGESTION",
// "-Xep:ParameterComment:SUGGESTION",
// "-Xep:ParameterNotNullable:SUGGESTION",
// "-Xep:PrivateConstructorForNoninstantiableModule:SUGGESTION",
// "-Xep:PrivateConstructorForUtilityClass:SUGGESTION",
// "-Xep:RemoveUnusedImports:SUGGESTION",
// "-Xep:ReturnMissingNullable:SUGGESTION",
// "-Xep:ScopeOnModule:SUGGESTION",
// "-Xep:SwitchDefault:SUGGESTION",
// "-Xep:TestExceptionRefactoring:SUGGESTION",
// "-Xep:ThrowsUncheckedException:SUGGESTION",
// "-Xep:TryFailRefactoring:SUGGESTION",
// "-Xep:TypeParameterNaming:SUGGESTION",
// "-Xep:UngroupedOverloads:SUGGESTION",
// "-Xep:UnnecessarySetDefault:SUGGESTION",
// "-Xep:UnnecessaryStaticImport:SUGGESTION",
// "-Xep:UseBinds:SUGGESTION",
// "-Xep:WildcardImport:SUGGESTION",
}
config.ErrorProneChecksOff = []string{
// We are not interested in Guava recommendations
// for String.split.
"-Xep:StringSplitter:OFF",
// b/117877739.
"-Xep:TruthAssertExpected:OFF",
}
config.ErrorProneFlags = []string{
"-Xdiags:verbose",
"-XDcompilePolicy=simple",
"-XDallowBetterNullChecks=false",
"-XDusePolyAttribution=true",
"-XDuseStrictMethodClashCheck=true",
"-XDuseStructuralMostSpecificResolution=true",
"-XDuseGraphInference=true",
"-XDandroidCompatible=true",
// As we emit errors as warnings,
// increase the warning limit.
"-Xmaxwarns 9999999",
// Extra flags needed by ErrorProne for OpenJDK9 from
// http://errorprone.info/docs/installation
"-J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
"-J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
"-J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
"-J--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
"-J--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
"-J--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
"-J--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
"-J--add-exports=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED",
"-J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED",
}
}