• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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	"android/soong/java/config"
19)
20
21func init() {
22	// These values are set into build/soong/java/config/config.go so that soong doesn't have any
23	// references to external/error_prone, which may not always exist.
24	config.ErrorProneClasspath = []string{
25		"external/error_prone/error_prone/error_prone_core-2.11.0-with-dependencies.jar",
26		"external/error_prone/error_prone/error_prone_annotations-2.11.0.jar",
27		"external/error_prone/error_prone/error_prone_type_annotations-2.11.0.jar",
28		"external/error_prone/checkerframework/dataflow-errorprone-3.21.2.jar",
29		"external/error_prone/jFormatString/jFormatString-3.0.0.jar",
30	}
31
32	// The checks that are fatal to the build.
33	config.ErrorProneChecksError = []string{
34		// Errorprone default severity ERROR
35		"-Xep:AndroidInjectionBeforeSuper:ERROR",
36		"-Xep:ArrayFillIncompatibleType:ERROR",
37		"-Xep:AsyncCallableReturnsNull:ERROR",
38		"-Xep:AsyncFunctionReturnsNull:ERROR",
39		"-Xep:AutoValueConstructorOrderChecker:ERROR",
40		"-Xep:BundleDeserializationCast:ERROR",
41		"-Xep:ChainingConstructorIgnoresParameter:ERROR",
42		"-Xep:CheckReturnValue:ERROR",
43		"-Xep:CollectionIncompatibleType:ERROR",
44		"-Xep:ComparingThisWithNull:ERROR",
45		"-Xep:ComparisonOutOfRange:ERROR",
46		"-Xep:CompatibleWithAnnotationMisuse:ERROR",
47		"-Xep:CompileTimeConstant:ERROR",
48		"-Xep:ConstantOverflow:ERROR",
49		"-Xep:DaggerProvidesNull:ERROR",
50		"-Xep:DeadException:ERROR",
51		"-Xep:DeadThread:ERROR",
52		"-Xep:DoNotCall:ERROR",
53		"-Xep:EqualsNaN:ERROR",
54		"-Xep:EqualsWrongThing:ERROR",
55		"-Xep:ErroneousThreadPoolConstructorChecker:ERROR",
56		"-Xep:ForOverride:ERROR",
57		"-Xep:FormatStringAnnotation:ERROR",
58		"-Xep:FunctionalInterfaceMethodChanged:ERROR",
59		"-Xep:FuturesGetCheckedIllegalExceptionType:ERROR",
60		"-Xep:GuiceAssistedInjectScoping:ERROR",
61		"-Xep:GuiceAssistedParameters:ERROR",
62		"-Xep:GuiceInjectOnFinalField:ERROR",
63		"-Xep:Immutable:ERROR",
64		"-Xep:IncompatibleArgumentType:ERROR",
65		"-Xep:IndexOfChar:ERROR",
66		"-Xep:InexactVarargsConditional:ERROR",
67		"-Xep:InfiniteRecursion:ERROR",
68		"-Xep:InjectMoreThanOneScopeAnnotationOnClass:ERROR",
69		"-Xep:InjectOnMemberAndConstructor:ERROR",
70		"-Xep:InvalidPatternSyntax:ERROR",
71		"-Xep:IsInstanceOfClass:ERROR",
72		"-Xep:JUnit3TestNotRun:ERROR",
73		"-Xep:JUnit4ClassAnnotationNonStatic:ERROR",
74		"-Xep:JUnit4SetUpNotRun:ERROR",
75		"-Xep:JUnit4TearDownNotRun:ERROR",
76		"-Xep:JUnit4TestNotRun:ERROR",
77		"-Xep:JUnitAssertSameCheck:ERROR",
78		"-Xep:JavaxInjectOnAbstractMethod:ERROR",
79		"-Xep:LiteByteStringUtf8:ERROR",
80		"-Xep:LoopConditionChecker:ERROR",
81		"-Xep:MissingTestCall:ERROR",
82		"-Xep:MockitoUsage:ERROR",
83		"-Xep:MoreThanOneInjectableConstructor:ERROR",
84		"-Xep:MustBeClosedChecker:ERROR",
85		"-Xep:NCopiesOfChar:ERROR",
86		"-Xep:NonCanonicalStaticImport:ERROR",
87		"-Xep:NonFinalCompileTimeConstant:ERROR",
88		"-Xep:OptionalEquality:ERROR",
89		"-Xep:OverlappingQualifierAndScopeAnnotation:ERROR",
90		"-Xep:PackageInfo:ERROR",
91		"-Xep:PrivateSecurityContractProtoAccess:ERROR",
92		"-Xep:ProtoFieldNullComparison:ERROR",
93		"-Xep:ProtoStringFieldReferenceEquality:ERROR",
94		"-Xep:ProvidesMethodOutsideOfModule:ERROR",
95		"-Xep:RandomCast:ERROR",
96		"-Xep:RestrictedApiChecker:ERROR",
97		"-Xep:SelfAssignment:ERROR",
98		"-Xep:ShouldHaveEvenArgs:ERROR",
99		"-Xep:StreamToString:ERROR",
100		"-Xep:SubstringOfZero:ERROR",
101		"-Xep:SuppressWarningsDeprecated:ERROR",
102		"-Xep:ThrowIfUncheckedKnownChecked:ERROR",
103		"-Xep:ThrowNull:ERROR",
104		"-Xep:TruthSelfEquals:ERROR",
105		"-Xep:TypeParameterQualifier:ERROR",
106		"-Xep:UnnecessaryTypeArgument:ERROR",
107		"-Xep:UnusedAnonymousClass:ERROR",
108		"-Xep:VarTypeName:ERROR",
109		// Errorprone default severity WARNING
110		// Errorprone default severity SUGGESTION
111	}
112
113	// The checks that are not fatal to the build.
114	config.ErrorProneChecksWarning = []string{
115		// Errorprone default severity ERROR
116		"-Xep:ArrayEquals:WARN",
117		"-Xep:ArrayHashCode:WARN",
118		"-Xep:ArrayToString:WARN",
119		"-Xep:ArraysAsListPrimitiveArray:WARN",
120		"-Xep:BadAnnotationImplementation:WARN",
121		"-Xep:BadShiftAmount:WARN",
122		"-Xep:ComparableType:WARN",
123		"-Xep:ComplexBooleanConstant:WARN",
124		"-Xep:CollectionToArraySafeParameter:WARN",
125		"-Xep:ConditionalExpressionNumericPromotion:WARN",
126		"-Xep:DangerousLiteralNull:WARN",
127		"-Xep:DurationFrom:WARN",
128		"-Xep:DurationTemporalUnit:WARN",
129		"-Xep:EqualsHashCode:WARN",
130		"-Xep:EqualsReference:WARN",
131		"-Xep:FormatString:WARN",
132		"-Xep:FromTemporalAccessor:WARN",
133		"-Xep:GetClassOnAnnotation:WARN",
134		"-Xep:GetClassOnClass:WARN",
135		"-Xep:GuardedBy:WARN",
136		"-Xep:HashtableContains:WARN",
137		"-Xep:IdentityBinaryExpression:WARN",
138		"-Xep:IdentityHashMapBoxing:WARN",
139		"-Xep:InstantTemporalUnit:WARN",
140		"-Xep:InvalidTimeZoneID:WARN",
141		"-Xep:InvalidZoneId:WARN",
142		"-Xep:IsInstanceIncompatibleType:WARN",
143		"-Xep:IsLoggableTagLength:WARN",
144		"-Xep:JUnitParameterMethodNotFound:WARN",
145		"-Xep:MathRoundIntLong:WARN",
146		"-Xep:MislabeledAndroidString:WARN",
147		"-Xep:MisusedDayOfYear:WARN",
148		"-Xep:MissingSuperCall:WARN",
149		"-Xep:MisusedWeekYear:WARN",
150		"-Xep:ModifyingCollectionWithItself:WARN",
151		"-Xep:NonRuntimeAnnotation:WARN",
152		"-Xep:NullTernary:WARN",
153		"-Xep:OverridesJavaxInjectableMethod:WARN",
154		"-Xep:ParcelableCreator:WARN",
155		"-Xep:PeriodFrom:WARN",
156		"-Xep:PreconditionsInvalidPlaceholder:WARN",
157		"-Xep:ProtoBuilderReturnValueIgnored:WARN",
158		"-Xep:ProtocolBufferOrdinal:WARN",
159		"-Xep:ProtoFieldNullComparison:WARN",
160		"-Xep:RandomModInteger:WARN",
161		"-Xep:RectIntersectReturnValueIgnored:WARN",
162		"-Xep:ReturnValueIgnored:WARN",
163		"-Xep:SelfAssignment:WARN",
164		"-Xep:SelfComparison:WARN",
165		"-Xep:SelfEquals:WARN",
166		"-Xep:SizeGreaterThanOrEqualsZero:WARN",
167		"-Xep:StringBuilderInitWithChar:WARN",
168		"-Xep:TryFailThrowable:WARN",
169		"-Xep:UnnecessaryCheckNotNull:WARN",
170		"-Xep:UnusedCollectionModifiedInPlace:WARN",
171		"-Xep:XorPower:WARN",
172	}
173
174	// The checks that are default-disabled
175	config.ErrorProneChecksDefaultDisabled = []string{
176	}
177
178	config.ErrorProneChecksOff = []string{
179		// We are not interested in Guava recommendations
180		// for String.split.
181		"-Xep:StringSplitter:OFF",
182		// b/117877739.
183		"-Xep:TruthAssertExpected:OFF",
184		// b/170172949
185		"-Xep:MissingOverride:OFF",
186		"-Xep:UnnecessaryParentheses:OFF",
187		// This triggers on android R classes, disable until we can ignore
188		// the generated R classes
189		"-Xep:MutablePublicArray:OFF",
190		// These checks crash
191		"-Xep:RethrowReflectiveOperationExceptionAsLinkageError:OFF",
192		"-Xep:InvalidLink:OFF",
193		// Commonly triggers for stubbed methods
194		"-Xep:DoNotCallSuggester:OFF",
195		"-Xep:MissingSummary:OFF",
196		// This check increates the `platformprotos` module's build
197		// time by ~15 minutes
198		"-Xep:SameNameButDifferent:OFF",
199	}
200
201	config.ErrorProneFlags = []string{
202		"-Xdiags:verbose",
203		"-XDcompilePolicy=simple",
204		"-XDallowBetterNullChecks=false",
205		"-XDusePolyAttribution=true",
206		"-XDuseStrictMethodClashCheck=true",
207		"-XDuseStructuralMostSpecificResolution=true",
208		"-XDuseGraphInference=true",
209		"-XDandroidCompatible=true",
210		// As we emit errors as warnings,
211		// increase the warning limit.
212		"-Xmaxwarns 9999999",
213
214		// Extra flags needed by ErrorProne for OpenJDK9 from
215		// http://errorprone.info/docs/installation
216		"-J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
217		"-J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
218		"-J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
219		"-J--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
220		"-J--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
221		"-J--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
222		"-J--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
223		"-J--add-exports=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED",
224		"-J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED",
225	}
226}
227