Coding standards

This project has adopted the following coding standards:

  • Code should be formatted using Oracle / WebLogic standards, which are identical to the Google Java Style.
  • Javadoc must be provided for all public packages, classes, and methods, and must include all parameters and returns. Javadoc is not required for methods that override or implement methods that are already documented.
  • All non-trivial methods should include LOGGER.entering() and LOGGER.exiting() calls.
  • The LOGGER.exiting() call should include the value that is going to be returned from the method, unless that value includes a credential or other sensitive information.
  • All logged messages must be internationalized using the resource bundle src/main/resources/Operator.properties and using a key itemized in src/main/java/oracle/kubernetes/operator/logging/MessageKeys.java.
  • After operator initialization, all operator work must be implemented using the asynchronous call model. In particular, worker threads must not use sleep() or IO or lock-based blocking methods.

Code formatting plugins

The following IDE plugins are available to assist with following the code formatting standards

IntelliJ

An IntelliJ plugin is available from the plugin repository.

The plugin will be enabled by default. To disable it in the current project, go to File > Settings... > google-java-format Settings (or IntelliJ IDEA > Preferences... > Other Settings > google-java-format Settings on macOS) and uncheck the “Enable google-java-format” checkbox.

To disable it by default in new projects, use File > Other Settings > Default Settings....

When enabled, it will replace the normal “Reformat Code” action, which can be triggered from the “Code” menu or with the Ctrl-Alt-L (by default) keyboard shortcut.

The import ordering is not handled by this plugin, unfortunately. To fix the import order, download the IntelliJ Java Google Style file and import it into File→Settings→Editor→Code Style.

Eclipse

An Eclipse plugin can be downloaded from the releases page. Drop it into the Eclipse drop-ins folder to activate the plugin.

The plugin adds a google-java-format formatter implementation that can be configured in Eclipse > Preferences > Java > Code Style > Formatter > Formatter Implementation.