You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2021/03/22 22:29:14 UTC

[lucene] branch jira/LUCENE-9856-static-analysis updated: LUCENE-9856: remove more unused local variables

This is an automated email from the ASF dual-hosted git repository.

rmuir pushed a commit to branch jira/LUCENE-9856-static-analysis
in repository https://gitbox.apache.org/repos/asf/lucene.git


The following commit(s) were added to refs/heads/jira/LUCENE-9856-static-analysis by this push:
     new e14a679  LUCENE-9856: remove more unused local variables
e14a679 is described below

commit e14a679e908bdb34eb4c677c11b8d0d60ba05dc3
Author: Robert Muir <rm...@apache.org>
AuthorDate: Mon Mar 22 18:28:17 2021 -0400

    LUCENE-9856: remove more unused local variables
    
    This fixes all the instances, except for the ones in generated code.
---
 .../charfilter/TestHTMLStripCharFilter.java        |  3 +-
 .../analysis/cjk/TestCJKBigramFilterFactory.java   | 11 ++---
 .../apache/lucene/analysis/core/TestAnalyzers.java |  2 +
 .../lucene/analysis/ngram/TestNGramTokenizer.java  |  2 +-
 .../pattern/TestSimplePatternSplitTokenizer.java   | 12 ++---
 .../wikipedia/TestWikipediaTokenizerFactory.java   |  3 +-
 .../opennlp/TestOpenNLPTokenizerFactory.java       | 14 +++---
 .../analysis/cn/smart/hhmm/BigramDictionary.java   |  3 +-
 .../stempel/src/java/org/egothor/stemmer/Trie.java |  3 +-
 .../lucene70/Lucene70SegmentInfoFormat.java        | 12 ++---
 .../backward_codecs/lucene80/TestIndexedDISI.java  |  5 +-
 .../codecs/lucene86/Lucene86SegmentInfoFormat.java |  2 +-
 .../codecs/lucene90/Lucene90FieldInfosFormat.java  | 12 ++---
 .../org/apache/lucene/analysis/TestStopFilter.java |  3 +-
 .../lucene/codecs/lucene90/TestIndexedDISI.java    |  5 +-
 .../lucene/index/Test2BSortedDocValuesOrds.java    |  1 -
 .../lucene/index/TestDemoParallelLeafReader.java   |  5 +-
 .../src/test/org/apache/lucene/index/TestDoc.java  |  2 +-
 .../org/apache/lucene/index/TestIndexSorting.java  |  2 -
 .../org/apache/lucene/index/TestIndexWriter.java   |  1 -
 .../apache/lucene/index/TestIndexWriterCommit.java |  2 -
 .../lucene/index/TestIndexWriterExceptions.java    |  2 +-
 .../lucene/index/TestIndexWriterOnDiskFull.java    |  3 --
 .../lucene/index/TestNumericDocValuesUpdates.java  |  7 ---
 .../apache/lucene/index/TestStressIndexing.java    |  3 +-
 .../apache/lucene/index/TestTermVectorsReader.java |  1 -
 .../apache/lucene/index/TestTermsHashPerField.java |  2 +-
 .../org/apache/lucene/search/TestBoolean2.java     |  3 --
 .../search/TestControlledRealTimeReopenThread.java |  2 +-
 .../apache/lucene/search/TestLongValuesSource.java |  1 -
 .../apache/lucene/search/TestMatchesIterator.java  |  2 -
 .../org/apache/lucene/search/TestTermQuery.java    |  3 --
 .../org/apache/lucene/store/TestMultiMMap.java     |  2 +-
 .../lucene/store/TestNRTCachingDirectory.java      |  3 +-
 .../test/org/apache/lucene/util/bkd/TestBKD.java   |  2 -
 .../test/org/apache/lucene/util/fst/TestFSTs.java  |  1 -
 .../lucene/expressions/js/JavascriptCompiler.java  |  2 +-
 .../java/org/apache/lucene/facet/FacetsConfig.java |  8 ----
 .../lucene/facet/TestLongValueFacetCounts.java     |  3 --
 .../directory/TestDirectoryTaxonomyReader.java     |  3 --
 .../grouping/TestAllGroupHeadsCollector.java       |  1 -
 .../lucene/search/grouping/TestGrouping.java       |  1 -
 .../uhighlight/TestUnifiedHighlighterMTQ.java      |  2 +-
 .../luke/models/documents/TestDocumentsImpl.java   | 18 ++++----
 .../apache/lucene/index/memory/MemoryIndex.java    |  7 +--
 .../apache/lucene/misc/util/fst/TestFSTsMisc.java  |  1 -
 .../lucene/queryparser/flexible/messages/NLS.java  |  5 +-
 .../flexible/standard/TestMultiFieldQPHelper.java  |  1 -
 .../TestIndexAndTaxonomyReplicationClient.java     |  3 +-
 .../lucene/replicator/nrt/SimplePrimaryNode.java   |  3 --
 .../lucene/replicator/nrt/SimpleReplicaNode.java   |  2 +-
 .../lucene/replicator/nrt/TestNRTReplication.java  |  2 -
 .../replicator/nrt/TestStressNRTReplication.java   |  9 ----
 .../idversion/TestIDVersionPostingsFormat.java     |  1 -
 .../sandbox/search/TestTermAutomatonQuery.java     |  2 +-
 .../spatial/prefix/tree/DateRangePrefixTree.java   |  1 -
 .../lucene/spatial/bbox/TestBBoxStrategy.java      |  3 +-
 .../prefix/TestRandomSpatialOpFuzzyPrefixTree.java |  2 -
 .../prefix/TestTermQueryPrefixGridStrategy.java    |  3 +-
 .../prefix/tree/TestDateRangePrefixTree.java       |  2 -
 .../TestGeo3dShapeWGS84ModelRectRelation.java      |  2 -
 .../apache/lucene/spatial3d/TestGeo3DPoint.java    |  8 ++--
 .../apache/lucene/spatial3d/geom/TestGeoBBox.java  |  1 -
 .../lucene/spatial3d/geom/TestGeoExactCircle.java  | 24 ++++------
 .../apache/lucene/spatial3d/geom/TestGeoPath.java  | 21 ++++-----
 .../lucene/spatial3d/geom/TestGeoPolygon.java      | 53 ++++++++--------------
 .../spatial3d/geom/TestRandomGeoPolygon.java       |  2 +-
 .../search/suggest/document/NRTSuggester.java      |  2 +-
 .../codecs/asserting/AssertingDocValuesFormat.java |  6 +--
 .../codecs/asserting/AssertingNormsFormat.java     |  2 +-
 .../lucene/index/BasePostingsFormatTestCase.java   |  1 -
 .../org/apache/lucene/util/TestExpectThrows.java   | 37 +++++++--------
 72 files changed, 128 insertions(+), 258 deletions(-)

