Skip to content

Commit 314aa5c

Browse files
authored
Merge branch '2.x' into backport2.x-1951
Signed-off-by: Mitchell Gale <[email protected]>
2 parents 70f45ee + d205bd6 commit 314aa5c

File tree

331 files changed

+6580
-6837
lines changed

Some content is hidden

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

331 files changed

+6580
-6837
lines changed

DEVELOPER_GUIDE.rst

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,31 @@ Note that other related project code has already merged into this single reposit
185185
Code Convention
186186
---------------
187187

188-
We’re integrated Checkstyle plugin into Gradle build: https://github.com/opensearch-project/sql/blob/main/config/checkstyle/google_checks.xml. So any violation will fail the build. You need to identify the offending code from Gradle error message and fix them and rerun the Gradle build. Here are the highlight of some Checkstyle rules:
188+
Java files in the OpenSearch codebase are formatted with the Eclipse JDT formatter, using the `Spotless Gradle <https://github.com/diffplug/spotless/tree/master/plugin-gradle>`_ plugin. This plugin is configured in the project `./gradle.properties`.
189189

190-
* 2 spaces indentation.
191-
* No line starts with tab character in source file.
192-
* Line width <= 100 characters.
193-
* Wildcard imports: You can enforce single import by configuring your IDE. Instructions for Intellij IDEA: https://www.jetbrains.com/help/idea/creating-and-optimizing-imports.html#disable-wildcard-imports.
194-
* Operator needs to wrap at next line.
190+
The formatting check can be run explicitly with::
195191

192+
./gradlew spotlessJavaCheck
193+
194+
The code can be formatted with::
195+
196+
./gradlew spotlessApply
197+
198+
These tasks can also be run for specific modules, e.g.::
199+
200+
./gradlew server:spotlessJavaCheck
201+
202+
For more information on the spotless for the OpenSearch project please see `https://github.com/opensearch-project/OpenSearch/blob/main/DEVELOPER_GUIDE.md#java-language-formatting-guidelines <https://github.com/opensearch-project/OpenSearch/blob/main/DEVELOPER_GUIDE.md#java-language-formatting-guidelines>`_.
203+
204+
Java files are formatted using `Spotless <https://github.com/diffplug/spotless>`_ conforming to `Google Java Format <https://github.com/google/google-java-format>`_.
205+
* - New line at end of file
206+
* - No unused import statements
207+
* - Fix import order to be alphabetical with static imports first (one block for static and one for non-static imports)
208+
* - Max line length is 100 characters (does not apply to import statements)
209+
* - Line spacing is 2 spaces
210+
* - Javadocs should be properly formatted in accordance to `Javadoc guidelines <https://www.oracle.com/ca-en/technical-resources/articles/java/javadoc-tool.html>`_
211+
* - Javadoc format can be maintained by wrapping javadoc with `<pre></pre>` HTML tags
212+
* - Strings can be formatted on multiple lines with a `+` with the correct indentation for the string.
196213

197214
Building and Running Tests
198215
==========================

build.gradle

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ spotless {
8585
java {
8686
target fileTree('.') {
8787
include 'core/src/main/java/org/opensearch/sql/DataSourceSchemaName.java',
88-
'core/src/test/java/org/opensearch/sql/data/**/*.java',
88+
include 'core/src/main/java/org/opensearch/sql/monitor/**/*.java',
89+
'core/src/main/java/org/opensearch/sql/exception/**/*.java',
90+
'core/src/main/java/org/opensearch/sql/DataSourceSchemaName.java',
8991
'core/src/test/java/org/opensearch/sql/config/**/*.java',
9092
'core/src/test/java/org/opensearch/sql/analysis/**/*.java',
9193
'core/src/main/java/org/opensearch/sql/planner/**/*.java',
@@ -94,11 +96,11 @@ spotless {
9496
'core/src/main/java/org/opensearch/sql/monitor/**/*.java',
9597
'core/src/main/java/org/opensearch/sql/expression/**/*.java',
9698
'core/src/main/java/org/opensearch/sql/executor/**/*.java',
97-
'core/src/main/java/org/opensearch/sql/exception/**/*.java',
9899
'core/src/main/java/org/opensearch/sql/analysis/**/*.java',
99100
'core/src/test/java/org/opensearch/sql/data/**/*.java',
100101
'core/src/test/java/org/opensearch/sql/datasource/**/*.java',
101102
'core/src/test/java/org/opensearch/sql/ast/**/*.java'
103+
'core/src/main/java/org/opensearch/sql/utils/**/*.java'
102104
exclude '**/build/**', '**/build-*/**'
103105
}
104106
importOrder()

core/build.gradle

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,17 @@ plugins {
2626
id 'java-library'
2727
id "io.freefair.lombok"
2828
id 'jacoco'
29-
id 'info.solidsoft.pitest' version '1.9.0'
3029
id 'java-test-fixtures'
3130
}
3231

3332
repositories {
3433
mavenCentral()
3534
}
3635

37-
// Being ignored as a temporary measure before being removed in favour of
38-
// spotless https://github.com/opensearch-project/sql/issues/1101
3936
checkstyleTest.ignoreFailures = true
4037
checkstyleMain.ignoreFailures = true
4138
checkstyleTestFixtures.ignoreFailures = true
4239

43-
pitest {
44-
targetClasses = ['org.opensearch.sql.*']
45-
pitestVersion = '1.9.0'
46-
threads = 4
47-
outputFormats = ['HTML', 'XML']
48-
timestampedReports = false
49-
junit5PluginVersion = '1.0.0'
50-
}
5140

5241
dependencies {
5342
api group: 'com.google.guava', name: 'guava', version: '32.0.1-jre'

core/src/main/java/org/opensearch/sql/DataSourceSchemaName.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,4 @@ public class DataSourceSchemaName {
1717
private final String dataSourceName;
1818

1919
private final String schemaName;
20-
2120
}

core/src/main/java/org/opensearch/sql/analysis/AnalysisContext.java

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
76
package org.opensearch.sql.analysis;
87

98
import java.util.ArrayList;
@@ -13,26 +12,22 @@
1312
import org.opensearch.sql.expression.NamedExpression;
1413
import org.opensearch.sql.expression.function.FunctionProperties;
1514

16-
/**
17-
* The context used for Analyzer.
18-
*/
15+
/** The context used for Analyzer. */
1916
public class AnalysisContext {
20-
/**
21-
* Environment stack for symbol scope management.
22-
*/
17+
/** Environment stack for symbol scope management. */
2318
private TypeEnvironment environment;
24-
@Getter
25-
private final List<NamedExpression> namedParseExpressions;
2619

27-
@Getter
28-
private final FunctionProperties functionProperties;
20+
@Getter private final List<NamedExpression> namedParseExpressions;
21+
22+
@Getter private final FunctionProperties functionProperties;
2923

3024
public AnalysisContext() {
3125
this(new TypeEnvironment(null));
3226
}
3327

3428
/**
3529
* Class CTOR.
30+
*
3631
* @param environment Env to set to a new instance.
3732
*/
3833
public AnalysisContext(TypeEnvironment environment) {
@@ -41,9 +36,7 @@ public AnalysisContext(TypeEnvironment environment) {
4136
this.functionProperties = new FunctionProperties();
4237
}
4338

44-
/**
45-
* Push a new environment.
46-
*/
39+
/** Push a new environment. */
4740
public void push() {
4841
environment = new TypeEnvironment(environment);
4942
}

0 commit comments

Comments
 (0)