mapstruct / mapstruct/mapstruct-idea

Unexpected warning: ''.'' should not be used as a source

オープン
#257 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
Java
スター
168
フォーク
41
PR マージ指標
30日以内にマージされた PR はありません

説明

I often have a use-case when `"."` is a valid and correct source of my mapping. It is officially supported mapping source, so why the plugin reports it as "should not be used"? Is there any particular reason or maybe it is just a historical burden from the times when MapStruct actually didn't support `"."` as a source?

Example:

```java
record Failure(String code, String detail) {}

class Foo {
Failure failure;
}

class FooDto {
String failureCode;
String failureDetail;
}

public abstract class FooMapper {

@Mapping(target = "failure", source = ".")
public abstract Foo fromDto(FooDto fooDto);

protected Failure mapFailure(FooDto fooDto) {
return new Failure(fooDto.getFailureCode(), fooDto.getFailureDetail());
}

}
```

Of course, in this particular case we can just use:

```java
@Mapping(target = "failure.code", source = "failureCode")
@Mapping(target = "failure.detail", source = "failureDetail")
```

But there are more complex cases when the target object should be created manually, by a custom code, and the only possible source is the whole source object.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず FooMapper の例で警告を再現し、MapStruct IntelliJ plugin が source が "." である @Mapping の値をどのように処理するかを調べます。その動作を、MapStruct がこの source 形式をサポートしているというドキュメント上の記載と比較します。有効なマッピングに対して誤った警告が表示されなくなるか、警告の理由が明確に特定できれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java
領域
tooling
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。