google / google/google-java-format
No empty line before method with Javadoc
- 主要語言
- Java
- 星號
- 6.2k
- 分支
- 937
- 平均合併
- 6 分鐘
- 30 天內合併 PR
- 3
描述
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.
貢獻指南
研究方向
首先,使用提供的 Dummy.java 範例和 google-java-format 指令重現格式化程式的行為。追蹤註解方法周圍的空行如何處理,然後確認在 method4 和 method6 前插入空行,同時保留現有的間距情況。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- java
- 領域
- tooling
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100