Skip to content

Commit 15c461d

Browse files
authored
ESQL: Disable format checks on generated imports (#127648)
This builds the infrastructure to disable spotless and some checkstyle rules on generated imports. This works around the most frustrating part of ESQL's string template generated files - the imports. It allows unused and out of order imports. This can let us remove a lot of cumbersome, tricky, and fairly useless `$if$` blocks from the templates.
1 parent f90b015 commit 15c461d

File tree

9 files changed

+37
-11
lines changed

9 files changed

+37
-11
lines changed

build-tools-internal/src/main/resources/checkstyle.xml

+5
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@
6868

6969
<!-- Unused imports are forbidden -->
7070
<module name="UnusedImports" />
71+
<module name="SuppressionCommentFilter">
72+
<property name="offCommentFormat" value="begin generated imports"/>
73+
<property name="onCommentFormat" value="end generated imports"/>
74+
<property name="checkFormat" value="UnusedImports"/>
75+
</module>
7176

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

x-pack/plugin/esql/compute/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ spotless {
4949
/*
5050
* Generated files go here.
5151
*/
52+
toggleOffOn('begin generated imports', 'end generated imports')
5253
targetExclude "src/main/generated/**/*.java"
5354
}
5455
}

x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/BooleanArrayVector.java

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/BytesRefArrayVector.java

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/DoubleArrayVector.java

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/FloatArrayVector.java

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/IntArrayVector.java

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/LongArrayVector.java

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/X-ArrayVector.java.st

+2-11
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
package org.elasticsearch.compute.data;
99

10-
$if(BytesRef)$
10+
// begin generated imports
1111
import org.apache.lucene.util.BytesRef;
1212
import org.apache.lucene.util.RamUsageEstimator;
1313
import org.elasticsearch.common.io.stream.StreamInput;
@@ -17,19 +17,10 @@ import org.elasticsearch.common.util.BytesRefArray;
1717
import org.elasticsearch.core.ReleasableIterator;
1818
import org.elasticsearch.core.Releasables;
1919

20-
import java.io.IOException;
21-
22-
$else$
23-
import org.apache.lucene.util.RamUsageEstimator;
24-
import org.elasticsearch.common.io.stream.StreamInput;
25-
import org.elasticsearch.common.io.stream.StreamOutput;
26-
import org.elasticsearch.common.unit.ByteSizeValue;
27-
import org.elasticsearch.core.ReleasableIterator;
28-
2920
import java.io.IOException;
3021
import java.util.stream.Collectors;
3122
import java.util.stream.IntStream;
32-
$endif$
23+
// end generated imports
3324

3425
/**
3526
* Vector implementation that stores an array of $type$ values.

0 commit comments

Comments
 (0)