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 ternary and null as method argument #2320

Closed
KroArtem opened this issue Feb 27, 2020 · 2 comments · Fixed by #3649
Closed

[java] NullAssignment - FP with ternary and null as method argument #2320

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

Comments

@KroArtem
Copy link
Contributor

KroArtem commented Feb 27, 2020

Affects PMD Version:
6.20

Rule: NullAssignment
Description:

Code Sample demonstrating the issue:

public String methodOne(String one, String two) {
        return "test";
    }
public String methodTwo(String one, String two) {
        List<String> strings = new ArrayList<>();
->>        return methodOne("one", strings.isEmpty() ? null : "two");
    }

Running PMD through: [CLI | Ant | Maven | Gradle | Designer | Other]
Programmatically

@KroArtem
Copy link
Contributor Author

Possible duplicate of #1050 , #1669

Will look for root of the problem later

@adangel adangel added the a:false-positive PMD flags a piece of code that is not problematic label Feb 29, 2020
@adangel adangel changed the title [wip] [java] FP in NullAssignment rule [java] NullAssignment - FP with ternary in method call Dec 23, 2021
@adangel adangel changed the title [java] NullAssignment - FP with ternary in method call [java] NullAssignment - FP with ternary and null as method argument Dec 23, 2021
@adangel adangel linked a pull request Dec 23, 2021 that will close this issue
@adangel adangel added this to the 7.0.0 milestone Dec 23, 2021
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.

2 participants