Skip to content

[java] RedundantFieldInitializer FP with expressions that start with zero #3743

@oowekyala

Description

@oowekyala

Affects PMD Version: 6.41.0

Rule: RedundantFieldInitializer

Description:

See #3684:

As @dykov pointed out, 0 + 1 - 1 is only flagged by chance. Expressions starting with 0 but not evaluating to zero (eg 0+1) would cause a false positive which should be fixed in pmd 6.

Code Sample demonstrating the issue:

class Impl {
    int b = 0 + 1; // FP
}

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions