-
Notifications
You must be signed in to change notification settings - Fork 3.3k
issue #426 Description of the coding style #502
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
# Coding style | ||
|
||
|
||
## Tabs and Indents | ||
* Tab size : 4 | ||
* Indent : 4 | ||
* Continuation indent : 8 | ||
* Label indent : 0 | ||
|
||
> Don't use tab characters. | ||
|
||
## Spaces | ||
|
||
### Before Parentheses | ||
* ```if``` parentheses | ||
* ```for``` parentheses | ||
* ```while``` parentheses | ||
* ```switch``` parentheses | ||
* ```try``` parentheses | ||
* ```catch``` parentheses | ||
* ```synchronized``` parentheses | ||
|
||
### Around Operators | ||
* Assignment operators (```=```, ```+=```, …) | ||
* Logical operators (```&&```, ```||```) | ||
* Equality operators (```==```, ```!=```) | ||
* Relational operators (```<```, ```>```, ```<=```, ```>=```) | ||
* Bitwise operators (```&```, ```|```, ```^```) | ||
* Additive operators (```+```, ```-```) | ||
* Multiplicative operators (```*```, ```/```, ```%```) | ||
* Shift operators (```<<```, ```>>```, ```>>>```) | ||
|
||
### Before Left Brace | ||
* Class left brace | ||
* Method left brace | ||
* ```if``` left brace | ||
* ```else``` left brace | ||
* ```for``` left brace | ||
* ```while``` left brace | ||
* ```do``` left brace | ||
* ```switch``` left brace | ||
* ```try``` left brace | ||
* ```catch``` left brace | ||
* ```finally``` left brace | ||
* ```synchronized``` left brace | ||
|
||
### Before Keywords | ||
* ```else``` keyword | ||
* ```while``` keyword | ||
* ```catch``` keyword | ||
* ```finally``` keyword | ||
|
||
### In Ternary Operator (?:) | ||
* Before ```?``` | ||
* After ```?``` | ||
* Before ```:``` | ||
* After ```:``` | ||
|
||
### Within Type Arguments | ||
* After comma | ||
|
||
### Other | ||
* After comma | ||
* After semicolon | ||
* After type cast | ||
|
||
## Wrapping and Braces | ||
|
||
### Braces placement | ||
* In class declaration : End of line | ||
* In method declaration : End of line | ||
* Other : End of line | ||
|
||
### Use Of Braces | ||
* ```if()``` statement : When multiline | ||
* ```for()``` statement : When multiline | ||
* ```while()``` statement : When multiline | ||
* ```do .. while()``` statement : When multiline | ||
|
||
### Annotations | ||
* Class annotations : Wrap always | ||
* Method annotations : Wrap always | ||
* Field annotations : Wrap always | ||
* Paramater annotations : Do not wrap | ||
* Local variable annotations : Do not wrap | ||
|
||
## Blank Lines | ||
|
||
### Keep Maximum Blank Lines | ||
* In declarations : 2 | ||
* In code : 2 | ||
* Before ```}``` : 2 | ||
|
||
### Minimum Blank Lines | ||
* Before package statement : 0 | ||
* After package statement : 1 | ||
* Before imports : 1 | ||
* After imports : 1 | ||
* Around class : 1 | ||
* After class header : 0 | ||
* After anonymous class header : 0 | ||
* Around field in interface : 0 | ||
* Around field : 0 | ||
* Around method in interface : 1 | ||
* Around method : 1 | ||
* Before method body : 0 | ||
|
||
## JavaDoc | ||
|
||
### Alignment | ||
* Align parameter descriptions | ||
* Align thrown exception descriptions | ||
|
||
### Blank Lines | ||
* After description | ||
|
||
### Invalid tags | ||
* Keep empty ```@param``` tags | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would actually like to remove any tags that only give information that could be read directly from the code. |
||
* Keep empty ```@return``` tags | ||
* Keep empty ```@throws``` tags | ||
|
||
### Other | ||
* Enable leading asterisks | ||
* Use ```@throws``` rather then ```@exception``` | ||
* Keep empty lines | ||
|
||
## Imports | ||
|
||
### Import layout | ||
__import static__ all other imports | ||
_blank line_ | ||
__import__ javax.* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. javax before java? Is that common? |
||
__import__ java.* | ||
__import__ com.* | ||
_blank line_ | ||
__import__ all other imports |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does "Keep Maximum Blank Lines" mean?