Skip to content

Apache Lucene open-source search software

Modernize and move error prone gradle plugin to Java (#15305)

Dawid Weissb4b80471ee0b
diff --git a/build-tools/build-infra-shadow/build.gradle b/build-tools/build-infra-shadow/build.gradle
index 5b0e3b1a594..7c02312be3d 100644
--- a/build-tools/build-infra-shadow/build.gradle
+++ b/build-tools/build-infra-shadow/build.gradle
@@ -1,3 +1,6 @@
+import org.apache.lucene.gradle.plugins.LuceneGradlePlugin
+import org.apache.lucene.gradle.plugins.globals.LuceneBuildGlobalsExtension
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -25,44 +28,12 @@ repositories {
}
apply from: rootProject.file("build-tools/build-infra/ecj-source.gradle")
-
-// Convert a plugin dependency to a regular dependency so that we can
-// use [plugins] section in the top-level toml but declare regular
-// project dependencies here.
-static Provider<String> plugin(Provider<PluginDependency> plugin) {
- return plugin.map {
- if (it.pluginId == "de.thetaphi.forbiddenapis") {
- // Uwe's forbiddenapis is on Maven Central, directly.
- return "de.thetaphi:forbiddenapis:${it.version}".toString()
- } else {
- // maven artifact pattern for gradle's plugin repositories.
- return "${it.pluginId}:${it.pluginId}.gradle.plugin:${it.version}".toString()
- }
- }
-}
+apply from: rootProject.file("build-tools/build-infra/declare-dependencies.gradle")
dependencies {
- implementation gradleApi()
- implementation localGroovy()
-
// seems to be required by gradle apis, otherwise compilation fails even though
// we don't use it.
compileOnly ("com.google.code.findbugs:findbugs-annotations:3.0.1")
-
- implementation deps.commons.codec
- implementation deps.randomizedtesting.runner
- implementation deps.zstd
-
- implementation deps.gjf
- implementation deps.jgit
- implementation deps.ecj
-
- implementation plugin(deps.plugins.carrotsearch.buildopts)
- implementation plugin(deps.plugins.carrotsearch.dependencychecks)
- implementation plugin(deps.plugins.forbiddenapis)
- implementation plugin(deps.plugins.spotless)
- implementation plugin(deps.plugins.undercouch.download)
- implementation plugin(deps.plugins.jacocolog)
}
tasks.matching {
@@ -72,11 +43,25 @@ tasks.matching {
"validateJarChecksums",
"validateJarLicenses",
"collectJarInfos",
- // we do need to compile the sources so that forbidden apis are applied (?)
- // "compileJava",
+ // "compileJava", we do need to compile the sources so that forbidden apis are applied.
"compileTestJava",
"assemble"
]
}.configureEach {
enabled = false
}
+
+
+// This redirects build-infra-shadow's main sources at build-infra sources so that we can
+// reapply the build plugin to ourselves (chicken and egg problem - you can't apply a plugin
+// to itself).
+def buildGlobals = getExtensions().getByType(LuceneBuildGlobalsExtension.class)
+if (!buildGlobals.getIntellijIdea().get().isIdea()) {
+ sourceSets.named("main").configure {
+ java.setSrcDirs([
+ LuceneGradlePlugin.getProjectRootPath(project)
+ .resolve("build-tools/build-infra/src/main/java")
+ .toFile()
+ ])
+ }
+}
diff --git a/build-tools/build-infra/build.gradle b/build-tools/build-infra/build.gradle
index f9b95276852..9dbb9a33b90 100644
--- a/build-tools/build-infra/build.gradle
+++ b/build-tools/build-infra/build.gradle
@@ -57,46 +57,7 @@ gradlePlugin {
}
}
-// Convert a plugin dependency to a regular dependency so that we can
-// use [plugins] section in the top-level toml but declare regular
-// project dependencies here.
-static Provider<String> plugin(Provider<PluginDependency> plugin) {
- return plugin.map {
- if (it.pluginId == "de.thetaphi.forbiddenapis") {
- // Uwe's forbiddenapis is on Maven Central, directly.
- return "de.thetaphi:forbiddenapis:${it.version}".toString()
- } else {
- // maven artifact pattern for gradle's plugin repositories.
- return "${it.pluginId}:${it.pluginId}.gradle.plugin:${it.version}".toString()
- }
- }
-}
-
-dependencies {
- implementation gradleApi()
- implementation localGroovy()
- implementation deps.commons.codec
- implementation deps.randomizedtesting.runner
- implementation deps.zstd
-
- implementation deps.flexmark.core
- implementation deps.flexmark.ext.abbreviation
- implementation deps.flexmark.ext.attributes
- implementation deps.flexmark.ext.autolink
- implementation deps.flexmark.ext.tables
- implementation deps.gjf
- implementation deps.jgit
- implementation deps.ecj
-
- implementation plugin(deps.plugins.carrotsearch.buildopts)
- implementation plugin(deps.plugins.carrotsearch.dependencychecks)
- implementation plugin(deps.plugins.forbiddenapis)
- implementation plugin(deps.plugins.spotless)
- implementation plugin(deps.plugins.undercouch.download)
- implementation plugin(deps.plugins.errorprone)
- implementation plugin(deps.plugins.jacocolog)
- implementation plugin(deps.plugins.versionCatalogUpdate)
-}
+apply from: file("declare-dependencies.gradle")
def hasJavaFlightRecorder = ModuleLayer.boot().findModule('jdk.jfr').map {otherModule ->
this.getClass().module.canRead(otherModule)
diff --git a/build-tools/build-infra/declare-dependencies.gradle b/build-tools/build-infra/declare-dependencies.gradle
new file mode 100644
index 00000000000..9fdd13abbda
--- /dev/null
+++ b/build-tools/build-infra/declare-dependencies.gradle
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// These are dependencies on gradle plugins. This file is extracted
+// from the main build.gradle because it's reused in build-infra-shadow.
+
+
+// Convert a plugin dependency to a regular dependency so that we can
+// use [plugins] section in the top-level libs.versions.toml but
+// redeclare them as regular project dependencies.
+static Provider<String> plugin(Provider<PluginDependency> plugin) {
+ return plugin.map {
+ if (it.pluginId == "de.thetaphi.forbiddenapis") {
+ // Uwe's forbiddenapis is on Maven Central, so don't remap coordinates.
+ return "de.thetaphi:forbiddenapis:${it.version}".toString()
+ } else {
+ // maven artifact pattern for gradle's plugin repositories.
+ return "${it.pluginId}:${it.pluginId}.gradle.plugin:${it.version}".toString()
+ }
+ }
+}
+
+dependencies {
+ implementation gradleApi()
+ implementation localGroovy()
+
+ implementation deps.commons.codec
+ implementation deps.randomizedtesting.runner
+ implementation deps.zstd
+
+ implementation deps.flexmark.core
+ implementation deps.flexmark.ext.abbreviation
+ implementation deps.flexmark.ext.attributes
+ implementation deps.flexmark.ext.autolink
+ implementation deps.flexmark.ext.tables
+ implementation deps.gjf
+ implementation deps.jgit
+ implementation deps.ecj
+ implementation deps.errorprone
+
+ implementation plugin(deps.plugins.carrotsearch.buildopts)
+ implementation plugin(deps.plugins.carrotsearch.dependencychecks)
+ implementation plugin(deps.plugins.forbiddenapis)
+ implementation plugin(deps.plugins.spotless)
+ implementation plugin(deps.plugins.undercouch.download)
+ implementation plugin(deps.plugins.errorprone)
+ implementation plugin(deps.plugins.jacocolog)
+ implementation plugin(deps.plugins.versionCatalogUpdate)
+}
diff --git a/build-tools/build-infra/src/main/groovy/lucene.documentation.gradle b/build-tools/build-infra/src/main/groovy/lucene.documentation.gradle
index 4e4ec7169c2..4839339b31f 100644
--- a/build-tools/build-infra/src/main/groovy/lucene.documentation.gradle
+++ b/build-tools/build-infra/src/main/groovy/lucene.documentation.gradle
@@ -36,10 +36,6 @@ configure(rootProject) {
}
})
- ext {
- luceneDocUrl = luceneJavadocUrl.getOrElse(null)
- }
-
def documentationTask = tasks.register("documentation", {
group = 'documentation'
description = 'Generate all documentation'
diff --git a/build-tools/build-infra/src/main/groovy/lucene.documentation.render-javadoc.gradle b/build-tools/build-infra/src/main/groovy/lucene.documentation.render-javadoc.gradle
index e53c4e8f594..1d4d5c517f0 100644
--- a/build-tools/build-infra/src/main/groovy/lucene.documentation.render-javadoc.gradle
+++ b/build-tools/build-infra/src/main/groovy/lucene.documentation.render-javadoc.gradle
@@ -116,7 +116,7 @@ allprojects {
("https://junit.org/junit4/javadoc/${junitVersion}/".toString()): junitJavadocPackages
]
- luceneDocUrl = provider({ rootProject.luceneDocUrl })
+ luceneDocUrl = project.rootProject.buildOptions.getOption('lucene.javadoc.url').asStringProvider()
// Set up custom doclet.
dependsOn configurations.missingdoclet
diff --git a/build-tools/build-infra/src/main/groovy/lucene.validation.error-prone.gradle b/build-tools/build-infra/src/main/groovy/lucene.validation.error-prone.gradle
deleted file mode 100644
index 1f80af5b0f4..00000000000
--- a/build-tools/build-infra/src/main/groovy/lucene.validation.error-prone.gradle
+++ /dev/null
@@ -1,635 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import org.apache.lucene.gradle.plugins.java.AlternativeJdkSupportPlugin
-import org.apache.lucene.gradle.plugins.globals.LuceneBuildGlobalsExtension
-
-// Applies error-prone for additional linting.
-
-if (project != project.rootProject) {
- throw new GradleException("Applicable to rootProject only: " + project.path)
-}
-
-LuceneBuildGlobalsExtension buildGlobals = rootProject.extensions.getByType(LuceneBuildGlobalsExtension)
-
-Provider<Boolean> errorproneOption = buildOptions.addBooleanOption("validation.errorprone",
- "Applies error-prone for additional source code linting.", buildGlobals.isCIBuild)
-
-// make sure we can apply error-prone or provide a reason why we can't.
-String skipReason = null
-if (rootProject.getExtensions().getByType(AlternativeJdkSupportPlugin.AltJvmExtension).altJvmUsed.get()) {
- skipReason = "won't work with alternative java toolchain"
-} else if (errorproneOption.get() == false) {
- if (buildGlobals.isCIBuild) {
- throw new GradleException("Odd, errorprone linting should always be enabled on CI builds.")
- } else {
- skipReason = "skipped on builds not running inside CI environments, pass -Pvalidation.errorprone=true to enable"
- }
-}
-
-if (skipReason != null) {
- tasks.register("errorProneSkipped", {
- doFirst {
- logger.warn("Errorprone linting turned off (${skipReason})")
- }
- })
-}
-
-allprojects { prj ->
- if (skipReason == null) {
- plugins.withType(JavaPlugin) {
- project.plugins.apply(deps.plugins.errorprone.get().pluginId)
- }
- }
-
- prj.plugins.withType(JavaPlugin).configureEach {
- // LUCENE-9650: Errorprone does not work when running as a plugin inside a forked Javac process.
- // Javac running inside Gradle works, because we have additional module system opens in place.
- if (skipReason != null) {
- tasks.withType(JavaCompile).configureEach { task -> task.dependsOn ":errorProneSkipped" }
-
- // Error prone plugin adds error prone to test classpath. We need to add it here too (manually) so that
- // versions.lock is consistent with or without error prone.
- configurations {
- errorprone
- }
- dependencies {
- errorprone deps.errorprone
- }
- configurations.annotationProcessor.extendsFrom(configurations.errorprone)
- } else {
- dependencies {
- errorprone deps.errorprone
- }
-
- tasks.withType(JavaCompile).configureEach { task ->
- // Exclude certain files (generated ones, mostly).
- switch (project.path) {
- case ":lucene:core":
- options.errorprone.excludedPaths.set(".*/StandardTokenizerImpl.java")
- break
-
- case ":lucene:analysis:common":
- options.errorprone.excludedPaths.set("" +
- ".*/HTMLStripCharFilter.java|" +
- ".*/UAX29URLEmailTokenizerImpl.java")
- break
-
- case ":lucene:test-framework":
- options.errorprone.excludedPaths.set("" +
- ".*/EmojiTokenizationTestUnicode_11_0.java|" +
- ".*/WordBreakTestUnicode_9_0_0.java")
- break
-
- case ":lucene:expressions":
- break
-
- case ":lucene:queryparser":
- options.errorprone.excludedPaths.set("" +
- ".*/classic/ParseException.java|" +
- ".*/classic/QueryParser.java|" +
- ".*/classic/QueryParserConstants.java|" +
- ".*/classic/QueryParserTokenManager.java|" +
- ".*/classic/Token.java|" +
- ".*/classic/TokenMgrError.java|" +
- ".*/standard/parser/ParseException.java|" +
- ".*/standard/parser/StandardSyntaxParser.java|" +
- ".*/standard/parser/StandardSyntaxParserConstants.java|" +
- ".*/standard/parser/StandardSyntaxParserTokenManager.java|" +
- ".*/standard/parser/Token.java|" +
- ".*/standard/parser/TokenMgrError.java|" +
- ".*/surround/parser/ParseException.java|" +
- ".*/surround/parser/QueryParser.java|" +
- ".*/surround/parser/QueryParserConstants.java|" +
- ".*/surround/parser/QueryParserTokenManager.java|" +
- ".*/surround/parser/Token.java|" +
- ".*/surround/parser/TokenMgrError.java")
- break
- }
-
- task.dependsOn ":checkJdkInternalsExportedToGradle"
-
- options.errorprone.disableWarningsInGeneratedCode = true
- options.errorprone.errorproneArgs = [
- '-XepDisableAllChecks',
- // only enable specific checks
- '-XepAllErrorsAsWarnings',
- // warnings still fail build by default, but allows usage of -Pjavac.failOnWarnings=false
-
- // List of enabled/disabled checks
- // Please keep this synced with https://errorprone.info/bugpatterns when upgrading!
- // Do *NOT* enable checks based on their name or description. Read the source code and make sure they are useful!
- // Most error-prone checks are not useful for non-google software.
-
- // On by Default : ERROR
-
- // '-Xep:AddNullMarkedToPackageInfo:OFF', // we don't use jspecify
- // '-Xep:AlwaysThrows:OFF', // we don't use google collections
- // '-Xep:AndroidInjectionBeforeSuper:OFF', // we don't use android
- '-Xep:ArrayEquals:ERROR',
- '-Xep:ArrayFillIncompatibleType:ERROR',
- '-Xep:ArrayHashCode:ERROR',
- '-Xep:ArrayToString:ERROR',
- // '-Xep:ArraysAsListPrimitiveArray:OFF', // we don't use guava
- // '-Xep:AssignmentExpression:OFF', // TODO: there are problems
- // '-Xep:AsyncCallableReturnsNull:OFF', // we don't use guava
- // '-Xep:AsyncFunctionReturnsNull:OFF', // we don't use guava
- // '-Xep:AutoValueBuilderDefaultsInConstructor:OFF', // we don't use autovalue
- // '-Xep:AutoValueConstructorOrderChecker:OFF', // we don't use autovalue
- '-Xep:BadAnnotationImplementation:ERROR',
- '-Xep:BadShiftAmount:ERROR',
- // '-Xep:BanClassLoader:OFF', // implemented with forbidden APIs instead
- // '-Xep:BanJNDI:OFF', // implemented with forbidden APIs instead
- // '-Xep:BoxedPrimitiveEquality:OFF', // TODO: there are problems
- '-Xep:BooleanLiteral:ERROR',
- // '-Xep:BundleDeserializationCast:OFF', // we don't use android
- '-Xep:ChainingConstructorIgnoresParameter:ERROR',
- // '-Xep:CheckNotNullMultipleTimes:OFF', // we don't use guava
- // '-Xep:CheckReturnValue:OFF', // we don't use these annotations
- '-Xep:CollectionToArraySafeParameter:ERROR',
- // '-Xep:ComparableType:OFF',
- // '-Xep:ComparingThisWithNull:OFF', // we use ast-grep for this check
- '-Xep:ComparisonOutOfRange:ERROR',
- // '-Xep:CompatibleWithAnnotationMisuse:OFF', // we don't use this annotation
- // '-Xep:CompileTimeConstant:OFF', // we don't use this annotation
- '-Xep:ComputeIfAbsentAmbiguousReference:ERROR',
- '-Xep:ConditionalExpressionNumericPromotion:ERROR',
- '-Xep:ConstantOverflow:ERROR',
- // '-Xep:DaggerProvidesNull:OFF', // we don't use dagger
- '-Xep:DangerousLiteralNull:ERROR',
- '-Xep:DeadException:ERROR',
- '-Xep:DeadThread:ERROR',
- '-Xep:DereferenceWithNullBranch:ERROR',
- '-Xep:DiscardedPostfixExpression:ERROR',
- // '-Xep:DoNotCall:OFF', // we don't use this annotation
- // '-Xep:DoNotMock:OFF', // we don't use mocking libraries
- // '-Xep:DoubleBraceInitialization:OFF', // we don't use guava
- '-Xep:DuplicateBranches:ERROR',
- '-Xep:DuplicateMapKeys:ERROR',
- // '-Xep:DurationFrom:OFF', // we don't use Duration.from()
- // '-Xep:DurationGetTemporalUnit:OFF', // we don't use Duration.get()
- // '-Xep:DurationTemporalUnit:OFF', // we don't use Duration.of() etc
- // '-Xep:DurationToLongTimeUnit:OFF', // we don't use TimeUnit.convert Duration, etc
- // '-Xep:EffectivelyPrivate:ERROR', // TODO: many violations of this.
- // '-Xep:EmptyTopLevelDeclaration:OFF', // noisy
- '-Xep:EqualsHashCode:ERROR',
- '-Xep:EqualsNaN:ERROR',
- '-Xep:EqualsNull:ERROR',
- '-Xep:EqualsReference:ERROR',
- '-Xep:EqualsWrongThing:ERROR',
- // '-Xep:ExpensiveLenientFormatString', // we don't use guava
- // '-Xep:FloggerFormatString:OFF', // we don't use flogger
- // '-Xep:FloggerLogVarargs:OFF', // we don't use flogger
- // '-Xep:FloggerSplitLogStatement:OFF', // we don't use flogger
- // '-Xep:ForOverride:OFF', // we don't use this annotation
- '-Xep:FormatString:ERROR',
- // '-Xep:FormatStringAnnotation:OFF', // we don't use this annotation
- // '-Xep:FromTemporalAccessor:OFF', // we don't use .from(LocalDate) etc
- '-Xep:FunctionalInterfaceMethodChanged:ERROR',
- // '-Xep:FuturesGetCheckedIllegalExceptionType:OFF', // we don't use guava
- // '-Xep:FuzzyEqualsShouldNotBeUsedInEqualsMethod:OFF', // we don't use guava
- '-Xep:GetClassOnAnnotation:ERROR',
- '-Xep:GetClassOnClass:ERROR',
- // '-Xep:GuardedBy:OFF', // we don't use this annotation
- // '-Xep:GuiceAssistedInjectScoping:OFF', // we don't use guice
- // '-Xep:GuiceAssistedParameters:OFF', // we don't use guice
- // '-Xep:GuiceInjectOnFinalField:OFF', // we don't use guice
- '-Xep:HashtableContains:ERROR',
- // '-Xep:IdentityBinaryExpression:OFF',
- '-Xep:IdentityHashMapBoxing:ERROR',
- // '-Xep:IgnoredPureGetter:OFF', // we don't use these annotations
- // '-Xep:Immutable:OFF', // we don't use this annotation
- // '-Xep:ImpossibleNullComparison:OFF', // we don't use protobuf
- '-Xep:Incomparable:ERROR',
- // '-Xep:IncompatibleArgumentType:OFF', // we don't use this annotation
- // '-Xep:IncompatibleModifiers:OFF', // we don't use this annotation
- '-Xep:IndexOfChar:ERROR',
- '-Xep:InexactVarargsConditional:ERROR',
- // '-Xep:InfiniteRecursion:OFF',
- // '-Xep:InjectMoreThanOneScopeAnnotationOnClass:OFF', // we don't use this annotation
- // '-Xep:InjectOnMemberAndConstructor:OFF', // we don't use this annotation
- // '-Xep:InlineMeValidator:OFF', // we don't use this annotation
- // '-Xep:InstantTemporalUnit:OFF', // we don't use Instant apis with strange temporal units
- '-Xep:IntFloatConversion:ERROR',
- // '-Xep:IntLiteralCast:OFF', // TODO: there are problems
- // '-Xep:InvalidJavaTimeConstant:OFF', // we don't use impacted java.time classes (Month, etc)
- // '-Xep:InvalidPatternSyntax:OFF',
- '-Xep:InvalidSnippet:ERROR',
- // '-Xep:InvalidTimeZoneID:OFF', // we don't use getTimeZone with constant IDs except UTC/GMT
- // '-Xep:InvalidZoneId:OFF', // we don't use ZoneId.of
- '-Xep:IsInstanceIncompatibleType:ERROR',
- '-Xep:IsInstanceOfClass:ERROR',
- // '-Xep:IsLoggableTagLength:OFF', // we don't use android
- // '-Xep:JUnit3TestNotRun:OFF', // we don't use junit3
- // '-Xep:JUnit4ClassAnnotationNonStatic:OFF', // we use ast-grep for this check
- // '-Xep:JUnit4EmptyMethods:OFF', // we use ast-grep for this check
- // '-Xep:JUnit4SetUpNotRun:OFF', // LuceneTestCase takes care
- // '-Xep:JUnit4TearDownNotRun:OFF', // LuceneTestCase takes care
- // '-Xep:JUnit4TestNotRun:OFF', // noisy
- '-Xep:JUnit4TestsNotRunWithinEnclosed:ERROR',
- '-Xep:JUnitAssertSameCheck:ERROR',
- '-Xep:JUnitParameterMethodNotFound:ERROR',
- // '-Xep:JavaxInjectOnAbstractMethod:OFF', // we don't this annotation
- // '-Xep:JodaToSelf:OFF', // we don't use joda-time
- // '-Xep:LenientFormatStringValidation:OFF' // we don't use these google libraries
- // '-Xep:LiteByteStringUtf8:OFF', // we don't use protobuf
- // '-Xep:LocalDateTemporalAmount:OFF', // we don't use LocalDate math
- '-Xep:LockOnBoxedPrimitive:ERROR',
- '-Xep:LoopConditionChecker:ERROR',
- '-Xep:LossyPrimitiveCompare:ERROR',
- '-Xep:MathRoundIntLong:ERROR',
- // '-Xep:MislabeledAndroidString:OFF', // we don't use android
- '-Xep:MisleadingEmptyVarargs:ERROR',
- '-Xep:MisleadingEscapedSpace:ERROR',
- // '-Xep:MissingRuntimeRetention:OFF', // we don't use this annotation
- // '-Xep:MisplacedScopeAnnotations:OFF', // we don't use this annotation
- // '-Xep:MissingSuperCall:OFF', // we don't use this annotation
- // '-Xep:MissingTestCall:OFF', // we don't use guava
- // '-Xep:MisusedDayOfYear:OFF', // we don't use date patterns
- // '-Xep:MisusedWeekYear:OFF', // we don't use date patterns
- // '-Xep:MixedDescriptors:OFF', // we don't use protobuf
- // '-Xep:MockIllegalThrows:OFF', // we don't use mockito
- // '-Xep:MockitoUsage:OFF', // we don't use mockito
- '-Xep:ModifyingCollectionWithItself:ERROR',
- // '-Xep:MoreThanOneInjectableConstructor:OFF', // we don't use this annotation
- // '-Xep:MustBeClosedChecker:OFF', // we don't use this annotation
- '-Xep:NCopiesOfChar:ERROR',
- // '-Xep:NegativeBoolean:OFF', // TODO: there are problems
- // '-Xep:NoCanIgnoreReturnValueOnClasses:OFF', // we don't use this annotation
- '-Xep:NonCanonicalStaticImport:ERROR',
- // '-Xep:NonFinalCompileTimeConstant:OFF', // we don't use this annotation
- '-Xep:NonRuntimeAnnotation:ERROR',
- // '-Xep:NullArgumentForNonNullParameter:OFF', // we don't use this annotation
- '-Xep:NullTernary:ERROR',
- // '-Xep:NullableOnContainingClass:OFF', // we don't use this annotation
- '-Xep:OptionalEquality:ERROR',
- '-Xep:OptionalMapUnusedValue:ERROR',
- '-Xep:OptionalOfRedundantMethod:ERROR',
- // '-Xep:OverlappingQualifierAndScopeAnnotation:OFF', // we don't use this annotation
- // '-Xep:OverridesJavaxInjectableMethod:OFF', // we don't use this annotation
- // '-Xep:PackageInfo:OFF', // we use ast-grep for this check
- '-Xep:ParametersButNotParameterized:ERROR',
- // '-Xep:ParcelableCreator:OFF', // we don't use android
- // '-Xep:PeriodFrom:OFF', // we don't use Period
- // '-Xep:PeriodGetTemporalUnit:OFF', // we don't use Period
- // '-Xep:PeriodTimeMath:OFF', // we don't use Period
- // '-Xep:PreconditionsInvalidPlaceholder:OFF', // we don't use guava
- // '-Xep:PreconditionsExpensiveString:OFF', // we don't use guava
- // '-Xep:PrivateSecurityContractProtoAccess:OFF', // we don't use protobuf
- // '-Xep:ProtoBuilderReturnValueIgnored:OFF', // we don't use protobuf
- // '-Xep:ProtoFieldNullComparison:OFF', // we don't use protobuf
- // '-Xep:ProtoStringFieldReferenceEquality:OFF', // we don't use protobuf
- // '-Xep:ProtoTruthMixedDescriptors:OFF', // we don't use protobuf
- // '-Xep:ProtocolBufferOrdinal:OFF', // we don't use protobuf
- // '-Xep:ProvidesMethodOutsideOfModule:OFF', // we don't use guice
- '-Xep:RandomCast:ERROR',
- '-Xep:RandomModInteger:ERROR',
- // '-Xep:RectIntersectReturnValueIgnored:OFF', // we don't use android
- // '-Xep:RequiredModifiers:OFF', // we don't use this annotation
- // '-Xep:RestrictedApiChecker:OFF', // we don't use this annotation
- // '-Xep:ReturnValueIgnored:OFF', // noisy
- '-Xep:RuleNotRun:ERROR',
- '-Xep:SelfAssertion:ERROR',
- '-Xep:SelfAssignment:ERROR',
- '-Xep:SelfComparison:ERROR',
- '-Xep:SelfEquals:ERROR',
- '-Xep:SelfSet:ERROR',
- // '-Xep:SetUnrecognized:OFF', // we don't use protobuf
- // '-Xep:ShouldHaveEvenArgs:OFF', // we don't use truth
- '-Xep:SizeGreaterThanOrEqualsZero:ERROR',
- '-Xep:StreamToString:ERROR',
- '-Xep:StringBuilderInitWithChar:ERROR',
- // '-Xep:StringConcatToTextBlock:OFF', // TODO: there are problems
- // '-Xep:SubstringOfZero:OFF', // we use ast-grep for this check
- '-Xep:SuppressWarningsDeprecated:ERROR',
- // '-Xep:TemporalAccessorGetChronoField:OFF', // we don't use TemporalAccessor.get
- // '-Xep:TestParametersNotInitialized:OFF', // we don't use this annotation
- // '-Xep:TheoryButNoTheories:OFF', // we don't use junit theory apis/runner
- // '-Xep:ThrowIfUncheckedKnownChecked:OFF', // we don't use this annotation
- // '-Xep:ThrowNull:OFF', // noisy (LuceneTestCase)
- '-Xep:TimeInStaticInitializer:ERROR',
- // '-Xep:TreeToString:OFF', // we don't use javac API
- // '-Xep:TryFailThrowable:OFF',
- '-Xep:TypeParameterQualifier:ERROR',
- '-Xep:UnicodeDirectionalityCharacters:ERROR',
- '-Xep:UnicodeInCode:ERROR',
- '-Xep:UnnecessaryCheckNotNull:ERROR',
- // '-Xep:UnnecessaryCopy:OFF', // we don't use google collections
- '-Xep:UnnecessaryTypeArgument:ERROR',
- // '-Xep:UnnecessaryQualifier:OFF', // we don't use guava
- '-Xep:UnsafeWildcard:ERROR',
- '-Xep:UnusedAnonymousClass:ERROR',
- '-Xep:UnusedCollectionModifiedInPlace:ERROR',
- // "-Xep:WildcardImport:OFF", // we use ast-grep for this check.
- '-Xep:VarTypeName:ERROR',
- // '-Xep:WrongOneof:OFF', // we don't use protobuf
- '-Xep:XorPower:ERROR',
- // '-Xep:ZoneIdOfZ:OFF', // we don't use ZoneId.of
-
- // On by Default : WARNING
-
- // '-Xep:ASTHelpersSuggestions:OFF', // we don't use ASTHelpers
- // '-Xep:AlmostJavadoc:OFF', // noisy (e.g. commented-out code misinterpreted as javadocs)
- // '-Xep:AlreadyChecked:OFF', // TODO: there are problems
- // '-Xep:AmbiguousMethodReference:OFF',
- // '-Xep:AnnotateFormatMethod:OFF', // we don't use this annotation
- // '-Xep:ArgumentSelectionDefectChecker:OFF', // noisy
- // '-Xep:ArrayAsKeyOfSetOrMap:OFF', // TODO: there are problems
- // '-Xep:ArrayRecordComponent:OFF', // TODO: there are problems
- '-Xep:AssertEqualsArgumentOrderChecker:WARN',
- '-Xep:AssertThrowsMultipleStatements:WARN',
- // '-Xep:AssertionFailureIgnored:OFF', // TODO: there are problems
- // '-Xep:AssistedInjectAndInjectOnSameConstructor:OFF', // we don't use this annotation
- '-Xep:AttemptedNegativeZero:WARN',
- // '-Xep:AutoValueBoxedValues:OFF', // we don't use autovalue
- // '-Xep:AutoValueFinalMethods:OFF', // we don't use autovalue
- // '-Xep:AutoValueImmutableFields:OFF', // we don't use autovalue
- // '-Xep:AutoValueSubclassLeaked:OFF', // we don't use autovalue
- '-Xep:BadComparable:WARN',
- // '-Xep:BadImport:OFF', // TODO: there are problems
- // '-Xep:BadInstanceof:OFF', // TODO: there are problems
- '-Xep:BareDotMetacharacter:WARN',
- // '-Xep:BigDecimalEquals:OFF', // BigDecimal barely used, can use forbidden-apis for this
- // '-Xep:BigDecimalLiteralDouble:OFF', // BigDecimal barely used, can use forbidden-apis for this
- // '-Xep:BoxedPrimitiveConstructor:OFF', // we have forbiddenapis for that
- // '-Xep:BugPatternNaming:OFF', // we don't use this annotation
- // '-Xep:ByteBufferBackingArray:OFF',
- // '-Xep:CacheLoaderNull:OFF', // we don't use guava
- // '-Xep:CanonicalDuration:OFF', // barely use Duration.of (one test), just a style thing
- // '-Xep:CatchAndPrintStackTrace:OFF', // noisy
- // '-Xep:CatchFail:OFF', // TODO: there are problems
- // '-Xep:ChainedAssertionLosesContext:OFF', // we don't use truth
- // '-Xep:CharacterGetNumericValue:OFF', // noisy
- // '-Xep:ClassCanBeStatic:OFF', // noisy
- // '-Xep:ClassInitializationDeadlock:OFF', // TODO: there are problems
- '-Xep:ClassNewInstance:WARN',
- // '-Xep:CloseableProvides:OFF', // we don't use this annotation
- '-Xep:ClosingStandardOutputStreams:WARN',
- // '-Xep:CollectionUndefinedEquality:OFF', // TODO: there are problems
- '-Xep:CollectorShouldNotUseState:WARN',
- '-Xep:ComparableAndComparator:WARN',
- '-Xep:CompareToZero:WARN',
- // '-Xep:ComplexBooleanConstant:OFF', // TODO: there are problems
- // '-Xep:DateChecker:OFF', // we don't use these Date setters/ctors
- // '-Xep:DateFormatConstant:OFF', // we don't use Date setters
- // '-Xep:DefaultCharset:OFF', // we have forbiddenapis for that
- // '-Xep:DefaultLocale:OFF', // we have forbiddenapis for that
- // '-Xep:DefaultPackage:OFF',
- '-Xep:DeprecatedVariable:WARN',
- '-Xep:DeeplyNested:WARN',
- // '-Xep:DirectInvocationOnMock:OFF', // we don't use mocking libraries
- // '-Xep:DistinctVarargsChecker:OFF', // we don't use google collections
- // '-Xep:DoNotCallSuggester:OFF', // we don't use this annotation
- // '-Xep:DoNotClaimAnnotations:OFF', // we don't use annotation processors
- // '-Xep:DoNotMockAutoValue:OFF', // we don't use autovalue
- // '-Xep:DoubleCheckedLocking:OFF', // TODO: there are problems
- '-Xep:DuplicateDateFormatField:WARN',
- // '-Xep:EmptyBlockTag:OFF', // ECJ takes care
- // '-Xep:EmptyCatch:OFF', // ECJ takes care
- // '-Xep:EmptySetMultibindingContributions:OFF', // we don't use this annotation
- // '-Xep:EnumOrdinal:OFF', // noisy
- // '-Xep:EqualsGetClass:OFF', // noisy
- // '-Xep:EqualsIncompatibleType:OFF',
- // '-Xep:EqualsUnsafeCast:OFF', // noisy
- '-Xep:EqualsUsingHashCode:WARN',
- '-Xep:ErroneousBitwiseExpression:WARN',
- '-Xep:ErroneousThreadPoolConstructorChecker:WARN',
- // '-Xep:EscapedEntity:OFF',
- // '-Xep:ExtendingJUnitAssert:OFF', // noisy
- // '-Xep:ExtendsObject:OFF', // TODO: there are problems
- // '-Xep:FallThrough:OFF', // TODO: there are problems
- '-Xep:Finalize:WARN',
- // catches actual finalizers that don't call super
- // '-Xep:Finally:OFF', // TODO: there are problems
- '-Xep:FloatCast:WARN',
- '-Xep:FloatingPointAssertionWithinEpsilon:WARN',
- // '-Xep:FloatingPointLiteralPrecision:OFF', // TODO: there are problems
- // '-Xep:FloggerArgumentToString:OFF', // we don't use flogger
- // '-Xep:FloggerStringConcatenation:OFF', // we don't use flogger
- // '-Xep:FragmentInjection:OFF', // we don't use android
- // '-Xep:FragmentNotInstantiable:OFF', // we don't use android
- // '-Xep:FutureReturnValueIgnored:OFF', // TODO: there are problems
- // '-Xep:FutureTransformAsync:OFF', // we don't use these google libraries
- '-Xep:GetClassOnEnum:WARN',
- // '-Xep:GuiceNestedCombine:OFF', // we don't use guice
- // '-Xep:HidingField:OFF', // noisy
- // '-Xep:ICCProfileGetInstance:OFF', // we use forbidden-apis for this
- // '-Xep:IdentityHashMapUsage:OFF', // noisy
- // '-Xep:ImmutableAnnotationChecker:OFF', // we don't use this annotation
- // '-Xep:ImmutableEnumChecker:OFF', // noisy
- // '-Xep:InconsistentCapitalization:OFF', // TODO: there are problems
- // '-Xep:InconsistentHashCode:OFF', // noisy
- // '-Xep:IgnoredPureGetter:OFF', // we don't use these google libraries
- // '-Xep:IncorrectMainMethod:OFF', // we use ast-grep for this
- '-Xep:IncrementInForLoopAndHeader:WARN',
- '-Xep:InheritDoc:WARN',
- // '-Xep:InjectOnBugCheckers:OFF', // we don't use this annotation
- // '-Xep:InjectInvalidTargetingOnScopingAnnotation:OFF', // we don't use this annotation
- // '-Xep:InjectOnConstructorOfAbstractClass:OFF', // we don't use this annotation
- // '-Xep:InjectScopeAnnotationOnInterfaceOrAbstractClass:OFF', // we don't use this annotation
- // '-Xep:InjectedConstructorAnnotations:OFF', // we don't use this annotation
- // '-Xep:InlineFormatString:OFF', // noisy
- // '-Xep:InlineMeInliner:OFF', // we don't use this annotation
- // '-Xep:InlineMeSuggester:OFF', // we don't use this annotation
- // '-Xep:InlineTrivialConstant:OFF', // stylistic
- // '-Xep:InputStreamSlowMultibyteRead:OFF',
- '-Xep:InstanceOfAndCastMatchWrongType:WARN',
- // '-Xep:IntLongMath:OFF', // noisy
- // '-Xep:InvalidBlockTag:OFF', // noisy (e.g. lucene.experimental)
- // '-Xep:InvalidInlineTag:OFF', // TODO: there are problems
- '-Xep:InvalidLink:WARN',
- // '-Xep:InvalidParam:OFF', // TODO: there are problems
- '-Xep:InvalidThrows:WARN',
- '-Xep:InvalidThrowsLink:WARN',
- '-Xep:IterableAndIterator:WARN',
- // '-Xep:JUnit3FloatingPointComparisonWithoutDelta:OFF', // we don't use junit3
- // '-Xep:JUnit4ClassUsedInJUnit3:OFF', // we don't use junit3
- // '-Xep:JUnitAmbiguousTestClass:OFF', // we don't use junit3
- // '-Xep:JavaDurationGetSecondsGetNano:OFF', // we don't use these Duration methods
- // '-Xep:JavaDurationGetSecondsToToSeconds:OFF', // we don't use these Duration methods
- // '-Xep:JavaDurationWithNanos:OFF', // we don't use these Duration methods
- // '-Xep:JavaDurationWithSeconds:OFF', // we don't use these Duration methods
- // '-Xep:JavaInstantGetSecondsGetNano:OFF', // we don't use these Instant methods
- // '-Xep:JavaLangClash:OFF', // TODO: there are problems
- // '-Xep:JavaLocalDateTimeGetNano:OFF', // we don't use LocalDateTime
- // '-Xep:JavaLocalTimeGetNano:OFF', // we don't use LocalTime
- // '-Xep:JavaPeriodGetDays:OFF', // we don't use Period
- // '-Xep:JavaTimeDefaultTimeZone:OFF', // forbidden-apis checks this
- // '-Xep:JavaUtilDate:OFF', // noisy
- // '-Xep:JavaxInjectOnFinalField:OFF', // we don't use this annotation
- // '-Xep:JdkObsolete:OFF', // noisy
- // '-Xep:JodaConstructors:OFF', // we don't use joda-time
- // '-Xep:JodaDateTimeConstants:OFF', // we don't use joda-time
- // '-Xep:JodaDurationWithMillis:OFF', // we don't use joda-time
- // '-Xep:JodaInstantWithMillis:OFF', // we don't use joda-time
- // '-Xep:JodaNewPeriod:OFF', // we don't use joda-time
- // '-Xep:JodaPlusMinusLong:OFF', // we don't use joda-time
- // '-Xep:JodaTimeConverterManager:OFF', // we don't use joda-time
- // '-Xep:JodaWithDurationAddedLong:OFF', // we don't use joda-time
- '-Xep:JUnitIncompatibleType:WARN',
- // '-Xep:LabelledBreakTarget:OFF', // stylistic
- // '-Xep:LiteEnumValueOf:OFF', // we don't use protobuf
- // '-Xep:LiteProtoToString:OFF', // we don't use protobuf
- // '-Xep:LockNotBeforeTry:OFF', // TODO: there are problems
- // '-Xep:LockOnNonEnclosingClassLiteral:OFF', // TODO: there are problems
- '-Xep:LogicalAssignment:WARN',
- '-Xep:LongDoubleConversion:WARN',
- '-Xep:LongFloatConversion:WARN',
- '-Xep:LoopOverCharArray:WARN',
- '-Xep:MalformedInlineTag:WARN',
- // '-Xep:MathAbsoluteNegative:OFF', // TODO: there are problems
- // '-Xep:MemoizeConstantVisitorStateLookups:OFF', // we don't use this class
- // '-Xep:MisformattedTestData:OFF', // stylistic
- // '-Xep:MissingCasesInEnumSwitch:OFF', // redundant with ECJ incompleteEnumSwitch/missingEnumCaseDespiteDefault
- // '-Xep:MissingFail:OFF', // TODO: there are problems
- '-Xep:MissingImplementsComparable:WARN',
- // '-Xep:MissingOverride:OFF', // ECJ takes care of this
- // '-Xep:MissingRefasterAnnotation:OFF', // we don't use this annotation
- // '-Xep:MissingSummary:OFF', // TODO: there are problems
- // '-Xep:MixedMutabilityReturnType:OFF', // noisy
- // '-Xep:MockitoDoSetup:OFF', // we don't use mocking libraries
- // '-Xep:MockNotUsedInProduction:OFF', // we don't use mocking libraries
- // '-Xep:ModifiedButNotUsed:OFF', // TODO: there are problems
- '-Xep:ModifyCollectionInEnhancedForLoop:WARN',
- '-Xep:ModifySourceCollectionInStream:WARN',
- '-Xep:MultimapKeys:WARN',
- // '-Xep:MultipleNullnessAnnotations:OFF', // we don't use these annotations
- '-Xep:MultipleParallelOrSequentialCalls:WARN',
- '-Xep:MultipleUnaryOperatorsInMethodCall:WARN',
- // '-Xep:MutableGuiceModule:OFF', // we don't use guice
- // '-Xep:MutablePublicArray:OFF', // TODO: there are problems
- '-Xep:NamedLikeContextualKeyword:WARN',
- '-Xep:NarrowCalculation:WARN',
- // '-Xep:NarrowingCompoundAssignment:OFF', // noisy
- '-Xep:NegativeCharLiteral:WARN',
- '-Xep:NestedInstanceOfConditions:WARN',
- // '-Xep:NewFileSystem:OFF', // we don't create new filesystems
- // '-Xep:NonApiType:OFF', // noisy
- // '-Xep:NonAtomicVolatileUpdate:OFF', // TODO: there are problems
- // '-Xep:NonCanonicalType:OFF', // noisy
- '-Xep:NonFinalStaticField:WARN',
- '-Xep:NonOverridingEquals:WARN',
- '-Xep:NotJavadoc:WARN',
- '-Xep:NullOptional:WARN',
- // '-Xep:NullableConstructor:OFF', // we don't use this annotation
- '-Xep:NullableOptional:WARN',
- // '-Xep:NullablePrimitive:OFF', // we don't use this annotation
- // '-Xep:NullablePrimitiveArray:OFF', // we don't use this annotation
- // '-Xep:NullableTypeParameter:OFF', // we don't use this annotation
- // '-Xep:NullableVoid:OFF', // we don't use this annotation
- // '-Xep:NullableWildcard:OFF', // we don't use this annotation
- '-Xep:ObjectEqualsForPrimitives:WARN',
- // '-Xep:ObjectToString:OFF', // TODO: there are problems
- // '-Xep:ObjectsHashCodePrimitive:OFF', // TODO: there are problems
- // '-Xep:OperatorPrecedence:OFF', // noisy
- '-Xep:OptionalMapToOptional:WARN',
- '-Xep:OptionalNotPresent:WARN',
- '-Xep:OrphanedFormatString:WARN',
- // '-Xep:OutlineNone:OFF', // we don't use gwt
- '-Xep:OverrideThrowableToString:WARN',
- '-Xep:Overrides:WARN',
- // '-Xep:OverridesGuiceInjectableMethod:OFF', // we don't use guice
- '-Xep:OverridingMethodInconsistentArgumentNamesChecker:WARN',
- // '-Xep:PatternMatchingInstanceof:OFF', // there are problems and check seems not great
- // '-Xep:ParameterName:OFF', // we don't pass parameters with comments in this way
- // '-Xep:PreconditionsCheckNotNullRepeated:OFF', // we don't use guava
- '-Xep:PrimitiveAtomicReference:WARN',
- // '-Xep:ProtectedMembersInFinalClass:OFF', // we don't use protobuf
- // '-Xep:ProtoDurationGetSecondsGetNano:OFF', // we don't use protobuf
- // '-Xep:ProtoRedundantSet:OFF', // we don't use protobuf
- // '-Xep:ProtoTimestampGetSecondsGetNano:OFF', // we don't use protobuf
- // '-Xep:QualifierOrScopeOnInjectMethod:OFF', // we don't use this annotation
- '-Xep:ReachabilityFenceUsage:WARN',
- // '-Xep:RedundantControlFlow:OFF', // stylistic
- // '-Xep:RedundantSetterCall:OFF', // we don't use protobuf
- // '-Xep:ReferenceEquality:OFF', // noisy
- '-Xep:RethrowReflectiveOperationExceptionAsLinkageError:WARN',
- // '-Xep:ReturnAtTheEndOfVoidFunction:OFF', // stylistic
- '-Xep:ReturnFromVoid:WARN',
- // '-Xep:RobolectricShadowDirectlyOn:OFF', // we don't use robolectric
- // '-Xep:RxReturnValueIgnored:OFF', // we don't use rxjava
- // '-Xep:SameNameButDifferent:OFF', // TODO: there are problems
- // '-Xep:SelfAlwaysReturnsThis:OFF', // we don't use self() methods, this isn't python.
- // '-Xep:ShortCircuitBoolean:OFF', // TODO: there are problems
- // '-Xep:StatementSwitchToExpressionSwitch:OFF', // TODO: there are problems
- // '-Xep:StaticAssignmentInConstructor:OFF',
- // '-Xep:StaticAssignmentOfThrowable:OFF', // noisy
- // '-Xep:StaticGuardedByInstance:OFF',
- // '-Xep:StaticMockMember:OFF', // we don't use mock libraries
- // '-Xep:StreamResourceLeak:OFF', // TODO: there are problems
- '-Xep:StreamToIterable:WARN',
- // '-Xep:StringCaseLocaleUsage:OFF', // noisy, can use forbidden-apis for this
- // '-Xep:StringCharset:OFF', // we use ast-grep for this
- '-Xep:StringFormatWithLiteral:WARN',
- // '-Xep:StringSplitter:OFF', // noisy, can use forbidden-apis for this
- '-Xep:SystemConsoleNull:WARN',
- // '-Xep:SunApi:OFF', // we use forbidden-apis for this
- '-Xep:SuperCallToObjectMethod:WARN',
- // '-Xep:SwigMemoryLeak:OFF', // we don't use swig
- // '-Xep:SynchronizeOnNonFinalField:OFF', // noisy
- // '-Xep:ThreadJoinLoop:OFF',
- // '-Xep:ThreadLocalUsage:OFF', // noisy
- // '-Xep:ThreadPriorityCheck:OFF', // noisy, forbidden APIs can do this
- // '-Xep:ThrowIfUncheckedKnownUnchecked:OFF', // we don't use these google libraries
- // '-Xep:ThreeLetterTimeZoneID:OFF', // we use ast-grep for this
- '-Xep:TimeUnitConversionChecker:WARN',
- // '-Xep:ToStringReturnsNull:OFF', // TODO: there are problems
- // '-Xep:TruthAssertExpected:OFF', // we don't use truth
- // '-Xep:TruthConstantAsserts:OFF', // we don't use truth
- // '-Xep:TruthContainsExactlyElementsInUsage:OFF', // we don't use truth
- // '-Xep:TruthGetOrDefault:OFF', // we don't use truth
- // '-Xep:TruthIncompatibleType:OFF', // we don't use truth
- // '-Xep:TypeEquals:OFF', // we don't use this internal javac api
- '-Xep:TypeNameShadowing:WARN',
- // '-Xep:TypeParameterShadowing:OFF',
- // '-Xep:TypeParameterUnusedInFormals:OFF',
- '-Xep:URLEqualsHashCode:WARN',
- // '-Xep:UndefinedEquals:OFF', // TODO: there are problems
- // '-Xep:UnescapedEntity:OFF', // TODO: there are problems
- // '-Xep:UnicodeEscape:OFF', // noisy
- '-Xep:UnnecessaryAsync:WARN',
- // '-Xep:UnnecessaryAssignment:OFF', // we don't use these annotations
- '-Xep:UnnecessaryBreakInSwitch:WARN',
- // '-Xep:UnnecessaryLambda:OFF', // TODO: there are problems
- // '-Xep:UnnecessaryLongToIntConversion:OFF', // TODO: there are problems
- // '-Xep:UnnecessaryMethodInvocationMatcher:OFF', // we don't use spring
- '-Xep:UnnecessaryMethodReference:WARN',
- // '-Xep:UnnecessaryParentheses:OFF', // noisy
- '-Xep:UnnecessaryStringBuilder:WARN',
- // '-Xep:UnnecessaryTestMethodPrefix:OFF', // stylistic
- // '-Xep:UnqualifiedYield:OFF', // javac takes care
- '-Xep:UnrecognisedJavadocTag:WARN',
- // '-Xep:UnsafeFinalization:OFF', // we don't use finalizers, deprecated for removal, fails build
- '-Xep:UnsafeReflectiveConstructionCast:WARN',
- // '-Xep:UnsynchronizedOverridesSynchronized:OFF', // TODO: there are problems
- // '-Xep:UnusedLabel:OFF', // TODO: there are problems
- // '-Xep:UnusedMethod:OFF', // TODO: there are problems
- '-Xep:UnusedNestedClass:WARN',
- // '-Xep:UnusedTypeParameter:OFF', // TODO: there are problems
- // '-Xep:UnusedVariable:OFF', // noisy, can use ECJ
- // '-Xep:UseBinds:OFF', // we don't use this annotation
- // '-Xep:UseCorrectAssertInTests:OFF', // noisy
- '-Xep:VariableNameSameAsType:WARN',
- '-Xep:VoidUsed:WARN',
- // '-Xep:WaitNotInLoop:OFF', // TODO: there are problems
- // '-Xep:WakelockReleasedDangerously:OFF', // we don't use android
- // '-Xep:WithSignatureDiscouraged:OFF', // we aren't using this error-prone internal api
- ]
- }
- }
- }
-}
diff --git a/build-tools/build-infra/src/main/groovy/lucene.validation.gradle-versions-cleanup.gradle b/build-tools/build-infra/src/main/groovy/lucene.validation.gradle-versions-cleanup.gradle
deleted file mode 100644
index 7e5d60c1c16..00000000000
--- a/build-tools/build-infra/src/main/groovy/lucene.validation.gradle-versions-cleanup.gradle
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// Apply cleanups to gradle/libs.gradle.toml
-
-if (project != project.rootProject) {
- throw new GradleException("Applicable to rootProject only: " + project.path)
-}
-
-project.plugins.apply(deps.plugins.versionCatalogUpdate.get().pluginId)
-
-versionCatalogUpdate {
- sortByKey = true
-
- versionCatalogs {
- deps {
- catalogFile = file("gradle/libs.versions.toml")
- }
- }
-}
-
-def formatDepsTask = tasks.named("versionCatalogFormatDeps")
-def updateDepsTask = tasks.named("versionCatalogUpdateDeps")
-
-tasks.named("tidy").configure {
- it.dependsOn(formatDepsTask)
-}
-
-// correct crlf/ default encoding after version catalog formatting finishes.
-formatDepsTask.configure {
- it.doLast {
- ant.fixcrlf(file: it.catalogFile.get().asFile,
- eol: "lf", fixlast: "true", encoding: "UTF-8")
- }
-}
-
-updateDepsTask.configure {
- it.interactive = true
-}
-
-tasks.register("updateDeps", {
- dependsOn updateDepsTask
-})
diff --git a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/LuceneGradlePlugin.java b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/LuceneGradlePlugin.java
index bc3f94197b6..2a455a448d4 100644
--- a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/LuceneGradlePlugin.java
+++ b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/LuceneGradlePlugin.java
@@ -54,7 +54,7 @@ public abstract class LuceneGradlePlugin implements Plugin<Project> {
}
/** Return the main Lucene project path (root path of the repository checkout). */
- protected static Path getProjectRootPath(Project project) {
+ public static Path getProjectRootPath(Project project) {
return project.getLayout().getSettingsDirectory().getAsFile().toPath();
}
diff --git a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/help/BuildOptionGroupsPlugin.java b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/help/BuildOptionGroupsPlugin.java
index 26b1de13a78..3cc7f72e4b4 100644
--- a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/help/BuildOptionGroupsPlugin.java
+++ b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/help/BuildOptionGroupsPlugin.java
@@ -22,6 +22,7 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.lucene.gradle.plugins.hacks.DumpGradleStateOnStalledBuildsPlugin;
import org.apache.lucene.gradle.plugins.ide.EclipseSupportPlugin;
+import org.apache.lucene.gradle.plugins.java.ErrorPronePlugin;
import org.apache.lucene.gradle.plugins.misc.MeasureTaskTimesPlugin;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
@@ -49,7 +50,7 @@ public class BuildOptionGroupsPlugin implements Plugin<Project> {
"Optional testing and test resources",
explicitList(
"tests.hunspell.regressions",
- "validation.errorprone",
+ ErrorPronePlugin.OPT_VALIDATION_ERRORPRONE,
"hunspell.corpora",
"hunspell.dictionaries",
"hunspell.repo.path",
diff --git a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/java/ErrorPronePlugin.java b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/java/ErrorPronePlugin.java
new file mode 100644
index 00000000000..09735541ddf
--- /dev/null
+++ b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/java/ErrorPronePlugin.java
@@ -0,0 +1,962 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.lucene.gradle.plugins.java;
+
+import com.google.errorprone.scanner.BuiltInCheckerSuppliers;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import net.ltgt.gradle.errorprone.CheckSeverity;
+import net.ltgt.gradle.errorprone.ErrorProneOptions;
+import org.apache.lucene.gradle.plugins.LuceneGradlePlugin;
+import org.apache.lucene.gradle.plugins.misc.CheckEnvironmentPlugin;
+import org.gradle.api.GradleException;
+import org.gradle.api.Project;
+import org.gradle.api.plugins.ExtensionAware;
+import org.gradle.api.plugins.JavaPlugin;
+import org.gradle.api.provider.Property;
+import org.gradle.api.provider.Provider;
+import org.gradle.api.tasks.compile.JavaCompile;
+
+/**
+ * Applies Google's error-prone project for additional linting.
+ *
+ * @see "https://github.com/google/error-prone"
+ */
+public class ErrorPronePlugin extends LuceneGradlePlugin {
+ private static final String TASK_ERROR_PRONE_SKIPPED = "errorProneSkipped";
+ public static final String OPT_VALIDATION_ERRORPRONE = "validation.errorprone";
+
+ public static class ErrorPronePluginRootExtPlugin extends LuceneGradlePlugin {
+
+ public abstract static class ErrorProneStatus {
+ public abstract Property<Boolean> getEnabled();
+ }
+
+ @Override
+ public void apply(Project project) {
+ applicableToRootProjectOnly(project);
+
+ // Ensure internal consistency with error-prone.
+ var verifyErrorProneCheckListSanity =
+ project
+ .getTasks()
+ .register(
+ "verifyErrorProneCheckListSanity",
+ t -> {
+ t.doFirst(
+ _ -> {
+ ensureCheckListIsComplete();
+ });
+ });
+ project
+ .getTasks()
+ .named("check")
+ .configure(t -> t.dependsOn(verifyErrorProneCheckListSanity));
+
+ // check if error-prone should be hooked up to javac or not.
+ var buildGlobals = getLuceneBuildGlobals(project);
+ Provider<Boolean> errorproneOption =
+ getBuildOptions(project)
+ .addBooleanOption(
+ OPT_VALIDATION_ERRORPRONE,
+ "Applies error-prone for additional source code linting.",
+ buildGlobals.isCIBuild);
+
+ var status = project.getExtensions().create("errorProneStatus", ErrorProneStatus.class);
+
+ String skipReason;
+ if (project
+ .getExtensions()
+ .getByType(AlternativeJdkSupportPlugin.AltJvmExtension.class)
+ .getAltJvmUsed()
+ .get()) {
+ // LUCENE-9650: Errorprone does not work when running as a plugin inside a forked Javac
+ // process.
+ skipReason = "won't work with alternative java toolchain";
+ } else {
+ if (errorproneOption.get()) {
+ // Enabled and fine to run.
+ skipReason = null;
+ } else {
+ if (buildGlobals.isCIBuild) {
+ throw new GradleException(
+ "Odd, errorprone linting should always be enabled on CI builds?");
+ } else {
+ skipReason =
+ "skipped on builds not running inside CI environments, pass -P"
+ + OPT_VALIDATION_ERRORPRONE
+ + "=true to enable";
+ }
+ }
+ }
+
+ if (skipReason != null) {
+ project
+ .getTasks()
+ .register(
+ TASK_ERROR_PRONE_SKIPPED,
+ task -> {
+ task.doFirst(
+ t -> {
+ t.getLogger().warn("Errorprone linting turned off ({})", skipReason);
+ });
+ });
+ }
+
+ status.getEnabled().set(skipReason == null && errorproneOption.get());
+ }
+
+ // double check we have all the checks from the current version of errorprone covered.
+ private void ensureCheckListIsComplete() {
+ Set<String> allCanonicalNames = new TreeSet<>();
+ Map<String, String> altToCanonical = new HashMap<>();
+
+ Stream.of(
+ BuiltInCheckerSuppliers.ENABLED_ERRORS,
+ BuiltInCheckerSuppliers.ENABLED_WARNINGS,
+ BuiltInCheckerSuppliers.DISABLED_CHECKS)
+ .flatMap(Collection::stream)
+ .forEach(
+ bugCheckerInfo -> {
+ var canonicalName = bugCheckerInfo.canonicalName();
+ allCanonicalNames.add(canonicalName);
+ bugCheckerInfo
+ .allNames()
+ .forEach(
+ name -> {
+ if (!name.equals(canonicalName)) {
+ altToCanonical.put(name, canonicalName);
+ }
+ });
+ });
+
+ var currentChecks = ALL_CHECKS_PARSED.keySet();
+
+ Set<String> missingChecks = new TreeSet<>(currentChecks);
+ missingChecks.removeAll(allCanonicalNames);
+ String pluginClassName = ErrorPronePlugin.class.getName();
+
+ if (!missingChecks.isEmpty()) {
+ throw new GradleException(
+ String.format(
+ Locale.ROOT,
+ "Verify the list of error-prone checks in '%s', there are unknown checks declared there:\n%s",
+ pluginClassName,
+ missingChecks.stream()
+ .map(
+ name ->
+ " - "
+ + (altToCanonical.containsKey(name)
+ ? name
+ + " (canonical check name is '"
+ + altToCanonical.get(name)
+ + "')"
+ : name))
+ .collect(Collectors.joining("\n"))));
+ }
+
+ Set<String> newChecks = new TreeSet<>(allCanonicalNames);
+ newChecks.removeAll(currentChecks);
+ if (!newChecks.isEmpty()) {
+ throw new GradleException(
+ String.format(
+ Locale.ROOT,
+ "Verify the list of error-prone checks in '%s', there are new checks in "
+ + "error-prone that are not declared there:\n%s",
+ pluginClassName,
+ newChecks.stream()
+ .map(
+ name ->
+ " - "
+ + name
+ + ", docs at: "
+ + "https://errorprone.info/bugpattern/"
+ + name)
+ .collect(Collectors.joining("\n"))));
+ }
+ }
+ }
+
+ @Override
+ public void apply(Project project) {
+ requiresAppliedPlugin(project, JavaPlugin.class);
+
+ if (project != project.getRootProject()) {
+ project.getRootProject().getPlugins().apply(ErrorPronePluginRootExtPlugin.class);
+ }
+
+ boolean errorProneEnabled =
+ project
+ .getRootProject()
+ .getExtensions()
+ .getByType(ErrorPronePluginRootExtPlugin.ErrorProneStatus.class)
+ .getEnabled()
+ .get();
+
+ if (errorProneEnabled) {
+ configureErrorProne(project);
+ } else {
+ project
+ .getTasks()
+ .withType(JavaCompile.class)
+ .configureEach(
+ t -> {
+ t.dependsOn(":" + TASK_ERROR_PRONE_SKIPPED);
+ });
+
+ // The errorprone plugin automatically adds test classpath entries.
+ // We need to add it here manually so that versions.lock is consistent with or without
+ // the errorprone plugin.
+ var errorproneConfiguration = project.getConfigurations().create("errorprone");
+ project
+ .getConfigurations()
+ .getByName("annotationProcessor")
+ .extendsFrom(errorproneConfiguration);
+
+ applyLocalDependency(project);
+ }
+ }
+
+ /**
+ * List of enabled/disabled checks.
+ *
+ * <p>Please keep this synced with <a href="https://errorprone.info/bugpatterns">bugpatterns</a>
+ * when upgrading. Do <em>NOT</em> enable checks based on their name or description. Read the
+ * source code and make sure they are useful! Most error-prone checks are not useful for
+ * non-google software.
+ *
+ * @see "https://errorprone.info/bugpatterns"
+ */
+ private static final String[] ALL_CHECKS = {
+ "ASTHelpersSuggestions:OFF", // we don't use ASTHelpers
+ "AddNullMarkedToPackageInfo:OFF", // we don't use jspecify
+ "AddressSelection:OFF", // TODO: new, not checked if applicable to Lucene
+ "AlmostJavadoc:OFF", // noisy (e.g. commented-out code misinterpreted as javadocs)
+ "AlreadyChecked:OFF", // TODO: there are problems
+ "AlwaysThrows:OFF", // we don't use guava
+ "AmbiguousMethodReference:OFF",
+ "AndroidInjectionBeforeSuper:OFF", // we don't use android
+ "AndroidJdkLibsChecker:OFF", // TODO: new, not checked if applicable to Lucene
+ "AnnotateFormatMethod:OFF", // we don't use this annotation
+ "AnnotationMirrorToString:OFF", // TODO: new, not checked if applicable to Lucene
+ "AnnotationPosition:OFF", // TODO: new, not checked if applicable to Lucene
+ "AnnotationValueToString:OFF", // TODO: new, not checked if applicable to Lucene
+ "ArgumentSelectionDefectChecker:OFF", // noisy
+ "ArrayAsKeyOfSetOrMap:OFF", // TODO: there are problems
+ "ArrayEquals:ERROR",
+ "ArrayFillIncompatibleType:ERROR",
+ "ArrayHashCode:ERROR",
+ "ArrayRecordComponent:OFF", // TODO: there are problems
+ "ArrayToString:ERROR",
+ "ArraysAsListPrimitiveArray:OFF", // we don't use guava
+ "AssertEqualsArgumentOrderChecker:WARN",
+ "AssertFalse:OFF", // TODO: new, not checked if applicable to Lucene
+ "AssertThrowsMultipleStatements:WARN",
+ "AssertionFailureIgnored:OFF", // TODO: there are problems
+ "AssignmentExpression:OFF", // TODO: there are problems
+ "AssistedInjectAndInjectOnConstructors:OFF", // TODO: new, not checked if applicable to Lucene
+ "AssistedInjectAndInjectOnSameConstructor:OFF", // we don't use this annotation
+ "AsyncCallableReturnsNull:OFF", // we don't use guava
+ "AsyncFunctionReturnsNull:OFF", // we don't use guava
+ "AttemptedNegativeZero:WARN",
+ "AutoFactoryAtInject:OFF", // TODO: new, not checked if applicable to Lucene
+ "AutoValueBoxedValues:OFF", // we don't use autovalue
+ "AutoValueBuilderDefaultsInConstructor:OFF", // we don't use autovalue
+ "AutoValueConstructorOrderChecker:OFF", // we don't use autovalue
+ "AutoValueFinalMethods:OFF", // we don't use autovalue
+ "AutoValueImmutableFields:OFF", // we don't use autovalue
+ "AutoValueSubclassLeaked:OFF", // we don't use autovalue
+ "AvoidObjectArrays:OFF", // TODO: new, not checked if applicable to Lucene
+ "BadAnnotationImplementation:ERROR",
+ "BadComparable:WARN",
+ "BadImport:OFF", // TODO: there are problems
+ "BadInstanceof:OFF", // TODO: there are problems
+ "BadShiftAmount:ERROR",
+ "BanClassLoader:OFF", // implemented with forbidden APIs instead
+ "BanJNDI:OFF", // implemented with forbidden APIs instead
+ "BanSerializableRead:OFF", // TODO: new, not checked if applicable to Lucene
+ "BareDotMetacharacter:WARN",
+ "BigDecimalEquals:OFF", // BigDecimal barely used, use forbidden-apis for this
+ "BigDecimalLiteralDouble:OFF", // BigDecimal barely used, use forbidden-apis for this
+ "BinderIdentityRestoredDangerously:OFF", // TODO: new, not checked if applicable to Lucene
+ "BindingToUnqualifiedCommonType:OFF", // TODO: new, not checked if applicable to Lucene
+ "BooleanLiteral:ERROR",
+ "BooleanParameter:OFF", // TODO: new, not checked if applicable to Lucene
+ "BoxedPrimitiveConstructor:OFF", // we have forbiddenapis for that
+ "BoxedPrimitiveEquality:OFF", // TODO: there are problems
+ "BugPatternNaming:OFF", // we don't use this annotation
+ "BuilderReturnThis:OFF", // TODO: new, not checked if applicable to Lucene
+ "BundleDeserializationCast:OFF", // we don't use android
+ "ByteBufferBackingArray:OFF",
+ "CacheLoaderNull:OFF", // we don't use guava
+ "CanIgnoreReturnValueSuggester:OFF", // TODO: new, not checked if applicable to Lucene
+ "CannotMockFinalClass:OFF", // TODO: new, not checked if applicable to Lucene
+ "CannotMockMethod:OFF", // TODO: new, not checked if applicable to Lucene
+ "CanonicalDuration:OFF", // barely use Duration.of (one test), just a style thing
+ "CatchAndPrintStackTrace:OFF", // noisy
+ "CatchFail:OFF", // TODO: there are problems
+ "CatchingUnchecked:OFF", // TODO: new, not checked if applicable to Lucene
+ "ChainedAssertionLosesContext:OFF", // we don't use truth
+ "ChainingConstructorIgnoresParameter:ERROR",
+ "CharacterGetNumericValue:OFF", // noisy
+ "CheckNotNullMultipleTimes:OFF", // we don't use guava
+ "CheckReturnValue:OFF", // we don't use these annotations
+ "CheckedExceptionNotThrown:OFF", // TODO: new, not checked if applicable to Lucene
+ "ClassCanBeStatic:OFF", // noisy
+ "ClassInitializationDeadlock:OFF", // TODO: there are problems
+ "ClassName:OFF", // TODO: new, not checked if applicable to Lucene
+ "ClassNamedLikeTypeParameter:OFF", // TODO: new, not checked if applicable to Lucene
+ "ClassNewInstance:WARN",
+ "CloseableProvides:OFF", // we don't use this annotation
+ "ClosingStandardOutputStreams:WARN",
+ "CollectionIncompatibleType:OFF", // TODO: new, not checked if applicable to Lucene
+ "CollectionToArraySafeParameter:ERROR",
+ "CollectionUndefinedEquality:OFF", // TODO: there are problems
+ "CollectorShouldNotUseState:WARN",
+ "ComparableAndComparator:WARN",
+ "ComparableType:OFF",
+ "CompareToZero:WARN",
+ "ComparingThisWithNull:OFF", // we use ast-grep for this check
+ "ComparisonContractViolated:OFF", // TODO: new, not checked if applicable to Lucene
+ "ComparisonOutOfRange:ERROR",
+ "CompatibleWithAnnotationMisuse:OFF", // we don't use this annotation
+ "CompileTimeConstant:OFF", // we don't use this annotation
+ "ComplexBooleanConstant:OFF", // TODO: there are problems
+ "ComputeIfAbsentAmbiguousReference:ERROR",
+ "ConditionalExpressionNumericPromotion:ERROR",
+ "ConstantField:OFF", // TODO: new, not checked if applicable to Lucene
+ "ConstantOverflow:ERROR",
+ "ConstantPatternCompile:OFF", // TODO: new, not checked if applicable to Lucene
+ "DaggerProvidesNull:OFF", // we don't use dagger
+ "DangerousLiteralNull:ERROR",
+ "DateChecker:OFF", // we don't use these Date setters/ctors
+ "DateFormatConstant:OFF", // we don't use Date setters
+ "DeadException:ERROR",
+ "DeadThread:ERROR",
+ "DeduplicateConstants:OFF", // TODO: new, not checked if applicable to Lucene
+ "DeeplyNested:WARN",
+ "DefaultCharset:OFF", // we have forbiddenapis for that
+ "DefaultLocale:OFF", // we have forbiddenapis for that
+ "DefaultPackage:OFF",
+ "DepAnn:OFF", // TODO: new, not checked if applicable to Lucene
+ "DeprecatedVariable:WARN",
+ "DereferenceWithNullBranch:ERROR",
+ "DifferentNameButSame:OFF", // TODO: new, not checked if applicable to Lucene
+ "DirectInvocationOnMock:OFF", // we don't use mocking libraries
+ "DiscardedPostfixExpression:ERROR",
+ "DistinctVarargsChecker:OFF", // we don't use google collections
+ "DoNotCall:OFF", // we don't use this annotation
+ "DoNotCallSuggester:OFF", // we don't use this annotation
+ "DoNotClaimAnnotations:OFF", // we don't use annotation processors
+ "DoNotMock:OFF", // we don't use mocking libraries
+ "DoNotMockAutoValue:OFF", // we don't use autovalue
+ "DoubleBraceInitialization:OFF", // we don't use guava
+ "DoubleCheckedLocking:OFF", // TODO: there are problems
+ "DuplicateBranches:ERROR",
+ "DuplicateDateFormatField:WARN",
+ "DuplicateMapKeys:ERROR",
+ "DurationFrom:OFF", // we don't use Duration.from()
+ "DurationGetTemporalUnit:OFF", // we don't use Duration.get()
+ "DurationTemporalUnit:OFF", // we don't use Duration.of() etc
+ "DurationToLongTimeUnit:OFF", // we don't use TimeUnit.convert Duration, etc
+ "EffectivelyPrivate:ERROR", // TODO: many violations of this.
+ "EmptyBlockTag:OFF", // ECJ takes care
+ "EmptyCatch:OFF", // ECJ takes care
+ "EmptyIf:OFF", // TODO: new, not checked if applicable to Lucene
+ "EmptySetMultibindingContributions:OFF", // we don't use this annotation
+ "EmptyTopLevelDeclaration:OFF", // noisy
+ "EnumOrdinal:OFF", // noisy
+ "EqualsBrokenForNull:OFF", // TODO: new, not checked if applicable to Lucene
+ "EqualsGetClass:OFF", // noisy
+ "EqualsHashCode:ERROR",
+ "EqualsIncompatibleType:OFF",
+ "EqualsMissingNullable:OFF", // TODO: new, not checked if applicable to Lucene
+ "EqualsNaN:ERROR",
+ "EqualsNull:ERROR",
+ "EqualsReference:ERROR",
+ "EqualsUnsafeCast:OFF", // noisy
+ "EqualsUsingHashCode:WARN",
+ "EqualsWrongThing:ERROR",
+ "ErroneousBitwiseExpression:WARN",
+ "ErroneousThreadPoolConstructorChecker:WARN",
+ "EscapedEntity:OFF",
+ "ExpectedExceptionChecker:OFF", // TODO: new, not checked if applicable to Lucene
+ "ExpensiveLenientFormatString:OFF", // we use astgrep for this check.
+ "ExplicitArrayForVarargs:OFF", // TODO: new, not checked if applicable to Lucene
+ "ExtendingJUnitAssert:OFF", // noisy
+ "ExtendsAutoValue:OFF", // TODO: new, not checked if applicable to Lucene
+ "ExtendsObject:OFF", // TODO: there are problems
+ "FallThrough:OFF", // TODO: there are problems
+ "FieldCanBeFinal:OFF", // TODO: new, not checked if applicable to Lucene
+ "FieldCanBeLocal:OFF", // TODO: new, not checked if applicable to Lucene
+ "FieldCanBeStatic:OFF", // TODO: new, not checked if applicable to Lucene
+ "FieldMissingNullable:OFF", // TODO: new, not checked if applicable to Lucene
+ "Finalize:WARN",
+ "Finally:OFF", // TODO: there are problems
+ "FloatCast:WARN",
+ "FloatingPointAssertionWithinEpsilon:WARN",
+ "FloatingPointLiteralPrecision:OFF", // TODO: there are problems
+ "FloggerArgumentToString:OFF", // we don't use flogger
+ "FloggerFormatString:OFF", // we don't use flogger
+ "FloggerLogString:OFF", // TODO: new, not checked if applicable to Lucene
+ "FloggerLogVarargs:OFF", // we don't use flogger
+ "FloggerLogWithCause:OFF", // TODO: new, not checked if applicable to Lucene
+ "FloggerMessageFormat:OFF", // TODO: new, not checked if applicable to Lucene
+ "FloggerPerWithoutRateLimit:OFF", // TODO: new, not checked if applicable to Lucene
+ "FloggerRedundantIsEnabled:OFF", // TODO: new, not checked if applicable to Lucene
+ "FloggerRequiredModifiers:OFF", // TODO: new, not checked if applicable to Lucene
+ "FloggerSplitLogStatement:OFF", // we don't use flogger
+ "FloggerStringConcatenation:OFF", // we don't use flogger
+ "FloggerWithCause:OFF", // TODO: new, not checked if applicable to Lucene
+ "FloggerWithoutCause:OFF", // TODO: new, not checked if applicable to Lucene
+ "ForEachIterable:OFF", // TODO: new, not checked if applicable to Lucene
+ "ForOverride:OFF", // we don't use this annotation
+ "FormatString:ERROR",
+ "FormatStringAnnotation:OFF", // we don't use this annotation
+ "FragmentInjection:OFF", // we don't use android
+ "FragmentNotInstantiable:OFF", // we don't use android
+ "FromTemporalAccessor:OFF", // we don't use .from(LocalDate) etc
+ "FunctionalInterfaceClash:OFF", // TODO: new, not checked if applicable to Lucene
+ "FunctionalInterfaceMethodChanged:ERROR",
+ "FutureReturnValueIgnored:OFF", // TODO: there are problems
+ "FutureTransformAsync:OFF", // we don't use these google libraries
+ "FuturesGetCheckedIllegalExceptionType:OFF", // we don't use guava
+ "FuzzyEqualsShouldNotBeUsedInEqualsMethod:OFF", // we don't use guava
+ "GetClassOnAnnotation:ERROR",
+ "GetClassOnClass:ERROR",
+ "GetClassOnEnum:WARN",
+ "GuardedBy:OFF", // we don't use this annotation
+ "GuiceAssistedInjectScoping:OFF", // we don't use guice
+ "GuiceAssistedParameters:OFF", // we don't use guice
+ "GuiceInjectOnFinalField:OFF", // we don't use guice
+ "GuiceNestedCombine:OFF", // we don't use guice
+ "HardCodedSdCardPath:OFF", // TODO: new, not checked if applicable to Lucene
+ "HashtableContains:ERROR",
+ "HidingField:OFF", // noisy
+ "ICCProfileGetInstance:OFF", // we use forbidden-apis for this
+ "IdentifierName:OFF", // TODO: new, not checked if applicable to Lucene
+ "IdentityBinaryExpression:OFF",
+ "IdentityHashMapBoxing:ERROR",
+ "IdentityHashMapUsage:OFF", // noisy
+ "IgnoredPureGetter:OFF", // we don't use these annotations
+ "Immutable:OFF", // we don't use this annotation
+ "ImmutableAnnotationChecker:OFF", // we don't use this annotation
+ "ImmutableEnumChecker:OFF", // noisy
+ "ImmutableMemberCollection:OFF", // TODO: new, not checked if applicable to Lucene
+ "ImmutableRefactoring:OFF", // TODO: new, not checked if applicable to Lucene
+ "ImmutableSetForContains:OFF", // TODO: new, not checked if applicable to Lucene
+ "ImplementAssertionWithChaining:OFF", // TODO: new, not checked if applicable to Lucene
+ "ImpossibleNullComparison:OFF", // we don't use protobuf
+ "Incomparable:ERROR",
+ "IncompatibleArgumentType:OFF", // we don't use this annotation
+ "IncompatibleModifiers:OFF", // we don't use this annotation
+ "InconsistentCapitalization:OFF", // TODO: there are problems
+ "InconsistentHashCode:OFF", // noisy
+ "InconsistentOverloads:OFF", // TODO: new, not checked if applicable to Lucene
+ "IncorrectMainMethod:OFF", // we use ast-grep for this
+ "IncrementInForLoopAndHeader:WARN",
+ "IndexOfChar:ERROR",
+ "InexactVarargsConditional:ERROR",
+ "InfiniteRecursion:OFF",
+ "InheritDoc:WARN",
+ "InitializeInline:OFF", // TODO: new, not checked if applicable to Lucene
+ "InjectInvalidTargetingOnScopingAnnotation:OFF", // we don't use this annotation
+ "InjectMoreThanOneQualifier:OFF", // TODO: new, not checked if applicable to Lucene
+ "InjectMoreThanOneScopeAnnotationOnClass:OFF", // we don't use this annotation
+ "InjectOnBugCheckers:OFF", // we don't use this annotation
+ "InjectOnConstructorOfAbstractClass:OFF", // we don't use this annotation
+ "InjectOnMemberAndConstructor:OFF", // we don't use this annotation
+ "InjectScopeAnnotationOnInterfaceOrAbstractClass:OFF", // we don't use this annotation
+ "InjectedConstructorAnnotations:OFF", // we don't use this annotation
+ "InlineFormatString:OFF", // noisy
+ "InlineMeInliner:OFF", // we don't use this annotation
+ "InlineMeSuggester:OFF", // we don't use this annotation
+ "InlineMeValidator:OFF", // we don't use this annotation
+ "InlineTrivialConstant:OFF", // stylistic
+ "InputStreamSlowMultibyteRead:OFF",
+ "InsecureCryptoUsage:OFF", // TODO: new, not checked if applicable to Lucene
+ "InstanceOfAndCastMatchWrongType:WARN",
+ "InstantTemporalUnit:OFF", // we don't use Instant apis with strange temporal units
+ "IntFloatConversion:ERROR",
+ "IntLiteralCast:OFF", // TODO: there are problems
+ "IntLongMath:OFF", // noisy
+ "InterfaceWithOnlyStatics:OFF", // TODO: new, not checked if applicable to Lucene
+ "InterruptedExceptionSwallowed:OFF", // TODO: new, not checked if applicable to Lucene
+ "Interruption:OFF", // TODO: new, not checked if applicable to Lucene
+ "InvalidBlockTag:OFF", // noisy (e.g. lucene.experimental)
+ "InvalidInlineTag:OFF", // TODO: there are problems
+ "InvalidJavaTimeConstant:OFF", // we don't use impacted java.time classes
+ "InvalidLink:WARN",
+ "InvalidParam:OFF", // TODO: there are problems
+ "InvalidPatternSyntax:OFF",
+ "InvalidSnippet:ERROR",
+ "InvalidThrows:WARN",
+ "InvalidThrowsLink:WARN",
+ "InvalidTimeZoneID:OFF", // we don't use getTimeZone with constant IDs
+ "InvalidZoneId:OFF", // we don't use ZoneId.of
+ "IsInstanceIncompatibleType:ERROR",
+ "IsInstanceOfClass:ERROR",
+ "IsLoggableTagLength:OFF", // we don't use android
+ "IterableAndIterator:WARN",
+ "IterablePathParameter:OFF", // TODO: new, not checked if applicable to Lucene
+ "JUnit3FloatingPointComparisonWithoutDelta:OFF", // we don't use junit3
+ "JUnit3TestNotRun:OFF", // we don't use junit3
+ "JUnit4ClassAnnotationNonStatic:OFF", // we use ast-grep for this check
+ "JUnit4ClassUsedInJUnit3:OFF", // we don't use junit3
+ "JUnit4EmptyMethods:OFF", // we use ast-grep for this check
+ "JUnit4SetUpNotRun:OFF", // LuceneTestCase takes care
+ "JUnit4TearDownNotRun:OFF", // LuceneTestCase takes care
+ "JUnit4TestNotRun:OFF", // noisy
+ "JUnit4TestsNotRunWithinEnclosed:ERROR",
+ "JUnitAmbiguousTestClass:OFF", // we don't use junit3
+ "JUnitAssertSameCheck:ERROR",
+ "JUnitIncompatibleType:WARN",
+ "JUnitParameterMethodNotFound:ERROR",
+ "Java8ApiChecker:OFF", // TODO: new, not checked if applicable to Lucene
+ "JavaDurationGetSecondsGetNano:OFF", // we don't use these Duration methods
+ "JavaDurationGetSecondsToToSeconds:OFF", // we don't use these Duration methods
+ "JavaDurationWithNanos:OFF", // we don't use these Duration methods
+ "JavaDurationWithSeconds:OFF", // we don't use these Duration methods
+ "JavaInstantGetSecondsGetNano:OFF", // we don't use these Instant methods
+ "JavaLangClash:OFF", // TODO: there are problems
+ "JavaLocalDateTimeGetNano:OFF", // we don't use LocalDateTime
+ "JavaLocalTimeGetNano:OFF", // we don't use LocalTime
+ "JavaPeriodGetDays:OFF", // we don't use Period
+ "JavaTimeDefaultTimeZone:OFF", // forbidden-apis checks this
+ "JavaUtilDate:OFF", // noisy
+ "JavaxInjectOnAbstractMethod:OFF", // we don't this annotation
+ "JavaxInjectOnFinalField:OFF", // we don't use this annotation
+ "JdkObsolete:OFF", // noisy
+ "JodaConstructors:OFF", // we don't use joda-time
+ "JodaDateTimeConstants:OFF", // we don't use joda-time
+ "JodaDurationWithMillis:OFF", // we don't use joda-time
+ "JodaInstantWithMillis:OFF", // we don't use joda-time
+ "JodaNewPeriod:OFF", // we don't use joda-time
+ "JodaPlusMinusLong:OFF", // we don't use joda-time
+ "JodaTimeConverterManager:OFF", // we don't use joda-time
+ "JodaToSelf:OFF", // we don't use joda-time
+ "JodaWithDurationAddedLong:OFF", // we don't use joda-time
+ "LabelledBreakTarget:OFF", // stylistic
+ "LambdaFunctionalInterface:OFF", // TODO: new, not checked if applicable to Lucene
+ "LenientFormatStringValidation:OFF", // we don't use these google libraries
+ "LiteByteStringUtf8:OFF", // we don't use protobuf
+ "LiteEnumValueOf:OFF", // we don't use protobuf
+ "LiteProtoToString:OFF", // we don't use protobuf
+ "LocalDateTemporalAmount:OFF", // we don't use LocalDate math
+ "LockNotBeforeTry:OFF", // TODO: there are problems
+ "LockOnBoxedPrimitive:ERROR",
+ "LockOnNonEnclosingClassLiteral:OFF", // TODO: there are problems
+ "LogicalAssignment:WARN",
+ "LongDoubleConversion:WARN",
+ "LongFloatConversion:WARN",
+ "LongLiteralLowerCaseSuffix:OFF", // TODO: new, not checked if applicable to Lucene
+ "LoopConditionChecker:ERROR",
+ "LoopOverCharArray:WARN",
+ "LossyPrimitiveCompare:ERROR",
+ "MalformedInlineTag:WARN",
+ "MathAbsoluteNegative:OFF", // TODO: there are problems
+ "MathRoundIntLong:ERROR",
+ "MemoizeConstantVisitorStateLookups:OFF", // we don't use this class
+ "MethodCanBeStatic:OFF", // TODO: new, not checked if applicable to Lucene
+ "MisformattedTestData:OFF", // stylistic
+ "MislabeledAndroidString:OFF", // we don't use android
+ "MisleadingEmptyVarargs:ERROR",
+ "MisleadingEscapedSpace:ERROR",
+ "MisplacedScopeAnnotations:OFF", // we don't use this annotation
+ "MissingBraces:OFF", // TODO: new, not checked if applicable to Lucene
+ "MissingCasesInEnumSwitch:OFF", // redundant (ECJ has the same)
+ "MissingDefault:OFF", // TODO: new, not checked if applicable to Lucene
+ "MissingFail:OFF", // TODO: there are problems
+ "MissingImplementsComparable:WARN",
+ "MissingOverride:OFF", // ECJ takes care of this
+ "MissingRefasterAnnotation:OFF", // we don't use this annotation
+ "MissingRuntimeRetention:OFF", // we don't use this annotation
+ "MissingSummary:OFF", // TODO: there are problems
+ "MissingSuperCall:OFF", // we don't use this annotation
+ "MissingTestCall:OFF", // we don't use guava
+ "MisusedDayOfYear:OFF", // we don't use date patterns
+ "MisusedWeekYear:OFF", // we don't use date patterns
+ "MixedArrayDimensions:OFF", // TODO: new, not checked if applicable to Lucene
+ "MixedDescriptors:OFF", // we don't use protobuf
+ "MixedMutabilityReturnType:OFF", // noisy
+ "MockIllegalThrows:OFF", // we don't use mockito
+ "MockNotUsedInProduction:OFF", // we don't use mocking libraries
+ "MockitoDoSetup:OFF", // we don't use mocking libraries
+ "MockitoUsage:OFF", // we don't use mockito
+ "ModifiedButNotUsed:OFF", // TODO: there are problems
+ "ModifyCollectionInEnhancedForLoop:WARN",
+ "ModifySourceCollectionInStream:WARN",
+ "ModifyingCollectionWithItself:ERROR",
+ "MoreThanOneInjectableConstructor:OFF", // we don't use this annotation
+ "MultiVariableDeclaration:OFF", // TODO: new, not checked if applicable to Lucene
+ "MultimapKeys:WARN",
+ "MultipleNullnessAnnotations:OFF", // we don't use these annotations
+ "MultipleParallelOrSequentialCalls:WARN",
+ "MultipleTopLevelClasses:OFF", // TODO: new, not checked if applicable to Lucene
+ "MultipleUnaryOperatorsInMethodCall:WARN",
+ "MustBeClosedChecker:OFF", // we don't use this annotation
+ "MutableGuiceModule:OFF", // we don't use guice
+ "MutablePublicArray:OFF", // TODO: there are problems
+ "NCopiesOfChar:ERROR",
+ "NamedLikeContextualKeyword:WARN",
+ "NarrowCalculation:WARN",
+ "NarrowingCompoundAssignment:OFF", // noisy
+ "NegativeBoolean:OFF", // TODO: there are problems
+ "NegativeCharLiteral:WARN",
+ "NestedInstanceOfConditions:WARN",
+ "NewFileSystem:OFF", // we don't create new filesystems
+ "NoAllocation:OFF", // TODO: new, not checked if applicable to Lucene
+ "NoCanIgnoreReturnValueOnClasses:OFF", // we don't use this annotation
+ "NonApiType:OFF", // noisy
+ "NonAtomicVolatileUpdate:OFF", // TODO: there are problems
+ "NonCanonicalStaticImport:ERROR",
+ "NonCanonicalStaticMemberImport:OFF", // TODO: new, not checked if applicable to Lucene
+ "NonCanonicalType:OFF", // noisy
+ "NonFinalCompileTimeConstant:OFF", // we don't use this annotation
+ "NonFinalStaticField:WARN",
+ "NonOverridingEquals:WARN",
+ "NonRuntimeAnnotation:ERROR",
+ "NotJavadoc:WARN",
+ "NullArgumentForNonNullParameter:OFF", // we don't use this annotation
+ "NullOptional:WARN",
+ "NullTernary:ERROR",
+ "NullableConstructor:OFF", // we don't use this annotation
+ "NullableOnContainingClass:OFF", // we don't use this annotation
+ "NullableOptional:WARN",
+ "NullablePrimitive:OFF", // we don't use this annotation
+ "NullablePrimitiveArray:OFF", // we don't use this annotation
+ "NullableTypeParameter:OFF", // we don't use this annotation
+ "NullableVoid:OFF", // we don't use this annotation
+ "NullableWildcard:OFF", // we don't use this annotation
+ "ObjectEqualsForPrimitives:WARN",
+ "ObjectToString:OFF", // TODO: there are problems
+ "ObjectsHashCodePrimitive:OFF", // TODO: there are problems
+ "OperatorPrecedence:OFF", // noisy
+ "OptionalEquality:ERROR",
+ "OptionalMapToOptional:WARN",
+ "OptionalMapUnusedValue:ERROR",
+ "OptionalNotPresent:WARN",
+ "OptionalOfRedundantMethod:ERROR",
+ "OrphanedFormatString:WARN",
+ "OutlineNone:OFF", // we don't use gwt
+ "OverlappingQualifierAndScopeAnnotation:OFF", // we don't use this annotation
+ "OverrideThrowableToString:WARN",
+ "Overrides:WARN",
+ "OverridesGuiceInjectableMethod:OFF", // we don't use guice
+ "OverridesJavaxInjectableMethod:OFF", // we don't use this annotation
+ "OverridingMethodInconsistentArgumentNamesChecker:WARN",
+ "PackageInfo:OFF", // we use ast-grep for this check
+ "PackageLocation:OFF", // TODO: new, not checked if applicable to Lucene
+ "ParameterComment:OFF", // TODO: new, not checked if applicable to Lucene
+ "ParameterMissingNullable:OFF", // TODO: new, not checked if applicable to Lucene
+ "ParameterName:OFF", // we don't pass parameters with comments in this way
+ "ParametersButNotParameterized:ERROR",
+ "ParcelableCreator:OFF", // we don't use android
+ "PatternMatchingInstanceof:OFF", // there are problems and check seems not great
+ "PeriodFrom:OFF", // we don't use Period
+ "PeriodGetTemporalUnit:OFF", // we don't use Period
+ "PeriodTimeMath:OFF", // we don't use Period
+ "PreconditionsCheckNotNullRepeated:OFF", // we don't use guava
+ "PreconditionsInvalidPlaceholder:OFF", // we don't use guava
+ "PreferInstanceofOverGetKind:OFF", // TODO: new, not checked if applicable to Lucene
+ "PreferJavaTimeOverload:OFF", // TODO: new, not checked if applicable to Lucene
+ "PreferredInterfaceType:OFF", // TODO: new, not checked if applicable to Lucene
+ "PrimitiveArrayPassedToVarargsMethod:OFF", // TODO: new, not checked if applicable to Lucene
+ "PrimitiveAtomicReference:WARN",
+ "PrivateConstructorForNoninstantiableModule:OFF", // TODO: new, not checked if applicable to
+ // Lucene
+ "PrivateConstructorForUtilityClass:OFF", // TODO: new, not checked if applicable to Lucene
+ "PrivateSecurityContractProtoAccess:OFF", // we don't use protobuf
+ "ProtectedMembersInFinalClass:OFF", // we don't use protobuf
+ "ProtoBuilderReturnValueIgnored:OFF", // we don't use protobuf
+ "ProtoDurationGetSecondsGetNano:OFF", // we don't use protobuf
+ "ProtoStringFieldReferenceEquality:OFF", // we don't use protobuf
+ "ProtoTimestampGetSecondsGetNano:OFF", // we don't use protobuf
+ "ProtoTruthMixedDescriptors:OFF", // we don't use protobuf
+ "ProtocolBufferOrdinal:OFF", // we don't use protobuf
+ "ProvidesMethodOutsideOfModule:OFF", // we don't use guice
+ "PublicApiNamedStreamShouldReturnStream:OFF", // TODO: new, not checked if applicable to Lucene
+ "QualifierOrScopeOnInjectMethod:OFF", // we don't use this annotation
+ "QualifierWithTypeUse:OFF", // TODO: new, not checked if applicable to Lucene
+ "RandomCast:ERROR",
+ "RandomModInteger:ERROR",
+ "ReachabilityFenceUsage:WARN",
+ "RectIntersectReturnValueIgnored:OFF", // we don't use android
+ "RedundantControlFlow:OFF", // stylistic
+ "RedundantOverride:OFF", // TODO: new, not checked if applicable to Lucene
+ "RedundantSetterCall:OFF", // we don't use protobuf
+ "RedundantThrows:OFF", // TODO: new, not checked if applicable to Lucene
+ "ReferenceEquality:OFF", // noisy
+ "RefersToDaggerCodegen:OFF", // TODO: new, not checked if applicable to Lucene
+ "RemoveUnusedImports:OFF", // TODO: new, not checked if applicable to Lucene
+ "RequiredModifiers:OFF", // we don't use this annotation
+ "RestrictedApi:OFF", // we don't use this annotation
+ "RethrowReflectiveOperationExceptionAsLinkageError:WARN",
+ "ReturnAtTheEndOfVoidFunction:OFF", // stylistic
+ "ReturnFromVoid:WARN",
+ "ReturnMissingNullable:OFF", // TODO: new, not checked if applicable to Lucene
+ "ReturnValueIgnored:OFF", // noisy
+ "ReturnsNullCollection:OFF", // TODO: new, not checked if applicable to Lucene
+ "RobolectricShadowDirectlyOn:OFF", // we don't use robolectric
+ "RuleNotRun:ERROR",
+ "RxReturnValueIgnored:OFF", // we don't use rxjava
+ "SameNameButDifferent:OFF", // TODO: there are problems
+ "ScopeOnModule:OFF", // TODO: new, not checked if applicable to Lucene
+ "SelfAlwaysReturnsThis:OFF", // we don't use self() methods, this isn't python.
+ "SelfAssertion:ERROR",
+ "SelfAssignment:ERROR",
+ "SelfComparison:ERROR",
+ "SelfEquals:ERROR",
+ "SelfSet:ERROR",
+ "SetUnrecognized:OFF", // we don't use protobuf
+ "ShortCircuitBoolean:OFF", // TODO: there are problems
+ "ShouldHaveEvenArgs:OFF", // we don't use truth
+ "SizeGreaterThanOrEqualsZero:ERROR",
+ "StatementSwitchToExpressionSwitch:OFF", // TODO: there are problems
+ "StaticAssignmentInConstructor:OFF",
+ "StaticAssignmentOfThrowable:OFF", // noisy
+ "StaticGuardedByInstance:OFF",
+ "StaticMockMember:OFF", // we don't use mock libraries
+ "StaticOrDefaultInterfaceMethod:OFF", // TODO: new, not checked if applicable to Lucene
+ "StaticQualifiedUsingExpression:OFF", // TODO: new, not checked if applicable to Lucene
+ "StreamResourceLeak:OFF", // TODO: there are problems
+ "StreamToIterable:WARN",
+ "StreamToString:ERROR",
+ "StringBuilderInitWithChar:ERROR",
+ "StringCaseLocaleUsage:OFF", // noisy, can use forbidden-apis for this
+ "StringCharset:OFF", // we use ast-grep for this
+ "StringConcatToTextBlock:OFF", // TODO: there are problems
+ "StringFormatWithLiteral:WARN",
+ "StringJoin:OFF", // TODO: new, not checked if applicable to Lucene
+ "StringSplitter:OFF", // noisy, can use forbidden-apis for this
+ "StronglyTypeByteString:OFF", // TODO: new, not checked if applicable to Lucene
+ "StronglyTypeTime:OFF", // TODO: new, not checked if applicable to Lucene
+ "SubstringOfZero:OFF", // we use ast-grep for this check
+ "SunApi:OFF", // we use forbidden-apis for this
+ "SuperCallToObjectMethod:WARN",
+ "SuppressWarningsDeprecated:ERROR",
+ "SuppressWarningsWithoutExplanation:OFF", // TODO: new, not checked if applicable to Lucene
+ "SwigMemoryLeak:OFF", // we don't use swig
+ "SwitchDefault:OFF", // TODO: new, not checked if applicable to Lucene
+ "SymbolToString:OFF", // TODO: new, not checked if applicable to Lucene
+ "SynchronizeOnNonFinalField:OFF", // noisy
+ "SystemConsoleNull:WARN",
+ "SystemExitOutsideMain:OFF", // TODO: new, not checked if applicable to Lucene
+ "SystemOut:OFF", // TODO: new, not checked if applicable to Lucene
+ "TemporalAccessorGetChronoField:OFF", // we don't use TemporalAccessor.get
+ "TestExceptionChecker:OFF", // TODO: new, not checked if applicable to Lucene
+ "TestParametersNotInitialized:OFF", // we don't use this annotation
+ "TheoryButNoTheories:OFF", // we don't use junit theory apis/runner
+ "ThreadBuilderNameWithPlaceholder:OFF", // TODO: new, not checked if applicable to Lucene
+ "ThreadJoinLoop:OFF",
+ "ThreadLocalUsage:OFF", // noisy
+ "ThreadPriorityCheck:OFF", // noisy, forbidden APIs can do this
+ "ThreeLetterTimeZoneID:OFF", // we use ast-grep for this
+ "ThrowIfUncheckedKnownChecked:OFF", // we don't use this annotation
+ "ThrowIfUncheckedKnownUnchecked:OFF", // we don't use these google libraries
+ "ThrowNull:OFF", // noisy (LuceneTestCase)
+ "ThrowSpecificExceptions:OFF", // TODO: new, not checked if applicable to Lucene
+ "ThrowsUncheckedException:OFF", // TODO: new, not checked if applicable to Lucene
+ "TimeInStaticInitializer:ERROR",
+ "TimeUnitConversionChecker:WARN",
+ "TimeUnitMismatch:OFF", // TODO: new, not checked if applicable to Lucene
+ "ToStringReturnsNull:OFF", // TODO: there are problems
+ "TooManyParameters:OFF", // TODO: new, not checked if applicable to Lucene
+ "TraditionalSwitchExpression:OFF", // TODO: new, not checked if applicable to Lucene
+ "TransientMisuse:OFF", // TODO: new, not checked if applicable to Lucene
+ "TreeToString:OFF", // we don't use javac API
+ "TruthAssertExpected:OFF", // we don't use truth
+ "TruthConstantAsserts:OFF", // we don't use truth
+ "TruthContainsExactlyElementsInUsage:OFF", // we don't use truth
+ "TruthGetOrDefault:OFF", // we don't use truth
+ "TruthIncompatibleType:OFF", // we don't use truth
+ "TryFailRefactoring:OFF", // TODO: new, not checked if applicable to Lucene
+ "TryFailThrowable:OFF",
+ "TryWithResourcesVariable:OFF", // TODO: new, not checked if applicable to Lucene
+ "TypeEquals:OFF", // we don't use this internal javac api
+ "TypeNameShadowing:WARN",
+ "TypeParameterNaming:OFF", // TODO: new, not checked if applicable to Lucene
+ "TypeParameterQualifier:ERROR",
+ "TypeParameterShadowing:OFF",
+ "TypeParameterUnusedInFormals:OFF",
+ "TypeToString:OFF", // TODO: new, not checked if applicable to Lucene
+ "URLEqualsHashCode:WARN",
+ "UndefinedEquals:OFF", // TODO: there are problems
+ "UnescapedEntity:OFF", // TODO: there are problems
+ "UngroupedOverloads:OFF", // TODO: new, not checked if applicable to Lucene
+ "UnicodeDirectionalityCharacters:ERROR",
+ "UnicodeEscape:OFF", // noisy
+ "UnicodeInCode:ERROR",
+ "UnnecessarilyFullyQualified:OFF", // TODO: new, not checked if applicable to Lucene
+ "UnnecessarilyUsedValue:OFF", // TODO: new, not checked if applicable to Lucene
+ "UnnecessarilyVisible:OFF", // TODO: new, not checked if applicable to Lucene
+ "UnnecessaryAnonymousClass:OFF", // TODO: new, not checked if applicable to Lucene
+ "UnnecessaryAssignment:OFF", // we don't use these annotations
+ "UnnecessaryAsync:WARN",
+ "UnnecessaryBoxedAssignment:OFF", // TODO: new, not checked if applicable to Lucene
+ "UnnecessaryBoxedVariable:OFF", // TODO: new, not checked if applicable to Lucene
+ "UnnecessaryBreakInSwitch:WARN",
+ "UnnecessaryCheckNotNull:ERROR",
+ "UnnecessaryCopy:OFF", // we don't use google collections
+ "UnnecessaryDefaultInEnumSwitch:OFF", // TODO: new, not checked if applicable to Lucene
+ "UnnecessaryFinal:OFF", // TODO: new, not checked if applicable to Lucene
+ "UnnecessaryLambda:OFF", // TODO: there are problems
+ "UnnecessaryLongToIntConversion:OFF", // TODO: there are problems
+ "UnnecessaryMethodInvocationMatcher:OFF", // we don't use spring
+ "UnnecessaryMethodReference:WARN",
+ "UnnecessaryOptionalGet:OFF", // TODO: new, not checked if applicable to Lucene
+ "UnnecessaryParentheses:OFF", // noisy
+ "UnnecessaryQualifier:OFF", // we don't use guava
+ "UnnecessarySetDefault:OFF", // TODO: new, not checked if applicable to Lucene
+ "UnnecessaryStaticImport:OFF", // TODO: new, not checked if applicable to Lucene
+ "UnnecessaryStringBuilder:WARN",
+ "UnnecessaryTestMethodPrefix:OFF", // stylistic
+ "UnnecessaryTypeArgument:ERROR",
+ "UnrecognisedJavadocTag:WARN",
+ "UnsafeFinalization:OFF", // we don't use finalizers, deprecated for removal, fails build
+ "UnsafeLocaleUsage:OFF", // TODO: new, not checked if applicable to Lucene
+ "UnsafeReflectiveConstructionCast:WARN",
+ "UnsafeWildcard:ERROR",
+ "UnsynchronizedOverridesSynchronized:OFF", // TODO: there are problems
+ "UnusedAnonymousClass:ERROR",
+ "UnusedCollectionModifiedInPlace:ERROR",
+ "UnusedException:OFF", // TODO: new, not checked if applicable to Lucene
+ "UnusedLabel:OFF", // TODO: there are problems
+ "UnusedMethod:OFF", // TODO: there are problems
+ "UnusedNestedClass:WARN",
+ "UnusedTypeParameter:OFF", // TODO: there are problems
+ "UnusedVariable:OFF", // noisy, can use ECJ
+ "UrlInSee:OFF", // TODO: new, not checked if applicable to Lucene
+ "UseBinds:OFF", // we don't use this annotation
+ "UseCorrectAssertInTests:OFF", // noisy
+ "UseEnumSwitch:OFF", // TODO: new, not checked if applicable to Lucene
+ "UsingJsr305CheckReturnValue:OFF", // TODO: new, not checked if applicable to Lucene
+ "Var:OFF", // TODO: new, not checked if applicable to Lucene
+ "VarTypeName:ERROR",
+ "VariableNameSameAsType:WARN",
+ "Varifier:OFF", // TODO: new, not checked if applicable to Lucene
+ "VoidMissingNullable:OFF", // TODO: new, not checked if applicable to Lucene
+ "VoidUsed:WARN",
+ "WaitNotInLoop:OFF", // TODO: there are problems
+ "WakelockReleasedDangerously:OFF", // we don't use android
+ "WildcardImport:OFF", // we use ast-grep for this check.
+ "WithSignatureDiscouraged:OFF", // we aren't using this error-prone internal api
+ "WrongOneof:OFF", // we don't use protobuf
+ "XorPower:ERROR",
+ "YodaCondition:OFF", // TODO: new, not checked if applicable to Lucene
+ "ZoneIdOfZ:OFF", // we don't use ZoneId.of
+ };
+
+ private static final Map<String, CheckSeverity> ALL_CHECKS_PARSED =
+ Stream.of(ALL_CHECKS)
+ .map(
+ check -> {
+ var colon = check.indexOf(":");
+ var checkName = check.substring(0, colon);
+ var severity = CheckSeverity.valueOf(check.substring(colon + 1));
+ return Map.entry(checkName, severity);
+ })
+ .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
+
+ /** Filter out all checks which are disabled. */
+ private static final Map<String, CheckSeverity> ENABLED_CHECKS =
+ ALL_CHECKS_PARSED.entrySet().stream()
+ .filter(e -> e.getValue() == CheckSeverity.OFF)
+ .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
+
+ private void configureErrorProne(Project project) {
+ // Apply the actual errorprone plugin.
+ project.getPlugins().apply(net.ltgt.gradle.errorprone.ErrorPronePlugin.class);
+
+ applyLocalDependency(project);
+
+ project
+ .getTasks()
+ .withType(JavaCompile.class)
+ .configureEach(
+ t -> {
+ t.dependsOn(":" + CheckEnvironmentPlugin.CHECK_JDK_INTERNALS_EXPOSED_TO_GRADLE_TASK);
+
+ var epOptions =
+ ((ExtensionAware) t.getOptions())
+ .getExtensions()
+ .getByType(ErrorProneOptions.class);
+
+ epOptions.getDisableWarningsInGeneratedCode().set(true);
+ epOptions.getAllErrorsAsWarnings().set(true);
+
+ // In case a named check is removed, fail.
+ epOptions.getIgnoreUnknownCheckNames().set(false);
+
+ // Turn off everything by default, then re-enable what's needed.
+ epOptions.getDisableAllChecks().set(true);
+ epOptions.getChecks().putAll(ENABLED_CHECKS);
+
+ // Exclude certain files (generated ones, mostly).
+ List<String> excludedPaths =
+ switch (project.getPath()) {
+ case ":lucene:core" -> List.of(".*/StandardTokenizerImpl.java");
+ case ":lucene:analysis:common" ->
+ List.of(
+ ".*/HTMLStripCharFilter.java", ".*/UAX29URLEmailTokenizerImpl.java");
+ case ":lucene:test-framework" ->
+ List.of(
+ ".*/EmojiTokenizationTestUnicode_11_0.java",
+ ".*/WordBreakTestUnicode_9_0_0.java");
+ case ":lucene:queryparser" ->
+ List.of(
+ ".*/classic/ParseException.java",
+ ".*/classic/QueryParser.java",
+ ".*/classic/QueryParserConstants.java",
+ ".*/classic/QueryParserTokenManager.java",
+ ".*/classic/Token.java",
+ ".*/classic/TokenMgrError.java",
+ ".*/standard/parser/ParseException.java",
+ ".*/standard/parser/StandardSyntaxParser.java",
+ ".*/standard/parser/StandardSyntaxParserConstants.java",
+ ".*/standard/parser/StandardSyntaxParserTokenManager.java",
+ ".*/standard/parser/Token.java",
+ ".*/standard/parser/TokenMgrError.java",
+ ".*/surround/parser/ParseException.java",
+ ".*/surround/parser/QueryParser.java",
+ ".*/surround/parser/QueryParserConstants.java",
+ ".*/surround/parser/QueryParserTokenManager.java",
+ ".*/surround/parser/Token.java",
+ ".*/surround/parser/TokenMgrError.java");
+ default -> List.of();
+ };
+
+ if (!excludedPaths.isEmpty()) {
+ epOptions.getExcludedPaths().set(String.join("|", excludedPaths));
+ }
+ });
+ }
+
+ // Add the local version of errorprone to the errorprone configuration.
+ private static void applyLocalDependency(Project project) {
+ project
+ .getDependencies()
+ .add("errorprone", getVersionCatalog(project).findLibrary("errorprone").get());
+ }
+}
diff --git a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/java/JavaFolderLayoutPlugin.java b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/java/JavaFolderLayoutPlugin.java
index 2094e4e8c1f..fd0e5d726a8 100644
--- a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/java/JavaFolderLayoutPlugin.java
+++ b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/java/JavaFolderLayoutPlugin.java
@@ -40,20 +40,6 @@ public class JavaFolderLayoutPlugin extends LuceneGradlePlugin {
mainSrcSet.java(srcSetDir -> srcSetDir.setSrcDirs(List.of("src/java")));
mainSrcSet.resources(resources -> resources.setSrcDirs(List.of("src/resources")));
- // point build-infra-shadow's main sources at build-infra sources so that we can
- // reapply the build to ourselves.
- if (project.getPath().equals(":build-tools:build-infra-shadow")
- && !getLuceneBuildGlobals(project).getIntellijIdea().get().isIdea()) {
- mainSrcSet.java(
- srcSetDir -> {
- srcSetDir.setSrcDirs(
- List.of(
- getProjectRootPath(project)
- .resolve("build-tools/build-infra/src/main/java")
- .toFile()));
- });
- }
-
SourceSet testSrcSet = sourceSets.named("test").get();
testSrcSet.java(srcSetDir -> srcSetDir.setSrcDirs(List.of("src/test")));
testSrcSet.resources(resources -> resources.setSrcDirs(List.of("src/test-files")));
diff --git a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/java/JavaProjectConventionsPlugin.java b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/java/JavaProjectConventionsPlugin.java
index dedb8499df4..3b331c8ab84 100644
--- a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/java/JavaProjectConventionsPlugin.java
+++ b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/java/JavaProjectConventionsPlugin.java
@@ -56,5 +56,6 @@ public class JavaProjectConventionsPlugin extends LuceneGradlePlugin {
plugins.apply(CodeCoveragePlugin.class);
plugins.apply(ShowSlowestTestsAtEndPlugin.class);
plugins.apply(ShowFailedTestsAtEndPlugin.class);
+ plugins.apply(ErrorPronePlugin.class);
}
}
diff --git a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/misc/CleanupVersionsFilePlugin.java b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/misc/CleanupVersionsFilePlugin.java
new file mode 100644
index 00000000000..3a463b45fed
--- /dev/null
+++ b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/misc/CleanupVersionsFilePlugin.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.lucene.gradle.plugins.misc;
+
+import nl.littlerobots.vcu.plugin.VersionCatalogFormatTask;
+import nl.littlerobots.vcu.plugin.VersionCatalogUpdateExtension;
+import nl.littlerobots.vcu.plugin.VersionCatalogUpdatePlugin;
+import nl.littlerobots.vcu.plugin.VersionCatalogUpdateTask;
+import org.apache.lucene.gradle.plugins.LuceneGradlePlugin;
+import org.apache.tools.ant.taskdefs.FixCRLF;
+import org.gradle.api.Project;
+
+/** Apply cleanups to {@code gradle/libs.gradle.toml}. */
+public class CleanupVersionsFilePlugin extends LuceneGradlePlugin {
+ @Override
+ public void apply(Project rootProject) {
+ applicableToRootProjectOnly(rootProject);
+
+ rootProject.getPlugins().apply(VersionCatalogUpdatePlugin.class);
+
+ // apply and configure the version catalog update plugin.
+ var versionCatalogUpdate =
+ rootProject.getExtensions().getByType(VersionCatalogUpdateExtension.class);
+ versionCatalogUpdate.getSortByKey().set(true);
+
+ // Hook up version catalog formatting to tidy.
+ var tasks = rootProject.getTasks();
+ var formatDepsTask =
+ tasks.withType(VersionCatalogFormatTask.class).named("versionCatalogFormat");
+
+ // correct crlf and the default encoding after version
+ // catalog formatting finishes. It is a pity it cannot be specified as the
+ // task's parameters.
+ formatDepsTask.configure(
+ task -> {
+ task.doLast(
+ _ -> {
+ var fixcrlf = (FixCRLF) task.getAnt().getAntProject().createTask("fixcrlf");
+ fixcrlf.setFile(task.getCatalogFile().getAsFile().get());
+ fixcrlf.setFixlast(true);
+ var lf = new FixCRLF.CrLf();
+ lf.setValue("lf");
+ fixcrlf.setEol(lf);
+ fixcrlf.setOutputEncoding("UTF-8");
+ fixcrlf.execute();
+ });
+ });
+
+ tasks
+ .named("tidy")
+ .configure(
+ task -> {
+ task.dependsOn(formatDepsTask);
+ });
+
+ // Configure versionCatalogUpdate task to be interactive (not automatically overwrite).
+ var updateDepsTask =
+ tasks.withType(VersionCatalogUpdateTask.class).named("versionCatalogUpdate");
+
+ updateDepsTask.configure(
+ task -> {
+ task.setInteractive(true);
+ });
+ }
+}
diff --git a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/misc/RootProjectSetupPlugin.java b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/misc/RootProjectSetupPlugin.java
index 08349c1a247..8ffe33969cf 100644
--- a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/misc/RootProjectSetupPlugin.java
+++ b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/misc/RootProjectSetupPlugin.java
@@ -79,6 +79,7 @@ public class RootProjectSetupPlugin extends LuceneGradlePlugin {
plugins.apply(CheckLicensesPlugin.class);
plugins.apply(ConfigureLockFilePlugin.class);
plugins.apply(CheckGradlewScriptsTweakedPlugin.class);
+ plugins.apply(CleanupVersionsFilePlugin.class);
plugins.apply(EclipseSupportPlugin.class);
plugins.apply(IdeaSupportPlugin.class);
diff --git a/build.gradle b/build.gradle
index 2e11e81b99c..07f8a7df129 100644
--- a/build.gradle
+++ b/build.gradle
@@ -25,9 +25,6 @@ plugins {
id "lucene.java-projects.conventions"
id "lucene.java.modules"
-
- id "lucene.validation.gradle-versions-cleanup"
- id "lucene.validation.error-prone"
id "lucene.validation.jar-checks"
id "lucene.publications.maven"