1// Copyright 2017 Google Inc. All rights reserved. 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15package error_prone 16 17import ( 18 "strings" 19 20 "android/soong/java/config" 21) 22 23func init() { 24 // These values are set into build/soong/java/config/config.go so that soong doesn't have any 25 // references to external/error_prone, which may not always exist. 26 config.ErrorProneJavacJar = "external/error_prone/javac/javac-9+181-r4173-1.jar" 27 config.ErrorProneJar = "external/error_prone/error_prone/error_prone_core-2.2.0-with-dependencies.jar" 28 config.ErrorProneClasspath = strings.Join([]string{ 29 "external/error_prone/error_prone/error_prone_annotations-2.2.0.jar", 30 "external/error_prone/checkerframework/dataflow-2.2.2.jar", 31 "external/error_prone/checkerframework/javacutil-2.2.2.jar", 32 "external/error_prone/jFormatString/jFormatString-3.0.0.jar", 33 }, ":") 34 35 // The checks that are fatal to the build. 36 config.ErrorProneChecksError = strings.Join([]string{ 37 "-Xep:AsyncCallableReturnsNull:ERROR", 38 "-Xep:AsyncFunctionReturnsNull:ERROR", 39 "-Xep:BundleDeserializationCast:ERROR", 40 "-Xep:ChainingConstructorIgnoresParameter:ERROR", 41 "-Xep:CheckReturnValue:ERROR", 42 "-Xep:ComparisonOutOfRange:ERROR", 43 "-Xep:CompatibleWithAnnotationMisuse:ERROR", 44 "-Xep:CompileTimeConstant:ERROR", 45 "-Xep:DaggerProvidesNull:ERROR", 46 "-Xep:DeadException:ERROR", 47 "-Xep:DeadThread:ERROR", 48 "-Xep:DoNotCall:ERROR", 49 "-Xep:EqualsNaN:ERROR", 50 "-Xep:ForOverride:ERROR", 51 "-Xep:FunctionalInterfaceMethodChanged:ERROR", 52 "-Xep:FuturesGetCheckedIllegalExceptionType:ERROR", 53 "-Xep:GuiceAssistedInjectScoping:ERROR", 54 "-Xep:GuiceAssistedParameters:ERROR", 55 "-Xep:GuiceInjectOnFinalField:ERROR", 56 "-Xep:Immutable:ERROR", 57 "-Xep:ImmutableModification:ERROR", 58 "-Xep:IncompatibleArgumentType:ERROR", 59 "-Xep:IndexOfChar:ERROR", 60 "-Xep:InfiniteRecursion:ERROR", 61 "-Xep:InjectMoreThanOneScopeAnnotationOnClass:ERROR", 62 "-Xep:InvalidPatternSyntax:ERROR", 63 "-Xep:IsInstanceOfClass:ERROR", 64 "-Xep:JavaxInjectOnAbstractMethod:ERROR", 65 "-Xep:JUnit3TestNotRun:ERROR", 66 "-Xep:JUnit4SetUpNotRun:ERROR", 67 "-Xep:JUnit4TearDownNotRun:ERROR", 68 "-Xep:JUnit4TestNotRun:ERROR", 69 "-Xep:JUnitAssertSameCheck:ERROR", 70 "-Xep:LiteByteStringUtf8:ERROR", 71 "-Xep:LoopConditionChecker:ERROR", 72 "-Xep:MockitoCast:ERROR", 73 "-Xep:MockitoUsage:ERROR", 74 "-Xep:MoreThanOneInjectableConstructor:ERROR", 75 "-Xep:MustBeClosedChecker:ERROR", 76 "-Xep:NonCanonicalStaticImport:ERROR", 77 "-Xep:NonFinalCompileTimeConstant:ERROR", 78 "-Xep:OptionalEquality:ERROR", 79 "-Xep:OverlappingQualifierAndScopeAnnotation:ERROR", 80 "-Xep:PackageInfo:ERROR", 81 "-Xep:PreconditionsCheckNotNull:ERROR", 82 "-Xep:PreconditionsCheckNotNullPrimitive:ERROR", 83 "-Xep:ProtoFieldNullComparison:ERROR", 84 "-Xep:ProvidesMethodOutsideOfModule:ERROR", 85 "-Xep:RandomCast:ERROR", 86 "-Xep:RestrictedApiChecker:ERROR", 87 "-Xep:SelfAssignment:ERROR", 88 "-Xep:StreamToString:ERROR", 89 "-Xep:SuppressWarningsDeprecated:ERROR", 90 "-Xep:ThrowIfUncheckedKnownChecked:ERROR", 91 "-Xep:ThrowNull:ERROR", 92 "-Xep:TruthSelfEquals:ERROR", 93 "-Xep:TypeParameterQualifier:ERROR", 94 "-Xep:UnnecessaryTypeArgument:ERROR", 95 "-Xep:UnusedAnonymousClass:ERROR", 96 }, " ") 97 98 config.ErrorProneFlags = strings.Join([]string{ 99 "com.google.errorprone.ErrorProneCompiler", 100 "-Xdiags:verbose", 101 "-XDcompilePolicy=simple", 102 "-XDallowBetterNullChecks=false", 103 "-XDusePolyAttribution=true", 104 "-XDuseStrictMethodClashCheck=true", 105 "-XDuseStructuralMostSpecificResolution=true", 106 "-XDuseGraphInference=true", 107 "-XDandroidCompatible=true", 108 "-XepAllErrorsAsWarnings", 109 // We are not interested in Guava recommendations 110 // for String.split. 111 "-Xep:StringSplitter:OFF", 112 "-Xmaxwarns 9999999", // As we emit errors as warnings, 113 // increase the warning limit. 114 }, " ") 115} 116