#3385 Warn when mapper-declared lifecycle methods are never used - #4114
Open
bkks1004 wants to merge 1 commit into
Open
#3385 Warn when mapper-declared lifecycle methods are never used#4114bkks1004 wants to merge 1 commit into
bkks1004 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Unused
@BeforeMapping/@AfterMappingmethods currently produce no diagnostic.If a developer adds an extra parameter by mistake, the method is silently ignored.
For the mapper from the issue:
goodis invoked, butnowarningis not, and MapStruct does not warn.Change
Warn only for lifecycle methods that are declared directly on the processed mapper and never type-match any generated mapping method.
Out of scope on purpose, so existing overload / inheritance patterns stay quiet:
BaseMapper)Mapper#usesCarMapper.neverMatched(...)is the remaining true unused case and now expects the warning.Verification
Run from the repository root with JDK 21.
Issue3385Testcovers unused@AfterMappingand@BeforeMappingCallbackMethodTest,CallbackMethodTypeMatchingTest,Issue3849Teststay green./mvnw -pl processor test -Dtest=Issue3385Test,CallbackMethodTest,CallbackMethodTypeMatchingTest,Issue3849TestFixes #3385