Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Source value mapped more than once inspection for @ValueMapping

Open
#265 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
75/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Quiet
Tech stack
java
Domain
devtools

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.

Description

feature hack.commit.push

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.

Dominant language
Java
Stars
168
Forks
41
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from mapstruct/mapstruct-idea

All issues in mapstruct/mapstruct-idea

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.