Skip to content

False positive for FL_FLOATS_AS_LOOP_COUNTERS #2126

@DanySK

Description

@DanySK

Relevant code:

double y = Double.NaN
while (Double.isNaN(y) && someOtherCondition) {
    ...
    y = Double.parseDouble(...);
    ...
}

Reported:

FL_FLOATS_AS_LOOP_COUNTERS: Do not use floating-point variables as loop counters

Using floating-point variables should not be used as loop counters, as they are not precise, which may result in incorrect loops. A loop counter is a variable that is changed with each iteration and controls when the loop should terminate. It is decreased or increased by a fixed amount each iteration.

See rule NUM09-J.


However, there is no fixed increment, so I think it does not apply here.

Bytecode:
FollowTarget.zip

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