Skip to content

An inconsistent detection result of rule SA_FIELD_SELF_ASSIGNMENT #2142

@vanguard-1024

Description

@vanguard-1024

Hi, I found an inconsistent detection result about the rule SA_FIELD_SELF_ASSIGNMENT, the code example is below. SpotBugs can detect the bug in line 4, but cannot in line 8. These two lines are equivalent, hence, I think this is a false negative.

public class C {
    int foo;
    void foo1() {
        foo = foo++;  // can report a warning in this line
    }
    class subC {
        void foo2() {
            foo = foo++; // should report a warning in this line
        }
    }
}

SpotBugs version: 4.7.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions