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] NullAssignment - FP with ternay and null as constructor argument #1669

Closed
Vampire opened this issue Feb 19, 2019 · 2 comments · Fixed by #3649
Closed

[java] NullAssignment - FP with ternay and null as constructor argument #1669

Vampire opened this issue Feb 19, 2019 · 2 comments · Fixed by #3649
Labels
a:false-positive PMD flags a piece of code that is not problematic
Milestone

Comments

@Vampire
Copy link
Contributor

Vampire commented Feb 19, 2019

Affects PMD Version: 6.11.0
Rule: NullAssignment
Description:
Should below code really trigger the NullAssignment rule?
Of course I could write "null" instead of null but why should this be worse than wasting a string constant pool place?
Code Sample demonstrating the issue:

throw new IllegalArgumentException(String.format(
        "Unsupported client with class '%s' given",
        (discordClient == null) ? null : discordClient.getClass()));

Running PMD through: Gradle

@jsotuyod
Copy link
Member

Sounds like a FP… the rule has some checks around ternaries, but I'm unsure at first glance what scenarios they are addressing…

I guess some further research is in place.

@adangel adangel changed the title [java] possible false-positive in NullAssignment [java] NullAssignment - FP with ternay and null as constructor argument Dec 23, 2021
@adangel adangel added the a:false-positive PMD flags a piece of code that is not problematic label Dec 23, 2021
@adangel adangel added this to the 7.0.0 milestone Dec 23, 2021
@adangel adangel linked a pull request Dec 23, 2021 that will close this issue
adangel added a commit to adangel/pmd that referenced this issue Dec 23, 2021
adangel added a commit to adangel/pmd that referenced this issue Dec 23, 2021
@adangel adangel mentioned this issue Jan 23, 2023
55 tasks
@adangel
Copy link
Member

adangel commented Apr 22, 2023

This has been fixed with PMD 7.0.0-rc1.

@adangel adangel closed this as completed Apr 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:false-positive PMD flags a piece of code that is not problematic
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants