Skip to content

Commit 67273d8

Browse files
Christoph Büscherkcm
authored andcommitted
Clean up "unused variable" warnings (#31876)
This change cleans up "unused variable" warnings. There are several cases were we most likely want to suppress the warnings (especially in the client documentation test where the snippets contain many unused variables). In a lot of cases the unused variables can just be deleted though.
1 parent 0504cb6 commit 67273d8

File tree

119 files changed

+320
-548
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+320
-548
lines changed

client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/CRUDDocumentationIT.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@
114114
*/
115115
public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
116116

117+
@SuppressWarnings("unused")
117118
public void testIndex() throws Exception {
118119
RestHighLevelClient client = highLevelClient();
119120

@@ -278,6 +279,7 @@ public void onFailure(Exception e) {
278279
}
279280
}
280281

282+
@SuppressWarnings("unused")
281283
public void testUpdate() throws Exception {
282284
RestHighLevelClient client = highLevelClient();
283285
{
@@ -546,6 +548,7 @@ public void onFailure(Exception e) {
546548
}
547549
}
548550

551+
@SuppressWarnings("unused")
549552
public void testDelete() throws Exception {
550553
RestHighLevelClient client = highLevelClient();
551554

@@ -665,6 +668,7 @@ public void onFailure(Exception e) {
665668
}
666669
}
667670

671+
@SuppressWarnings("unused")
668672
public void testBulk() throws Exception {
669673
RestHighLevelClient client = highLevelClient();
670674
{
@@ -767,6 +771,7 @@ public void onFailure(Exception e) {
767771
}
768772
}
769773

774+
@SuppressWarnings("unused")
770775
public void testReindex() throws Exception {
771776
RestHighLevelClient client = highLevelClient();
772777
{
@@ -905,6 +910,7 @@ public void onFailure(Exception e) {
905910
}
906911
}
907912

913+
@SuppressWarnings("unused")
908914
public void testReindexRethrottle() throws Exception {
909915
RestHighLevelClient client = highLevelClient();
910916
TaskId taskId = new TaskId("oTUltX4IQMOUUVeiohTt8A:124");
@@ -947,6 +953,7 @@ public void onFailure(Exception e) {
947953
assertTrue(latch.await(30L, TimeUnit.SECONDS));
948954
}
949955

956+
@SuppressWarnings("unused")
950957
public void testUpdateByQuery() throws Exception {
951958
RestHighLevelClient client = highLevelClient();
952959
{
@@ -1066,6 +1073,7 @@ public void onFailure(Exception e) {
10661073
}
10671074
}
10681075

1076+
@SuppressWarnings("unused")
10691077
public void testDeleteByQuery() throws Exception {
10701078
RestHighLevelClient client = highLevelClient();
10711079
{
@@ -1173,6 +1181,7 @@ public void onFailure(Exception e) {
11731181
}
11741182
}
11751183

1184+
@SuppressWarnings("unused")
11761185
public void testGet() throws Exception {
11771186
RestHighLevelClient client = highLevelClient();
11781187
{
@@ -1487,6 +1496,7 @@ public void afterBulk(long executionId, BulkRequest request, Throwable failure)
14871496
}
14881497
}
14891498

1499+
@SuppressWarnings("unused")
14901500
public void testMultiGet() throws Exception {
14911501
RestHighLevelClient client = highLevelClient();
14921502

client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/ClusterClientDocumentationIT.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ public void onFailure(Exception e) {
192192
}
193193
}
194194

195+
@SuppressWarnings("unused")
195196
public void testClusterGetSettings() throws IOException {
196197
RestHighLevelClient client = highLevelClient();
197198

@@ -257,6 +258,7 @@ public void onFailure(Exception e) {
257258
assertTrue(latch.await(30L, TimeUnit.SECONDS));
258259
}
259260

261+
@SuppressWarnings("unused")
260262
public void testClusterHealth() throws IOException {
261263
RestHighLevelClient client = highLevelClient();
262264
client.indices().create(new CreateIndexRequest("index"), RequestOptions.DEFAULT);

client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/IndicesClientDocumentationIT.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,7 @@ public void onFailure(Exception e) {
706706
}
707707
}
708708

709+
@SuppressWarnings("unused")
709710
public void testGetFieldMapping() throws IOException, InterruptedException {
710711
RestHighLevelClient client = highLevelClient();
711712

@@ -891,6 +892,7 @@ public void onFailure(Exception e) {
891892
}
892893
}
893894

895+
@SuppressWarnings("unused")
894896
public void testRefreshIndex() throws Exception {
895897
RestHighLevelClient client = highLevelClient();
896898

@@ -959,6 +961,7 @@ public void onFailure(Exception e) {
959961
}
960962
}
961963

964+
@SuppressWarnings("unused")
962965
public void testFlushIndex() throws Exception {
963966
RestHighLevelClient client = highLevelClient();
964967

@@ -1035,6 +1038,7 @@ public void onFailure(Exception e) {
10351038
}
10361039
}
10371040

1041+
@SuppressWarnings("unused")
10381042
public void testSyncedFlushIndex() throws Exception {
10391043
RestHighLevelClient client = highLevelClient();
10401044

@@ -1308,6 +1312,7 @@ public void onFailure(Exception e) {
13081312
assertTrue(latch.await(30L, TimeUnit.SECONDS));
13091313
}
13101314

1315+
@SuppressWarnings("unused")
13111316
public void testForceMergeIndex() throws Exception {
13121317
RestHighLevelClient client = highLevelClient();
13131318

@@ -1381,6 +1386,7 @@ public void onFailure(Exception e) {
13811386
}
13821387
}
13831388

1389+
@SuppressWarnings("unused")
13841390
public void testClearCache() throws Exception {
13851391
RestHighLevelClient client = highLevelClient();
13861392

@@ -1527,6 +1533,7 @@ public void onFailure(Exception e) {
15271533
}
15281534
}
15291535

1536+
@SuppressWarnings("unused")
15301537
public void testExistsAlias() throws Exception {
15311538
RestHighLevelClient client = highLevelClient();
15321539

@@ -1590,6 +1597,7 @@ public void onFailure(Exception e) {
15901597
}
15911598
}
15921599

1600+
@SuppressWarnings("unused")
15931601
public void testUpdateAliases() throws Exception {
15941602
RestHighLevelClient client = highLevelClient();
15951603

@@ -1915,6 +1923,7 @@ public void onFailure(Exception e) {
19151923
assertTrue(latch.await(30L, TimeUnit.SECONDS));
19161924
}
19171925

1926+
@SuppressWarnings("unused")
19181927
public void testGetAlias() throws Exception {
19191928
RestHighLevelClient client = highLevelClient();
19201929

@@ -1985,6 +1994,7 @@ public void onFailure(Exception e) {
19851994
}
19861995
}
19871996

1997+
@SuppressWarnings("unused")
19881998
public void testIndexPutSettings() throws Exception {
19891999
RestHighLevelClient client = highLevelClient();
19902000

@@ -2315,6 +2325,7 @@ public void onFailure(Exception e) {
23152325
assertTrue(latch.await(30L, TimeUnit.SECONDS));
23162326
}
23172327

2328+
@SuppressWarnings("unused")
23182329
public void testValidateQuery() throws IOException, InterruptedException {
23192330
RestHighLevelClient client = highLevelClient();
23202331

client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/IngestClientDocumentationIT.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ public void onFailure(Exception e) {
143143
}
144144
}
145145

146+
@SuppressWarnings("unused")
146147
public void testGetPipeline() throws IOException {
147148
RestHighLevelClient client = highLevelClient();
148149

client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/SearchDocumentationIT.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ public void testSearchRequestSuggestions() throws IOException {
413413
}
414414
}
415415

416+
@SuppressWarnings("unused")
416417
public void testSearchRequestHighlighting() throws IOException {
417418
RestHighLevelClient client = highLevelClient();
418419
{
@@ -831,6 +832,8 @@ public void onFailure(Exception e) {
831832
assertTrue(latch.await(30L, TimeUnit.SECONDS));
832833
}
833834

835+
836+
@SuppressWarnings("unused")
834837
public void testMultiSearchTemplateWithInlineScript() throws Exception {
835838
indexSearchTestData();
836839
RestHighLevelClient client = highLevelClient();

client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/SnapshotClientDocumentationIT.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,7 @@ public void onFailure(Exception exception) {
577577
}
578578
}
579579

580+
@SuppressWarnings("unused")
580581
public void testSnapshotGetSnapshots() throws IOException {
581582
RestHighLevelClient client = highLevelClient();
582583

client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/StoredScriptsDocumentationIT.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
*/
6767
public class StoredScriptsDocumentationIT extends ESRestHighLevelClientTestCase {
6868

69+
@SuppressWarnings("unused")
6970
public void testGetStoredScript() throws Exception {
7071
RestHighLevelClient client = highLevelClient();
7172

@@ -128,6 +129,7 @@ public void onFailure(Exception e) {
128129

129130
}
130131

132+
@SuppressWarnings("unused")
131133
public void testDeleteStoredScript() throws Exception {
132134
RestHighLevelClient client = highLevelClient();
133135

client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/TasksClientDocumentationIT.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
*/
6767
public class TasksClientDocumentationIT extends ESRestHighLevelClientTestCase {
6868

69+
@SuppressWarnings("unused")
6970
public void testListTasks() throws IOException {
7071
RestHighLevelClient client = highLevelClient();
7172
{
@@ -149,6 +150,7 @@ public void onFailure(Exception e) {
149150
}
150151
}
151152

153+
@SuppressWarnings("unused")
152154
public void testCancelTasks() throws IOException {
153155
RestHighLevelClient client = highLevelClient();
154156
{

libs/grok/src/main/java/org/elasticsearch/grok/Grok.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@
3535
import java.io.UncheckedIOException;
3636
import java.nio.charset.StandardCharsets;
3737
import java.util.ArrayList;
38+
import java.util.Collections;
3839
import java.util.HashMap;
3940
import java.util.Iterator;
4041
import java.util.List;
4142
import java.util.Locale;
4243
import java.util.Map;
43-
import java.util.Collections;
4444

4545
public final class Grok {
4646

@@ -184,6 +184,7 @@ public String toRegex(String grokPattern) {
184184
String namedPatternRef = groupMatch(NAME_GROUP, region, grokPattern);
185185
String subName = groupMatch(SUBNAME_GROUP, region, grokPattern);
186186
// TODO(tal): Support definitions
187+
@SuppressWarnings("unused")
187188
String definition = groupMatch(DEFINITION_GROUP, region, grokPattern);
188189
String patternName = groupMatch(PATTERN_GROUP, region, grokPattern);
189190

libs/grok/src/test/java/org/elasticsearch/grok/GrokTests.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,6 @@ public void testCircularReference() {
262262
}
263263

264264
public void testBooleanCaptures() {
265-
Map<String, String> bank = new HashMap<>();
266-
267265
String pattern = "%{WORD:name}=%{WORD:status:boolean}";
268266
Grok g = new Grok(basePatterns, pattern);
269267

0 commit comments

Comments
 (0)