Java Checkstyle Rule To Restrict Method Empty Lines

前端 未结 4 1370
春和景丽
春和景丽 2021-01-19 10:19

Is there a way to setup checkstyle to prevent leading, multiple or trailing empty lines in method bodies:

e.g.

private void a() {
-
int a = 1;
doStu         


        
4条回答
  •  北海茫月
    2021-01-19 10:36

    To enforce no blank lines at the beginning and end of any block, you can use multi-line regular expression checks:

    
        
        
        
    
    
        
        
        
    
    

    "^$" signifies the blank line.

提交回复
热议问题