mapstruct / mapstruct/mapstruct-idea
Source value mapped more than once inspection for @ValueMapping
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 168
- Forks
- 41
- PR merge metrics
- No merged PRs in 30d
Description
For value mappings a source value can only be mapped once. For example
```
import org.mapstruct.Mapper;
import org.mapstruct.ValueMapping;
@Mapper
public interface ValueMapper {
enum A {
A,B
}
enum B {
A,B
}
@ValueMapping(source = "A", target = "B")
@ValueMapping(source = "A", target = "A")
A from(B b);
}
```
is invalide as source `A` is mapped twice. MapStruct report this as
> Source value mapping: "A" cannot be mapped more than once.
Currently the plugin does not recognize this as an error. An inspection should be added for this.
For normal mappings there is already an inspection implemented and could be used as an example: https://github.com/mapstruct/mapstruct-idea/blob/main/src/main/java/org/mapstruct/intellij/inspection/TargetPropertyMappedMoreThanOnceInspection.java.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with src/main/java/org/mapstruct/intellij/inspection/TargetPropertyMappedMoreThanOnceInspection.java, which provides the existing inspection pattern. Trace how it detects duplicate normal mappings, then apply the same approach to @ValueMapping source values. Done means duplicate source values are recognized and reported with the expected error message.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 75/100