Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

use-isnan should only apply to comparison operators #2317

Merged
merged 4 commits into from
Mar 8, 2017
Merged

use-isnan should only apply to comparison operators #2317

merged 4 commits into from
Mar 8, 2017

Conversation

sbj42
Copy link
Contributor

@sbj42 sbj42 commented Mar 8, 2017

PR checklist

Overview of change:

The use-isnan rule was warning about all binary operators except for the simple assignment operator =. This was problematic because x || NaN is a reasonable thing to do. This change ensures that it only applies to comparison operators. Instead of checking for the assignment exception, the rule now checks against a complete list of comparison operators.

Is there anything you'd like reviewers to focus on?

Most binary operators would be silly to use with a literal NaN. I'm not sure whether it would have been better to just add more exceptions (specifically for || and &&). The technique in this PR has the risk that if a new comparison operator is later added to the language (e.g. <=>) then the rule will need to be updated. But it seemed better to me to limit the scope of the rule completely.

CHANGELOG.md entry:

[bugfix] use-isnan now applies only to comparison operators

`use-isnan` should only warn about the use of comparison operators with `NaN`.  It should ignore other operator classes.
`instanceof` and `in` are also binary operators.
The purpose of the rule is only  to prevent things like `x == NaN`.  It should not warn about the use of other operators, such as `x || NaN`.
@nchen63 nchen63 merged commit c7d934b into palantir:master Mar 8, 2017
@nchen63
Copy link
Contributor

nchen63 commented Mar 8, 2017

@sbj42 thanks for the contribution

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants