Skip to content

Latest commit

 

History

History
107 lines (71 loc) · 4.01 KB

CONTRIBUTING.md

File metadata and controls

107 lines (71 loc) · 4.01 KB

Contributing

Thank you very much for your interest in contributing to the improvement of this project. Please, follow the next guidelines.

General Guidelines

  1. Keep the code compatible with Java 11.
  2. Follow existing code styles present in the project.
  3. Avoid adding new dependencies as much as possible.
  4. Ensure to add Javadoc where necessary.
  5. Provide unit tests for your code.
  6. Large features should be discussed with maintainers before implementation. Use the Discussion section for this.

Code Formatting

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.

Static Analysis

This project is configured to use SonarCloud for static analysis. That analysis runs after every pull requst 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.

Configure IDE (Optional)

You could set your favorite IDE to be aligned to the custom code format. See details below.

IntelliJ
  1. Import the custom code format:

    • Settings > Editor > Code Style > Java > Scheme > ⚙ > Import Scheme > Eclipse XML Profile
  2. Select the file on codestyle/spotless_java_eclipseformat.xml

  3. 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
  4. 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
  1. Install the extension Language Support for Java by Red Hat

  2. 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
  3. 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
  1. Import the custom code format:

    • Preferences > Java > Code Style > Formatter > Import...
  2. Select the file on codestyle/spotless_java_eclipseformat.xml

  3. Import the custom import statement order:

    • Preferences > Java > Code Style > Organize Imports > Import...
  4. Select the file on codestyle/spotless_java.importorder

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