Inteiilj IDEA 团队代码格式规范
Intellij IDEA code format
Tabs and Indents
- Tab size 4
- keep indents on empty lines
Spaces
Before Parenthenses
- 
'if' parentheses 
- 
'for' parentheses 
- 
'while' parentheses 
- 
'switch' parentheses 
- 
'try' parentheses 
- 
'catch' parentheses 
- 
'synchronized' parentheses 
Around Operators
- 
Assignment operators (=,+=,....) 
- 
Logical operators (&&, ||) 
- 
Equality operatores 
- 
Relational operators 
- 
Bitwise operators 
- 
Additive operators 
- 
Multiplicative operators 
- 
Shift operators 
- 
Unary operators 
- 
lambda arrow 
Before Left Brace
- 
Class left brace 
- 
Method left brace 
- 
if left brace 
- 
else left brace 
- 
for left brace 
- 
while left brace 
- 
do left bvrace 
- 
Switch left brace 
- 
try left brace 
- 
catch left brace 
- 
finally left brace 
- 
Synchronized left brace 
- 
Array initializer left brace 
Before Keywords
- 
else keyword 
- 
while keyword 
- 
catch keyword 
- 
finally keyword 
Within
- Array initializer braces
In Ternary Opertator
- 
Before '?' 
- 
After '?' 
- 
Before ':' 
- 
After ':' 
Type Arguments
- After comma
Other
- 
After comma 
- 
Before for semicolon 
- 
After for semicolon 
- 
Sapce before colon in foreach (待确认) 
Type Paramters
- Around Type bounds
Wrapping and Braces
keep when reformatting
- 
comment at first column 
- 
Simple blocks in one line 
- 
simple methods in one line 
- 
simple lambda in one line 
- 
simple classes in one line 
if() statement
- 
Froce braces (always) 
- 
Special 'else if ' treatment 
for() statement
- 
Align when multiline 
- 
Force brace(always) 
while() statement
- Force brace (Always)
switch statment
- 
Indent case branch 
- 
case in new line 
try-with-resources
- Align when multiline
Imports
general
- User single class import
- Class count to use import with '*' : 8
- Names count to use static import with '*' 5
更新
最近发现了新大陆google 的codestyle github https://github.com/google/styleguide
[使用方式] (https://www.jianshu.com/p/a44329bf5935)
 
                    
                     
                    
                 
                    
                
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号