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

Developer guide update with Spotless details #2000

Merged
24 changes: 15 additions & 9 deletions DEVELOPER_GUIDE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -182,17 +182,23 @@ Note that other related project code has already merged into this single reposit
- ``workbench``: query workbench UI.


Code Convention
Code Convention (Spotless)
MitchellGale marked this conversation as resolved.
Show resolved Hide resolved
---------------

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:

* 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.

Java files are formatted using `Spotless <https://github.com/diffplug/spotless>` conforming to `Google Java Format <https://github.com/google/google-java-format>`.
acarbonetto marked this conversation as resolved.
Show resolved Hide resolved
* - 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>`
MitchellGale marked this conversation as resolved.
Show resolved Hide resolved
* - 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.

Spotless changes required can be run with:
`./gradlew spotlessJavaCheck`
Recommended changes can be applied automatically with:
`./gradlew spotlessJavaApply`
MitchellGale marked this conversation as resolved.
Show resolved Hide resolved

Building and Running Tests
==========================
Expand Down