[java] New rule PrimitiveWrapperInstantiation#3365
Conversation
Generated by 🚫 Danger |
adangel
left a comment
There was a problem hiding this comment.
Looks good, thanks!
I know now, what the problem will be, when we integrate BooleanInstantiation into this rule: for Boolean, we actually need a very different violation message: We don't want to say "Do not use new Boolean(...), prefer Boolean.valueOf(...)", instead we want e.g. "Do not use new Boolean(...) or Boolean.valueOf(...), prefer Boolean.TRUE or Boolean.FALSE".
Keeping it as a XPath rule, this might not be possible. But if we reimplement this as a simple Java rule, we can issue different messages.
Maybe I'll have a look at this on Thursday - otherwise we can integrate BooleanInstantiation later.
Reminder: We need to mention the deprecated rules in the release notes - and of course also the new rule.
Describe the PR
This new rule merges the rules
The rule may have some overlap with #3364, if the constructor call is unnecessary because of autoboxing or some other case caught by #3364. This looks ok though
This also deprecates the rule UnnecessaryWrapperObjectCreation because it's useless, as described in #3364. The replacement hinted at in the updated rule description is #3364.
Related issues
Ready?
./mvnw clean verifypasses (checked automatically by github actions)