Intellij Plugin breaks method inlining and variable extraction from inside if condition
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- java
調査の方向性
Issue 内の Java 再現から始め、if 条件内でのメソッドのインライン化および変数の抽出と IntelliJ plugin のフォーマット処理の相互作用を調査してください。plugin を有効にした状態で変換を再現し、無効にした場合の結果と比較してください。refactoring が不要な if (true) を挿入せず、エラーを報告せず、フォーマットを壊したままにしなくなれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Consider the following code and try inlining isEmpty2:
import java.util.Collection;
import java.util.List;
public class InliningWithJavaFormat {
static boolean isEmpty(Collection<?> c) {
return c == null || c.isEmpty();
}
static boolean isEmpty2(Collection<?> c) {
return isEmpty(c);
}
public static void main(String[] args){
var pojo = new MyPojo();
if (pojo != null && !isEmpty2(pojo.getCollection())) {
System.out.println("empty");
}
}
static class MyPojo {
Collection<String> getCollection() {
return List.of();
}
}
}
Not only does it fail (without reporting it), but it adds an additional if (true):
public static void main(String[] args){
var pojo = new MyPojo();
if (pojo != null && !isEmpty2(pojo.getCollection())) {
if (true) {
System.out.println("empty");
}
}
}
with the plugin disabled, it works:
public static void main(String[] args){
var pojo = new MyPojo();
if (pojo != null) {
Collection<?> c = pojo.getCollection();
if (!isEmpty(c)) {
System.out.println("empty");
}
}
}
(not the ideal result but at least it does not fail)
In addition, when I do that on my actual project I get an error notification from the plugin and the formatting gets broken:
(I did not try to reproduce this with an MRE, I guess it is a side effect of the first issue)
- 主要言語
- 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
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
elastic/gradle-plugins#157 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
cryptomator/hub#497 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
johanhaleby/occurrent#1120 ·