Skip to content

[java] Update rule UnnecessaryWrapperObjectCreation#3418

Merged
oowekyala merged 4 commits into
pmd:pmd/7.0.xfrom
adangel:pmd7-update-UnnecessaryWrapperObjectCreation
Aug 7, 2021
Merged

[java] Update rule UnnecessaryWrapperObjectCreation#3418
oowekyala merged 4 commits into
pmd:pmd/7.0.xfrom
adangel:pmd7-update-UnnecessaryWrapperObjectCreation

Conversation

@adangel

@adangel adangel commented Jul 24, 2021

Copy link
Copy Markdown
Member

Describe the PR

Updates the rule UnnecessaryWrapperObjectCreation. I've removed the check for the java version, as this looked wrong: Boolean.valueOf has been introduced with java 1.4, and all other *.valueOf method with java 1.5. So actually, this rule should have a minimum language version of 1.5, but I guess, that doesn't matter anymore.

The rule is also directly deprecated, as the new UnnecessaryBoxing replaces it.

The only useful check of this rule is this: Integer.valueOf(1).toString() - calls to "toString()", where one should simply use String.valueOf(1) instead or Integer.toString(1).

Related issues

Ready?

  • Added unit tests for fixed bug/feature
  • Passing all unit tests
  • Complete build ./mvnw clean verify passes (checked automatically by github actions)
  • Added (in-code) documentation (if needed)

@adangel adangel added the is:deprecation The main focus is deprecating public APIs or rules, eg to make them internal, or removing them label Jul 24, 2021
@adangel adangel added this to the 7.0.0 milestone Jul 24, 2021
@ghost

ghost commented Jul 24, 2021

Copy link
Copy Markdown
2 Messages
📖 Compared to pmd/7.0.x:
This changeset changes 0 violations,
introduces 5131 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.
Full report
📖 Compared to master:
This changeset changes 30764 violations,
introduces 36389 new violations, 3 new errors and 0 new configuration errors,
removes 138682 violations, 8 errors and 3 configuration errors.
Full report
Compared to pmd/7.0.x:
This changeset changes 0 violations,
introduces 4 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.
Full report
Compared to master:
This changeset changes 30753 violations,
introduces 34201 new violations, 3 new errors and 0 new configuration errors,
removes 141569 violations, 8 errors and 3 configuration errors.
Full report
Compared to pmd/7.0.x:
This changeset changes 0 violations,
introduces 4 new violations, 115 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.
Full report
Compared to master:
This changeset changes 30753 violations,
introduces 34201 new violations, 118 new errors and 0 new configuration errors,
removes 141569 violations, 8 errors and 3 configuration errors.
Full report

Generated by 🚫 Danger

@oowekyala

Copy link
Copy Markdown
Member

Thanks!

Maybe if we do the "staged release" of pmd 7 we talked about, then we could remove it in pmd 7.1.0? Like other @DeprecatedUntil700 api.

@adangel

adangel commented Jul 29, 2021

Copy link
Copy Markdown
Member Author

So, with #3365 we actually deprecated the rule UnnecessaryWrapperObjectCreation with PMD 6.37.0 without replacement. So we can actually delete it in PMD 7...

@adangel

adangel commented Jul 29, 2021

Copy link
Copy Markdown
Member Author

The only useful check of this rule is this: Integer.valueOf(1).toString() - calls to "toString()", where one should simply use String.valueOf(1) instead or Integer.toString(1).

Before deleting it, we should make sure, that we somewhere cover this case.

@oowekyala

Copy link
Copy Markdown
Member

Before deleting it, we should make sure, that we somewhere cover this case.

I think it should be part of UnnecessaryBoxing

oowekyala added a commit to adangel/pmd that referenced this pull request Aug 7, 2021
@oowekyala

Copy link
Copy Markdown
Member

So 85e9bfa ensures that UnnecessaryBoxing catches the string cases. So I'm going to merge this to open the pr removing deprecated rules, which includes this one

@oowekyala oowekyala merged commit 2242bad into pmd:pmd/7.0.x Aug 7, 2021
@adangel adangel deleted the pmd7-update-UnnecessaryWrapperObjectCreation branch August 19, 2021 08:28
@adangel adangel mentioned this pull request Jan 23, 2023
55 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

is:deprecation The main focus is deprecating public APIs or rules, eg to make them internal, or removing them

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants