Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wrong unmapped target warning when Mapping#target contains dot #123

Conversation

hduelme
Copy link
Contributor

@hduelme hduelme commented Apr 10, 2023

Currently the plugin gives a warning if an field is mapped with @Mapping where the target contains a dot.

This fixes the issue, by splitting the target on the dot and only removing the first part from allTargetProperties.

I also wrote a small test covering this issue.

Copy link
Member

@filiphr filiphr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good spot and great fix @hduelme.

I am only confused how UnmappedCurrentTargetPropertiesInspectionTest is still passing. The getBaseTarget is going to return an empty string for target = ".".

@hduelme
Copy link
Contributor Author

hduelme commented Apr 23, 2023

@filiphr the substring operation is only applied if the . is after the first character. String.indexOf returns 0 if the . is the fist character.

@filiphr filiphr added this to the 1.5.1 milestone Apr 23, 2023
@filiphr filiphr added the bug label Apr 23, 2023
@filiphr filiphr merged commit feec705 into mapstruct:main Apr 23, 2023
@filiphr
Copy link
Member

filiphr commented Apr 23, 2023

Good point @hduelme, I completely missed the fact that we do a > 0 check and not >=0

@filiphr filiphr changed the title fix wrong unmapped target warning with Mapping annotation Fix wrong unmapped target warning when Mapping#target contains dot May 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants