...
Info | ||
---|---|---|
| ||
As of March June 2023, the below VIVO/Vitro Java Style Guide is will be enforced on all Pull Requests to the "main" branch for newly created files. Therefore, if a Pull Request to the "main" branch does not align with the below Style Guide, it will fail the build process within our GitHub CI.
|
- 4-space indents. NO TABS ALLOWED.
One true brace style. Braces are required on all blocks.
Code Block if (code) { // code } else { // code }
- Do not use wildcard imports (e.g.
import java.util.*
). Duplicated or unused imports are not allowed. Maximum length of lines is 100 characters (except for long URLs, packages or imports)
- No trailing spaces allowed (except in comments)
Tokens should be surrounded by whitespace, e.g. http://checkstyle.sourceforge.net/config_whitespace.html#WhitespaceAround
Code Block // This is NOT valid. Whitespace around tokens is missing String []={"one","two","three"} // This is valid. Whitespace exists around all tokens String [] = { "one", "two", "three" }
Each line of code can only include one statement. This also means each variable declaration must be on its own line, e.g.
Code Block // This is NOT valid. Three variables are declared on one line String first = "", second = "", third = ""; // This is valid. Each statement is on its own line String first = ""; String second = ""; String third = "";
Each source file must contain the required VIVO/Vitro license header, e.g.
Code Block /* * This file is distributed under the terms of the license in the LICENSE file in the root of this project */
Resources
IDE Support
Most major IDEs include plugins that support Checkstyle configurations. The plugin usually let you import an existing "checkstyle.xml" configuration to configure your IDE to use and/or validate against that style.
...