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

[java] New rule ConfusingArgumentToVarargsMethod #4971

Merged

Conversation

oowekyala
Copy link
Member

Describe the PR

The new rule ConfusingArgumentToVarargsMethod is in errorprone and cares about the "confusing argument" part. This makes it so that:

  • UnnecessaryVarargsArrayCreation is now always trivially fixable
  • ConfusingArgumentToVarargsMethod is more general and does not only check for array allocations, but expressions of any form. For instance it catches the case where you call a varargs method with null as the argument, which is also confusing. Note that this rule corresponds to a javac compiler warning (eg https://github.com/pmd/pmd/actions/runs/8764585900/job/24054740589#step:7:2865)

This PR also fixes the violations of both rules in our codebase

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)

@oowekyala oowekyala added the a:new-rule Proposal to add a new built-in rule label Apr 21, 2024
@pmd-test
Copy link

pmd-test commented Apr 21, 2024

1 Message
📖 Compared to master:
This changeset changes 113 violations,
introduces 14 new violations, 0 new errors and 0 new configuration errors,
removes 1 violations, 0 errors and 0 configuration errors.
Download full report as build artifact
Compared to master:
This changeset changes 0 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 142863 violations, 13 errors and 7 configuration errors.
Download full report as build artifact

Generated by 🚫 Danger

@adangel adangel added this to the 7.1.0 milestone Apr 25, 2024
@adangel adangel changed the title [java] Split UnnecessaryVarargsArrayCreation into two rules [java] New rule ConfusingArgumentToVarargsMethod Apr 25, 2024
Copy link
Member

@adangel adangel left a comment

Choose a reason for hiding this comment

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

Thanks!

There seems to be a problem with the regression tester being confused, see pmd/pmd-regression-tester#124
I've now disabled that - maybe we see then some regression results.

If that works, I'm going to merge this later today.

Also thanks for cleanup up the existing code base!

adangel added a commit that referenced this pull request Apr 25, 2024
Merge pull request #4971 from oowekyala:new-rule-UnnecessaryVarargsArrayCreation
@adangel adangel merged commit f5d47ac into pmd:master Apr 25, 2024
3 checks passed
@oowekyala oowekyala deleted the new-rule-UnnecessaryVarargsArrayCreation branch April 25, 2024 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:new-rule Proposal to add a new built-in rule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants