String wrapping is not idempotent
まだ誰も着手していません。
評価
調査の方向性
Java 17 上で google-java-format 1.15.0 または 1.16.0 の all-deps JAR を使用し、提供された TestFormat.java の例で問題を再現します。フォーマットを繰り返し実行し、各パス後の switch-expression の文字列レイアウトを比較します。変更していないファイルをフォーマットした結果が、その後の実行ごとに同一の出力になることを確認できれば完了です。
索引モデルが issue の本文から書いたものです。
説明
This happened with the all deps jar from github, for both versions 1.15.0 and 1.16.0.
$ java --version
openjdk 17.0.6 2023-01-17
OpenJDK Runtime Environment (build 17.0.6+10)
OpenJDK 64-Bit Server VM (build 17.0.6+10, mixed mode)
Example code is
package com.example;
public class TestFormat {
public void main() {
var value = 1;
var responseMessage =
switch (value) {
case 1 -> "This is a long string;This is a long string;This is a long string;This is a long string;This is a long string;This is a long string;This is a long string;";
case 2 -> "some short string";
case 3 -> "some medium string some medium string some medium string some medium string";
};
}
}
Now these strings in the switch statement will be different formatted depending on how often I call google java format.
Weirdly enough, the cosium maven plugin (gjf v1.15.0) does not change the strings in this example at all. This would be preferable for me, but mostly I want a consistent format.
## executing preview only
$ java -jar /home/dev/dev/libs/google-java-format-1.15.0-all-deps.jar Testformat.java
package com.example;
public class TestFormat {
public void main() {
var value = 1;
var responseMessage =
switch (value) {
case 1 -> "This is a long string;This is a long string;This is a long string;This is a"
+ " long string;This is a long string;This is a long string;This is a long"
+ " string;";
case 2 -> "some short string";
case 3 -> "some medium string some medium string some medium string some medium string";
};
}
}
## applying changes
$ java -jar /home/dev/dev/libs/google-java-format-1.15.0-all-deps.jar -r Testformat.java
## executing preview only
$ java -jar /home/dev/dev/libs/google-java-format-1.15.0-all-deps.jar Testformat.java
package com.example;
public class TestFormat {
public void main() {
var value = 1;
var responseMessage =
switch (value) {
case 1 -> "This is a long string;This is a long string;This is a long string;This is a"
+ " long string;This is a long string;This is a long string;This is a long"
+ " string;";
case 2 -> "some short string";
case 3 -> "some medium string some medium string some medium string some medium string";
};
}
}
The expectation would be that once I format a file every future format call would not change anything anymore as long as nothing was changed on the file.
- 主要言語
- 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日 初心者へのやさしさ 62/100
google/google-java-format#1436 · コメント 2 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 48/100
google/google-java-format#1428 · コメント 4 件 ·
google/google-java-format の issue をすべて見る
似ている issue
-
area/plugin
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
kestra-io/plugin-kestra#190 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
google-ai-edge/LiteRT-LM#3739 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
integra-team-red/meet-map#249 ·
-
[Studio][Bug] Cancelled create-user dialog keeps the password and admin switch for the next attempt オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
apache/rocketmq-dashboard#5064 ·