Skip to content
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

[Spotless] Applying Google Code Format for core/src/main files #1 #312

Merged
merged 3 commits into from
Aug 3, 2023

Conversation

MitchellGale
Copy link

@MitchellGale MitchellGale commented Jul 25, 2023

Description

This PR applies Spotless on Java code for:
core/src/main/java/org/opensearch/sql/analysis
core/src/main/java/org/opensearch/sql/ast
core/src/main/java/org/opensearch/sql/data
core/src/main/java/org/opensearch/sql/datasource

Issues Resolved

[List any issues this PR will resolve]

Check List

  • New functionality includes testing.
    • All tests pass, including unit test, integration test and doctest
  • New functionality has been documented.
    • New functionality has javadoc added
    • New functionality has user manual doc added
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@codecov
Copy link

codecov bot commented Jul 25, 2023

Codecov Report

❗ No coverage uploaded for pull request base (integ/sl_GoogleJavaFormat1@d2de909). Click here to learn what that means.
The diff coverage is n/a.

❗ Current head 7c1b27a differs from pull request most recent head c88dc80. Consider uploading reports for the commit c88dc80 to get more accurate results

@@                      Coverage Diff                      @@
##             integ/sl_GoogleJavaFormat1     #312   +/-   ##
=============================================================
  Coverage                              ?   97.42%           
  Complexity                            ?     4646           
=============================================================
  Files                                 ?      408           
  Lines                                 ?    11550           
  Branches                              ?      838           
=============================================================
  Hits                                  ?    11253           
  Misses                                ?      290           
  Partials                              ?        7           
Flag Coverage Δ
sql-engine 97.42% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