diff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/charfilter/TestHTMLStripCharFilter.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/charfilter/TestHTMLStripCharFilter.java
index 76aa70b..d91baa6 100644
--- a/lucene/analysis/common/src/test/org/apache/lucene/analysis/charfilter/TestHTMLStripCharFilter.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/charfilter/TestHTMLStripCharFilter.java
@@ -358,9 +358,8 @@ public class TestHTMLStripCharFilter extends BaseTokenStreamTestCase {
   static void assertLegalOffsets(String in) throws Exception {
     int length = in.length();
     HTMLStripCharFilter reader = new HTMLStripCharFilter(new BufferedReader(new StringReader(in)));
-    int ch = 0;
     int off = 0;
-    while ((ch = reader.read()) != -1) {
+    while (reader.read() != -1) {
       int correction = reader.correctOffset(off);
       assertTrue(
           "invalid offset correction: " + off + "->" + correction + " for doc of length: " + length,
diff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/cjk/TestCJKBigramFilterFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/cjk/TestCJKBigramFilterFactory.java
index b7bbb24..2bf8bed 100644
--- a/lucene/analysis/common/src/test/org/apache/lucene/analysis/cjk/TestCJKBigramFilterFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/cjk/TestCJKBigramFilterFactory.java
@@ -56,11 +56,10 @@ public class TestCJKBigramFilterFactory extends BaseTokenStreamFactoryTestCase {
 
   /** Test that bogus arguments result in exception */
   public void testBogusArguments() throws Exception {
-    IllegalArgumentException expected =
-        expectThrows(
-            IllegalArgumentException.class,
-            () -> {
-              tokenFilterFactory("CJKBigram", "bogusArg", "bogusValue");
-            });
+    expectThrows(
+        IllegalArgumentException.class,
+        () -> {
+          tokenFilterFactory("CJKBigram", "bogusArg", "bogusValue");
+        });
   }
 }
diff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestAnalyzers.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestAnalyzers.java
index 31bb9f1..c1161fa 100644
--- a/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestAnalyzers.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestAnalyzers.java
@@ -109,7 +109,9 @@ public class TestAnalyzers extends BaseTokenStreamTestCase {
     x = StandardTokenizer.HIRAGANA;
     x = StandardTokenizer.KATAKANA;
     x = StandardTokenizer.HANGUL;
+    assert x >= 0;
     String[] y = StandardTokenizer.TOKEN_TYPES;
+    assert y != null;
   }
 
   private static class LowerCaseWhitespaceAnalyzer extends Analyzer {
diff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/ngram/TestNGramTokenizer.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/ngram/TestNGramTokenizer.java
index f0b1066..5908cdf 100644
--- a/lucene/analysis/common/src/test/org/apache/lucene/analysis/ngram/TestNGramTokenizer.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/ngram/TestNGramTokenizer.java
@@ -44,7 +44,7 @@ public class TestNGramTokenizer extends BaseTokenStreamTestCase {
     expectThrows(
         IllegalArgumentException.class,
         () -> {
-          NGramTokenizer tok = new NGramTokenizer(2, 1);
+          new NGramTokenizer(2, 1);
         });
   }
 
diff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/pattern/TestSimplePatternSplitTokenizer.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/pattern/TestSimplePatternSplitTokenizer.java
index 2cafcfc..82fc2ec 100644
--- a/lucene/analysis/common/src/test/org/apache/lucene/analysis/pattern/TestSimplePatternSplitTokenizer.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/pattern/TestSimplePatternSplitTokenizer.java
@@ -70,7 +70,7 @@ public class TestSimplePatternSplitTokenizer extends BaseTokenStreamTestCase {
 
   public void testNoTokens() throws Exception {
     Tokenizer t = new SimplePatternSplitTokenizer(".*");
-    CharTermAttribute termAtt = t.getAttribute(CharTermAttribute.class);
+    t.getAttribute(CharTermAttribute.class);
     String s;
     while (true) {
       s = TestUtil.randomUnicodeString(random());
@@ -95,7 +95,7 @@ public class TestSimplePatternSplitTokenizer extends BaseTokenStreamTestCase {
 
   public void testSplitSingleCharWhitespace() throws Exception {
     Tokenizer t = new SimplePatternSplitTokenizer("[ \t\r\n]");
-    CharTermAttribute termAtt = t.getAttribute(CharTermAttribute.class);
+    t.getAttribute(CharTermAttribute.class);
     t.setReader(new StringReader("a \tb   c"));
     assertTokenStreamContents(
         t, new String[] {"a", "b", "c"}, new int[] {0, 3, 7}, new int[] {1, 4, 8});
@@ -103,7 +103,7 @@ public class TestSimplePatternSplitTokenizer extends BaseTokenStreamTestCase {
 
   public void testSplitMultiCharWhitespace() throws Exception {
     Tokenizer t = new SimplePatternSplitTokenizer("[ \t\r\n]*");
-    CharTermAttribute termAtt = t.getAttribute(CharTermAttribute.class);
+    t.getAttribute(CharTermAttribute.class);
     t.setReader(new StringReader("a \tb   c"));
     assertTokenStreamContents(
         t, new String[] {"a", "b", "c"}, new int[] {0, 3, 7}, new int[] {1, 4, 8});
@@ -111,21 +111,21 @@ public class TestSimplePatternSplitTokenizer extends BaseTokenStreamTestCase {
 
   public void testLeadingNonToken() throws Exception {
     Tokenizer t = new SimplePatternSplitTokenizer("[ \t\r\n]*");
-    CharTermAttribute termAtt = t.getAttribute(CharTermAttribute.class);
+    t.getAttribute(CharTermAttribute.class);
     t.setReader(new StringReader("    a c"));
     assertTokenStreamContents(t, new String[] {"a", "c"}, new int[] {4, 6}, new int[] {5, 7});
   }
 
   public void testTrailingNonToken() throws Exception {
     Tokenizer t = new SimplePatternSplitTokenizer("[ \t\r\n]*");
-    CharTermAttribute termAtt = t.getAttribute(CharTermAttribute.class);
+    t.getAttribute(CharTermAttribute.class);
     t.setReader(new StringReader("a c   "));
     assertTokenStreamContents(t, new String[] {"a", "c"}, new int[] {0, 2}, new int[] {1, 3});
   }
 
   public void testEmptyStringPatternOneMatch() throws Exception {
     Tokenizer t = new SimplePatternSplitTokenizer("a*");
-    CharTermAttribute termAtt = t.getAttribute(CharTermAttribute.class);
+    t.getAttribute(CharTermAttribute.class);
     t.setReader(new StringReader("bbab"));
     assertTokenStreamContents(t, new String[] {"bb", "b"}, new int[] {0, 3}, new int[] {2, 4});
   }
diff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/wikipedia/TestWikipediaTokenizerFactory.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/wikipedia/TestWikipediaTokenizerFactory.java
index b654880..ae2491f 100644
--- a/lucene/analysis/common/src/test/org/apache/lucene/analysis/wikipedia/TestWikipediaTokenizerFactory.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/wikipedia/TestWikipediaTokenizerFactory.java
@@ -156,8 +156,7 @@ public class TestWikipediaTokenizerFactory extends BaseTokenStreamFactoryTestCas
         expectThrows(
             IllegalArgumentException.class,
             () -> {
-              Tokenizer tf =
-                  tokenizerFactory(WIKIPEDIA, TOKEN_OUTPUT, "-1").create(newAttributeFactory());
+              tokenizerFactory(WIKIPEDIA, TOKEN_OUTPUT, "-1").create(newAttributeFactory());
             });
     assertTrue(
         expected
diff --git a/lucene/analysis/opennlp/src/test/org/apache/lucene/analysis/opennlp/TestOpenNLPTokenizerFactory.java b/lucene/analysis/opennlp/src/test/org/apache/lucene/analysis/opennlp/TestOpenNLPTokenizerFactory.java
index 4573ce7..315af01 100644
--- a/lucene/analysis/opennlp/src/test/org/apache/lucene/analysis/opennlp/TestOpenNLPTokenizerFactory.java
+++ b/lucene/analysis/opennlp/src/test/org/apache/lucene/analysis/opennlp/TestOpenNLPTokenizerFactory.java
@@ -82,10 +82,9 @@ public class TestOpenNLPTokenizerFactory extends BaseTokenStreamTestCase {
         expectThrows(
             IllegalArgumentException.class,
             () -> {
-              CustomAnalyzer analyzer =
-                  CustomAnalyzer.builder(new ClasspathResourceLoader(getClass()))
-                      .withTokenizer("opennlp", "tokenizerModel", "en-test-tokenizer.bin")
-                      .build();
+              CustomAnalyzer.builder(new ClasspathResourceLoader(getClass()))
+                  .withTokenizer("opennlp", "tokenizerModel", "en-test-tokenizer.bin")
+                  .build();
             });
     assertTrue(
         expected.getMessage().contains("Configuration Error: missing parameter 'sentenceModel'"));
@@ -97,10 +96,9 @@ public class TestOpenNLPTokenizerFactory extends BaseTokenStreamTestCase {
         expectThrows(
             IllegalArgumentException.class,
             () -> {
-              CustomAnalyzer analyzer =
-                  CustomAnalyzer.builder(new ClasspathResourceLoader(getClass()))
-                      .withTokenizer("opennlp", "sentenceModel", "en-test-sent.bin")
-                      .build();
+              CustomAnalyzer.builder(new ClasspathResourceLoader(getClass()))
+                  .withTokenizer("opennlp", "sentenceModel", "en-test-sent.bin")
+                  .build();
             });
     assertTrue(
         expected.getMessage().contains("Configuration Error: missing parameter 'tokenizerModel'"));
diff --git a/lucene/analysis/smartcn/src/java/org/apache/lucene/analysis/cn/smart/hhmm/BigramDictionary.java b/lucene/analysis/smartcn/src/java/org/apache/lucene/analysis/cn/smart/hhmm/BigramDictionary.java
index 766ea5e..4d7f395 100644
--- a/lucene/analysis/smartcn/src/java/org/apache/lucene/analysis/cn/smart/hhmm/BigramDictionary.java
+++ b/lucene/analysis/smartcn/src/java/org/apache/lucene/analysis/cn/smart/hhmm/BigramDictionary.java
@@ -143,7 +143,7 @@ class BigramDictionary extends AbstractDictionary {
    */
   public void loadFromFile(String dctFilePath) throws IOException {
 
-    int i, cnt, length, total = 0;
+    int i, cnt, length;
     // The file only counted 6763 Chinese characters plus 5 reserved slots 3756~3760.
     // The 3756th is used (as a header) to store information.
     int[] buffer = new int[3];
@@ -163,7 +163,6 @@ class BigramDictionary extends AbstractDictionary {
       if (cnt <= 0) {
         continue;
       }
-      total += cnt;
       int j = 0;
       while (j < cnt) {
         dctFile.read(intBuffer);
diff --git a/lucene/analysis/stempel/src/java/org/egothor/stemmer/Trie.java b/lucene/analysis/stempel/src/java/org/egothor/stemmer/Trie.java
index 471cb98..f09656e 100644
--- a/lucene/analysis/stempel/src/java/org/egothor/stemmer/Trie.java
+++ b/lucene/analysis/stempel/src/java/org/egothor/stemmer/Trie.java
@@ -228,7 +228,6 @@ public class Trie {
     int cmd = -1;
     StrEnum e = new StrEnum(key, forward);
     Character ch = null;
-    Character aux = null;
 
     for (int i = 0; i < key.length(); ) {
       ch = e.next();
@@ -243,7 +242,7 @@ public class Trie {
 
       for (int skip = c.skip; skip > 0; skip--) {
         if (i < key.length()) {
-          aux = e.next();
+          e.next();
         } else {
           return null;
         }
diff --git a/lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene70/Lucene70SegmentInfoFormat.java b/lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene70/Lucene70SegmentInfoFormat.java
index 47070fb..2d96dba 100644
--- a/lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene70/Lucene70SegmentInfoFormat.java
+++ b/lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene70/Lucene70SegmentInfoFormat.java
@@ -107,12 +107,12 @@ public class Lucene70SegmentInfoFormat extends SegmentInfoFormat {
       SegmentInfo si = null;
       try {
         CodecUtil.checkIndexHeader(
-                                   input,
-                                   Lucene70SegmentInfoFormat.CODEC_NAME,
-                                   Lucene70SegmentInfoFormat.VERSION_START,
-                                   Lucene70SegmentInfoFormat.VERSION_CURRENT,
-                                   segmentID,
-                                   "");
+            input,
+            Lucene70SegmentInfoFormat.CODEC_NAME,
+            Lucene70SegmentInfoFormat.VERSION_START,
+            Lucene70SegmentInfoFormat.VERSION_CURRENT,
+            segmentID,
+            "");
         si = parseSegmentInfo(dir, input, segment, segmentID);
       } catch (Throwable exception) {
         priorE = exception;
diff --git a/lucene/backward-codecs/src/test/org/apache/lucene/backward_codecs/lucene80/TestIndexedDISI.java b/lucene/backward-codecs/src/test/org/apache/lucene/backward_codecs/lucene80/TestIndexedDISI.java
index bf54bf3..de8b8f0 100644
--- a/lucene/backward-codecs/src/test/org/apache/lucene/backward_codecs/lucene80/TestIndexedDISI.java
+++ b/lucene/backward-codecs/src/test/org/apache/lucene/backward_codecs/lucene80/TestIndexedDISI.java
@@ -97,7 +97,6 @@ public class TestIndexedDISI extends LuceneTestCase {
   private void assertAdvanceBeyondEnd(BitSet set, Directory dir) throws IOException {
     final int cardinality = set.cardinality();
     final byte denseRankPower = 9; // Not tested here so fixed to isolate factors
-    long length;
     int jumpTableentryCount;
     try (IndexOutput out = dir.createOutput("bar", IOContext.DEFAULT)) {
       jumpTableentryCount =
@@ -434,9 +433,7 @@ public class TestIndexedDISI extends LuceneTestCase {
         length = out.getFilePointer();
       }
       try (IndexInput in = dir.openInput("foo", IOContext.DEFAULT)) {
-        IndexedDISI disi =
-            new IndexedDISI(
-                in, 0L, length, jumpTableEntryCount, denseRankPowerRead, set.cardinality());
+        new IndexedDISI(in, 0L, length, jumpTableEntryCount, denseRankPowerRead, set.cardinality());
       }
       // This tests the legality of the denseRankPower only, so we don't do anything with the disi
     }
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene86/Lucene86SegmentInfoFormat.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene86/Lucene86SegmentInfoFormat.java
index 87462a8..32a141b 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene86/Lucene86SegmentInfoFormat.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene86/Lucene86SegmentInfoFormat.java
@@ -104,7 +104,7 @@ public class Lucene86SegmentInfoFormat extends SegmentInfoFormat {
       SegmentInfo si = null;
       try {
         CodecUtil.checkIndexHeader(
-                                   input, CODEC_NAME, VERSION_START, VERSION_CURRENT, segmentID, "");
+            input, CODEC_NAME, VERSION_START, VERSION_CURRENT, segmentID, "");
         si = parseSegmentInfo(dir, input, segment, segmentID);
       } catch (Throwable exception) {
         priorE = exception;
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene90/Lucene90FieldInfosFormat.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene90/Lucene90FieldInfosFormat.java
index 3a13f41..1ee6102 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene90/Lucene90FieldInfosFormat.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene90/Lucene90FieldInfosFormat.java
@@ -126,12 +126,12 @@ public final class Lucene90FieldInfosFormat extends FieldInfosFormat {
       FieldInfo infos[] = null;
       try {
         CodecUtil.checkIndexHeader(
-                                   input,
-                                   Lucene90FieldInfosFormat.CODEC_NAME,
-                                   Lucene90FieldInfosFormat.FORMAT_START,
-                                   Lucene90FieldInfosFormat.FORMAT_CURRENT,
-                                   segmentInfo.getId(),
-                                   segmentSuffix);
+            input,
+            Lucene90FieldInfosFormat.CODEC_NAME,
+            Lucene90FieldInfosFormat.FORMAT_START,
+            Lucene90FieldInfosFormat.FORMAT_CURRENT,
+            segmentInfo.getId(),
+            segmentSuffix);
 
         final int size = input.readVInt(); // read in the size
         infos = new FieldInfo[size];
diff --git a/lucene/core/src/test/org/apache/lucene/analysis/TestStopFilter.java b/lucene/core/src/test/org/apache/lucene/analysis/TestStopFilter.java
index 0172e67..13b2ea9 100644
--- a/lucene/core/src/test/org/apache/lucene/analysis/TestStopFilter.java
+++ b/lucene/core/src/test/org/apache/lucene/analysis/TestStopFilter.java
@@ -191,8 +191,7 @@ public class TestStopFilter extends BaseTokenStreamTestCase {
       StopFilter stopfilter, List<Integer> stopwordPositions, final int numberOfTokens)
       throws IOException {
     CharTermAttribute termAtt = stopfilter.getAttribute(CharTermAttribute.class);
-    PositionIncrementAttribute posIncrAtt =
-        stopfilter.getAttribute(PositionIncrementAttribute.class);
+    stopfilter.getAttribute(PositionIncrementAttribute.class);
     stopfilter.reset();
     log("Test stopwords positions:");
     for (int i = 0; i < numberOfTokens; i++) {
diff --git a/lucene/core/src/test/org/apache/lucene/codecs/lucene90/TestIndexedDISI.java b/lucene/core/src/test/org/apache/lucene/codecs/lucene90/TestIndexedDISI.java
index 97f22bd..8c21c74 100644
--- a/lucene/core/src/test/org/apache/lucene/codecs/lucene90/TestIndexedDISI.java
+++ b/lucene/core/src/test/org/apache/lucene/codecs/lucene90/TestIndexedDISI.java
@@ -98,7 +98,6 @@ public class TestIndexedDISI extends LuceneTestCase {
   private void assertAdvanceBeyondEnd(BitSet set, Directory dir) throws IOException {
     final int cardinality = set.cardinality();
     final byte denseRankPower = 9; // Not tested here so fixed to isolate factors
-    long length;
     int jumpTableentryCount;
     try (IndexOutput out = dir.createOutput("bar", IOContext.DEFAULT)) {
       jumpTableentryCount =
@@ -435,9 +434,7 @@ public class TestIndexedDISI extends LuceneTestCase {
         length = out.getFilePointer();
       }
       try (IndexInput in = dir.openInput("foo", IOContext.DEFAULT)) {
-        IndexedDISI disi =
-            new IndexedDISI(
-                in, 0L, length, jumpTableEntryCount, denseRankPowerRead, set.cardinality());
+        new IndexedDISI(in, 0L, length, jumpTableEntryCount, denseRankPowerRead, set.cardinality());
       }
       // This tests the legality of the denseRankPower only, so we don't do anything with the disi
     }
diff --git a/lucene/core/src/test/org/apache/lucene/index/Test2BSortedDocValuesOrds.java b/lucene/core/src/test/org/apache/lucene/index/Test2BSortedDocValuesOrds.java
index eb25138..a91695c 100644
--- a/lucene/core/src/test/org/apache/lucene/index/Test2BSortedDocValuesOrds.java
+++ b/lucene/core/src/test/org/apache/lucene/index/Test2BSortedDocValuesOrds.java
@@ -84,7 +84,6 @@ public class Test2BSortedDocValuesOrds extends LuceneTestCase {
     int counter = 0;
     for (LeafReaderContext context : r.leaves()) {
       LeafReader reader = context.reader();
-      BytesRef scratch = new BytesRef();
       BinaryDocValues dv = DocValues.getBinary(reader, "dv");
       for (int i = 0; i < reader.maxDoc(); i++) {
         assertEquals(i, dv.nextDoc());
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestDemoParallelLeafReader.java b/lucene/core/src/test/org/apache/lucene/index/TestDemoParallelLeafReader.java
index b2732df..1466699 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestDemoParallelLeafReader.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestDemoParallelLeafReader.java
@@ -869,7 +869,7 @@ public class TestDemoParallelLeafReader extends LuceneTestCase {
           for (int i = 0; i < maxDoc; i++) {
             // TODO: is this still O(blockSize^2)?
             assertEquals(i, oldValues.nextDoc());
-            Document oldDoc = reader.document(i);
+            reader.document(i);
             Document newDoc = new Document();
             newDoc.add(new NumericDocValuesField("number_" + newSchemaGen, oldValues.longValue()));
             w.addDocument(newDoc);
@@ -996,7 +996,7 @@ public class TestDemoParallelLeafReader extends LuceneTestCase {
           assertNotNull("oldSchemaGen=" + oldSchemaGen, oldValues);
           for (int i = 0; i < maxDoc; i++) {
             // TODO: is this still O(blockSize^2)?
-            Document oldDoc = reader.document(i);
+            reader.document(i);
             Document newDoc = new Document();
             assertEquals(i, oldValues.nextDoc());
             newDoc.add(
@@ -1518,7 +1518,6 @@ public class TestDemoParallelLeafReader extends LuceneTestCase {
     NumericDocValues numbers = MultiDocValues.getNumericValues(r, fieldName);
     int maxDoc = r.maxDoc();
     boolean failed = false;
-    long t0 = System.currentTimeMillis();
     for (int i = 0; i < maxDoc; i++) {
       Document oldDoc = r.document(i);
       long value = multiplier * Long.parseLong(oldDoc.get("text").split(" ")[1]);
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestDoc.java b/lucene/core/src/test/org/apache/lucene/index/TestDoc.java
index d062ee7..ae635a3 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestDoc.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestDoc.java
@@ -238,7 +238,7 @@ public class TestDoc extends LuceneTestCase {
             new FieldInfos.FieldNumbers(null),
             context);
 
-    MergeState mergeState = merger.merge();
+    merger.merge();
     r1.close();
     r2.close();
     si.setFiles(new HashSet<>(trackingDir.getCreatedFiles()));
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestIndexSorting.java b/lucene/core/src/test/org/apache/lucene/index/TestIndexSorting.java
index deb938d..425573c 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestIndexSorting.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexSorting.java
@@ -1720,7 +1720,6 @@ public class TestIndexSorting extends LuceneTestCase {
   }
 
   public void testRandom1() throws IOException {
-    boolean withDeletes = random().nextBoolean();
     Directory dir = newDirectory();
     IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
     Sort indexSort = new Sort(new SortField("foo", SortField.Type.LONG));
@@ -1791,7 +1790,6 @@ public class TestIndexSorting extends LuceneTestCase {
   }
 
   public void testMultiValuedRandom1() throws IOException {
-    boolean withDeletes = random().nextBoolean();
     Directory dir = newDirectory();
     IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
     Sort indexSort = new Sort(new SortedNumericSortField("foo", SortField.Type.LONG));
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java
index 1ee5813..bd496ad 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java
@@ -2967,7 +2967,6 @@ public class TestIndexWriter extends LuceneTestCase {
     // Use WindowsFS to prevent open files from being deleted:
     FileSystem fs = new WindowsFS(path.getFileSystem()).getFileSystem(URI.create("file:///"));
     Path root = new FilterPath(path, fs);
-    DirectoryReader reader;
     // MMapDirectory doesn't work because it closes its file handles after mapping!
     try (FSDirectory dir = new NIOFSDirectory(root)) {
       IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterCommit.java b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterCommit.java
index 489a8c5..c18d5fc 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterCommit.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterCommit.java
@@ -182,8 +182,6 @@ public class TestIndexWriterCommit extends LuceneTestCase {
     // sum because the merged FST may use array encoding for
     // some arcs (which uses more space):
 
-    final String idFormat = TestUtil.getPostingsFormat("id");
-    final String contentFormat = TestUtil.getPostingsFormat("content");
     MockDirectoryWrapper dir = newMockDirectory();
     Analyzer analyzer;
     if (random().nextBoolean()) {
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java
index dcb605c..a9c6d87 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java
@@ -1430,7 +1430,7 @@ public class TestIndexWriterExceptions extends LuceneTestCase {
         w.close();
         IndexReader reader = DirectoryReader.open(dir);
         assertTrue(reader.numDocs() > 0);
-        SegmentInfos sis = SegmentInfos.readLatestCommit(dir);
+        SegmentInfos.readLatestCommit(dir);
         for (LeafReaderContext context : reader.leaves()) {
           assertFalse(context.reader().getFieldInfos().hasVectors());
         }
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java
index 8f1d114..bec09c5 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java
@@ -159,9 +159,6 @@ public class TestIndexWriterOnDiskFull extends LuceneTestCase {
     // sum because the merged FST may use array encoding for
     // some arcs (which uses more space):
 
-    final String idFormat = TestUtil.getPostingsFormat("id");
-    final String contentFormat = TestUtil.getPostingsFormat("content");
-
     int START_COUNT = 57;
     int NUM_DIR = TEST_NIGHTLY ? 50 : 5;
     int END_COUNT = START_COUNT + NUM_DIR * (TEST_NIGHTLY ? 25 : 5);
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestNumericDocValuesUpdates.java b/lucene/core/src/test/org/apache/lucene/index/TestNumericDocValuesUpdates.java
index 0d54180..ed6d9aa 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestNumericDocValuesUpdates.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestNumericDocValuesUpdates.java
@@ -138,9 +138,6 @@ public class TestNumericDocValuesUpdates extends LuceneTestCase {
       writer.addDocument(doc(i, val));
     }
 
-    int numDocUpdates = 0;
-    int numValueUpdates = 0;
-
     for (int i = 0; i < numOperations; i++) {
       final int op = TestUtil.nextInt(random(), 1, 100);
       final long val = random().nextLong();
@@ -152,10 +149,8 @@ public class TestNumericDocValuesUpdates extends LuceneTestCase {
         final int id = TestUtil.nextInt(random(), 0, expected.size() - 1);
         expected.put(id, val);
         if (op <= UPD_CUTOFF) {
-          numDocUpdates++;
           writer.updateDocument(new Term("id", "doc-" + id), doc(id, val));
         } else {
-          numValueUpdates++;
           writer.updateNumericDocValue(new Term("id", "doc-" + id), "val", val);
         }
       }
@@ -832,7 +827,6 @@ public class TestNumericDocValuesUpdates extends LuceneTestCase {
     int refreshChance = TestUtil.nextInt(random(), 5, 200);
     int deleteChance = TestUtil.nextInt(random(), 2, 100);
 
-    int idUpto = 0;
     int deletedCount = 0;
 
     List<OneSortDoc> docs = new ArrayList<>();
@@ -1600,7 +1594,6 @@ public class TestNumericDocValuesUpdates extends LuceneTestCase {
 
       // update all doc values
       long value = random().nextInt();
-      NumericDocValuesField[] update = new NumericDocValuesField[numDocs];
       for (int i = 0; i < numDocs; i++) {
         Term term = new Term("id", new BytesRef(Integer.toString(i)));
         writer.updateDocValues(term, new NumericDocValuesField("ndv", value));
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestStressIndexing.java b/lucene/core/src/test/org/apache/lucene/index/TestStressIndexing.java
index d1c2395..ea48143 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestStressIndexing.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestStressIndexing.java
@@ -19,7 +19,6 @@ package org.apache.lucene.index;
 import org.apache.lucene.analysis.MockAnalyzer;
 import org.apache.lucene.document.*;
 import org.apache.lucene.index.IndexWriterConfig.OpenMode;
-import org.apache.lucene.search.*;
 import org.apache.lucene.store.*;
 import org.apache.lucene.util.*;
 
@@ -103,7 +102,7 @@ public class TestStressIndexing extends LuceneTestCase {
     public void doWork() throws Throwable {
       for (int i = 0; i < 100; i++) {
         IndexReader ir = DirectoryReader.open(directory);
-        IndexSearcher is = newSearcher(ir);
+        newSearcher(ir);
         ir.close();
       }
       count += 100;
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestTermVectorsReader.java b/lucene/core/src/test/org/apache/lucene/index/TestTermVectorsReader.java
index 3feeec5..3ab1d5b 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestTermVectorsReader.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestTermVectorsReader.java
@@ -249,7 +249,6 @@ public class TestTermVectorsReader extends LuceneTestCase {
         Codec.getDefault()
             .termVectorsFormat()
             .vectorsReader(dir, seg.info, fieldInfos, newIOContext(random()));
-    BytesRef[] terms;
     Terms vector = reader.get(0).terms(testFields[0]);
     assertNotNull(vector);
     assertEquals(testTerms.length, vector.size());
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestTermsHashPerField.java b/lucene/core/src/test/org/apache/lucene/index/TestTermsHashPerField.java
index 971cf4c..823dbb9 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestTermsHashPerField.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestTermsHashPerField.java
@@ -263,7 +263,7 @@ public class TestTermsHashPerField extends LuceneTestCase {
     for (int i = 0; i < numDocs; i++) {
       int numTerms = 1 + random().nextInt(200);
       int doc = i;
-      for (int j = 0; i < numTerms; i++) {
+      for (int j = 0; j < numTerms; j++) {
         BytesRef ref = RandomPicks.randomFrom(random(), bytesRefs);
         Posting posting = postingMap.get(ref);
         if (posting.termId == -1) {
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestBoolean2.java b/lucene/core/src/test/org/apache/lucene/search/TestBoolean2.java
index 8e0136d..5181c67 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestBoolean2.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestBoolean2.java
@@ -356,8 +356,6 @@ public class TestBoolean2 extends LuceneTestCase {
   public void testRandomQueries() throws Exception {
     String[] vals = {"w1", "w2", "w3", "w4", "w5", "xx", "yy", "zzz"};
 
-    int tot = 0;
-
     BooleanQuery q1 = null;
     try {
 
@@ -395,7 +393,6 @@ public class TestBoolean2 extends LuceneTestCase {
         collector = TopFieldCollector.create(sort, 1000, 1);
         searcher.search(q1, collector);
         ScoreDoc[] hits2 = collector.topDocs().scoreDocs;
-        tot += hits2.length;
         CheckHits.checkEqual(q1, hits1, hits2);
 
         BooleanQuery.Builder q3 = new BooleanQuery.Builder();
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestControlledRealTimeReopenThread.java b/lucene/core/src/test/org/apache/lucene/search/TestControlledRealTimeReopenThread.java
index 9dcdcd8..c1882e0 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestControlledRealTimeReopenThread.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestControlledRealTimeReopenThread.java
@@ -585,7 +585,7 @@ public class TestControlledRealTimeReopenThread extends ThreadedIndexingAndSearc
     nrtDeletesThread.setDaemon(true);
     nrtDeletesThread.start();
 
-    long gen1 = w.addDocument(new Document());
+    w.addDocument(new Document());
     long gen2 = w.deleteAll();
     nrtDeletesThread.waitForGeneration(gen2);
     IOUtils.close(nrtDeletesThread, nrtDeletes, w, dir);
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestLongValuesSource.java b/lucene/core/src/test/org/apache/lucene/search/TestLongValuesSource.java
index 4d19a82..be8ce3c 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestLongValuesSource.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestLongValuesSource.java
@@ -46,7 +46,6 @@ public class TestLongValuesSource extends LuceneTestCase {
     dir = newDirectory();
     RandomIndexWriter iw = new RandomIndexWriter(random(), dir);
     int numDocs = TestUtil.nextInt(random(), 2049, 4000);
-    int leastValue = 45;
     for (int i = 0; i < numDocs; i++) {
       Document document = new Document();
       document.add(newTextField("english", English.intToEnglish(i), Field.Store.NO));
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestMatchesIterator.java b/lucene/core/src/test/org/apache/lucene/search/TestMatchesIterator.java
index c8888be..4c4222e 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestMatchesIterator.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestMatchesIterator.java
@@ -646,8 +646,6 @@ public class TestMatchesIterator extends LuceneTestCase {
   // "a phrase sentence with many phrase sentence iterations of a phrase sentence",
 
   public void testSloppyPhraseQueryWithRepeats() throws IOException {
-    Term p = new Term(FIELD_WITH_OFFSETS, "phrase");
-    Term s = new Term(FIELD_WITH_OFFSETS, "sentence");
     PhraseQuery pq = new PhraseQuery(10, FIELD_WITH_OFFSETS, "phrase", "sentence", "sentence");
     checkMatches(
         pq,
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestTermQuery.java b/lucene/core/src/test/org/apache/lucene/search/TestTermQuery.java
index cd7f35c..32437a1 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestTermQuery.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestTermQuery.java
@@ -126,9 +126,6 @@ public class TestTermQuery extends LuceneTestCase {
     w.addDocument(new Document());
 
     DirectoryReader reader = w.getReader();
-    FilterDirectoryReader noSeekReader = new NoSeekDirectoryReader(reader);
-    IndexSearcher noSeekSearcher = new IndexSearcher(noSeekReader);
-    Query query = new TermQuery(new Term("foo", "bar"));
     TermQuery queryWithContext =
         new TermQuery(
             new Term("foo", "bar"),
diff --git a/lucene/core/src/test/org/apache/lucene/store/TestMultiMMap.java b/lucene/core/src/test/org/apache/lucene/store/TestMultiMMap.java
index b664a45..e34cf78 100644
--- a/lucene/core/src/test/org/apache/lucene/store/TestMultiMMap.java
+++ b/lucene/core/src/test/org/apache/lucene/store/TestMultiMMap.java
@@ -181,7 +181,7 @@ public class TestMultiMMap extends BaseDirectoryTestCase {
 
   public void testSeekSliceZero() throws Exception {
     int upto = TEST_NIGHTLY ? 31 : 3;
-    for (int i = 0; i < 3; i++) {
+    for (int i = 0; i < upto; i++) {
       MMapDirectory mmapDir = new MMapDirectory(createTempDir("testSeekSliceZero"), 1 << i);
       IndexOutput io = mmapDir.createOutput("zeroBytes", newIOContext(random()));
       io.close();
diff --git a/lucene/core/src/test/org/apache/lucene/store/TestNRTCachingDirectory.java b/lucene/core/src/test/org/apache/lucene/store/TestNRTCachingDirectory.java
index d530310..ee40c3a 100644
--- a/lucene/core/src/test/org/apache/lucene/store/TestNRTCachingDirectory.java
+++ b/lucene/core/src/test/org/apache/lucene/store/TestNRTCachingDirectory.java
@@ -30,7 +30,6 @@ import org.apache.lucene.index.RandomIndexWriter;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.TermQuery;
-import org.apache.lucene.search.TopDocs;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.LineFileDocs;
 import org.apache.lucene.util.TestUtil;
@@ -82,7 +81,7 @@ public class TestNRTCachingDirectory extends BaseDirectoryTestCase {
         final IndexSearcher s = newSearcher(r);
         // Just make sure search can run; we can't assert
         // totHits since it could be 0
-        TopDocs hits = s.search(new TermQuery(new Term("body", "the")), 10);
+        s.search(new TermQuery(new Term("body", "the")), 10);
         // System.out.println("tot hits " + hits.totalHits);
       }
     }
diff --git a/lucene/core/src/test/org/apache/lucene/util/bkd/TestBKD.java b/lucene/core/src/test/org/apache/lucene/util/bkd/TestBKD.java
index 6e5c600..37a6cf6 100644
--- a/lucene/core/src/test/org/apache/lucene/util/bkd/TestBKD.java
+++ b/lucene/core/src/test/org/apache/lucene/util/bkd/TestBKD.java
@@ -1723,7 +1723,6 @@ public class TestBKD extends LuceneTestCase {
   public void testTooManyPoints() throws Exception {
     Directory dir = newDirectory();
     final int numValues = 10;
-    final int numPointsAdded = 50; // exceeds totalPointCount
     final int numBytesPerDim = TestUtil.nextInt(random(), 1, 4);
     final byte[] pointValue = new byte[numBytesPerDim];
     BKDWriter w =
@@ -1755,7 +1754,6 @@ public class TestBKD extends LuceneTestCase {
   public void testTooManyPoints1D() throws Exception {
     Directory dir = newDirectory();
     final int numValues = 10;
-    final int numPointsAdded = 50; // exceeds totalPointCount
     final int numBytesPerDim = TestUtil.nextInt(random(), 1, 4);
     final byte[][] pointValue = new byte[11][numBytesPerDim];
     BKDWriter w =
diff --git a/lucene/core/src/test/org/apache/lucene/util/fst/TestFSTs.java b/lucene/core/src/test/org/apache/lucene/util/fst/TestFSTs.java
index a437f06..2097c54 100644
--- a/lucene/core/src/test/org/apache/lucene/util/fst/TestFSTs.java
+++ b/lucene/core/src/test/org/apache/lucene/util/fst/TestFSTs.java
@@ -294,7 +294,6 @@ public class TestFSTs extends LuceneTestCase {
       for (int inputMode = 0; inputMode < 2; inputMode++) {
         final int numWords = random.nextInt(maxNumWords + 1);
         Set<IntsRef> termsSet = new HashSet<>();
-        IntsRef[] terms = new IntsRef[numWords];
         while (termsSet.size() < numWords) {
           final String term = getRandomString(random);
           termsSet.add(toIntsRef(term, inputMode));
diff --git a/lucene/expressions/src/java/org/apache/lucene/expressions/js/JavascriptCompiler.java b/lucene/expressions/src/java/org/apache/lucene/expressions/js/JavascriptCompiler.java
index 5bb7d2e..d7663d2 100644
--- a/lucene/expressions/src/java/org/apache/lucene/expressions/js/JavascriptCompiler.java
+++ b/lucene/expressions/src/java/org/apache/lucene/expressions/js/JavascriptCompiler.java
@@ -166,7 +166,7 @@ public final class JavascriptCompiler {
   @SuppressWarnings({"unused", "null"})
   private static void unusedTestCompile() throws IOException {
     DoubleValues f = null;
-    double ret = f.doubleValue();
+    f.doubleValue();
   }
 
   /**
diff --git a/lucene/facet/src/java/org/apache/lucene/facet/FacetsConfig.java b/lucene/facet/src/java/org/apache/lucene/facet/FacetsConfig.java
index f4f396e..4d4fedd 100644
--- a/lucene/facet/src/java/org/apache/lucene/facet/FacetsConfig.java
+++ b/lucene/facet/src/java/org/apache/lucene/facet/FacetsConfig.java
@@ -441,15 +441,7 @@ public class FacetsConfig {
         System.arraycopy(field.assoc.bytes, field.assoc.offset, bytes, upto, field.assoc.length);
         upto += field.assoc.length;
 
-        FacetsConfig.DimConfig ft = getDimConfig(field.dim);
-
         // Drill down:
-        int start;
-        if (ft.requireDimensionDrillDown) {
-          start = 1;
-        } else {
-          start = 2;
-        }
         for (int i = 1; i <= label.length; i++) {
           doc.add(
               new StringField(indexFieldName, pathToString(label.components, i), Field.Store.NO));
diff --git a/lucene/facet/src/test/org/apache/lucene/facet/TestLongValueFacetCounts.java b/lucene/facet/src/test/org/apache/lucene/facet/TestLongValueFacetCounts.java
index 0e17bd2..1c4b5eb 100644
--- a/lucene/facet/src/test/org/apache/lucene/facet/TestLongValueFacetCounts.java
+++ b/lucene/facet/src/test/org/apache/lucene/facet/TestLongValueFacetCounts.java
@@ -385,7 +385,6 @@ public class TestLongValueFacetCounts extends LuceneTestCase {
     }
 
     long[][] values = new long[valueCount][];
-    int missingCount = 0;
     for (int i = 0; i < valueCount; i++) {
       Document doc = new Document();
       doc.add(new IntPoint("id", i));
@@ -407,8 +406,6 @@ public class TestLongValueFacetCounts extends LuceneTestCase {
         }
 
       } else {
-        missingCount++;
-
         if (VERBOSE) {
           System.out.println("  doc=" + i + " missing values");
         }
diff --git a/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestDirectoryTaxonomyReader.java b/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestDirectoryTaxonomyReader.java
index 47e42dc..bb34dee 100644
--- a/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestDirectoryTaxonomyReader.java
+++ b/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestDirectoryTaxonomyReader.java
@@ -545,7 +545,6 @@ public class TestDirectoryTaxonomyReader extends FacetTestCase {
     Directory dir = newDirectory();
     DirectoryTaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(dir);
     int numCategories = atLeast(10);
-    int numA = 0, numB = 0;
     Random random = random();
     // add the two categories for which we'll also add children (so asserts are simpler)
     taxoWriter.addCategory(new FacetLabel("a"));
@@ -553,10 +552,8 @@ public class TestDirectoryTaxonomyReader extends FacetTestCase {
     for (int i = 0; i < numCategories; i++) {
       if (random.nextBoolean()) {
         taxoWriter.addCategory(new FacetLabel("a", Integer.toString(i)));
-        ++numA;
       } else {
         taxoWriter.addCategory(new FacetLabel("b", Integer.toString(i)));
-        ++numB;
       }
     }
     // add category with no children
diff --git a/lucene/grouping/src/test/org/apache/lucene/search/grouping/TestAllGroupHeadsCollector.java b/lucene/grouping/src/test/org/apache/lucene/search/grouping/TestAllGroupHeadsCollector.java
index 9b7baae..1e4553c 100644
--- a/lucene/grouping/src/test/org/apache/lucene/search/grouping/TestAllGroupHeadsCollector.java
+++ b/lucene/grouping/src/test/org/apache/lucene/search/grouping/TestAllGroupHeadsCollector.java
@@ -228,7 +228,6 @@ public class TestAllGroupHeadsCollector extends LuceneTestCase {
       Directory dir = newDirectory();
       RandomIndexWriter w =
           new RandomIndexWriter(random(), dir, newIndexWriterConfig(new MockAnalyzer(random())));
-      DocValuesType valueType = DocValuesType.SORTED;
 
       Document doc = new Document();
       Document docNoGroup = new Document();
diff --git a/lucene/grouping/src/test/org/apache/lucene/search/grouping/TestGrouping.java b/lucene/grouping/src/test/org/apache/lucene/search/grouping/TestGrouping.java
index df53dff..3cbf735 100644
--- a/lucene/grouping/src/test/org/apache/lucene/search/grouping/TestGrouping.java
+++ b/lucene/grouping/src/test/org/apache/lucene/search/grouping/TestGrouping.java
@@ -1371,7 +1371,6 @@ public class TestGrouping extends LuceneTestCase {
     final List<Collection<SearchGroup<BytesRef>>> shardGroups = new ArrayList<>();
     List<FirstPassGroupingCollector<?>> firstPassGroupingCollectors = new ArrayList<>();
     FirstPassGroupingCollector<?> firstPassCollector = null;
-    boolean shardsCanUseIDV = canUseIDV;
 
     String groupField = "group";
 
diff --git a/lucene/highlighter/src/test/org/apache/lucene/search/uhighlight/TestUnifiedHighlighterMTQ.java b/lucene/highlighter/src/test/org/apache/lucene/search/uhighlight/TestUnifiedHighlighterMTQ.java
index f70ce3e..2eebfd9 100644
--- a/lucene/highlighter/src/test/org/apache/lucene/search/uhighlight/TestUnifiedHighlighterMTQ.java
+++ b/lucene/highlighter/src/test/org/apache/lucene/search/uhighlight/TestUnifiedHighlighterMTQ.java
@@ -911,7 +911,7 @@ public class TestUnifiedHighlighterMTQ extends LuceneTestCase {
     BooleanQuery query = queryBuilder.build();
     TopDocs topDocs = searcher.search(query, 10, Sort.INDEXORDER);
     try {
-      String snippets[] = highlighter.highlight("body", query, topDocs, 2);
+      highlighter.highlight("body", query, topDocs, 2);
       // don't even care what the results are; just want to test exception behavior
       if (fieldType == UHTestHelper.reanalysisType) {
         fail("Expecting EXPECTED IOException");
diff --git a/lucene/luke/src/test/org/apache/lucene/luke/models/documents/TestDocumentsImpl.java b/lucene/luke/src/test/org/apache/lucene/luke/models/documents/TestDocumentsImpl.java
index cf08f1f..ddddbef 100644
--- a/lucene/luke/src/test/org/apache/lucene/luke/models/documents/TestDocumentsImpl.java
+++ b/lucene/luke/src/test/org/apache/lucene/luke/models/documents/TestDocumentsImpl.java
@@ -150,7 +150,7 @@ public class TestDocumentsImpl extends DocumentsTestBase {
     assertEquals("adventures", term.text());
 
     while (documents.nextTerm().isPresent()) {
-      Integer freq = documents.getDocFreq().orElseThrow(IllegalStateException::new);
+      documents.getDocFreq().orElseThrow(IllegalStateException::new);
     }
   }
 
@@ -208,16 +208,16 @@ public class TestDocumentsImpl extends DocumentsTestBase {
   @Test
   public void testNextTermDoc_unPositioned() {
     DocumentsImpl documents = new DocumentsImpl(reader);
-    Term term = documents.firstTerm("title").orElseThrow(IllegalStateException::new);
+    documents.firstTerm("title").orElseThrow(IllegalStateException::new);
     assertFalse(documents.nextTermDoc().isPresent());
   }
 
   @Test
   public void testTermPositions() {
     DocumentsImpl documents = new DocumentsImpl(reader);
-    Term term = documents.firstTerm("author").orElseThrow(IllegalStateException::new);
-    term = documents.seekTerm("carroll").orElseThrow(IllegalStateException::new);
-    int docid = documents.firstTermDoc().orElseThrow(IllegalStateException::new);
+    documents.firstTerm("author").orElseThrow(IllegalStateException::new);
+    documents.seekTerm("carroll").orElseThrow(IllegalStateException::new);
+    documents.firstTermDoc().orElseThrow(IllegalStateException::new);
     List<TermPosting> postings = documents.getTermPositions();
     assertEquals(1, postings.size());
     assertEquals(1, postings.get(0).getPosition());
@@ -228,21 +228,21 @@ public class TestDocumentsImpl extends DocumentsTestBase {
   @Test
   public void testTermPositions_unPositioned() {
     DocumentsImpl documents = new DocumentsImpl(reader);
-    Term term = documents.firstTerm("author").orElseThrow(IllegalStateException::new);
+    documents.firstTerm("author").orElseThrow(IllegalStateException::new);
     assertEquals(0, documents.getTermPositions().size());
   }
 
   @Test
   public void testTermPositions_noPositions() {
     DocumentsImpl documents = new DocumentsImpl(reader);
-    Term term = documents.firstTerm("title").orElseThrow(IllegalStateException::new);
-    int docid = documents.firstTermDoc().orElseThrow(IllegalStateException::new);
+    documents.firstTerm("title").orElseThrow(IllegalStateException::new);
+    documents.firstTermDoc().orElseThrow(IllegalStateException::new);
     assertEquals(0, documents.getTermPositions().size());
   }
 
   @Test(expected = AlreadyClosedException.class)
   public void testClose() throws Exception {
-    DocumentsImpl documents = new DocumentsImpl(reader);
+    new DocumentsImpl(reader);
     reader.close();
     IndexUtils.getFieldNames(reader);
   }
diff --git a/lucene/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java b/lucene/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java
index 6dcf8d0..af51fbf 100644
--- a/lucene/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java
+++ b/lucene/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java
@@ -1440,11 +1440,8 @@ public class MemoryIndex {
 
       @Override
       public int size() {
-        int size = 0;
-        for (String fieldName : this) {
-          size++;
-        }
-        return size;
+        return Math.toIntExact(
+            fields.entrySet().stream().filter(e -> e.getValue().numTokens > 0).count());
       }
     }
 
diff --git a/lucene/misc/src/test/org/apache/lucene/misc/util/fst/TestFSTsMisc.java b/lucene/misc/src/test/org/apache/lucene/misc/util/fst/TestFSTsMisc.java
index 540ce25..55c1675 100644
--- a/lucene/misc/src/test/org/apache/lucene/misc/util/fst/TestFSTsMisc.java
+++ b/lucene/misc/src/test/org/apache/lucene/misc/util/fst/TestFSTsMisc.java
@@ -67,7 +67,6 @@ public class TestFSTsMisc extends LuceneTestCase {
       for (int inputMode = 0; inputMode < 2; inputMode++) {
         final int numWords = random.nextInt(maxNumWords + 1);
         Set<IntsRef> termsSet = new HashSet<>();
-        IntsRef[] terms = new IntsRef[numWords];
         while (termsSet.size() < numWords) {
           final String term = FSTTester.getRandomString(random);
           termsSet.add(FSTTester.toIntsRef(term, inputMode));
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/messages/NLS.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/messages/NLS.java
index 3462a06..326da0b 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/messages/NLS.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/messages/NLS.java
@@ -143,10 +143,7 @@ public class NLS {
       ResourceBundle resourceBundle =
           ResourceBundle.getBundle(clazz.getName(), Locale.getDefault());
       if (resourceBundle != null) {
-        Object obj = resourceBundle.getObject(key);
-        // if (obj == null)
-        //  System.err.println("WARN: Message with key:" + key + " and locale: "
-        //      + Locale.getDefault() + " not found.");
+        resourceBundle.getObject(key);
       }
     } catch (MissingResourceException e) {
       // System.err.println("WARN: Message with key:" + key + " and locale: "
diff --git a/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestMultiFieldQPHelper.java b/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestMultiFieldQPHelper.java
index d362340..cbb4aff 100644
--- a/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestMultiFieldQPHelper.java
+++ b/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestMultiFieldQPHelper.java
@@ -63,7 +63,6 @@ public class TestMultiFieldQPHelper extends LuceneTestCase {
   // verify parsing of query using a stopping analyzer
   private void assertStopQueryIsMatchNoDocsQuery(String qtxt) throws Exception {
     String[] fields = {"b", "t"};
-    Occur occur[] = {Occur.SHOULD, Occur.SHOULD};
     TestQPHelper.QPTestAnalyzer a = new TestQPHelper.QPTestAnalyzer();
     StandardQueryParser mfqp = new StandardQueryParser();
     mfqp.setMultiFields(fields);
diff --git a/lucene/replicator/src/test/org/apache/lucene/replicator/TestIndexAndTaxonomyReplicationClient.java b/lucene/replicator/src/test/org/apache/lucene/replicator/TestIndexAndTaxonomyReplicationClient.java
index 4e80e30..d9ae94b 100644
--- a/lucene/replicator/src/test/org/apache/lucene/replicator/TestIndexAndTaxonomyReplicationClient.java
+++ b/lucene/replicator/src/test/org/apache/lucene/replicator/TestIndexAndTaxonomyReplicationClient.java
@@ -419,13 +419,12 @@ public class TestIndexAndTaxonomyReplicationClient extends ReplicatorTestCase {
                 // verify taxonomy index is fully consistent (since we only add one
                 // category to all documents, there's nothing much more to validate.
                 ByteArrayOutputStream bos = new ByteArrayOutputStream(1024);
-                CheckIndex.Status indexStatus = null;
 
                 try (CheckIndex checker = new CheckIndex(handlerTaxoDir.getDelegate())) {
                   checker.setFailFast(true);
                   checker.setInfoStream(new PrintStream(bos, false, IOUtils.UTF_8), false);
                   try {
-                    indexStatus = checker.checkIndex(null);
+                    checker.checkIndex(null);
                   } catch (IOException | RuntimeException ioe) {
                     // ok: we fallback below
                   }
diff --git a/lucene/replicator/src/test/org/apache/lucene/replicator/nrt/SimplePrimaryNode.java b/lucene/replicator/src/test/org/apache/lucene/replicator/nrt/SimplePrimaryNode.java
index 51f1fc2..30aaba4 100644
--- a/lucene/replicator/src/test/org/apache/lucene/replicator/nrt/SimplePrimaryNode.java
+++ b/lucene/replicator/src/test/org/apache/lucene/replicator/nrt/SimplePrimaryNode.java
@@ -196,9 +196,6 @@ class SimplePrimaryNode extends PrimaryNode {
     warmingSegments.add(preCopy);
 
     try {
-
-      Set<String> fileNames = files.keySet();
-
       // Ask all currently known replicas to pre-copy this newly merged segment's files:
       for (int replicaTCPPort : replicaTCPPorts) {
         try {
diff --git a/lucene/replicator/src/test/org/apache/lucene/replicator/nrt/SimpleReplicaNode.java b/lucene/replicator/src/test/org/apache/lucene/replicator/nrt/SimpleReplicaNode.java
index 17f6fd1..d32dcd6 100644
--- a/lucene/replicator/src/test/org/apache/lucene/replicator/nrt/SimpleReplicaNode.java
+++ b/lucene/replicator/src/test/org/apache/lucene/replicator/nrt/SimpleReplicaNode.java
@@ -332,7 +332,7 @@ class SimpleReplicaNode extends ReplicaNode {
           Map<String, FileMetaData> files = SimpleServer.readFilesMetaData(in);
           message("done reading files to copy files=" + files.keySet());
           AtomicBoolean finished = new AtomicBoolean();
-          CopyJob job = launchPreCopyMerge(finished, newPrimaryGen, files);
+          launchPreCopyMerge(finished, newPrimaryGen, files);
           message("done launching copy job files=" + files.keySet());
 
           // Silly keep alive mechanism, else if e.g. we (replica node) crash, the primary
diff --git a/lucene/replicator/src/test/org/apache/lucene/replicator/nrt/TestNRTReplication.java b/lucene/replicator/src/test/org/apache/lucene/replicator/nrt/TestNRTReplication.java
index 1c42d07..d02bd41 100644
--- a/lucene/replicator/src/test/org/apache/lucene/replicator/nrt/TestNRTReplication.java
+++ b/lucene/replicator/src/test/org/apache/lucene/replicator/nrt/TestNRTReplication.java
@@ -125,7 +125,6 @@ public class TestNRTReplication extends LuceneTestCase {
     long initCommitVersion = -1;
     long initInfosVersion = -1;
     Pattern logTimeStart = Pattern.compile("^[0-9\\.]+s .*");
-    boolean sawExistingSegmentsFile = false;
 
     while (true) {
       String l = r.readLine();
@@ -159,7 +158,6 @@ public class TestNRTReplication extends LuceneTestCase {
       } else if (l.startsWith("NODE STARTED")) {
         break;
       } else if (l.contains("replica cannot start: existing segments file=")) {
-        sawExistingSegmentsFile = true;
       }
     }
 
diff --git a/lucene/replicator/src/test/org/apache/lucene/replicator/nrt/TestStressNRTReplication.java b/lucene/replicator/src/test/org/apache/lucene/replicator/nrt/TestStressNRTReplication.java
index fd05821..09aaf8f 100644
--- a/lucene/replicator/src/test/org/apache/lucene/replicator/nrt/TestStressNRTReplication.java
+++ b/lucene/replicator/src/test/org/apache/lucene/replicator/nrt/TestStressNRTReplication.java
@@ -44,9 +44,6 @@ import java.util.concurrent.atomic.AtomicLong;
 import java.util.regex.Pattern;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
-import org.apache.lucene.index.Term;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.search.TermQuery;
 import org.apache.lucene.store.MockDirectoryWrapper;
 import org.apache.lucene.util.IOUtils;
 import org.apache.lucene.util.LineFileDocs;
@@ -444,7 +441,6 @@ public class TestStressNRTReplication extends LuceneTestCase {
       return;
     }
 
-    int id = replicaToPromote.id;
     message("top: now startPrimary " + replicaToPromote);
     startPrimary(replicaToPromote.id);
   }
@@ -1005,9 +1001,6 @@ public class TestStressNRTReplication extends LuceneTestCase {
 
     @Override
     public void run() {
-      // Maps version to number of hits for silly 'the' TermQuery:
-      Query theQuery = new TermQuery(new Term("body", "the"));
-
       // Persists connections
       Map<Integer, Connection> connections = new HashMap<>();
 
@@ -1221,8 +1214,6 @@ public class TestStressNRTReplication extends LuceneTestCase {
 
         message("top: indexer: updatePct=" + updatePct + " sleepChance=" + sleepChance);
 
-        long lastTransLogLoc = transLog.getNextLocation();
-
         NodeProcess curPrimary = null;
         Connection c = null;
 
diff --git a/lucene/sandbox/src/test/org/apache/lucene/sandbox/codecs/idversion/TestIDVersionPostingsFormat.java b/lucene/sandbox/src/test/org/apache/lucene/sandbox/codecs/idversion/TestIDVersionPostingsFormat.java
index 683f329..3332a60 100644
--- a/lucene/sandbox/src/test/org/apache/lucene/sandbox/codecs/idversion/TestIDVersionPostingsFormat.java
+++ b/lucene/sandbox/src/test/org/apache/lucene/sandbox/codecs/idversion/TestIDVersionPostingsFormat.java
@@ -571,7 +571,6 @@ public class TestIDVersionPostingsFormat extends LuceneTestCase {
     payload.length = 8;
     IDVersionPostingsFormat.longToBytes(17, payload);
     ts.setValue("foo", payload);
-    Field field = new Field("id", ts, ft);
     doc.add(new Field("id", ts, ft));
     expectThrows(
         IllegalArgumentException.class,
diff --git a/lucene/sandbox/src/test/org/apache/lucene/sandbox/search/TestTermAutomatonQuery.java b/lucene/sandbox/src/test/org/apache/lucene/sandbox/search/TestTermAutomatonQuery.java
index 3c2c83b..7ca592e 100644
--- a/lucene/sandbox/src/test/org/apache/lucene/sandbox/search/TestTermAutomatonQuery.java
+++ b/lucene/sandbox/src/test/org/apache/lucene/sandbox/search/TestTermAutomatonQuery.java
@@ -775,7 +775,7 @@ public class TestTermAutomatonQuery extends LuceneTestCase {
 
   public void testRewriteNoMatch() throws Exception {
     TermAutomatonQuery q = new TermAutomatonQuery("field");
-    int initState = q.createState();
+    q.createState(); // initState
     q.finish();
 
     Directory dir = newDirectory();
diff --git a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/tree/DateRangePrefixTree.java b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/tree/DateRangePrefixTree.java
index 72ee20b..c1facb8 100644
--- a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/tree/DateRangePrefixTree.java
+++ b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/tree/DateRangePrefixTree.java
@@ -446,7 +446,6 @@ public class DateRangePrefixTree extends NumberRangePrefixTree {
 
   private void appendPadded(StringBuilder builder, int integer, short positions) {
     assert integer >= 0 && positions >= 1 && positions <= 4;
-    int preBuilderLen = builder.length();
     int intStrLen;
     if (integer > 999) {
       intStrLen = 4;
diff --git a/lucene/spatial-extras/src/test/org/apache/lucene/spatial/bbox/TestBBoxStrategy.java b/lucene/spatial-extras/src/test/org/apache/lucene/spatial/bbox/TestBBoxStrategy.java
index 0df4883..b9d3384 100644
--- a/lucene/spatial-extras/src/test/org/apache/lucene/spatial/bbox/TestBBoxStrategy.java
+++ b/lucene/spatial-extras/src/test/org/apache/lucene/spatial/bbox/TestBBoxStrategy.java
@@ -170,7 +170,6 @@ public class TestBBoxStrategy extends RandomSpatialOpStrategyTestCase {
     final Rectangle indexedShape = ctx.getShapeFactory().rect(180, 180, -10, 10);
     final Rectangle queryShape = ctx.getShapeFactory().rect(-180, -180, -20, 20);
     final SpatialOperation operation = SpatialOperation.IsWithin;
-    final boolean match = true; // yes it is within
 
     // the rest is super.testOperation without leading assert:
 
@@ -179,7 +178,7 @@ public class TestBBoxStrategy extends RandomSpatialOpStrategyTestCase {
     Query query = strategy.makeQuery(new SpatialArgs(operation, queryShape));
     SearchResults got = executeQuery(query, 1);
     assert got.numFound <= 1 : "unclean test env";
-    if ((got.numFound == 1) != match) fail(operation + " I:" + indexedShape + " Q:" + queryShape);
+    if (got.numFound != 1) fail(operation + " I:" + indexedShape + " Q:" + queryShape);
     deleteAll(); // clean up after ourselves
   }
 
diff --git a/lucene/spatial-extras/src/test/org/apache/lucene/spatial/prefix/TestRandomSpatialOpFuzzyPrefixTree.java b/lucene/spatial-extras/src/test/org/apache/lucene/spatial/prefix/TestRandomSpatialOpFuzzyPrefixTree.java
index 1556370..6fae979 100644
--- a/lucene/spatial-extras/src/test/org/apache/lucene/spatial/prefix/TestRandomSpatialOpFuzzyPrefixTree.java
+++ b/lucene/spatial-extras/src/test/org/apache/lucene/spatial/prefix/TestRandomSpatialOpFuzzyPrefixTree.java
@@ -292,7 +292,6 @@ public class TestRandomSpatialOpFuzzyPrefixTree extends StrategyTestCase {
     Map<String, Shape> indexedShapes = new LinkedHashMap<>();
     Map<String, Shape> indexedShapesGS = new LinkedHashMap<>(); // grid snapped
     final int numIndexedShapes = randomIntBetween(1, 6);
-    boolean indexedAtLeastOneShapePair = false;
     final boolean pointsOnly = ((PrefixTreeStrategy) strategy).isPointsOnly();
     for (int i = 0; i < numIndexedShapes; i++) {
       String id = "" + i;
@@ -305,7 +304,6 @@ public class TestRandomSpatialOpFuzzyPrefixTree extends StrategyTestCase {
       } else if (R <= 4) { // 3 in 12
         // comprised of more than one shape
         indexedShape = randomShapePairRect(biasContains);
-        indexedAtLeastOneShapePair = true;
       } else {
         indexedShape = randomRectangle(); // just one rect
       }
diff --git a/lucene/spatial-extras/src/test/org/apache/lucene/spatial/prefix/TestTermQueryPrefixGridStrategy.java b/lucene/spatial-extras/src/test/org/apache/lucene/spatial/prefix/TestTermQueryPrefixGridStrategy.java
index 306c9f8..5f0d8b3 100644
--- a/lucene/spatial-extras/src/test/org/apache/lucene/spatial/prefix/TestTermQueryPrefixGridStrategy.java
+++ b/lucene/spatial-extras/src/test/org/apache/lucene/spatial/prefix/TestTermQueryPrefixGridStrategy.java
@@ -24,7 +24,6 @@ import org.apache.lucene.document.StoredField;
 import org.apache.lucene.document.StringField;
 import org.apache.lucene.spatial.SpatialTestCase;
 import org.apache.lucene.spatial.prefix.tree.QuadPrefixTree;
-import org.apache.lucene.spatial.query.SpatialArgsParser;
 import org.junit.Test;
 import org.locationtech.spatial4j.context.SpatialContext;
 import org.locationtech.spatial4j.shape.Shape;
@@ -51,7 +50,7 @@ public class TestTermQueryPrefixGridStrategy extends SpatialTestCase {
     addDocumentsAndCommit(Arrays.asList(losAngeles));
 
     // This won't work with simple spatial context...
-    SpatialArgsParser spatialArgsParser = new SpatialArgsParser();
+    // SpatialArgsParser spatialArgsParser = new SpatialArgsParser();
     // TODO... use a non polygon query
     //    SpatialArgs spatialArgs = spatialArgsParser.parse(
     //        "Intersects(POLYGON((-127.00390625 39.8125,-112.765625 39.98828125,-111.53515625
diff --git a/lucene/spatial-extras/src/test/org/apache/lucene/spatial/prefix/tree/TestDateRangePrefixTree.java b/lucene/spatial-extras/src/test/org/apache/lucene/spatial/prefix/tree/TestDateRangePrefixTree.java
index 44bc6b0..edc862c 100644
--- a/lucene/spatial-extras/src/test/org/apache/lucene/spatial/prefix/tree/TestDateRangePrefixTree.java
+++ b/lucene/spatial-extras/src/test/org/apache/lucene/spatial/prefix/tree/TestDateRangePrefixTree.java
@@ -184,7 +184,6 @@ public class TestDateRangePrefixTree extends LuceneTestCase {
 
   private void roundTrip(Calendar calOrig) throws ParseException {
     Calendar cal = (Calendar) calOrig.clone();
-    String lastString = null;
     while (true) {
       String calString;
       {
@@ -231,7 +230,6 @@ public class TestDateRangePrefixTree extends LuceneTestCase {
         if (e.getMessage().equals("Calendar underflow")) return;
         throw e;
       }
-      lastString = calString;
     }
   }
 
diff --git a/lucene/spatial-extras/src/test/org/apache/lucene/spatial/spatial4j/TestGeo3dShapeWGS84ModelRectRelation.java b/lucene/spatial-extras/src/test/org/apache/lucene/spatial/spatial4j/TestGeo3dShapeWGS84ModelRectRelation.java
index 6376fc0..45e7539 100644
--- a/lucene/spatial-extras/src/test/org/apache/lucene/spatial/spatial4j/TestGeo3dShapeWGS84ModelRectRelation.java
+++ b/lucene/spatial-extras/src/test/org/apache/lucene/spatial/spatial4j/TestGeo3dShapeWGS84ModelRectRelation.java
@@ -112,8 +112,6 @@ public class TestGeo3dShapeWGS84ModelRectRelation extends ShapeRectRelationTestC
             16 * RADIANS_PER_DEGREE,
             4 * RADIANS_PER_DEGREE,
             36 * RADIANS_PER_DEGREE);
-    final GeoPoint pt =
-        new GeoPoint(planetModel, 16 * RADIANS_PER_DEGREE, 23.81626064835212 * RADIANS_PER_DEGREE);
     final GeoPoint[] pathPoints =
         new GeoPoint[] {
           new GeoPoint(
diff --git a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/TestGeo3DPoint.java b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/TestGeo3DPoint.java
index d4616e1..6589e66 100644
--- a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/TestGeo3DPoint.java
+++ b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/TestGeo3DPoint.java
@@ -1180,12 +1180,12 @@ public class TestGeo3DPoint extends LuceneTestCase {
     int iters = atLeast(100);
     for (int i = 0; i < iters; i++) {
       // Create a polygon that's less than 180 degrees
-      final Polygon clockWise = makePoly(pm, randomPole, true, true);
+      makePoly(pm, randomPole, true, true);
     }
     iters = atLeast(100);
     for (int i = 0; i < iters; i++) {
       // Create a polygon that's greater than 180 degrees
-      final Polygon counterClockWise = makePoly(pm, randomPole, false, true);
+      makePoly(pm, randomPole, false, true);
     }
   }
 
@@ -1260,12 +1260,12 @@ public class TestGeo3DPoint extends LuceneTestCase {
       // the polygon, so we're going to use Geo3D to help us select those given the points we just
       // made.
 
-      final int holeCount = createHoles ? TestUtil.nextInt(random(), 0, 2) : 0;
-
       final List<Polygon> holeList = new ArrayList<>();
 
       /* Hole logic is broken and needs rethinking
 
+      final int holeCount = createHoles ? TestUtil.nextInt(random(), 0, 2) : 0;
+
       // Create the geo3d polygon, so we can test out our poles.
       final GeoPolygon poly;
       try {
diff --git a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/TestGeoBBox.java b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/TestGeoBBox.java
index 749c092..5cb74fc 100755
--- a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/TestGeoBBox.java
+++ b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/TestGeoBBox.java
@@ -31,7 +31,6 @@ public class TestGeoBBox {
   @Test
   public void testBBoxDegenerate() {
     GeoBBox box;
-    GeoConvexPolygon cp;
     int relationship;
     List<GeoPoint> points = new ArrayList<GeoPoint>();
     points.add(
diff --git a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/TestGeoExactCircle.java b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/TestGeoExactCircle.java
index d3e354d..1ab6261 100644
--- a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/TestGeoExactCircle.java
+++ b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/TestGeoExactCircle.java
@@ -146,18 +146,16 @@ public class TestGeoExactCircle extends RandomGeo3dShapeGenerator {
   public void exactCircleLargeTest() {
     boolean success = true;
     try {
-      GeoCircle circle =
-          GeoCircleFactory.makeExactGeoCircle(
-              new PlanetModel(0.99, 1.05), 0.25 * Math.PI, 0, 0.35 * Math.PI, 1e-12);
+      GeoCircleFactory.makeExactGeoCircle(
+          new PlanetModel(0.99, 1.05), 0.25 * Math.PI, 0, 0.35 * Math.PI, 1e-12);
     } catch (IllegalArgumentException e) {
       success = false;
     }
     assertTrue(success);
     success = false;
     try {
-      GeoCircle circle =
-          GeoCircleFactory.makeExactGeoCircle(
-              PlanetModel.WGS84, 0.25 * Math.PI, 0, 0.9996 * Math.PI, 1e-12);
+      GeoCircleFactory.makeExactGeoCircle(
+          PlanetModel.WGS84, 0.25 * Math.PI, 0, 0.9996 * Math.PI, 1e-12);
     } catch (IllegalArgumentException e) {
       success = true;
     }
@@ -168,13 +166,8 @@ public class TestGeoExactCircle extends RandomGeo3dShapeGenerator {
   public void testExactCircleDoesNotFit() {
     boolean exception = false;
     try {
-      GeoCircle circle =
-          GeoCircleFactory.makeExactGeoCircle(
-              PlanetModel.WGS84,
-              1.5633796542562415,
-              -1.0387149580695152,
-              3.1409865861032844,
-              1e-12);
+      GeoCircleFactory.makeExactGeoCircle(
+          PlanetModel.WGS84, 1.5633796542562415, -1.0387149580695152, 3.1409865861032844, 1e-12);
     } catch (IllegalArgumentException e) {
       exception = true;
     }
@@ -315,9 +308,8 @@ public class TestGeoExactCircle extends RandomGeo3dShapeGenerator {
     PlanetModel planetModel = new PlanetModel(1.6304230055804751, 1.0199671157571204);
     boolean fail = false;
     try {
-      GeoCircle circle =
-          GeoCircleFactory.makeExactGeoCircle(
-              planetModel, 0.8853814403571284, 0.9784990176851283, 0.9071033527030907, 1e-11);
+      GeoCircleFactory.makeExactGeoCircle(
+          planetModel, 0.8853814403571284, 0.9784990176851283, 0.9071033527030907, 1e-11);
     } catch (IllegalArgumentException e) {
       fail = true;
     }
diff --git a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/TestGeoPath.java b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/TestGeoPath.java
index 262a622..59c1242 100755
--- a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/TestGeoPath.java
+++ b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/TestGeoPath.java
@@ -130,9 +130,6 @@ public class TestGeoPath extends LuceneTestCase {
     GeoStandardPath p;
     GeoStandardPath c;
     GeoPoint point;
-    GeoPoint pointApprox;
-    int relationship;
-    GeoArea area;
     PlanetModel planetModel;
 
     planetModel = new PlanetModel(1.151145876105594, 0.8488541238944061);
@@ -141,16 +138,14 @@ public class TestGeoPath extends LuceneTestCase {
     c.addPoint(0.27828548161836364, 0.6785795524104564);
     c.done();
     point = new GeoPoint(planetModel, -0.49298555067758226, 0.9892440995026406);
-    pointApprox = new GeoPoint(0.5110940362119821, 0.7774603209946239, -0.49984312299556544);
-    area =
-        GeoAreaFactory.makeGeoArea(
-            planetModel,
-            0.49937141144985997,
-            0.5161765426256085,
-            0.3337218719537796,
-            0.8544419570901649,
-            -0.6347692823688085,
-            0.3069696588119369);
+    GeoAreaFactory.makeGeoArea(
+        planetModel,
+        0.49937141144985997,
+        0.5161765426256085,
+        0.3337218719537796,
+        0.8544419570901649,
+        -0.6347692823688085,
+        0.3069696588119369);
     assertTrue(!c.isWithin(point));
 
     // Start by testing the basic kinds of relationship, increasing in order of difficulty.
diff --git a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/TestGeoPolygon.java b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/TestGeoPolygon.java
index 9516491..4fdfe87 100755
--- a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/TestGeoPolygon.java
+++ b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/TestGeoPolygon.java
@@ -465,7 +465,6 @@ public class TestGeoPolygon extends LuceneTestCase {
   @Test
   public void testPolygonBoundsCase1() {
     GeoPolygon c;
-    LatLonBounds b;
     List<GeoPoint> points;
     XYZBounds xyzb;
     GeoPoint point1;
@@ -608,10 +607,6 @@ public class TestGeoPolygon extends LuceneTestCase {
     c.addShape(new GeoConcavePolygon(pm, points2, p2bits, false));
     // System.out.println(zScaling);
 
-    GeoPoint point = new GeoPoint(pm, -0.9825762558001477, 2.4832136904725273);
-    GeoPoint quantizedPoint =
-        new GeoPoint(-0.4505446160475436, 0.34850109186970535, -0.8539966368663765);
-
     GeoArea xyzSolid =
         GeoAreaFactory.makeGeoArea(
             pm,
@@ -666,7 +661,7 @@ public class TestGeoPolygon extends LuceneTestCase {
 
     boolean illegalArgumentException = false;
     try {
-      final GeoPolygon p = GeoPolygonFactory.makeGeoPolygon(PlanetModel.WGS84, points, null);
+      GeoPolygonFactory.makeGeoPolygon(PlanetModel.WGS84, points, null);
     } catch (IllegalArgumentException e) {
       illegalArgumentException = true;
     }
@@ -699,7 +694,7 @@ public class TestGeoPolygon extends LuceneTestCase {
 
     boolean illegalArgumentException = false;
     try {
-      final GeoPolygon p = GeoPolygonFactory.makeGeoPolygon(PlanetModel.WGS84, points, null);
+      GeoPolygonFactory.makeGeoPolygon(PlanetModel.WGS84, points, null);
     } catch (IllegalArgumentException e) {
       illegalArgumentException = true;
     }
@@ -729,18 +724,17 @@ public class TestGeoPolygon extends LuceneTestCase {
     final GeoCompositePolygon rval = new GeoCompositePolygon(PlanetModel.WGS84);
     final GeoPolygonFactory.MutableBoolean mutableBoolean = new GeoPolygonFactory.MutableBoolean();
 
-    boolean result =
-        GeoPolygonFactory.buildPolygonShape(
-            rval,
-            mutableBoolean,
-            PlanetModel.WGS84,
-            points,
-            internal,
-            0,
-            1,
-            new SidedPlane(p1, p3, p2),
-            new ArrayList<GeoPolygon>(),
-            null);
+    GeoPolygonFactory.buildPolygonShape(
+        rval,
+        mutableBoolean,
+        PlanetModel.WGS84,
+        points,
+        internal,
+        0,
+        1,
+        new SidedPlane(p1, p3, p2),
+        new ArrayList<GeoPolygon>(),
+        null);
 
     assertFalse(mutableBoolean.value);
   }
@@ -770,7 +764,7 @@ public class TestGeoPolygon extends LuceneTestCase {
 
     shapeList.add(desc);
 
-    GeoPolygon p = GeoPolygonFactory.makeLargeGeoPolygon(PlanetModel.WGS84, shapeList);
+    GeoPolygonFactory.makeLargeGeoPolygon(PlanetModel.WGS84, shapeList);
   }
 
   @Test
@@ -854,8 +848,6 @@ public class TestGeoPolygon extends LuceneTestCase {
     */
 
     final GeoPoint point = new GeoPoint(PlanetModel.WGS84, -0.41518838180529244, 3.141592653589793);
-    final GeoPoint encodedPoint =
-        new GeoPoint(-0.9155623168963972, 2.3309121299774915E-10, -0.40359240449795253);
 
     assertTrue(p.isWithin(point) ? solid.isWithin(point) : true);
   }
@@ -1040,7 +1032,7 @@ public class TestGeoPolygon extends LuceneTestCase {
 
     boolean result;
     try {
-      final GeoConvexPolygon poly2 = new GeoConvexPolygon(PlanetModel.WGS84, poly2List);
+      new GeoConvexPolygon(PlanetModel.WGS84, poly2List);
       result = true;
     } catch (IllegalArgumentException e) {
       result = false;
@@ -1397,9 +1389,9 @@ public class TestGeoPolygon extends LuceneTestCase {
     points.add(
         new GeoPoint(
             PlanetModel.SPHERE, Geo3DUtil.fromDegrees(64.53775), Geo3DUtil.fromDegrees(-52.19148)));
-    GeoPolygon polygon = GeoPolygonFactory.makeGeoPolygon(PlanetModel.SPHERE, points);
+    GeoPolygonFactory.makeGeoPolygon(PlanetModel.SPHERE, points);
     Collections.reverse(points);
-    polygon = GeoPolygonFactory.makeGeoPolygon(PlanetModel.SPHERE, points);
+    GeoPolygonFactory.makeGeoPolygon(PlanetModel.SPHERE, points);
   }
 
   @Test
@@ -1495,9 +1487,9 @@ public class TestGeoPolygon extends LuceneTestCase {
     points.add(
         new GeoPoint(
             PlanetModel.SPHERE, Geo3DUtil.fromDegrees(50.455467), Geo3DUtil.fromDegrees(-3.48905)));
-    GeoPolygon polygon = GeoPolygonFactory.makeGeoPolygon(PlanetModel.SPHERE, points);
+    GeoPolygonFactory.makeGeoPolygon(PlanetModel.SPHERE, points);
     Collections.reverse(points);
-    polygon = GeoPolygonFactory.makeGeoPolygon(PlanetModel.SPHERE, points);
+    GeoPolygonFactory.makeGeoPolygon(PlanetModel.SPHERE, points);
   }
 
   /*
@@ -1582,7 +1574,6 @@ public class TestGeoPolygon extends LuceneTestCase {
     // Is the north pole in set, or out of set?
     final GeoPoint northPole = new GeoPoint(PlanetModel.WGS84, Math.PI * 0.5, 0.0);
     final GeoPoint negativeX = new GeoPoint(PlanetModel.WGS84, 0.0, Math.PI);
-    final GeoPoint negativeY = new GeoPoint(PlanetModel.WGS84, 0.0, -Math.PI * 0.5);
     final GeoPoint positiveY = new GeoPoint(PlanetModel.WGS84, 0.0, Math.PI * 0.5);
     final GeoPoint testPoint =
         new GeoPoint(-0.074161727332972, 0.5686488061123504, 0.8178445379383386);
@@ -1729,11 +1720,6 @@ public class TestGeoPolygon extends LuceneTestCase {
     // These are too close to parallel.  The only solution is to prevent the poly from being
     // created.  Let's see if Geo3d thinks they are parallel.
 
-    final Plane p1 = new Plane(-1.224646799147353E-16, -1.0, -7.498798913309287E-33, 0.0);
-    final Plane p2 =
-        new Plane(-3.0261581679831E-12, -0.9999999999999999, -1.8529874570670608E-28, 0.0);
-    final Plane p3 = new Plane(4.234084035470679E-12, 1.0, -1.5172037954732973E-12, 0.0);
-
     assertFalse(shape.isWithin(unquantized));
 
     // This point is indeed outside the shape but it doesn't matter
@@ -2704,7 +2690,6 @@ public class TestGeoPolygon extends LuceneTestCase {
 
     final GeoPolygonFactory.PolygonDescription description =
         new GeoPolygonFactory.PolygonDescription(points);
-    final GeoPolygon polygon = GeoPolygonFactory.makeGeoPolygon(PlanetModel.WGS84, description);
     final GeoPolygon largePolygon =
         GeoPolygonFactory.makeLargeGeoPolygon(
             PlanetModel.WGS84, Collections.singletonList(description));
diff --git a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/TestRandomGeoPolygon.java b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/TestRandomGeoPolygon.java
index 74fcfee..f7a5788 100644
--- a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/TestRandomGeoPolygon.java
+++ b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/TestRandomGeoPolygon.java
@@ -61,7 +61,7 @@ public class TestRandomGeoPolygon extends RandomGeo3dShapeGenerator {
     points.add(point3);
     points.add(point4);
     try {
-      GeoPolygon polygon = GeoPolygonFactory.makeGeoPolygon(PlanetModel.SPHERE, points);
+      GeoPolygonFactory.makeGeoPolygon(PlanetModel.SPHERE, points);
     } catch (Exception e) {
       fail(points.toString());
     }
diff --git a/lucene/suggest/src/java/org/apache/lucene/search/suggest/document/NRTSuggester.java b/lucene/suggest/src/java/org/apache/lucene/search/suggest/document/NRTSuggester.java
index 47a8035..f06f5f5 100644
--- a/lucene/suggest/src/java/org/apache/lucene/search/suggest/document/NRTSuggester.java
+++ b/lucene/suggest/src/java/org/apache/lucene/search/suggest/document/NRTSuggester.java
@@ -364,7 +364,7 @@ public final class NRTSuggester implements Accountable {
      * Label used to denote the end of an input in the FST and
      * the beginning of dedup bytes
      */
-    int endByte = input.readVInt();
+    input.readVInt(); // endByte
     int payloadSep = input.readVInt();
     return new NRTSuggester(fst, maxAnalyzedPathsPerOutput, payloadSep);
   }
diff --git a/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingDocValuesFormat.java b/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingDocValuesFormat.java
index 2b85a9a..27cedfe 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingDocValuesFormat.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingDocValuesFormat.java
@@ -82,7 +82,7 @@ public class AssertingDocValuesFormat extends DocValuesFormat {
         assert docID >= 0 && docID < maxDoc;
         assert docID > lastDocID;
         lastDocID = docID;
-        long value = values.longValue();
+        values.longValue();
       }
 
       in.addNumericField(field, valuesProducer);
@@ -146,7 +146,6 @@ public class AssertingDocValuesFormat extends DocValuesFormat {
         throws IOException {
       SortedNumericDocValues values = valuesProducer.getSortedNumeric(field);
 
-      long valueCount = 0;
       int lastDocID = -1;
       while (true) {
         int docID = values.nextDoc();
@@ -157,7 +156,6 @@ public class AssertingDocValuesFormat extends DocValuesFormat {
         lastDocID = values.docID();
         int count = values.docValueCount();
         assert count > 0;
-        valueCount += count;
         long previous = Long.MIN_VALUE;
         for (int i = 0; i < count; i++) {
           long nextValue = values.nextValue();
@@ -185,14 +183,12 @@ public class AssertingDocValuesFormat extends DocValuesFormat {
         lastValue = BytesRef.deepCopyOf(b);
       }
 
-      int docCount = 0;
       LongBitSet seenOrds = new LongBitSet(valueCount);
       while (true) {
         int docID = values.nextDoc();
         if (docID == NO_MORE_DOCS) {
           break;
         }
-        docCount++;
 
         long lastOrd = -1;
         while (true) {
diff --git a/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingNormsFormat.java b/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingNormsFormat.java
index b6683d7..ae10d84 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingNormsFormat.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingNormsFormat.java
@@ -69,7 +69,7 @@ public class AssertingNormsFormat extends NormsFormat {
         assert docID >= 0 && docID < maxDoc;
         assert docID > lastDocID;
         lastDocID = docID;
-        long value = values.longValue();
+        values.longValue();
       }
 
       in.addNormsField(field, valuesProducer);
diff --git a/lucene/test-framework/src/java/org/apache/lucene/index/BasePostingsFormatTestCase.java b/lucene/test-framework/src/java/org/apache/lucene/index/BasePostingsFormatTestCase.java
index a95c346..95e9b88 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/index/BasePostingsFormatTestCase.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/index/BasePostingsFormatTestCase.java
@@ -357,7 +357,6 @@ public abstract class BasePostingsFormatTestCase extends BaseIndexFileFormatTest
   public void testLevel2Ghosts() throws Exception {
     Directory dir = newDirectory();
 
-    Analyzer analyzer = new MockAnalyzer(random());
     IndexWriterConfig iwc = newIndexWriterConfig(null);
     iwc.setCodec(getCodec());
     iwc.setMergePolicy(newLogMergePolicy());
diff --git a/lucene/test-framework/src/test/org/apache/lucene/util/TestExpectThrows.java b/lucene/test-framework/src/test/org/apache/lucene/util/TestExpectThrows.java
index d29b28c..6b4a597 100644
--- a/lucene/test-framework/src/test/org/apache/lucene/util/TestExpectThrows.java
+++ b/lucene/test-framework/src/test/org/apache/lucene/util/TestExpectThrows.java
@@ -55,12 +55,11 @@ public class TestExpectThrows extends LuceneTestCase {
     final AtomicBoolean ran = new AtomicBoolean(false);
     AssertionError caught = null;
     try {
-      final IOException returned =
-          expectThrows(
-              IOException.class,
-              () -> {
-                ran.getAndSet(true);
-              });
+      expectThrows(
+          IOException.class,
+          () -> {
+            ran.getAndSet(true);
+          });
       fail("must not complete"); // NOTE: we don't use expectThrows to test expectThrows
     } catch (AssertionError ae) {
       caught = ae;
@@ -78,13 +77,12 @@ public class TestExpectThrows extends LuceneTestCase {
     final AtomicBoolean ran = new AtomicBoolean(false);
     AssertionError caught = null;
     try {
-      final IOException returned =
-          expectThrows(
-              IOException.class,
-              () -> {
-                ran.getAndSet(true);
-                fail("this failure should propogate");
-              });
+      expectThrows(
+          IOException.class,
+          () -> {
+            ran.getAndSet(true);
+            fail("this failure should propogate");
+          });
       fail("must not complete"); // NOTE: we don't use expectThrows to test expectThrows
     } catch (AssertionError ae) {
       caught = ae;
@@ -103,13 +101,12 @@ public class TestExpectThrows extends LuceneTestCase {
     final AtomicBoolean ran = new AtomicBoolean(false);
     AssumptionViolatedException caught = null;
     try {
-      final IOException returned =
-          expectThrows(
-              IOException.class,
-              () -> {
-                ran.getAndSet(true);
-                assumeTrue("this assumption should propogate", false);
-              });
+      expectThrows(
+          IOException.class,
+          () -> {
+            ran.getAndSet(true);
+            assumeTrue("this assumption should propogate", false);
+          });
       fail("must not complete"); // NOTE: we don't use expectThrows to test expectThrows
     } catch (AssumptionViolatedException ave) {
       caught = ave;