Skip to content

Commit

Permalink
Developer guide update with Spotless details (#2000)
Browse files Browse the repository at this point in the history
* Added spotless java format rules to dev guide

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

* Fixed formatting of URLS in DEVELOPER_GUIDE.rst

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

* addressed PR comments

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

* addressed PR comments

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

* addressed PR comments

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

* Update DEVELOPER_GUIDE.rst

Co-authored-by: Yury-Fridlyand <yury.fridlyand@improving.com>
Signed-off-by: Mitchell Gale <Mitchell.gale@improving.com>

* Update DEVELOPER_GUIDE.rst

Co-authored-by: Yury-Fridlyand <yury.fridlyand@improving.com>
Signed-off-by: Mitchell Gale <Mitchell.gale@improving.com>

* Update DEVELOPER_GUIDE.rst

Co-authored-by: Yury-Fridlyand <yury.fridlyand@improving.com>
Signed-off-by: Mitchell Gale <Mitchell.gale@improving.com>

* Update DEVELOPER_GUIDE.rst

Co-authored-by: Yury-Fridlyand <yury.fridlyand@improving.com>
Signed-off-by: Mitchell Gale <Mitchell.gale@improving.com>

* Update DEVELOPER_GUIDE.rst

Co-authored-by: Yury-Fridlyand <yury.fridlyand@improving.com>
Signed-off-by: Mitchell Gale <Mitchell.gale@improving.com>

* fixed link format

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

---------

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>
Signed-off-by: Mitchell Gale <Mitchell.gale@improving.com>
Co-authored-by: Yury-Fridlyand <yury.fridlyand@improving.com>
  • Loading branch information
MitchellGale and Yury-Fridlyand authored Aug 21, 2023
1 parent 6055c7e commit 8f650e8
Showing 1 changed file with 23 additions and 6 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

0 comments on commit 8f650e8

Please sign in to comment.