google / google/google-java-format

No empty line before method with Javadoc

Đang mở
#399 1 bình luận 3 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Java
Star
6.2k
Fork
937
Merge trung bình
6 phút
Pull request đã merge (30 ngày)
3

Mô tả

Consider the following code:
```java
class Dummy {
void method1() {}
void method2() {}

void method3() {}
/** Documentation. */
void method4() {}

class Inner1 {}
void method5() {}

class Inner2 {}
// Comment
void method6() {}
}
```

Running `java -jar google-java-format-1.7-all-deps.jar Dummy.java` produces:
```java
class Dummy {
void method1() {}

void method2() {}

void method3() {}
/** Documentation. */
void method4() {}

class Inner1 {}

void method5() {}

class Inner2 {}
// Comment
void method6() {}
}
```

Note how a newline is inserted before `method2` and `method5`, but not before `method4` and `method6`. Based on all occurrences I found in our private code base (using Checkstyle's [`EmptyLineSeparatorCheck`](https://checkstyle.sourceforge.io/apidocs/com/puppycrawl/tools/checkstyle/checks/whitespace/EmptyLineSeparatorCheck.html)) the issue seems to happen:
- only when there is a comment (`//**`, `/*` or `//`) on the method.
- but irrespective of the syntactic construct (another method, a field, a class, ....) that precedes it.

Based on [section 4.6.1](https://google.github.io/styleguide/javaguide.html#s4.6.1-vertical-whitespace) of the style guide I do think such empty lines should be introduced.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.