blob: e05a7057647b3616ce57ee4c80278fc32e653994 [file] [log] [blame]
load(
"@bazel_tools//tools/jdk:default_java_toolchain.bzl",
"NONPREBUILT_TOOLCHAIN_CONFIGURATION",
"default_java_toolchain",
)
load("@rules_java//java:defs.bzl", "java_package_configuration")
exports_files(["nongoogle.bzl"])
default_java_toolchain(
name = "error_prone_warnings_toolchain_java11",
configuration = NONPREBUILT_TOOLCHAIN_CONFIGURATION,
package_configuration = [
":error_prone",
],
source_version = "11",
target_version = "11",
visibility = ["//visibility:public"],
)
default_java_toolchain(
name = "error_prone_warnings_toolchain_java17",
configuration = dict(),
java_runtime = "@bazel_tools//tools/jdk:remotejdk_17",
package_configuration = [
":error_prone",
],
source_version = "17",
target_version = "17",
visibility = ["//visibility:public"],
)
# Error Prone errors enabled by default; see ../.bazelrc for how this is
# enabled. This warnings list is originally based on:
# https://github.com/bazelbuild/BUILD_file_generator/blob/master/tools/bazel_defs/java.bzl
# Additionally, items used internally in google is added. Such items have
# the same or higher verbosity level than in google.
# However, feel free to add any additional errors. Thus far they have all been pretty useful.
# All warnings are commented to avoid noise in the output.
# Newer versions of error-prone have XepDisableAllWarnings flag which could
# be used instead of commenting. Bazel should be updated to use a new version
# of error-prone.
java_package_configuration(
name = "error_prone",
javacopts = [
"-XepDisableWarningsInGeneratedCode",
# The XepDisableWarningsInGeneratedCode disables only warnings, but
# not errors. We should manually exclude all files generated by
# AutoValue; such files always start AutoValue_..., $AutoValue_...,
# $$AutoValue_... or AutoValueGson_...
# XepExcludedPaths is a regexp. If you need more paths - use | as
# separator.
"-XepExcludedPaths:.*/\\\\$$?\\\\$$?AutoValue(Gson)?_.*\\.java",
"-Xep:AlmostJavadoc:ERROR",
"-Xep:AlreadyChecked:ERROR",
"-Xep:AlwaysThrows:ERROR",
"-Xep:AmbiguousMethodReference:ERROR",
"-Xep:AnnotateFormatMethod:ERROR",
"-Xep:ArgumentSelectionDefectChecker:ERROR",
"-Xep:ArrayAsKeyOfSetOrMap:ERROR",
"-Xep:ArrayEquals:ERROR",
"-Xep:ArrayFillIncompatibleType:ERROR",
"-Xep:ArrayHashCode:ERROR",
"-Xep:ArrayToString:ERROR",
"-Xep:ArraysAsListPrimitiveArray:ERROR",
"-Xep:AssertEqualsArgumentOrderChecker:ERROR",
"-Xep:AssertionFailureIgnored:ERROR",
"-Xep:AsyncCallableReturnsNull:ERROR",
"-Xep:AsyncFunctionReturnsNull:ERROR",
"-Xep:AutoValueConstructorOrderChecker:ERROR",
"-Xep:AutoValueFinalMethods:ERROR",
"-Xep:AutoValueImmutableFields:ERROR",
"-Xep:AutoValueSubclassLeaked:ERROR",
"-Xep:BadAnnotationImplementation:ERROR",
"-Xep:BadComparable:ERROR",
"-Xep:BadImport:ERROR",
"-Xep:BadInstanceof:ERROR",
"-Xep:BadShiftAmount:ERROR",
"-Xep:BanJNDI:WARN",
"-Xep:BanSerializableRead:ERROR",
"-Xep:BigDecimalEquals:ERROR",
"-Xep:BigDecimalLiteralDouble:ERROR",
"-Xep:BoxedPrimitiveConstructor:ERROR",
"-Xep:BoxedPrimitiveEquality:ERROR",
"-Xep:BundleDeserializationCast:ERROR",
"-Xep:ByteBufferBackingArray:ERROR",
"-Xep:CacheLoaderNull:ERROR",
"-Xep:CannotMockFinalClass:ERROR",
"-Xep:CanonicalDuration:ERROR",
"-Xep:CatchAndPrintStackTrace:ERROR",
"-Xep:CatchFail:ERROR",
"-Xep:ChainedAssertionLosesContext:ERROR",
"-Xep:ChainingConstructorIgnoresParameter:ERROR",
"-Xep:CharacterGetNumericValue:ERROR",
"-Xep:CheckNotNullMultipleTimes:ERROR",
"-Xep:CheckReturnValue:ERROR",
"-Xep:ClassCanBeStatic:ERROR",
"-Xep:ClassName:ERROR",
"-Xep:ClassNewInstance:ERROR",
"-Xep:CollectionIncompatibleType:ERROR",
"-Xep:CollectionToArraySafeParameter:ERROR",
"-Xep:CollectionUndefinedEquality:ERROR",
"-Xep:CollectorShouldNotUseState:ERROR",
"-Xep:ComparableAndComparator:ERROR",
"-Xep:ComparableType:ERROR",
"-Xep:CompareToZero:ERROR",
"-Xep:ComparingThisWithNull:ERROR",
"-Xep:ComparisonOutOfRange:ERROR",
"-Xep:CompatibleWithAnnotationMisuse:ERROR",
"-Xep:CompileTimeConstant:ERROR",
"-Xep:ComplexBooleanConstant:ERROR",
"-Xep:ComputeIfAbsentAmbiguousReference:ERROR",
"-Xep:ConditionalExpressionNumericPromotion:ERROR",
"-Xep:ConstantOverflow:ERROR",
"-Xep:DaggerProvidesNull:ERROR",
"-Xep:DangerousLiteralNull:ERROR",
"-Xep:DateChecker:ERROR",
"-Xep:DateFormatConstant:ERROR",
"-Xep:DeadException:ERROR",
"-Xep:DeadThread:ERROR",
"-Xep:DefaultCharset:ERROR",
"-Xep:DefaultPackage:ERROR",
"-Xep:DepAnn:ERROR",
"-Xep:DeprecatedVariable:ERROR",
"-Xep:DiscardedPostfixExpression:ERROR",
"-Xep:DoNotCall:ERROR",
"-Xep:DoNotCallSuggester:ERROR",
"-Xep:DoNotClaimAnnotations:ERROR",
"-Xep:DoNotMock:ERROR",
"-Xep:DoNotMockAutoValue:ERROR",
"-Xep:DoubleBraceInitialization:ERROR",
"-Xep:DoubleCheckedLocking:ERROR",
"-Xep:DuplicateMapKeys:ERROR",
"-Xep:DurationFrom:ERROR",
"-Xep:DurationGetTemporalUnit:ERROR",
"-Xep:DurationTemporalUnit:ERROR",
"-Xep:DurationToLongTimeUnit:ERROR",
"-Xep:EmptyBlockTag:ERROR",
"-Xep:EmptyCatch:ERROR",
"-Xep:EmptySetMultibindingContributions:ERROR",
"-Xep:EqualsGetClass:ERROR",
"-Xep:EqualsHashCode:ERROR",
"-Xep:EqualsIncompatibleType:ERROR",
"-Xep:EqualsNaN:ERROR",
"-Xep:EqualsNull:ERROR",
"-Xep:EqualsReference:ERROR",
"-Xep:EqualsUnsafeCast:ERROR",
"-Xep:EqualsUsingHashCode:ERROR",
"-Xep:EqualsWrongThing:ERROR",
"-Xep:ErroneousThreadPoolConstructorChecker:ERROR",
"-Xep:EscapedEntity:ERROR",
"-Xep:ExpectedExceptionChecker:ERROR",
"-Xep:ExtendingJUnitAssert:ERROR",
"-Xep:ExtendsAutoValue:ERROR",
"-Xep:FallThrough:ERROR",
"-Xep:Finally:ERROR",
"-Xep:FloatCast:ERROR",
"-Xep:FloatingPointAssertionWithinEpsilon:ERROR",
"-Xep:FloatingPointLiteralPrecision:ERROR",
"-Xep:FloggerArgumentToString:ERROR",
"-Xep:FloggerFormatString:ERROR",
"-Xep:FloggerLogVarargs:ERROR",
"-Xep:FloggerSplitLogStatement:ERROR",
"-Xep:FloggerStringConcatenation:ERROR",
"-Xep:ForOverride:ERROR",
"-Xep:FormatString:ERROR",
"-Xep:FormatStringAnnotation:ERROR",
"-Xep:FragmentInjection:ERROR",
"-Xep:FragmentNotInstantiable:ERROR",
"-Xep:FromTemporalAccessor:ERROR",
"-Xep:FunctionalInterfaceClash:ERROR",
"-Xep:FunctionalInterfaceMethodChanged:ERROR",
"-Xep:FutureReturnValueIgnored:ERROR",
"-Xep:FuturesGetCheckedIllegalExceptionType:ERROR",
"-Xep:GetClassOnAnnotation:ERROR",
"-Xep:GetClassOnClass:ERROR",
"-Xep:GetClassOnEnum:ERROR",
"-Xep:GuardedBy:ERROR",
"-Xep:GuiceAssistedInjectScoping:ERROR",
"-Xep:GuiceAssistedParameters:ERROR",
"-Xep:HashtableContains:ERROR",
"-Xep:HidingField:ERROR",
"-Xep:IdentityBinaryExpression:ERROR",
"-Xep:IdentityHashMapBoxing:ERROR",
"-Xep:IdentityHashMapUsage:ERROR",
"-Xep:IgnoredPureGetter:ERROR",
"-Xep:Immutable:ERROR",
"-Xep:ImmutableAnnotationChecker:ERROR",
"-Xep:ImmutableEnumChecker:ERROR",
"-Xep:ImmutableModification:ERROR",
"-Xep:ImpossibleNullComparison:WARN",
"-Xep:Incomparable:ERROR",
"-Xep:IncompatibleArgumentType:ERROR",
"-Xep:IncompatibleModifiers:ERROR",
"-Xep:InconsistentCapitalization:ERROR",
"-Xep:InconsistentHashCode:ERROR",
"-Xep:IncrementInForLoopAndHeader:ERROR",
"-Xep:IndexOfChar:ERROR",
"-Xep:InexactVarargsConditional:ERROR",
"-Xep:InfiniteRecursion:ERROR",
"-Xep:InjectOnConstructorOfAbstractClass:ERROR",
"-Xep:InheritDoc:ERROR",
"-Xep:InlineFormatString:ERROR",
"-Xep:InlineMeInliner:ERROR",
"-Xep:InlineMeSuggester:ERROR",
"-Xep:InlineMeValidator:ERROR",
"-Xep:InputStreamSlowMultibyteRead:ERROR",
"-Xep:InsecureCryptoUsage:ERROR",
"-Xep:InstanceOfAndCastMatchWrongType:ERROR",
"-Xep:InstantTemporalUnit:ERROR",
"-Xep:IntLongMath:ERROR",
"-Xep:InvalidBlockTag:ERROR",
"-Xep:InvalidInlineTag:ERROR",
"-Xep:InvalidJavaTimeConstant:ERROR",
"-Xep:InvalidLink:ERROR",
"-Xep:InvalidParam:ERROR",
"-Xep:InvalidPatternSyntax:ERROR",
"-Xep:InvalidThrows:ERROR",
"-Xep:InvalidThrowsLink:ERROR",
"-Xep:InvalidTimeZoneID:ERROR",
"-Xep:InvalidZoneId:ERROR",
"-Xep:IsInstanceIncompatibleType:ERROR",
"-Xep:IsInstanceOfClass:ERROR",
"-Xep:IsLoggableTagLength:ERROR",
"-Xep:IterableAndIterator:ERROR",
"-Xep:IterablePathParameter:ERROR",
"-Xep:JUnit3FloatingPointComparisonWithoutDelta:ERROR",
"-Xep:JUnit3TestNotRun:ERROR",
"-Xep:JUnit4ClassAnnotationNonStatic:ERROR",
"-Xep:JUnit4ClassUsedInJUnit3:ERROR",
"-Xep:JUnit4SetUpNotRun:ERROR",
"-Xep:JUnit4TearDownNotRun:ERROR",
"-Xep:JUnit4TestNotRun:ERROR",
"-Xep:JUnit4TestsNotRunWithinEnclosed:ERROR",
"-Xep:JUnitAmbiguousTestClass:ERROR",
"-Xep:JUnitAssertSameCheck:ERROR",
"-Xep:JUnitParameterMethodNotFound:ERROR",
"-Xep:JavaDurationGetSecondsGetNano:ERROR",
"-Xep:JavaDurationWithNanos:ERROR",
"-Xep:JavaDurationWithSeconds:ERROR",
"-Xep:JavaInstantGetSecondsGetNano:ERROR",
"-Xep:JavaLangClash:ERROR",
"-Xep:JavaLocalDateTimeGetNano:ERROR",
"-Xep:JavaLocalTimeGetNano:ERROR",
"-Xep:JavaPeriodGetDays:ERROR",
"-Xep:JavaTimeDefaultTimeZone:ERROR",
"-Xep:JavaUtilDate:ERROR",
"-Xep:JdkObsolete:ERROR",
"-Xep:JodaConstructors:ERROR",
"-Xep:JodaDateTimeConstants:ERROR",
"-Xep:JodaDurationWithMillis:ERROR",
"-Xep:JodaInstantWithMillis:ERROR",
"-Xep:JodaNewPeriod:ERROR",
"-Xep:JodaPlusMinusLong:ERROR",
"-Xep:JodaTimeConverterManager:ERROR",
"-Xep:JodaToSelf:ERROR",
"-Xep:JodaWithDurationAddedLong:ERROR",
"-Xep:LiteByteStringUtf8:ERROR",
"-Xep:LiteEnumValueOf:ERROR",
"-Xep:LiteProtoToString:WARN",
"-Xep:LocalDateTemporalAmount:ERROR",
"-Xep:LockNotBeforeTry:ERROR",
"-Xep:LockOnBoxedPrimitive:ERROR",
"-Xep:LogicalAssignment:ERROR",
"-Xep:LongFloatConversion:ERROR",
"-Xep:LongLiteralLowerCaseSuffix:ERROR",
"-Xep:LoopConditionChecker:ERROR",
"-Xep:LoopOverCharArray:ERROR",
"-Xep:LossyPrimitiveCompare:ERROR",
"-Xep:MathAbsoluteRandom:ERROR",
"-Xep:MathRoundIntLong:ERROR",
"-Xep:MemoizeConstantVisitorStateLookups:ERROR",
"-Xep:MislabeledAndroidString:ERROR",
"-Xep:MissingCasesInEnumSwitch:ERROR",
"-Xep:MissingFail:ERROR",
"-Xep:MissingOverride:ERROR",
"-Xep:MissingSummary:ERROR",
"-Xep:MissingSuperCall:ERROR",
"-Xep:MissingTestCall:ERROR",
"-Xep:MisusedDayOfYear:ERROR",
"-Xep:MisusedWeekYear:ERROR",
"-Xep:MixedDescriptors:ERROR",
"-Xep:MixedMutabilityReturnType:ERROR",
"-Xep:MockitoUsage:ERROR",
"-Xep:ModifiedButNotUsed:ERROR",
"-Xep:ModifyCollectionInEnhancedForLoop:ERROR",
"-Xep:ModifySourceCollectionInStream:ERROR",
"-Xep:ModifyingCollectionWithItself:ERROR",
"-Xep:MultipleParallelOrSequentialCalls:ERROR",
"-Xep:MultipleUnaryOperatorsInMethodCall:ERROR",
"-Xep:MustBeClosedChecker:ERROR",
"-Xep:MutableConstantField:WARN",
"-Xep:MutablePublicArray:ERROR",
"-Xep:NCopiesOfChar:ERROR",
"-Xep:NarrowingCompoundAssignment:ERROR",
"-Xep:NestedInstanceOfConditions:ERROR",
"-Xep:NonAtomicVolatileUpdate:ERROR",
"-Xep:NonCanonicalStaticImport:ERROR",
"-Xep:NonCanonicalType:ERROR",
"-Xep:NonFinalCompileTimeConstant:ERROR",
"-Xep:NonOverridingEquals:ERROR",
"-Xep:NonRuntimeAnnotation:ERROR",
"-Xep:NullOptional:ERROR",
"-Xep:NullTernary:ERROR",
"-Xep:NullableConstructor:ERROR",
"-Xep:NullablePrimitive:ERROR",
"-Xep:NullablePrimitiveArray:ERROR",
"-Xep:NullableVoid:ERROR",
"-Xep:ObjectEqualsForPrimitives:ERROR",
"-Xep:ObjectToString:ERROR",
"-Xep:ObjectsHashCodePrimitive:ERROR",
"-Xep:OperatorPrecedence:ERROR",
"-Xep:OptionalEquality:ERROR",
"-Xep:OptionalMapToOptional:ERROR",
"-Xep:OptionalMapUnusedValue:ERROR",
"-Xep:OptionalNotPresent:ERROR",
"-Xep:OptionalOfRedundantMethod:ERROR",
"-Xep:OrphanedFormatString:ERROR",
"-Xep:OutlineNone:ERROR",
"-Xep:OverlappingQualifierAndScopeAnnotation:ERROR",
"-Xep:OverrideThrowableToString:ERROR",
"-Xep:Overrides:ERROR",
"-Xep:OverridesGuiceInjectableMethod:ERROR",
"-Xep:OverridesJavaxInjectableMethod:ERROR",
"-Xep:PackageInfo:ERROR",
"-Xep:ParameterName:ERROR",
"-Xep:ParametersButNotParameterized:ERROR",
"-Xep:ParcelableCreator:ERROR",
"-Xep:PeriodFrom:ERROR",
"-Xep:PeriodGetTemporalUnit:ERROR",
"-Xep:PeriodTimeMath:ERROR",
"-Xep:PreconditionsCheckNotNullRepeated:ERROR",
"-Xep:PreconditionsInvalidPlaceholder:ERROR",
"-Xep:PrimitiveAtomicReference:ERROR",
"-Xep:PrivateSecurityContractProtoAccess:ERROR",
"-Xep:ProtectedMembersInFinalClass:ERROR",
"-Xep:ProtoBuilderReturnValueIgnored:ERROR",
"-Xep:ProtoDurationGetSecondsGetNano:ERROR",
"-Xep:ProtoFieldNullComparison:ERROR",
"-Xep:ProtoRedundantSet:ERROR",
"-Xep:ProtoStringFieldReferenceEquality:ERROR",
"-Xep:ProtoTimestampGetSecondsGetNano:ERROR",
"-Xep:ProtoTruthMixedDescriptors:ERROR",
"-Xep:ProtocolBufferOrdinal:ERROR",
"-Xep:ProvidesMethodOutsideOfModule:WARN",
"-Xep:RandomCast:ERROR",
"-Xep:RandomModInteger:ERROR",
"-Xep:ReachabilityFenceUsage:ERROR",
"-Xep:RectIntersectReturnValueIgnored:ERROR",
"-Xep:ReferenceEquality:ERROR",
"-Xep:RefersToDaggerCodegen:ERROR",
"-Xep:RemovedInJDK11:ERROR",
"-Xep:RequiredModifiers:ERROR",
"-Xep:RestrictedApiChecker:ERROR",
"-Xep:RethrowReflectiveOperationExceptionAsLinkageError:ERROR",
"-Xep:ReturnFromVoid:ERROR",
"-Xep:ReturnMissingNullable:ERROR",
"-Xep:ReturnValueIgnored:ERROR",
"-Xep:RxReturnValueIgnored:ERROR",
"-Xep:SameNameButDifferent:ERROR",
"-Xep:SelfAssignment:ERROR",
"-Xep:SelfComparison:ERROR",
"-Xep:SelfEquals:ERROR",
"-Xep:ShortCircuitBoolean:ERROR",
"-Xep:ShouldHaveEvenArgs:ERROR",
"-Xep:SizeGreaterThanOrEqualsZero:ERROR",
"-Xep:StaticAssignmentInConstructor:ERROR",
"-Xep:StaticGuardedByInstance:ERROR",
"-Xep:StaticMockMember:ERROR",
"-Xep:StaticQualifiedUsingExpression:ERROR",
"-Xep:StreamToString:ERROR",
"-Xep:StringBuilderInitWithChar:ERROR",
"-Xep:StringEquality:ERROR",
"-Xep:StringSplitter:ERROR",
"-Xep:SubstringOfZero:ERROR",
"-Xep:SuppressWarningsDeprecated:ERROR",
"-Xep:SwigMemoryLeak:ERROR",
"-Xep:SynchronizeOnNonFinalField:ERROR",
"-Xep:TemporalAccessorGetChronoField:ERROR",
"-Xep:TestParametersNotInitialized:ERROR",
"-Xep:TheoryButNoTheories:ERROR",
"-Xep:ThreadJoinLoop:ERROR",
"-Xep:ThreadLocalUsage:ERROR",
"-Xep:ThreadPriorityCheck:ERROR",
"-Xep:ThreeLetterTimeZoneID:ERROR",
"-Xep:ThrowIfUncheckedKnownChecked:ERROR",
"-Xep:ThrowNull:ERROR",
"-Xep:TimeUnitConversionChecker:ERROR",
"-Xep:ToStringReturnsNull:ERROR",
"-Xep:TreeToString:ERROR",
"-Xep:TruthAssertExpected:ERROR",
"-Xep:TruthConstantAsserts:ERROR",
"-Xep:TruthGetOrDefault:ERROR",
"-Xep:TruthIncompatibleType:ERROR",
"-Xep:TruthSelfEquals:ERROR",
"-Xep:TryFailThrowable:ERROR",
"-Xep:TypeEquals:ERROR",
"-Xep:TypeNameShadowing:ERROR",
"-Xep:TypeParameterQualifier:ERROR",
"-Xep:TypeParameterShadowing:ERROR",
"-Xep:TypeParameterUnusedInFormals:ERROR",
"-Xep:URLEqualsHashCode:ERROR",
"-Xep:UndefinedEquals:ERROR",
"-Xep:UnescapedEntity:ERROR",
"-Xep:UnnecessaryAssignment:ERROR",
"-Xep:UnnecessaryCheckNotNull:ERROR",
"-Xep:UnnecessaryLambda:ERROR",
"-Xep:UnnecessaryMethodInvocationMatcher:ERROR",
"-Xep:UnnecessaryMethodReference:ERROR",
"-Xep:UnnecessaryParentheses:ERROR",
"-Xep:UnnecessaryTypeArgument:ERROR",
"-Xep:UnrecognisedJavadocTag:ERROR",
"-Xep:UnsafeFinalization:ERROR",
"-Xep:UnsafeReflectiveConstructionCast:ERROR",
"-Xep:UnsynchronizedOverridesSynchronized:ERROR",
"-Xep:UnusedAnonymousClass:ERROR",
"-Xep:UnusedCollectionModifiedInPlace:ERROR",
"-Xep:UnusedException:ERROR",
"-Xep:UnusedMethod:ERROR",
"-Xep:UnusedNestedClass:ERROR",
"-Xep:UnusedVariable:ERROR",
"-Xep:UseBinds:ERROR",
"-Xep:UseCorrectAssertInTests:ERROR",
"-Xep:VarTypeName:ERROR",
"-Xep:VariableNameSameAsType:ERROR",
"-Xep:WaitNotInLoop:ERROR",
"-Xep:WakelockReleasedDangerously:ERROR",
"-Xep:WildcardImport:ERROR",
"-Xep:WithSignatureDiscouraged:ERROR",
"-Xep:WrongOneof:ERROR",
"-Xep:XorPower:ERROR",
"-Xep:ZoneIdOfZ:ERROR",
"-Xlint:unchecked",
],
packages = ["error_prone_packages"],
)
package_group(
name = "error_prone_packages",
packages = [
"//java/...",
"//javatests/...",
"//plugins/codemirror-editor/...",
"//plugins/commit-message-length-validator/...",
"//plugins/delete-project/...",
"//plugins/download-commands/...",
"//plugins/gitiles/...",
"//plugins/hooks/...",
"//plugins/plugin-manager/...",
"//plugins/replication/...",
"//plugins/reviewnotes/...",
"//plugins/singleusergroup/...",
"//plugins/webhooks/...",
],
)