Skip to content

Applying spotless changes. #289

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 5 additions & 1 deletion DEVELOPER_GUIDE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Note that missing license header will be detected by Gradle license plugin and f
Making Code Changes
===================

Project Strucure
Project Structure
----------------

The plugin codebase is in standard layout of Gradle project::
Expand Down Expand Up @@ -224,6 +224,10 @@ Most of the time you just need to run ./gradlew build which will make sure you p
- Build plugin by run all tasks above (this takes time).
* - ./gradlew pitest
- Run PiTest mutation testing (see more info in `#1204 <https://github.com/opensearch-project/sql/pull/1204>`_)
* - ./gradlew spotlessCheck
- Runs Spotless to check for code style.
* - ./gradlew spotlessApply
- Automatically apply spotless code style changes.

For integration test, you can use ``-Dtests.class`` “UT full path” to run a task individually. For example ``./gradlew :integ-test:integTest -Dtests.class="*QueryIT"``.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
@Fork(value = 1)
public class ComparisonOperatorBenchmark {

@Param(value = { "int", "string", "date" })
@Param(value = {"int", "string", "date"})
private String testDataType;

private final Map<String, ExprValue> params =
Expand All @@ -65,9 +65,7 @@ public void testGreaterOperator() {

private void run(Function<Expression[], FunctionExpression> dsl) {
ExprValue param = params.get(testDataType);
FunctionExpression func = dsl.apply(new Expression[] {
literal(param), literal(param)
});
FunctionExpression func = dsl.apply(new Expression[] {literal(param), literal(param)});
func.valueOf();
}
}
15 changes: 15 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ plugins {
id 'checkstyle'
id "io.freefair.lombok" version "6.4.0"
id 'jacoco'
id 'com.diffplug.spotless' version '6.19.0'
}

// import versions defined in https://github.com/opensearch-project/OpenSearch/blob/main/buildSrc/src/main/java/org/opensearch/gradle/OpenSearchJavaPlugin.java#L94
Expand All @@ -79,6 +80,20 @@ repositories {
maven { url 'https://jitpack.io' }
}

spotless {
java {
target fileTree('.') {
include '**/*.java'
exclude '**/build/**', '**/build-*/**'
}
importOrder()
removeUnusedImports()
trimTrailingWhitespace()
endWithNewline()
googleJavaFormat()
}
}

allprojects {
version = opensearch_version.tokenize('-')[0] + '.0'
if (buildVersionQualifier) {
Expand Down
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.common.antlr;

import org.antlr.v4.runtime.CharStream;
Expand Down
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.common.antlr;

import java.util.Locale;
Expand Down
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.common.antlr;

public class SyntaxCheckException extends RuntimeException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,17 @@ public class AwsSigningInterceptor implements Interceptor {
private static final Logger LOG = LogManager.getLogger();

/**
* AwsSigningInterceptor which intercepts http requests
* and adds required headers for sigv4 authentication.
* AwsSigningInterceptor which intercepts http requests and adds required headers for sigv4
* authentication.
*
* @param awsCredentialsProvider awsCredentialsProvider.
* @param region region.
* @param serviceName serviceName.
*/
public AwsSigningInterceptor(@NonNull AWSCredentialsProvider awsCredentialsProvider,
@NonNull String region, @NonNull String serviceName) {
public AwsSigningInterceptor(
@NonNull AWSCredentialsProvider awsCredentialsProvider,
@NonNull String region,
@NonNull String serviceName) {
this.okHttpAwsV4Signer = new OkHttpAwsV4Signer(region, serviceName);
this.awsCredentialsProvider = awsCredentialsProvider;
}
Expand All @@ -48,25 +50,27 @@ public AwsSigningInterceptor(@NonNull AWSCredentialsProvider awsCredentialsProvi
public Response intercept(Interceptor.Chain chain) throws IOException {
Request request = chain.request();

DateTimeFormatter timestampFormat = DateTimeFormatter.ofPattern("yyyyMMdd'T'HHmmss'Z'")
.withZone(ZoneId.of("GMT"));
DateTimeFormatter timestampFormat =
DateTimeFormatter.ofPattern("yyyyMMdd'T'HHmmss'Z'").withZone(ZoneId.of("GMT"));


Request.Builder newRequestBuilder = request.newBuilder()
.addHeader("x-amz-date", timestampFormat.format(ZonedDateTime.now()))
.addHeader("host", request.url().host());
Request.Builder newRequestBuilder =
request
.newBuilder()
.addHeader("x-amz-date", timestampFormat.format(ZonedDateTime.now()))
.addHeader("host", request.url().host());

AWSCredentials awsCredentials = awsCredentialsProvider.getCredentials();
if (awsCredentialsProvider instanceof STSAssumeRoleSessionCredentialsProvider) {
newRequestBuilder.addHeader("x-amz-security-token",
newRequestBuilder.addHeader(
"x-amz-security-token",
((STSAssumeRoleSessionCredentialsProvider) awsCredentialsProvider)
.getCredentials()
.getSessionToken());
}
Request newRequest = newRequestBuilder.build();
Request signed = okHttpAwsV4Signer.sign(newRequest,
awsCredentials.getAWSAccessKeyId(), awsCredentials.getAWSSecretKey());
Request signed =
okHttpAwsV4Signer.sign(
newRequest, awsCredentials.getAWSAccessKeyId(), awsCredentials.getAWSSecretKey());
return chain.proceed(signed);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@ public BasicAuthenticationInterceptor(@NonNull String username, @NonNull String
this.credentials = Credentials.basic(username, password);
}


@Override
public Response intercept(Interceptor.Chain chain) throws IOException {
Request request = chain.request();
Request authenticatedRequest = request.newBuilder()
.header("Authorization", credentials).build();
Request authenticatedRequest =
request.newBuilder().header("Authorization", credentials).build();
return chain.proceed(authenticatedRequest);
}

}
Loading