blob: 6d15a21945b2043da414e98d21d281b730676598 [file] [log] [blame]
David Pursehouseb98f9c82018-09-23 12:58:27 +09001load(
2 "@bazel_tools//tools/jdk:default_java_toolchain.bzl",
3 "JDK9_JVM_OPTS",
4 "default_java_toolchain",
5)
6
7default_java_toolchain(
8 name = "error_prone_warnings_toolchain",
David Pursehouse65630312018-11-07 15:39:49 +09009 bootclasspath = ["@bazel_tools//tools/jdk:platformclasspath.jar"],
David Pursehouseb98f9c82018-09-23 12:58:27 +090010 jvm_opts = JDK9_JVM_OPTS,
11 package_configuration = [
12 ":error_prone",
13 ],
14 visibility = ["//visibility:public"],
15)
16
David Pursehouse956bd7d2019-05-25 17:07:28 +090017# Error Prone errors enabled by default; see ../.bazelrc for how this is
18# enabled. This warnings list is originally based on:
David Pursehouseb98f9c82018-09-23 12:58:27 +090019# https://github.com/bazelbuild/BUILD_file_generator/blob/master/tools/bazel_defs/java.bzl
David Pursehouse956bd7d2019-05-25 17:07:28 +090020# However, feel free to add any additional errors. Thus far they have all been pretty useful.
David Pursehouseb98f9c82018-09-23 12:58:27 +090021java_package_configuration(
22 name = "error_prone",
23 javacopts = [
24 "-XepDisableWarningsInGeneratedCode",
David Pursehousec0dafc92019-05-25 17:19:44 +090025 "-Xep:AmbiguousMethodReference:ERROR",
26 "-Xep:BadAnnotationImplementation:ERROR",
27 "-Xep:BadComparable:ERROR",
David Pursehouseb98f9c82018-09-23 12:58:27 +090028 "-Xep:BoxedPrimitiveConstructor:ERROR",
David Pursehousec0dafc92019-05-25 17:19:44 +090029 "-Xep:CannotMockFinalClass:ERROR",
30 "-Xep:ClassCanBeStatic:ERROR",
31 "-Xep:ClassNewInstance:ERROR",
David Pursehouse00e3a292018-11-08 11:25:00 +090032 "-Xep:DefaultCharset:ERROR",
David Pursehousec0dafc92019-05-25 17:19:44 +090033 "-Xep:DoubleCheckedLocking:ERROR",
34 "-Xep:ElementsCountedInLoop:ERROR",
35 "-Xep:DoubleCheckedLocking:ERROR",
36 "-Xep:ElementsCountedInLoop:ERROR",
37 "-Xep:EqualsHashCode:ERROR",
38 "-Xep:EqualsIncompatibleType:ERROR",
39 "-Xep:ExpectedExceptionChecker:ERROR",
40 "-Xep:Finally:ERROR",
41 "-Xep:FloatingPointLiteralPrecision:ERROR",
42 "-Xep:FragmentInjection:ERROR",
43 "-Xep:FragmentNotInstantiable:ERROR",
44 "-Xep:FunctionalInterfaceClash:ERROR",
45 "-Xep:FutureReturnValueIgnored:ERROR",
46 "-Xep:GetClassOnEnum:ERROR",
David Pursehouseb98f9c82018-09-23 12:58:27 +090047 "-Xep:ImmutableAnnotationChecker:WARN",
48 "-Xep:ImmutableEnumChecker:WARN",
David Pursehousec0dafc92019-05-25 17:19:44 +090049 "-Xep:IncompatibleModifiers:ERROR",
50 "-Xep:InjectOnConstructorOfAbstractClass:ERROR",
51 "-Xep:InputStreamSlowMultibyteRead:ERROR",
52 "-Xep:IterableAndIterator:ERROR",
53 "-Xep:JUnit3FloatingPointComparisonWithoutDelta:ERROR",
54 "-Xep:JUnitAmbiguousTestClass:ERROR",
55 "-Xep:LiteralClassName:ERROR",
56 "-Xep:MissingCasesInEnumSwitch:ERROR",
57 "-Xep:MissingFail:ERROR",
58 "-Xep:MissingOverride:ERROR",
59 "-Xep:MutableConstantField:ERROR",
60 "-Xep:NarrowingCompoundAssignment:ERROR",
61 "-Xep:NonAtomicVolatileUpdate:ERROR",
62 "-Xep:NonOverridingEquals:ERROR",
63 "-Xep:NullableConstructor:ERROR",
64 "-Xep:NullablePrimitive:ERROR",
65 "-Xep:NullableVoid:ERROR",
66 "-Xep:OperatorPrecedence:ERROR",
67 "-Xep:OverridesGuiceInjectableMethod:ERROR",
68 "-Xep:PreconditionsInvalidPlaceholder:ERROR",
69 "-Xep:ProtoFieldPreconditionsCheckNotNull:ERROR",
70 "-Xep:ProtocolBufferOrdinal:ERROR",
71 "-Xep:ReferenceEquality:WARN",
72 "-Xep:RequiredModifiers:ERROR",
73 "-Xep:ShortCircuitBoolean:ERROR",
74 "-Xep:SimpleDateFormatConstant:ERROR",
75 "-Xep:StaticGuardedByInstance:ERROR",
76 "-Xep:StringEquality:ERROR",
77 "-Xep:SynchronizeOnNonFinalField:ERROR",
78 "-Xep:TruthConstantAsserts:ERROR",
79 "-Xep:TypeParameterShadowing:ERROR",
80 "-Xep:TypeParameterUnusedInFormals:ERROR",
81 "-Xep:URLEqualsHashCode:ERROR",
82 "-Xep:UnsynchronizedOverridesSynchronized:ERROR",
83 "-Xep:WaitNotInLoop:ERROR",
84 "-Xep:WildcardImport:ERROR",
David Pursehouseb98f9c82018-09-23 12:58:27 +090085 ],
86 packages = ["error_prone_packages"],
87)
88
89package_group(
90 name = "error_prone_packages",
91 packages = [
92 "//java/...",
93 "//javatests/...",
94 ],
95)