Skip to content

Commit 4d7447c

Browse files
authored
Reenable Checkstyle's unused import rule (#31270)
1 parent 2d4c9ce commit 4d7447c

File tree

19 files changed

+19
-47
lines changed

19 files changed

+19
-47
lines changed

buildSrc/src/main/resources/checkstyle.xml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,9 @@
2626
</module>
2727

2828
<module name="AvoidStarImport" />
29-
<!-- Doesn't pass but we could make it pass pretty quick.
30-
<module name="UnusedImports">
31-
The next property is optional. If we remove it then imports that are
32-
only referenced by Javadoc cause the check to fail.
33-
<property name="processJavadoc" value="true" />
34-
</module>
35-
-->
29+
30+
<!-- Unused imports are forbidden -->
31+
<module name="UnusedImports" />
3632

3733
<!-- Non-inner classes must be in files that match their names. -->
3834
<module name="OuterTypeFilename" />

client/rest/src/test/java/org/elasticsearch/client/RestClientMultipleHostsIntegTests.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,12 @@
3333
import java.net.InetAddress;
3434
import java.net.InetSocketAddress;
3535
import java.util.ArrayList;
36-
import java.util.Collections;
3736
import java.util.Iterator;
3837
import java.util.List;
3938
import java.util.concurrent.CopyOnWriteArrayList;
4039
import java.util.concurrent.CountDownLatch;
4140
import java.util.concurrent.TimeUnit;
4241

43-
import static java.util.Collections.singletonList;
4442
import static org.elasticsearch.client.RestClientTestUtil.getAllStatusCodes;
4543
import static org.elasticsearch.client.RestClientTestUtil.randomErrorNoRetryStatusCode;
4644
import static org.elasticsearch.client.RestClientTestUtil.randomOkStatusCode;

client/rest/src/test/java/org/elasticsearch/client/RestClientMultipleHostsTests.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,12 @@
5353
import java.util.concurrent.Executors;
5454
import java.util.concurrent.Future;
5555

56-
import static java.util.Collections.singletonList;
5756
import static org.elasticsearch.client.RestClientTestUtil.randomErrorNoRetryStatusCode;
5857
import static org.elasticsearch.client.RestClientTestUtil.randomErrorRetryStatusCode;
5958
import static org.elasticsearch.client.RestClientTestUtil.randomHttpMethod;
6059
import static org.elasticsearch.client.RestClientTestUtil.randomOkStatusCode;
6160
import static org.hamcrest.CoreMatchers.equalTo;
6261
import static org.hamcrest.CoreMatchers.instanceOf;
63-
import static org.hamcrest.Matchers.hasItem;
6462
import static org.junit.Assert.assertEquals;
6563
import static org.junit.Assert.assertThat;
6664
import static org.junit.Assert.assertTrue;

client/rest/src/test/java/org/elasticsearch/client/documentation/RestClientDocumentation.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import org.apache.http.ssl.SSLContextBuilder;
3737
import org.apache.http.ssl.SSLContexts;
3838
import org.apache.http.util.EntityUtils;
39-
import org.elasticsearch.client.HttpAsyncResponseConsumerFactory;
4039
import org.elasticsearch.client.HttpAsyncResponseConsumerFactory.HeapBufferedResponseConsumerFactory;
4140
import org.elasticsearch.client.Node;
4241
import org.elasticsearch.client.NodeSelector;

client/sniffer/src/main/java/org/elasticsearch/client/sniff/ElasticsearchNodesSniffer.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,8 @@
3636
import java.io.InputStream;
3737
import java.net.URI;
3838
import java.util.ArrayList;
39-
import java.util.Collections;
4039
import java.util.HashSet;
4140
import java.util.List;
42-
import java.util.Map;
4341
import java.util.Objects;
4442
import java.util.Set;
4543
import java.util.concurrent.TimeUnit;

client/sniffer/src/main/java/org/elasticsearch/client/sniff/SniffOnFailureListener.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
package org.elasticsearch.client.sniff;
2121

22-
import org.apache.http.HttpHost;
2322
import org.elasticsearch.client.Node;
2423
import org.elasticsearch.client.RestClient;
2524

modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4HttpPipeliningHandlerTests.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,10 @@
2828
import io.netty.channel.embedded.EmbeddedChannel;
2929
import io.netty.handler.codec.http.DefaultFullHttpRequest;
3030
import io.netty.handler.codec.http.DefaultFullHttpResponse;
31-
import io.netty.handler.codec.http.DefaultHttpRequest;
3231
import io.netty.handler.codec.http.FullHttpRequest;
3332
import io.netty.handler.codec.http.FullHttpResponse;
3433
import io.netty.handler.codec.http.HttpMethod;
3534
import io.netty.handler.codec.http.HttpRequest;
36-
import io.netty.handler.codec.http.HttpVersion;
3735
import io.netty.handler.codec.http.LastHttpContent;
3836
import io.netty.handler.codec.http.QueryStringDecoder;
3937
import org.elasticsearch.common.Randomness;

