load( "@bazel_tools//tools/jdk:default_java_toolchain.bzl", "default_java_toolchain", ) load("@rules_java//java:defs.bzl", "java_package_configuration") default_java_toolchain( name = "error_prone_warnings_toolchain_java17", configuration = dict(), java_runtime = "@rules_java//toolchains:remotejdk_17", package_configuration = [ ":error_prone", ":error_prone_tests", ], source_version = "17", target_version = "17", visibility = ["//visibility:public"], ) default_java_toolchain( name = "error_prone_warnings_toolchain_java21", configuration = dict(), java_runtime = "@rules_java//toolchains:remotejdk_21", package_configuration = [ ":error_prone", ":error_prone_tests", ], source_version = "21", target_version = "21", 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 # However, feel free to add any additional errors. Thus far they have all been pretty useful. errorprone_checks = [ "-XepDisableWarningsInGeneratedCode", # The XepDisableWarningsInGeneratedCode disables only warnings, but # not errors. We should manually exclude all files generated by # AutoValue; such files always start $AutoValue_..... # XepExcludedPaths is a regexp. If you need more paths - use | as # separator. "-XepExcludedPaths:.*/\\\\$$AutoValue_.*\\.java", "-Xep:AlmostJavadoc:ERROR", "-Xep:AlwaysThrows:ERROR", "-Xep:AmbiguousMethodReference:ERROR", # don't want to add dependency to errorprone "-Xep:AnnotateFormatMethod:OFF", "-Xep:ArgumentSelectionDefectChecker:ERROR", "-Xep:ArrayAsKeyOfSetOrMap:ERROR", "-Xep:ArrayEquals:ERROR", "-Xep:ArrayFillIncompatibleType:ERROR", "-Xep:ArrayHashCode:ERROR", "-Xep:ArraysAsListPrimitiveArray:ERROR", "-Xep:ArrayToString:ERROR", "-Xep:AssertEqualsArgumentOrderChecker:ERROR", "-Xep:AssertionFailureIgnored:WARN", "-Xep:AsyncCallableReturnsNull:ERROR", "-Xep:AsyncFunctionReturnsNull:ERROR", "-Xep:AutoValueConstructorOrderChecker:ERROR", "-Xep:AutoValueFinalMethods:ERROR", "-Xep:AutoValueImmutableFields:ERROR", "-Xep:AutoValueSubclassLeaked:WARN", "-Xep:BadAnnotationImplementation:ERROR", "-Xep:BadComparable:ERROR", "-Xep:BadImport:ERROR", "-Xep:BadInstanceof:ERROR", "-Xep:BadShiftAmount:ERROR", "-Xep:BanSerializableRead:ERROR", "-Xep:BigDecimalEquals:ERROR", "-Xep:BigDecimalLiteralDouble:ERROR", "-Xep:BoxedPrimitiveConstructor:ERROR", "-Xep:BoxedPrimitiveEquality:ERROR", "-Xep:BundleDeserializationCast:ERROR", "-Xep:ByteBufferBackingArray:WARN", "-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:WARN", "-Xep:DoubleBraceInitialization:ERROR", "-Xep:DoubleCheckedLocking:ERROR", "-Xep:DuplicateMapKeys:ERROR", "-Xep:DurationFrom:ERROR", "-Xep:DurationGetTemporalUnit:ERROR", "-Xep:DurationTemporalUnit:ERROR", "-Xep:DurationToLongTimeUnit:ERROR", "-Xep:EmptyBlockTag:WARN", "-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:WARN", "-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:FormatString:ERROR", "-Xep:FormatStringAnnotation:ERROR", "-Xep:ForOverride: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:WARN", "-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:Incomparable:ERROR", "-Xep:IncompatibleArgumentType:ERROR", "-Xep:IncompatibleModifiers:ERROR", "-Xep:InconsistentCapitalization:WARN", "-Xep:InconsistentHashCode:ERROR", "-Xep:IncrementInForLoopAndHeader:ERROR", "-Xep:IndexOfChar:ERROR", "-Xep:InexactVarargsConditional:ERROR", "-Xep:InfiniteRecursion:ERROR", "-Xep:InheritDoc:ERROR", "-Xep:InjectOnConstructorOfAbstractClass:ERROR", "-Xep:InlineFormatString:ERROR", "-Xep:InlineMeInliner:ERROR", # don't want to add dependency to errorprone "-Xep:InlineMeSuggester:OFF", "-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: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:WARN", "-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: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:LiteByteStringUtf8:ERROR", "-Xep:LiteEnumValueOf:ERROR", "-Xep:LiteProtoToString:ERROR", "-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:WARN", "-Xep:MissingSuperCall:ERROR", "-Xep:MissingTestCall:ERROR", "-Xep:MisusedDayOfYear:ERROR", "-Xep:MisusedWeekYear:ERROR", "-Xep:MixedDescriptors:ERROR", "-Xep:MixedMutabilityReturnType:WARN", "-Xep:MockitoUsage:ERROR", "-Xep:ModifiedButNotUsed:ERROR", "-Xep:ModifyCollectionInEnhancedForLoop:ERROR", "-Xep:ModifyingCollectionWithItself:ERROR", "-Xep:ModifySourceCollectionInStream:ERROR", "-Xep:MultipleParallelOrSequentialCalls:ERROR", "-Xep:MultipleUnaryOperatorsInMethodCall:ERROR", "-Xep:MustBeClosedChecker:ERROR", "-Xep:MutableConstantField:ERROR", # Java provides no good alternative "-Xep:MutablePublicArray:OFF", "-Xep:NarrowingCompoundAssignment:ERROR", "-Xep:NCopiesOfChar:ERROR", "-Xep:NestedInstanceOfConditions:ERROR", "-Xep:NonAtomicVolatileUpdate:ERROR", "-Xep:NonCanonicalStaticImport:ERROR", "-Xep:NonCanonicalType:ERROR", "-Xep:NonFinalCompileTimeConstant:ERROR", "-Xep:NonOverridingEquals:ERROR", "-Xep:NonRuntimeAnnotation:ERROR", "-Xep:NullableConstructor:ERROR", "-Xep:NullablePrimitive:ERROR", "-Xep:NullablePrimitiveArray:ERROR", "-Xep:NullableVoid:ERROR", "-Xep:NullOptional:ERROR", "-Xep:NullTernary:ERROR", "-Xep:ObjectEqualsForPrimitives:ERROR", "-Xep:ObjectsHashCodePrimitive:ERROR", "-Xep:ObjectToString: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:Overrides:ERROR", "-Xep:OverridesGuiceInjectableMethod:ERROR", "-Xep:OverridesJavaxInjectableMethod:ERROR", "-Xep:OverrideThrowableToString: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:PreferredInterfaceType:OFF", "-Xep:PrimitiveAtomicReference:ERROR", "-Xep:PrivateSecurityContractProtoAccess:ERROR", "-Xep:ProtectedMembersInFinalClass:ERROR", "-Xep:ProtoBuilderReturnValueIgnored:ERROR", "-Xep:ProtocolBufferOrdinal:ERROR", "-Xep:ProtoDurationGetSecondsGetNano:ERROR", "-Xep:ProtoFieldNullComparison:ERROR", "-Xep:ProtoFieldPreconditionsCheckNotNull:ERROR", "-Xep:ProtoRedundantSet:ERROR", "-Xep:ProtoStringFieldReferenceEquality:ERROR", "-Xep:ProtoTimestampGetSecondsGetNano:ERROR", "-Xep:ProtoTruthMixedDescriptors:ERROR", "-Xep:ProvidesMethodOutsideOfModule:ERROR", "-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: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:WARN", "-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:WARN", "-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:UndefinedEquals:WARN", "-Xep:UnescapedEntity:WARN", "-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:WARN", "-Xep:UnusedNestedClass:ERROR", "-Xep:UnusedVariable:ERROR", "-Xep:URLEqualsHashCode:ERROR", "-Xep:UseBinds:ERROR", "-Xep:UseCorrectAssertInTests:ERROR", "-Xep:VariableNameSameAsType:ERROR", "-Xep:VarTypeName:ERROR", "-Xep:WaitNotInLoop:ERROR", "-Xep:WakelockReleasedDangerously:ERROR", "-Xep:WildcardImport:ERROR", "-Xep:WithSignatureDiscouraged:ERROR", "-Xep:WrongOneof:ERROR", "-Xep:XorPower:ERROR", "-Xep:ZoneIdOfZ:ERROR", ] exclude_in_tests = ["-Xep:EmptyBlockTag:WARN", "-Xep:MissingSummary:WARN"] java_package_configuration( name = "error_prone", javacopts = errorprone_checks, packages = ["error_prone_packages"], ) java_package_configuration( name = "error_prone_tests", javacopts = [ check for check in errorprone_checks if check not in exclude_in_tests], packages = ["error_prone_packages_test"], ) package_group( name = "error_prone_packages", packages = [ "//org.eclipse.jgit.ant/...", "//org.eclipse.jgit.archive/...", "//org.eclipse.jgit.gpg.bc/...", "//org.eclipse.jgit.http.apache/...", "//org.eclipse.jgit.http.server/...", "//org.eclipse.jgit.junit.ssh/...", "//org.eclipse.jgit.junit/...", "//org.eclipse.jgit.junit/http/...", "//org.eclipse.jgit.lfs.server/...", "//org.eclipse.jgit.lfs/...", "//org.eclipse.jgit.pgm/...", "//org.eclipse.jgit.ssh.apache.agent/...", "//org.eclipse.jgit.ssh.apache/...", "//org.eclipse.jgit.ssh.jsch/...", "//org.eclipse.jgit.ui/...", "//org.eclipse.jgit/...", ], ) package_group( name = "error_prone_packages_test", packages = [ "//org.eclipse.jgit.ant.test/...", "//org.eclipse.jgit.gpg.bc.test/...", "//org.eclipse.jgit.http.test/...", "//org.eclipse.jgit.lfs.server.test/...", "//org.eclipse.jgit.lfs.test/...", "//org.eclipse.jgit.pgm.test/...", "//org.eclipse.jgit.ssh.apache.test/...", "//org.eclipse.jgit.ssh.jsch.test/...", "//org.eclipse.jgit.test/...", ], )