blob: ae85460bae093c5ff1a75e9b87b33b52626659ae [file]
# This file contains the ErrorProne configuration shared by the Bazel build.
# It mirrors the ErrorProne configuration of the Gradle build (see
# buildSrc/src/main/groovy/rhino.library-conventions.gradle) so that both
# builds report the same warnings.
#
# Note that Bazel's built-in ErrorProne (bundled with the rules_java JDK
# toolchain) only runs the checks whose default severity is ERROR, while
# the Gradle build runs all checks whose default severity is ERROR or
# WARNING. DEFAULT_WARNING_CHECKS below therefore enables the
# WARNING-severity checks explicitly. It is the list of checks that are
# enabled by default in error_prone_core 2.45.0 (the version used by the
# Gradle build) with a default severity of WARNING, minus DISABLED_CHECKS.
DEFAULT_OPTS = [
"-XepAllErrorsAsWarnings",
]
# Checks that the Gradle build disables ("checks we aren't ready to fix yet")
DISABLED_CHECKS = [
"AnnotateFormatMethod",
"AssignmentExpression",
"BooleanLiteral",
"ClassInitializationDeadlock",
"DoNotCallSuggester",
"DuplicateBranches",
"EmptyBlockTag",
"EmptyCatch",
"EscapedEntity",
"EffectivelyPrivate",
"ImmutableEnumChecker",
"InlineMeSuggester",
"InvalidBlockTag",
"JavaUtilDate",
"LabelledBreakTarget",
"MissingSummary",
"PatternMatchingInstanceof",
"StatementSwitchToExpressionSwitch",
"UnicodeEscape",
"UnusedVariable",
]
# Checks that the Gradle build runs by default with severity WARNING
DEFAULT_WARNING_CHECKS = [
"ASTHelpersSuggestions",
"AddressSelection",
"AlmostJavadoc",
"AlreadyChecked",
"AmbiguousMethodReference",
"ArgumentSelectionDefectChecker",
"ArrayAsKeyOfSetOrMap",
"ArrayRecordComponent",
"AssertEqualsArgumentOrderChecker",
"AssertSameIncompatible",
"AssertThrowsMultipleStatements",
"AssertionFailureIgnored",
"AssistedInjectAndInjectOnSameConstructor",
"AttemptedNegativeZero",
"AutoValueBoxedValues",
"AutoValueFinalMethods",
"AutoValueImmutableFields",
"AutoValueSubclassLeaked",
"BadComparable",
"BadImport",
"BadInstanceof",
"BareDotMetacharacter",
"BigDecimalEquals",
"BigDecimalLiteralDouble",
"BoxedPrimitiveConstructor",
"BugPatternNaming",
"ByteBufferBackingArray",
"CacheLoaderNull",
"CanonicalDuration",
"CatchAndPrintStackTrace",
"CatchFail",
"ChainedAssertionLosesContext",
"CharacterGetNumericValue",
"ClassCanBeStatic",
"ClassNewInstance",
"CloseableProvides",
"ClosingStandardOutputStreams",
"CollectionUndefinedEquality",
"CollectorShouldNotUseState",
"ComparableAndComparator",
"CompareToZero",
"ComplexBooleanConstant",
"DateChecker",
"DateFormatConstant",
"DeeplyNested",
"DefaultCharset",
"DefaultPackage",
"DeprecatedVariable",
"DirectInvocationOnMock",
"DistinctVarargsChecker",
"DoNotClaimAnnotations",
"DoNotMockAutoValue",
"DoubleCheckedLocking",
"DuplicateDateFormatField",
"EmptySetMultibindingContributions",
"EmptyTopLevelDeclaration",
"EnumOrdinal",
"EqualsGetClass",
"EqualsIncompatibleType",
"EqualsUnsafeCast",
"EqualsUsingHashCode",
"ErroneousBitwiseExpression",
"ErroneousThreadPoolConstructorChecker",
"ExpensiveLenientFormatString",
"ExtendingJUnitAssert",
"ExtendsObject",
"FallThrough",
"Finalize",
"Finally",
"FloatCast",
"FloatingPointAssertionWithinEpsilon",
"FloatingPointLiteralPrecision",
"FloggerArgumentToString",
"FloggerPerWithoutRateLimit",
"FloggerStringConcatenation",
"FormatStringShouldUsePlaceholders",
"FragmentInjection",
"FragmentNotInstantiable",
"FutureReturnValueIgnored",
"FutureTransformAsync",
"GetClassOnEnum",
"GuiceNestedCombine",
"HidingField",
"ICCProfileGetInstance",
"IdentityHashMapUsage",
"IgnoredPureGetter",
"ImmutableAnnotationChecker",
"InconsistentCapitalization",
"InconsistentHashCode",
"IncorrectMainMethod",
"IncrementInForLoopAndHeader",
"InheritDoc",
"InjectInvalidTargetingOnScopingAnnotation",
"InjectOnBugCheckers",
"InjectOnConstructorOfAbstractClass",
"InjectScopeAnnotationOnInterfaceOrAbstractClass",
"InjectedConstructorAnnotations",
"InlineFormatString",
"InlineMeInliner",
"InlineTrivialConstant",
"InputStreamSlowMultibyteRead",
"InstanceOfAndCastMatchWrongType",
"IntFloatConversion",
"IntLiteralCast",
"IntLongMath",
"InvalidInlineTag",
"InvalidLink",
"InvalidParam",
"InvalidSnippet",
"InvalidThrows",
"InvalidThrowsLink",
"IterableAndIterator",
"JUnit3FloatingPointComparisonWithoutDelta",
"JUnit4ClassUsedInJUnit3",
"JUnit4EmptyMethods",
"JUnitAmbiguousTestClass",
"JUnitIncompatibleType",
"JavaDurationGetSecondsGetNano",
"JavaDurationGetSecondsToToSeconds",
"JavaDurationWithNanos",
"JavaDurationWithSeconds",
"JavaInstantGetSecondsGetNano",
"JavaLangClash",
"JavaLocalDateTimeGetNano",
"JavaLocalTimeGetNano",
"JavaPeriodGetDays",
"JavaTimeDefaultTimeZone",
"JavaxInjectOnFinalField",
"JdkObsolete",
"JodaConstructors",
"JodaDateTimeConstants",
"JodaDurationWithMillis",
"JodaInstantWithMillis",
"JodaNewPeriod",
"JodaPlusMinusLong",
"JodaTimeConverterManager",
"JodaWithDurationAddedLong",
"LiteEnumValueOf",
"LiteProtoToString",
"LockNotBeforeTry",
"LockOnNonEnclosingClassLiteral",
"LogicalAssignment",
"LongDoubleConversion",
"LongFloatConversion",
"LoopOverCharArray",
"MalformedInlineTag",
"MathAbsoluteNegative",
"MemoizeConstantVisitorStateLookups",
"MisformattedTestData",
"MissingCasesInEnumSwitch",
"MissingFail",
"MissingImplementsComparable",
"MissingOverride",
"MissingRefasterAnnotation",
"MixedMutabilityReturnType",
"MockIllegalThrows",
"MockNotUsedInProduction",
"ModifiedButNotUsed",
"ModifyCollectionInEnhancedForLoop",
"ModifySourceCollectionInStream",
"MultimapKeys",
"MultipleNullnessAnnotations",
"MultipleParallelOrSequentialCalls",
"MultipleUnaryOperatorsInMethodCall",
"MutablePublicArray",
"NamedLikeContextualKeyword",
"NarrowCalculation",
"NarrowingCompoundAssignment",
"NegativeCharLiteral",
"NestedInstanceOfConditions",
"NewFileSystem",
"NonApiType",
"NonAtomicVolatileUpdate",
"NonCanonicalType",
"NonOverridingEquals",
"NotJavadoc",
"NullOptional",
"NullableConstructor",
"NullableOptional",
"NullablePrimitive",
"NullablePrimitiveArray",
"NullableTypeParameter",
"NullableVoid",
"NullableWildcard",
"ObjectEqualsForPrimitives",
"ObjectToString",
"ObjectsHashCodePrimitive",
"OperatorPrecedence",
"OptionalMapToOptional",
"OptionalNotPresent",
"OrphanedFormatString",
"OutlineNone",
"OverrideThrowableToString",
"Overrides",
"OverridesGuiceInjectableMethod",
"OverridingMethodInconsistentArgumentNamesChecker",
"ParameterName",
"PreconditionsCheckNotNullRepeated",
"PreferInstanceofOverGetKind",
"PrimitiveAtomicReference",
"ProtectedMembersInFinalClass",
"ProtoDurationGetSecondsGetNano",
"ProtoTimestampGetSecondsGetNano",
"QualifierOrScopeOnInjectMethod",
"ReachabilityFenceUsage",
"RedundantControlFlow",
"ReferenceEquality",
"RethrowReflectiveOperationExceptionAsLinkageError",
"ReturnAtTheEndOfVoidFunction",
"ReturnFromVoid",
"RobolectricShadowDirectlyOn",
"RuleNotRun",
"RxReturnValueIgnored",
"SameNameButDifferent",
"SelfAlwaysReturnsThis",
"SelfSet",
"ShortCircuitBoolean",
"StaticAssignmentInConstructor",
"StaticAssignmentOfThrowable",
"StaticGuardedByInstance",
"StaticMockMember",
"StreamResourceLeak",
"StreamToIterable",
"StringCaseLocaleUsage",
"StringCharset",
"StringConcatToTextBlock",
"StringSplitter",
"SuperCallToObjectMethod",
"SwigMemoryLeak",
"SynchronizeOnNonFinalField",
"SystemConsoleNull",
"ThreadJoinLoop",
"ThreadLocalUsage",
"ThreadPriorityCheck",
"ThreeLetterTimeZoneID",
"ThrowIfUncheckedKnownUnchecked",
"TimeInStaticInitializer",
"TimeUnitConversionChecker",
"ToStringReturnsNull",
"TraditionalSwitchExpression",
"TruthAssertExpected",
"TruthConstantAsserts",
"TruthGetOrDefault",
"TruthIncompatibleType",
"TypeEquals",
"TypeNameShadowing",
"TypeParameterShadowing",
"TypeParameterUnusedInFormals",
"URLEqualsHashCode",
"UndefinedEquals",
"UnnecessaryAssignment",
"UnnecessaryAsync",
"UnnecessaryBreakInSwitch",
"UnnecessaryCopy",
"UnnecessaryLambda",
"UnnecessaryLongToIntConversion",
"UnnecessaryMethodInvocationMatcher",
"UnnecessaryMethodReference",
"UnnecessaryParentheses",
"UnnecessaryQualifier",
"UnnecessaryStringBuilder",
"UnrecognisedJavadocTag",
"UnsafeFinalization",
"UnsafeReflectiveConstructionCast",
"UnsynchronizedOverridesSynchronized",
"UnusedLabel",
"UnusedMethod",
"UnusedNestedClass",
"UnusedTypeParameter",
"UseBinds",
"VariableNameSameAsType",
"VoidUsed",
"WaitNotInLoop",
"WakelockReleasedDangerously",
"WithSignatureDiscouraged",
]
LIBRARY_OPTS = DEFAULT_OPTS + [
"-Xlint:deprecation",
"-Xlint:unchecked",
"-Xlint:-removal",
] + [
# Same disabled checks as the Gradle build
"-Xep:%s:OFF" % c
for c in DISABLED_CHECKS
] + [
# Same enabled-by-default checks as the Gradle build
"-Xep:%s:WARN" % c
for c in DEFAULT_WARNING_CHECKS
] + [
# Same additional checks as the Gradle build. Both have default severity
# SUGGESTION, so they are enabled but do not produce output.
"-Xep:RemoveUnusedImports",
"-Xep:WildcardImport",
]
TEST_OPTS = [
# The Gradle build excludes test sources from ErrorProne entirely.
"-XepDisableAllChecks",
"-Xlint:deprecation",
"-Xlint:unchecked",
"-Xlint:-removal",
]
# For targets that the Gradle build compiles without ErrorProne at all.
NO_ERRORPRONE_OPTS = [
"-XepDisableAllChecks",
"-Xlint:deprecation",
"-Xlint:unchecked",
"-Xlint:-removal",
]