Skip to content

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

@KroArtem

Description

@KroArtem

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:false-positivePMD flags a piece of code that is not problematic

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions