mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-30 17:16:44 +01:00
3.0 KiB
3.0 KiB
- git enforced \n line endings
- 4-spaces instead of tabs for indentation
- Spaces after control statements before beginning parenthesis or brace
-
if (
-
for (
-
while (
-
do {
-
try {
-
public class SomeClass {
- Spaces after closing parenthesis in a control statement
- No newline after closing parenthesis and space in a control statement:
-
if () {
-
for () {
-
while () {
-
catch () {
-
switch () {
- Newlines before an else, else if, catch, and finally statement
-
}
else {
-
}
else if () {
-
}
catch () {
-
}
finally () {
- Space after ; in for statement, not before
-
for (int i = 0; i < 10; i++) {
- Spaces around operators
-
a + b
-
a == b
-
for (Type blah : blahs) {
-
"String " + "concatenation"
- Spaces around { and } on one-line declarations
-
public boolean aMethod() { return something; }
- Fewer extraneous parentheses, except when they increase readability
-
if (a == b || b == c)
- Indent on case in switch case statements
-
switch () { case 1:
- Mandatory comment for when a case falls through, and when not stacking
-
switch () { case 1: // Fallthrough case 2:
-
switch () { case 1: case 2: case 3: case 4: case 5: // Fallthrough case 6:
- Empty line between cases after break, return, or fallthrough
-
switch () { case 1: break; case 2:
- Prefer early returns over method indentation. Example:
-
if (!precondition) { // Possibly cleanup return; } // Continue with task
- Java standard class and method naming, with exception to McMMO in a class name
-
thisIsAMethod()
-
ThisIsAClass
- Exception:
McMMOCustomClass
- No space before opening parenthesis for methods, or constructors
-
public void thisIsAMethod() {
-
public ThisIsAClass() {
- Spaces after comma in method calls and constructors, not before
-
something.methodCall(variable, otherVariable);
- Accessing of variables with this. only when necessary to resolve scope
- Class variables always defined at the top, before the constructor
- No empty line between class declaration and beginning of variable declaration
- Always a empty line at the end of a method or constructor definition
- Constructors come before methods, and are typically ordered from the ones with the least arguments to the most
- Methods should be ordered in this manner:
- override public
- public
- static public
- abstract public
- override protected
- protected
- static protected
- abstract protected
- private
- static private
- No one-line if statements, they should all have brackets