OpenLMIS v3 Java coding style

61 views
Skip to first unread message

Chongsun Ahn

unread,
Jun 7, 2016, 2:40:53 PM6/7/16
to OpenLMIS Dev
Hey everyone,

So we’ve been establishing infrastructure and conventions and I’ve been working on OLMIS-722, which adds checkstyle to the service template and the example and requisition services. From this, it has been decided we are going to follow Google Java coding style conventions.

In this story, I have added the Gradle checkstyle plugin and configured it to check Java and test Java classes for checkstyle issues. This gradle task ‘check’ is built into the ‘build' task. The checkstyle configuration XML was copied into the local repository.

Please try to fix any checkstyle warnings that result from development. If you are using IntelliJ, you can make it easier with some configuration below.

To have IntelliJ flag some checkstyle warnings, install the Checkstyle-IDEA plugin and enable it (under Plugins). Then for each project, configure Checkstyle (under Other Settings) by adding the checkstyle.xml in the project folder. Enable the checkbox, enable the “Scan test classes” checkbox as well and save.

To help with whitespace, imports and column limits, you can get the IntelliJ Google Java XML, and import it (under Editor -> Code Style -> Java). The official XML is found online—however, it is old and does not actually match the most recent version of the guide. Attached is a modified version that fits the coding style guide better. Once it is imported, you can reformat code and optimize imports under the Code menu.

Please let me know if there’s any feedback or questions.

GoogleStyle.xml
ATT00001.htm

Josh Zamor

unread,
Jun 8, 2016, 8:30:07 PM6/8/16
to OpenLMIS Dev
In addition to the Google Java Style Guide, we should be documenting conventions not covered by that guide that we'd like to follow.  I threw up a service style guide in the service template that we should use for documenting project conventions that are beyond the level of detail that the Google Java Styleguide we've adopted would get into.  e.g. postgres naming conventions.  Lets use this as a working document to communicate these conventions.  https://github.com/OpenLMIS/openlmis-template-service/blob/master/STYLE-GUIDE.md
Reply all
Reply to author
Forward
0 new messages