Skip to content

Commit

Permalink
Merge branch '2.x' into backport2.x-1951
Browse files Browse the repository at this point in the history
Signed-off-by: Mitchell Gale <[email protected]>
  • Loading branch information
MitchellGale authored Aug 22, 2023
2 parents 70f45ee + d205bd6 commit 314aa5c
Show file tree
Hide file tree
Showing 331 changed files with 6,580 additions and 6,837 deletions.
29 changes: 23 additions & 6 deletions DEVELOPER_GUIDE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,31 @@ Note that other related project code has already merged into this single reposit
Code Convention
---------------

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:
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`.

* 2 spaces indentation.
* No line starts with tab character in source file.
* Line width <= 100 characters.
* 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.
* Operator needs to wrap at next line.
The formatting check can be run explicitly with::

./gradlew spotlessJavaCheck

The code can be formatted with::

./gradlew spotlessApply

These tasks can also be run for specific modules, e.g.::

./gradlew server:spotlessJavaCheck

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>`_.

Java files are formatted using `Spotless <https://github.com/diffplug/spotless>`_ conforming to `Google Java Format <https://github.com/google/google-java-format>`_.
* - New line at end of file
* - No unused import statements
* - Fix import order to be alphabetical with static imports first (one block for static and one for non-static imports)
* - Max line length is 100 characters (does not apply to import statements)
* - Line spacing is 2 spaces
* - Javadocs should be properly formatted in accordance to `Javadoc guidelines <https://www.oracle.com/ca-en/technical-resources/articles/java/javadoc-tool.html>`_
* - Javadoc format can be maintained by wrapping javadoc with `<pre></pre>` HTML tags
* - Strings can be formatted on multiple lines with a `+` with the correct indentation for the string.

Building and Running Tests
==========================
Expand Down
6 changes: 4 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ spotless {
java {
target fileTree('.') {
include 'core/src/main/java/org/opensearch/sql/DataSourceSchemaName.java',
'core/src/test/java/org/opensearch/sql/data/**/*.java',
include 'core/src/main/java/org/opensearch/sql/monitor/**/*.java',
'core/src/main/java/org/opensearch/sql/exception/**/*.java',
'core/src/main/java/org/opensearch/sql/DataSourceSchemaName.java',
'core/src/test/java/org/opensearch/sql/config/**/*.java',
'core/src/test/java/org/opensearch/sql/analysis/**/*.java',
'core/src/main/java/org/opensearch/sql/planner/**/*.java',
Expand All @@ -94,11 +96,11 @@ spotless {
'core/src/main/java/org/opensearch/sql/monitor/**/*.java',
'core/src/main/java/org/opensearch/sql/expression/**/*.java',
'core/src/main/java/org/opensearch/sql/executor/**/*.java',
'core/src/main/java/org/opensearch/sql/exception/**/*.java',
'core/src/main/java/org/opensearch/sql/analysis/**/*.java',
'core/src/test/java/org/opensearch/sql/data/**/*.java',
'core/src/test/java/org/opensearch/sql/datasource/**/*.java',
'core/src/test/java/org/opensearch/sql/ast/**/*.java'
'core/src/main/java/org/opensearch/sql/utils/**/*.java'
exclude '**/build/**', '**/build-*/**'
}
importOrder()
Expand Down
11 changes: 0 additions & 11 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,17 @@ plugins {
id 'java-library'
id "io.freefair.lombok"
id 'jacoco'
id 'info.solidsoft.pitest' version '1.9.0'
id 'java-test-fixtures'
}

repositories {
mavenCentral()
}

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

pitest {
targetClasses = ['org.opensearch.sql.*']
pitestVersion = '1.9.0'
threads = 4
outputFormats = ['HTML', 'XML']
timestampedReports = false
junit5PluginVersion = '1.0.0'
}

dependencies {
api group: 'com.google.guava', name: 'guava', version: '32.0.1-jre'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@ public class DataSourceSchemaName {
private final String dataSourceName;

private final String schemaName;

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* SPDX-License-Identifier: Apache-2.0
*/


package org.opensearch.sql.analysis;

import java.util.ArrayList;
Expand All @@ -13,26 +12,22 @@
import org.opensearch.sql.expression.NamedExpression;
import org.opensearch.sql.expression.function.FunctionProperties;

/**
* The context used for Analyzer.
*/
/** The context used for Analyzer. */
public class AnalysisContext {
/**
* Environment stack for symbol scope management.
*/
/** Environment stack for symbol scope management. */
private TypeEnvironment environment;
@Getter
private final List<NamedExpression> namedParseExpressions;

@Getter
private final FunctionProperties functionProperties;
@Getter private final List<NamedExpression> namedParseExpressions;

@Getter private final FunctionProperties functionProperties;

public AnalysisContext() {
this(new TypeEnvironment(null));
}

/**
* Class CTOR.
*
* @param environment Env to set to a new instance.
*/
public AnalysisContext(TypeEnvironment environment) {
Expand All @@ -41,9 +36,7 @@ public AnalysisContext(TypeEnvironment environment) {
this.functionProperties = new FunctionProperties();
}

/**
* Push a new environment.
*/
/** Push a new environment. */
public void push() {
environment = new TypeEnvironment(environment);
}
Expand Down
Loading

0 comments on commit 314aa5c

Please sign in to comment.