1load( 2 "@bazel_tools//tools/jdk:default_java_toolchain.bzl", 3 "JDK9_JVM_OPTS", 4 "default_java_toolchain", 5) 6load("@rules_java//java:defs.bzl", "java_package_configuration") 7 8default_java_toolchain( 9 name = "error_prone_warnings_toolchain", 10 bootclasspath = ["@bazel_tools//tools/jdk:platformclasspath.jar"], 11 jvm_opts = JDK9_JVM_OPTS, 12 package_configuration = [ 13 ":error_prone", 14 ], 15 visibility = ["//visibility:public"], 16) 17 18# Error Prone errors enabled by default; see ../.bazelrc for how this is 19# enabled. This warnings list is originally based on: 20# https://github.com/bazelbuild/BUILD_file_generator/blob/master/tools/bazel_defs/java.bzl 21# However, feel free to add any additional errors. Thus far they have all been pretty useful. 22java_package_configuration( 23 name = "error_prone", 24 javacopts = [ 25 "-XepDisableWarningsInGeneratedCode", 26 "-Xep:MissingCasesInEnumSwitch:ERROR", 27 "-Xep:ReferenceEquality:WARN", 28 "-Xep:StringEquality:WARN", 29 "-Xep:WildcardImport:ERROR", 30 "-Xep:AmbiguousMethodReference:ERROR", 31 "-Xep:BadAnnotationImplementation:ERROR", 32 "-Xep:BadComparable:WARN", 33 "-Xep:BoxedPrimitiveConstructor:ERROR", 34 "-Xep:CannotMockFinalClass:ERROR", 35 "-Xep:ClassCanBeStatic:ERROR", 36 "-Xep:ClassNewInstance:ERROR", 37 "-Xep:DefaultCharset:ERROR", 38 "-Xep:DoubleCheckedLocking:ERROR", 39 "-Xep:ElementsCountedInLoop:ERROR", 40 "-Xep:EqualsHashCode:ERROR", 41 "-Xep:EqualsIncompatibleType:ERROR", 42 "-Xep:Finally:WARN", 43 "-Xep:FloatingPointLiteralPrecision:ERROR", 44 "-Xep:FragmentInjection:ERROR", 45 "-Xep:FragmentNotInstantiable:ERROR", 46 "-Xep:FunctionalInterfaceClash:ERROR", 47 "-Xep:FutureReturnValueIgnored:ERROR", 48 "-Xep:GetClassOnEnum:ERROR", 49 "-Xep:ImmutableAnnotationChecker:ERROR", 50 "-Xep:ImmutableEnumChecker:ERROR", 51 "-Xep:IncompatibleModifiers:ERROR", 52 "-Xep:InjectOnConstructorOfAbstractClass:ERROR", 53 "-Xep:InputStreamSlowMultibyteRead:ERROR", 54 "-Xep:IterableAndIterator:ERROR", 55 "-Xep:JUnit3FloatingPointComparisonWithoutDelta:ERROR", 56 "-Xep:JUnitAmbiguousTestClass:ERROR", 57 "-Xep:LiteralClassName:ERROR", 58 "-Xep:MissingFail:ERROR", 59 "-Xep:MissingOverride:ERROR", 60 "-Xep:MutableConstantField:ERROR", 61 "-Xep:NarrowingCompoundAssignment:ERROR", 62 "-Xep:NonAtomicVolatileUpdate:ERROR", 63 "-Xep:NonOverridingEquals:ERROR", 64 "-Xep:NullableConstructor:ERROR", 65 "-Xep:NullablePrimitive:ERROR", 66 "-Xep:NullableVoid:ERROR", 67 "-Xep:OperatorPrecedence:ERROR", 68 "-Xep:OverridesGuiceInjectableMethod:ERROR", 69 "-Xep:PreconditionsInvalidPlaceholder:ERROR", 70 "-Xep:ProtoFieldPreconditionsCheckNotNull:ERROR", 71 "-Xep:ProtocolBufferOrdinal:ERROR", 72 "-Xep:RequiredModifiers:ERROR", 73 "-Xep:ShortCircuitBoolean:ERROR", 74 "-Xep:SimpleDateFormatConstant:ERROR", 75 "-Xep:StaticGuardedByInstance:ERROR", 76 "-Xep:SynchronizeOnNonFinalField:ERROR", 77 "-Xep:TruthConstantAsserts:ERROR", 78 "-Xep:TypeParameterShadowing:ERROR", 79 "-Xep:TypeParameterUnusedInFormals:WARN", 80 "-Xep:URLEqualsHashCode:ERROR", 81 "-Xep:UnusedException:ERROR", 82 "-Xep:UnsynchronizedOverridesSynchronized:ERROR", 83 "-Xep:WaitNotInLoop:ERROR", 84 ], 85 packages = ["error_prone_packages"], 86) 87 88package_group( 89 name = "error_prone_packages", 90 packages = [ 91 "//org.eclipse.jgit.ant.test/...", 92 "//org.eclipse.jgit.ant/...", 93 "//org.eclipse.jgit.archive/...", 94 "//org.eclipse.jgit.http.apache/...", 95 "//org.eclipse.jgit.http.server/...", 96 "//org.eclipse.jgit.http.test/...", 97 "//org.eclipse.jgit.junit.http/...", 98 "//org.eclipse.jgit.junit/...", 99 "//org.eclipse.jgit.lfs.server.test/...", 100 "//org.eclipse.jgit.lfs.server/...", 101 "//org.eclipse.jgit.lfs.test/...", 102 "//org.eclipse.jgit.lfs/...", 103 "//org.eclipse.jgit.packaging/...", 104 "//org.eclipse.jgit.pgm.test/...", 105 "//org.eclipse.jgit.pgm/...", 106 "//org.eclipse.jgit.test/...", 107 "//org.eclipse.jgit.ui/...", 108 "//org.eclipse.jgit/...", 109 ], 110) 111