blob: 2b208744b58dbdec5e209ac720e6f4c2bf491ca2 [file] [log] [blame]
David Ostrovsky7d89f0a2018-08-26 16:14:32 +02001load(
2 "@bazel_tools//tools/jdk:default_java_toolchain.bzl",
3 "JDK9_JVM_OPTS",
4 "default_java_toolchain",
5)
Matthias Sohn22973d12019-09-08 14:59:29 +02006load("@rules_java//java:defs.bzl", "java_package_configuration")
David Ostrovsky7d89f0a2018-08-26 16:14:32 +02007
8default_java_toolchain(
9 name = "error_prone_warnings_toolchain",
David Ostrovsky9625db22018-11-01 08:37:29 +010010 bootclasspath = ["@bazel_tools//tools/jdk:platformclasspath.jar"],
David Ostrovsky7d89f0a2018-08-26 16:14:32 +020011 jvm_opts = JDK9_JVM_OPTS,
12 package_configuration = [
13 ":error_prone",
14 ],
15 visibility = ["//visibility:public"],
16)
17
David Pursehouse4c33f702019-05-26 17:47:08 +090018# Error Prone errors enabled by default; see ../.bazelrc for how this is
19# enabled. This warnings list is originally based on:
David Ostrovsky7d89f0a2018-08-26 16:14:32 +020020# https://github.com/bazelbuild/BUILD_file_generator/blob/master/tools/bazel_defs/java.bzl
David Pursehouse4c33f702019-05-26 17:47:08 +090021# However, feel free to add any additional errors. Thus far they have all been pretty useful.
David Ostrovsky7d89f0a2018-08-26 16:14:32 +020022java_package_configuration(
23 name = "error_prone",
24 javacopts = [
25 "-XepDisableWarningsInGeneratedCode",
26 "-Xep:MissingCasesInEnumSwitch:ERROR",
27 "-Xep:ReferenceEquality:WARN",
28 "-Xep:StringEquality:WARN",
David Pursehouse245c2c02019-05-26 18:03:07 +090029 "-Xep:WildcardImport:ERROR",
David Pursehouse40f6c922019-08-09 16:06:56 +090030 "-Xep:AmbiguousMethodReference:ERROR",
David Pursehouse245c2c02019-05-26 18:03:07 +090031 "-Xep:BadAnnotationImplementation:ERROR",
David Ostrovsky7d89f0a2018-08-26 16:14:32 +020032 "-Xep:BadComparable:WARN",
33 "-Xep:BoxedPrimitiveConstructor:ERROR",
David Pursehouse245c2c02019-05-26 18:03:07 +090034 "-Xep:CannotMockFinalClass:ERROR",
David Pursehouse1385f4b2018-11-08 11:09:54 +090035 "-Xep:ClassCanBeStatic:ERROR",
David Pursehousedad9e1f2019-06-22 18:40:49 +090036 "-Xep:ClassNewInstance:ERROR",
David Pursehoused54fc952018-09-30 17:02:11 +090037 "-Xep:DefaultCharset:ERROR",
David Pursehouse245c2c02019-05-26 18:03:07 +090038 "-Xep:DoubleCheckedLocking:ERROR",
39 "-Xep:ElementsCountedInLoop:ERROR",
40 "-Xep:EqualsHashCode:ERROR",
41 "-Xep:EqualsIncompatibleType:ERROR",
David Ostrovsky7d89f0a2018-08-26 16:14:32 +020042 "-Xep:Finally:WARN",
David Pursehouse245c2c02019-05-26 18:03:07 +090043 "-Xep:FloatingPointLiteralPrecision:ERROR",
44 "-Xep:FragmentInjection:ERROR",
45 "-Xep:FragmentNotInstantiable:ERROR",
46 "-Xep:FunctionalInterfaceClash:ERROR",
David Pursehouse8bd0ba02019-06-08 15:47:42 +090047 "-Xep:FutureReturnValueIgnored:ERROR",
David Pursehouse245c2c02019-05-26 18:03:07 +090048 "-Xep:GetClassOnEnum:ERROR",
49 "-Xep:ImmutableAnnotationChecker:ERROR",
David Pursehouse13696b82019-06-16 13:57:45 +090050 "-Xep:ImmutableEnumChecker:ERROR",
David Pursehouse245c2c02019-05-26 18:03:07 +090051 "-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",
David Pursehousef5d7f932018-09-29 13:23:22 +090058 "-Xep:MissingFail:ERROR",
David Pursehouse245c2c02019-05-26 18:03:07 +090059 "-Xep:MissingOverride:ERROR",
60 "-Xep:MutableConstantField:ERROR",
David Pursehouse72ae0892019-06-22 18:47:43 +090061 "-Xep:NarrowingCompoundAssignment:ERROR",
David Pursehouse245c2c02019-05-26 18:03:07 +090062 "-Xep:NonAtomicVolatileUpdate:ERROR",
David Pursehouse430be892019-06-16 16:28:02 +090063 "-Xep:NonOverridingEquals:ERROR",
David Pursehouse245c2c02019-05-26 18:03:07 +090064 "-Xep:NullableConstructor:ERROR",
65 "-Xep:NullablePrimitive:ERROR",
66 "-Xep:NullableVoid:ERROR",
David Pursehouse0f4554f2019-06-12 09:06:46 +090067 "-Xep:OperatorPrecedence:ERROR",
David Pursehouse245c2c02019-05-26 18:03:07 +090068 "-Xep:OverridesGuiceInjectableMethod:ERROR",
69 "-Xep:PreconditionsInvalidPlaceholder:ERROR",
70 "-Xep:ProtoFieldPreconditionsCheckNotNull:ERROR",
71 "-Xep:ProtocolBufferOrdinal:ERROR",
72 "-Xep:RequiredModifiers:ERROR",
David Pursehouse4fe4b0a2019-06-12 14:23:42 +090073 "-Xep:ShortCircuitBoolean:ERROR",
David Pursehouse245c2c02019-05-26 18:03:07 +090074 "-Xep:SimpleDateFormatConstant:ERROR",
75 "-Xep:StaticGuardedByInstance:ERROR",
76 "-Xep:SynchronizeOnNonFinalField:ERROR",
77 "-Xep:TruthConstantAsserts:ERROR",
78 "-Xep:TypeParameterShadowing:ERROR",
David Ostrovsky7d89f0a2018-08-26 16:14:32 +020079 "-Xep:TypeParameterUnusedInFormals:WARN",
David Pursehouse245c2c02019-05-26 18:03:07 +090080 "-Xep:URLEqualsHashCode:ERROR",
David Pursehouse4cc13292020-01-27 09:47:05 +090081 "-Xep:UnusedException:ERROR",
David Pursehouse245c2c02019-05-26 18:03:07 +090082 "-Xep:UnsynchronizedOverridesSynchronized:ERROR",
83 "-Xep:WaitNotInLoop:ERROR",
David Ostrovsky7d89f0a2018-08-26 16:14:32 +020084 ],
85 packages = ["error_prone_packages"],
86)
87
88package_group(
89 name = "error_prone_packages",
90 packages = [
David Ostrovsky7d89f0a2018-08-26 16:14:32 +020091 "//org.eclipse.jgit.ant.test/...",
David Pursehouse3ec3ca02018-11-06 13:50:04 +090092 "//org.eclipse.jgit.ant/...",
David Ostrovsky7d89f0a2018-08-26 16:14:32 +020093 "//org.eclipse.jgit.archive/...",
94 "//org.eclipse.jgit.http.apache/...",
95 "//org.eclipse.jgit.http.server/...",
96 "//org.eclipse.jgit.http.test/...",
David Ostrovsky7d89f0a2018-08-26 16:14:32 +020097 "//org.eclipse.jgit.junit.http/...",
David Pursehouse3ec3ca02018-11-06 13:50:04 +090098 "//org.eclipse.jgit.junit/...",
David Ostrovsky7d89f0a2018-08-26 16:14:32 +020099 "//org.eclipse.jgit.lfs.server.test/...",
David Pursehouse3ec3ca02018-11-06 13:50:04 +0900100 "//org.eclipse.jgit.lfs.server/...",
David Ostrovsky7d89f0a2018-08-26 16:14:32 +0200101 "//org.eclipse.jgit.lfs.test/...",
David Pursehouse3ec3ca02018-11-06 13:50:04 +0900102 "//org.eclipse.jgit.lfs/...",
David Ostrovsky7d89f0a2018-08-26 16:14:32 +0200103 "//org.eclipse.jgit.packaging/...",
David Ostrovsky7d89f0a2018-08-26 16:14:32 +0200104 "//org.eclipse.jgit.pgm.test/...",
David Pursehouse3ec3ca02018-11-06 13:50:04 +0900105 "//org.eclipse.jgit.pgm/...",
David Ostrovsky7d89f0a2018-08-26 16:14:32 +0200106 "//org.eclipse.jgit.test/...",
107 "//org.eclipse.jgit.ui/...",
David Pursehouse3ec3ca02018-11-06 13:50:04 +0900108 "//org.eclipse.jgit/...",
David Ostrovsky7d89f0a2018-08-26 16:14:32 +0200109 ],
110)