* LogicalProject[Ref("abs(age)"), sub(Ref("sum(age)"), Ref("avg(age)"))
* LogicalAgg(agg=[sum(age), avg(age)], group=[abs(age)]]
* LogicalRelation
* The optimizer used to replace the expression referred in the SelectClause e.g. The query SELECT

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This javadoc loses info with merging lines. Probably you need to add javadoc tags (pre I suppose) to keep it visual and readable.
Please, go though all changed multiline javadocs to review.

core/build.gradle Outdated Show resolved Hide resolved
@MitchellGale MitchellGale force-pushed the dev/sl_GoogleJavaFormat1 branch 3 times, most recently from 03127d0 to 613535f Compare July 27, 2023 18:06
* [WHEN compare_expr THEN result_expr] ...
* [ELSE result_expr]
* END
* CASE case_value_expr WHEN compare_expr THEN result_expr [WHEN compare_expr THEN result_expr]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also needs <pre> tag

* NULL MISSING FALSE
* MISSING NULL FALSE
* MISSING MISSING TRUE
* The customize equals logic. The table below list the NULL and MISSING handling logic. A B A ==
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also needs <pre> tag

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed by adding table in d455533

Copy link

@acarbonetto acarbonetto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MitchellGale There's one of Yury's commits in here. Would you be able to rebase and remove that commit?

@MitchellGale MitchellGale force-pushed the dev/sl_GoogleJavaFormat1 branch 4 times, most recently from 54cb07d to a43d97d Compare July 31, 2023 21:29
import java.util.List;
import java.util.Set;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cleaning imports is a part of another check. Do you want to do it first?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's on the agenda for being put into upstream, I don't think it'll cause a merge conflict. Need to wait for opensearch-project#1924 to be merged then I can put up the remove unused imports PR up.

when.getResult()
), context));
whens.add(
(WhenClause)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really?

* LogicalPlan should be<br>
* LogicalProject[Ref("abs(age)"), sub(Ref("sum(age)"), Ref("avg(age)"))<br>
* &ensp LogicalAgg(agg=[sum(age), avg(age)], group=[abs(age)]]<br>
* &emsp LogicalRelation

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it better than using pre? Or GJF ignores pre and rewrites the comment?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's properly formatted this way vs using pre tag and just asking it not to be formatted. Both work.

* Agg(Alias("AVG(age)", aggExpr), Alias("length(name)", groupExpr))
* </pre>
* The Alias could be<br>
* 1. SELECT name, AVG(age) FROM s BY name -><br>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use ul and li HTML tags for list formatting.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@ToString
@EqualsAndHashCode(callSuper = false)
public class AllFields extends UnresolvedExpression {
public static final AllFields INSTANCE = new AllFields();

private AllFields() {
}
private AllFields() {}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This conflicts with checkstyle, but I like it more.
Consider updating checkstyle rules in future.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checkstyle will be removed in favour of spotless. Currently it is set to "ignore test failures".

throw new SemanticCheckException(String.format("date:%s in unsupported format, please use "
+ "yyyy-MM-dd", date));
throw new SemanticCheckException(
String.format("date:%s in unsupported format, please use " + "yyyy-MM-dd", date));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
String.format("date:%s in unsupported format, please use " + "yyyy-MM-dd", date));
String.format("date: %s in unsupported format, please use 'yyyy-MM-dd'", date));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably you need to update test if you apply this change.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partly resolved in da35a7e. (no additional quotes)

+ "use yyyy-MM-dd HH:mm:ss[.SSSSSSSSS]", datetime));
throw new SemanticCheckException(
String.format(
"datetime:%s in unsupported format, please " + "use yyyy-MM-dd HH:mm:ss[.SSSSSSSSS]",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"datetime:%s in unsupported format, please " + "use yyyy-MM-dd HH:mm:ss[.SSSSSSSSS]",
"datetime: %s in unsupported format, please 'use yyyy-MM-dd HH:mm:ss[.SSSSSSSSS]'",

Could be followed by test update

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want the single quotes around yyyy-MM-dd instead?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right

Comment on lines 49 to 50
"datetime:%s in unsupported format, please "
+ "use yyyy-MM-dd HH:mm:ss[.SSSSSSSSS]",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"datetime:%s in unsupported format, please "
+ "use yyyy-MM-dd HH:mm:ss[.SSSSSSSSS]",
"datetime: %s in unsupported format, please use 'yyyy-MM-dd HH:mm:ss[.SSSSSSSSS]'",

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved.

@@ -34,6 +34,7 @@
import lombok.SneakyThrows;
import org.apache.commons.lang3.reflect.FieldUtils;
import org.apache.lucene.search.TotalHits;
import org.junit.jupiter.api.BeforeAll;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Suggested change
import org.junit.jupiter.api.BeforeAll;

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Added as a part of an old fix I was testing... missed removing the import.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed.

@MitchellGale MitchellGale changed the base branch from integ/sl_GoogleJavaFormat1 to Failing-CI-Hot-Fix August 3, 2023 07:20
@MitchellGale MitchellGale changed the base branch from Failing-CI-Hot-Fix to integ/sl_GoogleJavaFormat1 August 3, 2023 07:20
MitchellGale and others added 2 commits August 3, 2023 09:27
# This is the 1st commit message:

Fix create_index/create_index_with_IOException issue caused by OpenSearch PR change (opensearch-project#1899)

* Added setDefaultMediaType for create_index and create_index_with_IOException

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>
(cherry picked from commit 7b932a7)
Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>

Resolving merge conflicts for pre tag in java docs.

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>

running spotless check on newly pre tagged javadocs.

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>

Converts java doc table to proper java doc table.

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>

Resolving merge conflicts for pre tag in java docs 2

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>

running spotless check on newly pre tagged javadocs.

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>

cherry pick 60c0018

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>

Addressed PR comment for table format in AbstractExprValue.

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>

Removed pre tag from ExpressionReferenceOptimizer.

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>

Removed pre tag from AstDSL.java

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>

Removed pre tag from AstDSL.java

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>

Removed pre tag from SelectExpressionAnalyzer.java

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>

fixed java doc in QualifiedName.java

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>

Removing checkstyle test for core and added spotless for relevant directories.

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>

# This is the commit message #2:

Fixing spacing around headers in ExpressionReferenceOptimizer.java SelectExpressionAnalyzer.java

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>

# This is the commit message #3:

Fix breaking changes. Disable some flaky tests in legacy.

Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>

(cherry picked from commit 809e656)
Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>

# This is the commit message #4:

Resolving merge conflicts for pre tag in java docs.

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>

# This is the commit message #5:

running spotless check on newly pre tagged javadocs.

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>

# This is the commit message #6:

Fixed java doc spelling and improving string concatination.

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>

# This is the commit message #7:

improving string concatination.

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>

# This is the commit message #8:

Improving failure format on some functions.

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>

# This is the commit message #9:

spotless apply and fix of build.gradle

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>
author Mitchell Gale <Mitchell.Gale@improving.com> 1691080710 -0700
committer Mitchell Gale <Mitchell.Gale@improving.com> 1691080766 -0700

Fix create_index/create_index_with_IOException issue caused by OpenSearch PR change (opensearch-project#1899)

* Added setDefaultMediaType for create_index and create_index_with_IOException

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>
(cherry picked from commit 7b932a7)
Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>

Resolving merge conflicts for pre tag in java docs.

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>

running spotless check on newly pre tagged javadocs.

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>

Converts java doc table to proper java doc table.

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>

Resolving merge conflicts for pre tag in java docs 2

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>

running spotless check on newly pre tagged javadocs.

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>

cherry pick 60c0018

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>

Addressed PR comment for table format in AbstractExprValue.

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>

Removed pre tag from ExpressionReferenceOptimizer.

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>

Removed pre tag from AstDSL.java

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>

Removed pre tag from AstDSL.java

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>

Removed pre tag from SelectExpressionAnalyzer.java

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>

fixed java doc in QualifiedName.java

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>

Removing checkstyle test for core and added spotless for relevant directories.

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>

Fixing spacing around headers in ExpressionReferenceOptimizer.java SelectExpressionAnalyzer.java

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>

Fix breaking changes. Disable some flaky tests in legacy.

Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>

(cherry picked from commit 809e656)
Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>

Resolving merge conflicts for pre tag in java docs.

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>

running spotless check on newly pre tagged javadocs.

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>

Fixed java doc spelling and improving string concatination.

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>

improving string concatination.

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>

Improving failure format on some functions.

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>

spotless apply and fix of build.gradle

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>

Resolving merge conflicts for pre tag in java docs.

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>

running spotless check on newly pre tagged javadocs.

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>

Converts java doc table to proper java doc table.

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>

Removing unused import in OpenSearchRestClientTest.java

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>
* The Alias could be<br>
*
* <ol>
* <li>ELECT name, AVG(age) FROM s BY name -><br>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SELECT

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, ty

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>
@MitchellGale MitchellGale merged commit ec7035e into integ/sl_GoogleJavaFormat1 Aug 3, 2023
12 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants