Skip to content

Commit 6cc0670

Browse files
Enable compiler warnings in xpack core plugin project (#66899)
Co-authored-by: Elastic Machine <[email protected]>
1 parent 7be55a2 commit 6cc0670

File tree

51 files changed

+118
-67
lines changed

Some content is hidden

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

51 files changed

+118
-67
lines changed

test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,11 +713,15 @@ public static int randomInt(int max) {
713713
}
714714

715715
/** Pick a random object from the given array. The array must not be empty. */
716+
@SafeVarargs
717+
@SuppressWarnings("varargs")
716718
public static <T> T randomFrom(T... array) {
717719
return randomFrom(random(), array);
718720
}
719721

720722
/** Pick a random object from the given array. The array must not be empty. */
723+
@SafeVarargs
724+
@SuppressWarnings("varargs")
721725
public static <T> T randomFrom(Random random, T... array) {
722726
return RandomPicks.randomFrom(random, array);
723727
}

x-pack/plugin/core/build.gradle

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,6 @@ tasks.named('forbiddenApisMain').configure {
106106
signaturesFiles += files('forbidden/hasher-signatures.txt')
107107
}
108108

109-
tasks.withType(JavaCompile).configureEach {
110-
options.compilerArgs << "-Xlint:-rawtypes,-unchecked"
111-
}
112109

113110
// make LicenseSigner available for testing signed licenses
114111
sourceSets.test.resources {

x-pack/plugin/core/src/internalClusterTest/java/org/elasticsearch/xpack/core/search/PointInTimeIT.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@ public void testPITTiebreak() throws Exception {
415415
}
416416
}
417417

418+
@SuppressWarnings({"rawtypes","unchecked"})
418419
private void assertPagination(PointInTimeBuilder pit, int expectedNumDocs, int size, SortBuilder<?>... sorts) throws Exception {
419420
Set<String> seen = new HashSet<>();
420421
SearchRequestBuilder builder = client().prepareSearch()

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/action/AbstractGetResourcesResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public boolean equals(Object obj) {
7171
if (obj instanceof AbstractGetResourcesResponse == false) {
7272
return false;
7373
}
74-
AbstractGetResourcesResponse other = (AbstractGetResourcesResponse) obj;
74+
AbstractGetResourcesResponse<?> other = (AbstractGetResourcesResponse<?>) obj;
7575
return Objects.equals(resources, other.resources);
7676
}
7777

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/EvaluateDataFrameAction.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public static class Request extends ActionRequest implements ToXContentObject {
5151
private static final ParseField QUERY = new ParseField("query");
5252
private static final ParseField EVALUATION = new ParseField("evaluation");
5353

54+
@SuppressWarnings({ "unchecked"})
5455
private static final ConstructingObjectParser<Request, Void> PARSER = new ConstructingObjectParser<>(
5556
NAME,
5657
a -> new Request((List<String>) a[0], (QueryProvider) a[1], (Evaluation) a[2]));

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/ExplainDataFrameAnalyticsAction.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public static class Response extends ActionResponse implements ToXContentObject
3737
public static final ParseField FIELD_SELECTION = new ParseField("field_selection");
3838
public static final ParseField MEMORY_ESTIMATION = new ParseField("memory_estimation");
3939

40+
@SuppressWarnings({ "unchecked"})
4041
static final ConstructingObjectParser<Response, Void> PARSER =
4142
new ConstructingObjectParser<>(
4243
TYPE.getPreferredName(),

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/DataFrameAnalyticsSource.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public class DataFrameAnalyticsSource implements Writeable, ToXContentObject {
4343
public static final ParseField QUERY = new ParseField("query");
4444
public static final ParseField _SOURCE = new ParseField("_source");
4545

46+
@SuppressWarnings({ "unchecked"})
4647
public static ConstructingObjectParser<DataFrameAnalyticsSource, Void> createParser(boolean ignoreUnknownFields) {
4748
ConstructingObjectParser<DataFrameAnalyticsSource, Void> parser = new ConstructingObjectParser<>("data_frame_analytics_source",
4849
ignoreUnknownFields, a -> new DataFrameAnalyticsSource(

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/outlierdetection/ConfusionMatrix.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public class ConfusionMatrix extends AbstractConfusionMatrixMetric {
2828

2929
public static final ParseField NAME = new ParseField("confusion_matrix");
3030

31+
@SuppressWarnings("unchecked")
3132
private static final ConstructingObjectParser<ConfusionMatrix, Void> PARSER = new ConstructingObjectParser<>(NAME.getPreferredName(),
3233
a -> new ConfusionMatrix((List<Double>) a[0]));
3334

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/outlierdetection/OutlierDetection.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public class OutlierDetection implements Evaluation {
3838

3939
private static final ParseField METRICS = new ParseField("metrics");
4040

41+
@SuppressWarnings("unchecked")
4142
public static final ConstructingObjectParser<OutlierDetection, Void> PARSER = new ConstructingObjectParser<>(
4243
NAME.getPreferredName(), a -> new OutlierDetection((String) a[0], (String) a[1], (List<EvaluationMetric>) a[2]));
4344

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/outlierdetection/Precision.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public class Precision extends AbstractConfusionMatrixMetric {
2626

2727
public static final ParseField NAME = new ParseField("precision");
2828

29+
@SuppressWarnings("unchecked")
2930
private static final ConstructingObjectParser<Precision, Void> PARSER = new ConstructingObjectParser<>(NAME.getPreferredName(),
3031
a -> new Precision((List<Double>) a[0]));
3132

0 commit comments

Comments
 (0)