unused import removal leaves extra blank line between package declaration and class Javadoc / declaration
まだ誰も着手していません。
評価
調査の方向性
まず、TestBug.java の例と google-java-format コマンドを使って問題を再現します。未使用の import を削除し、パッケージ宣言とクラスの Javadoc の間の垂直方向の空白を処理するフォーマットパスを追跡します。最初のフォーマットパスで期待される出力と一致する空行が 1 行生成され、2 回目のパスが不要になれば完了です。
索引モデルが issue の本文から書いたものです。
説明
When google-java-format removes an unused import statement located between a package declaration and class Javadoc or class declaration, it does not collapse the vertical whitespace in the same formatting pass. As a result, the formatted output contains extra blank lines (two consecutive blank lines instead of one).
Running google-java-format a second time on the output collapses the extra blank line as expected. We observed this in generated code, more context here: https://github.com/googleapis/librarian/issues/7146
Environment
google-java-formatVersion: Tested on1.25.2through1.35.0(including recent builds).- Operating System: Linux / macOS / Cross-platform
Minimal Reproducible Example
Input Code (TestBug.java)
```java
package com.example;
import static io.grpc.MethodDescriptor.generateFullMethodName;
/**
* Javadoc for class.
*/
public class TestBug {
}
Command Executed
google-java-format TestBug.java
Actual Output (First Pass)
package com.example;
/** Javadoc for class. */
public class TestBug {}
(Notice the two consecutive empty lines between package com.example; and /** Javadoc for class. */.)
Expected Output
package com.example;
/** Javadoc for class. */
public class TestBug {}
Additional Context & Workaround
• Second Pass Result: Executing google-java-format a second time on the first pass output (google-java-format TestBug.java | google-java-format -) produces the correct output with a single blank line.
- 主要言語
- Java
- スター
- 6.2k
- フォーク
- 936
- 平均マージ
- 6分
- マージ済み PR(30日)
- 3
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
google/google-java-format のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
google/google-java-format#1094 · コメント 1 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 15/100
google/google-java-format#1450 · リアクション 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
google/google-java-format#1439 · コメント 1 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 48/100
google/google-java-format#1428 · コメント 3 件 ·
-
Eclipse
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
google/google-java-format#1417 ·
google/google-java-format の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
elastic/gradle-plugins#157 ·
-
enhancement Tools
難易度 1/5 1時間未満 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
apache/rocketmq-dashboard#5008 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
DETECT_PARAMETER_NAMES=false silently disables @ConstructorProperties-based Creator detection too オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
FasterXML/jackson-databind#6229 ·