Thank you very much for your interest in contributing to the improvement of this project. Please, follow the next guidelines.
- Keep the code compatible with Java 11.
- Follow existing code styles present in the project.
- Avoid adding new dependencies as much as possible.
- Ensure to add Javadoc where necessary.
- Provide unit tests for your code.
- Large features should be discussed with maintainers before implementation. Use the Discussion section for this.
This project is configured with Spotless to automatically check code formatting against a custom code format specification of modern Java, as well as import order.
Spotless comes with two Maven commands that you can run at any moment, preferably before committing your changes:
mvn spotless:check
, to verify if code is formatted correctly.mvn spotless:apply
, to rewrite the source code in place.
The remote build will check the code formatting, so the build will fail if the code isn't formatted correctly.
This project is configured to use SonarCloud for static analysis. That analysis runs after every pull request to the main
branch and the results can be examined in the project dashboard.
It is highly recommended you install the free SonarLint extension in your favorite IDE, so you can analyze your code in advance before your pull request.
You could set your favorite IDE to be aligned to the custom code format. See details below.
IntelliJ
-
Import the custom code format:
- Settings > Editor > Code Style > Java > Scheme > ⚙ > Import Scheme > Eclipse XML Profile
-
Select the file on codestyle/spotless_java_eclipseformat.xml
-
In the Imports tab for the previous scheme, change the values:
- In General section, mark the option Use single class import
- In the field Class count to use import with '*' put the value 99
- In the field Names count to use static import with '*' put the value 99
-
At the bottom part in the Imports section, change the import statement order as:
- import all other imports
- import javax.*
- import java.*
- import static all other imports
VSCode
-
Install the extension Language Support for Java by Red Hat
-
Set the custom code format:
- Settings > Workspace > Extensions > Language Support for Java(TM) by Red Hat > Formatting
- Choose the box Java/Format/Settings:Url and put the value codestyle/spotless_java_eclipseformat.xml
-
Set the import order:
-
Settings > Workspace > Extensions > Language Support for Java(TM) by Red Hat > Code Completion
-
Choose the box Java/Completion:ImportOrder and click the link Edit in settings.json
-
In the editor, make sure to add the following entries:
"java.completion.importOrder": [ "", "javax", "java", "*" ]
-
Eclipse
-
Import the custom code format:
- Preferences > Java > Code Style > Formatter > Import...
-
Select the file on codestyle/spotless_java_eclipseformat.xml
-
Import the custom import statement order:
- Preferences > Java > Code Style > Organize Imports > Import...
-
Select the file on codestyle/spotless_java.importorder
-
In the Organize Imports section, make sure the values are set as:
- Sorting order:
- * - all unmatched type imports
- javax
- java
- * - all unmatched static imports
- Number of imports needed for .*: 99
- Number of static imports needed for .*: 99
- Sorting order: