Apache Lucene open-source search software
ecj: enable possibleAccidentalBooleanAssignment and fix issues (#14966)
Robert Muir346d7624db51
diff --git a/gradle/validation/ecj-lint/ecj.javadocs.prefs b/gradle/validation/ecj-lint/ecj.javadocs.prefsindex 5796a7ec002..ee8d648367e 100644--- a/gradle/validation/ecj-lint/ecj.javadocs.prefs+++ b/gradle/validation/ecj-lint/ecj.javadocs.prefs@@ -89,7 +89,7 @@ org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=errororg.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=errororg.eclipse.jdt.core.compiler.problem.parameterAssignment=ignoreorg.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=error-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=errororg.eclipse.jdt.core.compiler.problem.potentialNullReference=ignoreorg.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignoreorg.eclipse.jdt.core.compiler.problem.rawTypeReference=errordiff --git a/lucene/core/src/java/org/apache/lucene/index/ConcurrentApproximatePriorityQueue.java b/lucene/core/src/java/org/apache/lucene/index/ConcurrentApproximatePriorityQueue.javaindex 8a8fc72ab4c..6309276fdc6 100644--- a/lucene/core/src/java/org/apache/lucene/index/ConcurrentApproximatePriorityQueue.java+++ b/lucene/core/src/java/org/apache/lucene/index/ConcurrentApproximatePriorityQueue.java@@ -136,7 +136,7 @@ final class ConcurrentApproximatePriorityQueue<T> {// Only used for assertionsboolean contains(Object o) {boolean assertionsAreEnabled = false;- assert assertionsAreEnabled = true;+ assert (assertionsAreEnabled = true) == true; // Intentional side-effect!!!if (assertionsAreEnabled == false) {throw new AssertionError("contains should only be used for assertions");}diff --git a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/bbox/BBoxStrategy.java b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/bbox/BBoxStrategy.javaindex f7192ec87c5..3fe7af422db 100644--- a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/bbox/BBoxStrategy.java+++ b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/bbox/BBoxStrategy.java@@ -138,19 +138,22 @@ public class BBoxStrategy extends SpatialStrategy {fieldType.freeze();this.optionsFieldType = fieldType;+ this.hasStored = fieldType.stored();+ this.hasDocVals = fieldType.docValuesType() != DocValuesType.NONE;+ this.hasPointVals = fieldType.pointDimensionCount() > 0;int numQuads = 0;- if ((this.hasStored = fieldType.stored())) {- numQuads++;- }- if ((this.hasDocVals = fieldType.docValuesType() != DocValuesType.NONE)) {++ if (hasStored) {numQuads++;}- if ((this.hasPointVals = fieldType.pointDimensionCount() > 0)) {++ if (hasDocVals) {numQuads++;}if (hasPointVals) { // if we have an index...+ numQuads++;xdlFieldType = new FieldType(StringField.TYPE_NOT_STORED);xdlFieldType.setIndexOptions(IndexOptions.DOCS);xdlFieldType.freeze();diff --git a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/vector/PointVectorStrategy.java b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/vector/PointVectorStrategy.javaindex b3d58fd1dc9..5cb44939f81 100644--- a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/vector/PointVectorStrategy.java+++ b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/vector/PointVectorStrategy.java@@ -126,15 +126,18 @@ public class PointVectorStrategy extends SpatialStrategy {super(ctx, fieldNamePrefix);this.fieldNameX = fieldNamePrefix + SUFFIX_X;this.fieldNameY = fieldNamePrefix + SUFFIX_Y;+ this.hasStored = fieldType.stored();+ this.hasDocVals = fieldType.docValuesType() != DocValuesType.NONE;+ this.hasPointVals = fieldType.pointDimensionCount() > 0;int numPairs = 0;- if ((this.hasStored = fieldType.stored())) {+ if (hasStored) {numPairs++;}- if ((this.hasDocVals = fieldType.docValuesType() != DocValuesType.NONE)) {+ if (hasDocVals) {numPairs++;}- if ((this.hasPointVals = fieldType.pointDimensionCount() > 0)) {+ if (hasPointVals) {numPairs++;}this.fieldsLen = numPairs * 2;diff --git a/lucene/test-framework/src/java/org/apache/lucene/tests/util/LuceneTestCase.java b/lucene/test-framework/src/java/org/apache/lucene/tests/util/LuceneTestCase.javaindex 6ea9855e218..1ba5848d0f1 100644--- a/lucene/test-framework/src/java/org/apache/lucene/tests/util/LuceneTestCase.java+++ b/lucene/test-framework/src/java/org/apache/lucene/tests/util/LuceneTestCase.java@@ -3120,7 +3120,7 @@ public abstract class LuceneTestCase extends Assert {static {boolean enabled = false;- assert enabled = true; // Intentional side-effect!!!+ assert (enabled = true) == true; // Intentional side-effect!!!assertsAreEnabled = enabled;}