Skip to content

[java] A false negative for NullAssignment  #3959

@ghost

Description

Affects PMD Version:6.42.0

Rule:NullAssignment

Please provide the rule name and a link to the rule documentation:
https://pmd.github.io/latest/pmd_rules_java_errorprone.html#nullassignment

Description:
Hi, I found a false negative about the rule NullAssignment. PMD should have reported a warning in line 5, but it doesn't. I think this FN is caused by the parenthesis. Thanks for your consideration.

Code Sample demonstrating the issue:

public void foo() {
        Object x;
        x = new Object();
        bar(x);
        x = (null); // should report a warning in this line
    }

Expected outcome:

PMD should report a violation at line 5, but doesn't. This is a false-negative.

Running PMD through: [Maven]

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:false-negativePMD doesn't flag a problematic piece of code

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions