Skip to content

Commit ba49b86

Browse files
committed
ESQL: Disable format checks on generated imports
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 6263f44 commit ba49b86

File tree

9 files changed

+37
-11
lines changed

9 files changed

+37
-11
lines changed

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

Lines changed: 5 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 5 additions & 0 deletions
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

Lines changed: 4 additions & 0 deletions
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

Lines changed: 5 additions & 0 deletions
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

Lines changed: 5 additions & 0 deletions
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

Lines changed: 5 additions & 0 deletions
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

Lines changed: 5 additions & 0 deletions
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

Lines changed: 2 additions & 11 deletions
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)