Line Seperator issue between windows and unix
まだ誰も着手していません。
評価
調査の方向性
google-java-format-1.10.0-all-deps.jar と MinimalExample.java の例を使用し、LF と CRLF の両方の行末で不一致を再現します。フォーマッタが異なる折り返しを生成する理由を追跡し、その後、同じソースをフォーマットした場合に、両方のプラットフォームで余分な改行のない一貫した出力になることを確認します。
索引モデルが issue の本文から書いたものです。
説明
When applying GJF, some code is formatted differently between Unix-style line seperators (LF) and Windows-style line seperators (CRLF). With windows-style an extra linebreak is added, caused by the char difference between LF (\n) and CRLF (\r\n).
I changed the line-separator-style with Intellij (File>File Properties> Line Separators, while having the file opened) and got the following outputs:
Executing java -jar google-java-format-1.10.0-all-deps.jar MinimalExample.java when the file is formatted with Unix line endings:
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import feign.FeignException;
public class MinimalExample {
void googleJavaFormatWindowsFail() {
FeignException feignException = mock(FeignException.class);
when(feignException.contentUTF8()).thenReturn("""
{
"errorCode" : 420
}
""");
}
}
Executing java -jar google-java-format-1.10.0-all-deps.jar MinimalExample.java when the file is formatted with Windows line endings:
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import feign.FeignException;
public class MinimalExample {
void googleJavaFormatWindowsFail() {
FeignException feignException = mock(FeignException.class);
when(feignException.contentUTF8())
.thenReturn("""
{
"errorCode" : 420
}
""");
}
}
If two chars are added, Unix-style generates the same line-break:
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import feign.FeignException;
public class MinimalExample {
void googleJavaFormatWindowsFail() {
FeignException feignException = mock(FeignException.class);
when(feignException.contentUTF8())
.thenReturn("""
{
"errorCode" : 42069
}
""");
}
}
Done on GJF 1.10.0, 1,9 and 1.8 with Java 15.0.2
Windows 10 10.0
IntelliJ IDEA 2021.1.1 (Community Edition)
- 主要言語
- 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 · コメント 3 件 ·
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 ·
-
難易度 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 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
wso2/dpdp-accelerator#287 ·