Skip to content

lint: floatCompare tuning for less false-positives #511

@quasilyte

Description

@quasilyte

We have many warnings on GOROOT.
Many (most) of them look like false-positives.
It's better to constrain floatCompare to be less greedy (or this should be controlled by config).

For example, comparison with zero usually makes sense, same goes for Inf and self-comparison like x == x or x != x (the latter is NaN check).

We may also want to skip simple v != literal and v == literal unless v is a expression, not just a var:

v != 5.0 // OK
foo() != -1.0 // OK? Maybe function documents that it sometimes returns -1.0
x + y != 5.0 // suspicious
x*2 - y != 5.0 // suspicious
// and so on...

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