plugins/repository-azure/src/main/java/org/elasticsearch/repositories/azure/AzureBlobContainer.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import java.io.InputStream;
3333
import java.net.HttpURLConnection;
3434
import java.net.URISyntaxException;
35-
import java.nio.file.FileAlreadyExistsException;
3635
import java.nio.file.NoSuchFileException;
3736
import java.util.Map;
3837

server/src/main/java/org/elasticsearch/action/bulk/TransportShardBulkAction.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import org.elasticsearch.action.index.IndexRequest;
3030
import org.elasticsearch.action.index.IndexResponse;
3131
import org.elasticsearch.action.support.ActionFilters;
32-
import org.elasticsearch.action.support.TransportActions;
3332
import org.elasticsearch.action.support.replication.ReplicationOperation;
3433
import org.elasticsearch.action.support.replication.ReplicationResponse.ShardInfo;
3534
import org.elasticsearch.action.support.replication.TransportReplicationAction;

server/src/main/java/org/elasticsearch/common/CheckedRunnable.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919

2020
package org.elasticsearch.common;
2121

22-
import java.lang.Runnable;
23-
2422
/**
2523
* A {@link Runnable}-like interface which allows throwing checked exceptions.
2624
*/

server/src/main/java/org/elasticsearch/common/lucene/search/function/FunctionScoreQuery.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030
import org.apache.lucene.search.ScorerSupplier;
3131
import org.apache.lucene.search.Weight;
3232
import org.apache.lucene.util.Bits;
33-
import org.apache.lucene.search.TopDocsCollector;
34-
import org.apache.lucene.search.TopScoreDocCollector;
3533
import org.elasticsearch.ElasticsearchException;
3634
import org.elasticsearch.common.io.stream.StreamInput;
3735
import org.elasticsearch.common.io.stream.StreamOutput;
@@ -376,9 +374,9 @@ public float score() throws IOException {
376374
double factor = computeScore(docId, subQueryScore);
377375
float finalScore = scoreCombiner.combine(subQueryScore, factor, maxBoost);
378376
if (finalScore == Float.NEGATIVE_INFINITY || Float.isNaN(finalScore)) {
379-
/**
380-
* These scores are invalid for score based {@link TopDocsCollector}s.
381-
* See {@link TopScoreDocCollector} for details.
377+
/*
378+
These scores are invalid for score based {@link org.apache.lucene.search.TopDocsCollector}s.
379+
See {@link org.apache.lucene.search.TopScoreDocCollector} for details.
382380
*/
383381
throw new ElasticsearchException("function score query returned an invalid score: " + finalScore + " for doc: " + docId);
384382
}

server/src/main/java/org/elasticsearch/index/search/MatchQuery.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
import org.elasticsearch.common.lucene.search.MultiPhrasePrefixQuery;
5252
import org.elasticsearch.common.lucene.search.Queries;
5353
import org.elasticsearch.common.unit.Fuzziness;
54-
import org.elasticsearch.index.analysis.ShingleTokenFilterFactory;
5554
import org.elasticsearch.index.mapper.KeywordFieldMapper;
5655
import org.elasticsearch.index.mapper.MappedFieldType;
5756
import org.elasticsearch.index.query.QueryShardContext;
@@ -62,7 +61,7 @@
6261
import static org.elasticsearch.common.lucene.search.Queries.newLenientFieldQuery;
6362
import static org.elasticsearch.common.lucene.search.Queries.newUnmappedFieldQuery;
6463

65-
public class MatchQuery {
64+
public class MatchQuery {
6665

6766
public enum Type implements Writeable {
6867
/**
@@ -401,9 +400,9 @@ protected Query createFieldQuery(Analyzer analyzer, BooleanClause.Occur operator
401400
// query based on the analysis chain.
402401
try (TokenStream source = analyzer.tokenStream(field, queryText)) {
403402
if (source.hasAttribute(DisableGraphAttribute.class)) {
404-
/**
405-
* A {@link TokenFilter} in this {@link TokenStream} disabled the graph analysis to avoid
406-
* paths explosion. See {@link ShingleTokenFilterFactory} for details.
403+
/*
404+
A {@link TokenFilter} in this {@link TokenStream} disabled the graph analysis to avoid
405+
paths explosion. See {@link org.elasticsearch.index.analysis.ShingleTokenFilterFactory} for details.
407406
*/
408407
setEnableGraphQueries(false);
409408
}

server/src/main/java/org/elasticsearch/index/shard/PrimaryReplicaSyncer.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import org.elasticsearch.common.unit.ByteSizeValue;
3636
import org.elasticsearch.common.util.concurrent.AbstractRunnable;
3737
import org.elasticsearch.common.xcontent.XContentBuilder;
38-
import org.elasticsearch.index.seqno.SeqNoStats;
3938
import org.elasticsearch.index.seqno.SequenceNumbers;
4039
import org.elasticsearch.index.translog.Translog;
4140
import org.elasticsearch.tasks.Task;

server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/CompositeAggregator.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import org.apache.lucene.search.CollectionTerminatedException;
2626
import org.apache.lucene.search.DocIdSet;
2727
import org.apache.lucene.search.DocIdSetIterator;
28-
import org.apache.lucene.search.MultiCollector;
2928
import org.apache.lucene.search.Query;
3029
import org.apache.lucene.search.Scorer;
3130
import org.apache.lucene.search.Weight;
@@ -147,20 +146,20 @@ protected LeafBucketCollector getLeafCollector(LeafReaderContext ctx, LeafBucket
147146
finishLeaf();
148147
boolean fillDocIdSet = deferredCollectors != NO_OP_COLLECTOR;
149148
if (sortedDocsProducer != null) {
150-
/**
151-
* The producer will visit documents sorted by the leading source of the composite definition
152-
* and terminates when the leading source value is guaranteed to be greater than the lowest
153-
* composite bucket in the queue.
149+
/*
150+
The producer will visit documents sorted by the leading source of the composite definition
151+
and terminates when the leading source value is guaranteed to be greater than the lowest
152+
composite bucket in the queue.
154153
*/
155154
DocIdSet docIdSet = sortedDocsProducer.processLeaf(context.query(), queue, ctx, fillDocIdSet);
156155
if (fillDocIdSet) {
157156
entries.add(new Entry(ctx, docIdSet));
158157
}
159158

160-
/**
161-
* We can bypass search entirely for this segment, all the processing has been done in the previous call.
162-
* Throwing this exception will terminate the execution of the search for this root aggregation,
163-
* see {@link MultiCollector} for more details on how we handle early termination in aggregations.
159+
/*
160+
We can bypass search entirely for this segment, all the processing has been done in the previous call.
161+
Throwing this exception will terminate the execution of the search for this root aggregation,
162+
see {@link org.apache.lucene.search.MultiCollector} for more details on how we handle early termination in aggregations.
164163
*/
165164
throw new CollectionTerminatedException();
166165
} else {

server/src/main/java/org/elasticsearch/search/fetch/subphase/highlight/HighlightPhase.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import org.elasticsearch.common.component.AbstractComponent;
2424
import org.elasticsearch.common.regex.Regex;
2525
import org.elasticsearch.common.settings.Settings;
26-
import org.elasticsearch.index.mapper.DocumentMapper;
2726
import org.elasticsearch.index.mapper.KeywordFieldMapper;
2827
import org.elasticsearch.index.mapper.MappedFieldType;
2928
import org.elasticsearch.index.mapper.SourceFieldMapper;

server/src/main/java9/org/elasticsearch/monitor/jvm/JvmPid.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919

2020
package org.elasticsearch.monitor.jvm;
2121

22-
import java.lang.ProcessHandle;
23-
2422
class JvmPid {
2523

2624
static long getPid() {

test/framework/src/main/java/org/elasticsearch/index/replication/ESIndexLevelReplicationTestCase.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@
7474
import org.elasticsearch.threadpool.ThreadPool;
7575

7676
import java.io.IOException;
77-
import java.util.ArrayList;
7877
import java.util.Collections;
7978
import java.util.HashSet;
8079
import java.util.Iterator;

x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/saml/SamlAuthenticatorTests.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import org.apache.xml.security.keys.content.X509Data;
1515
import org.elasticsearch.ElasticsearchSecurityException;
1616
import org.elasticsearch.common.CheckedConsumer;
17-
import org.elasticsearch.common.Nullable;
1817
import org.elasticsearch.common.Strings;
1918
import org.elasticsearch.common.collect.Tuple;
2019
import org.elasticsearch.common.logging.Loggers;

x-pack/qa/smoke-test-plugins-ssl/src/test/java/org/elasticsearch/smoketest/SmokeTestMonitoringWithSecurityIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ private boolean getMonitoringUsageExportersDefined() throws Exception {
9595
public void testHTTPExporterWithSSL() throws Exception {
9696
// Ensures that the exporter is actually on
9797
assertBusy(() -> assertThat("[_http] exporter is not defined", getMonitoringUsageExportersDefined(), is(true)));
98-
98+
9999
// Checks that the monitoring index templates have been installed
100100
assertBusy(() -> {
101101
GetIndexTemplatesResponse response = client().admin().indices().prepareGetTemplates(MONITORING_PATTERN).get();

0 commit comments

Comments
 (0)