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

Tautology Checker in Conditions #803

Closed
jkillian opened this issue Nov 16, 2015 · 1 comment
Closed

Tautology Checker in Conditions #803

jkillian opened this issue Nov 16, 2015 · 1 comment

Comments

@jkillian
Copy link
Contributor

I was writing code to check if two objects were equivalent and wrote code like this:

function areEqual(obj1: SomeClass, obj2: SomeClass) {
return obj1 != null
    && obj2 != null
    && obj1.foo === obj1.foo
    && obj1.foo === obj2.bar
    && obj1.baz === obj2.baz
}

The error in the code above is comparing obj1.foo === obj1.foo. In very few cases is an obviously true condition like this actually what the developer intended. While tslint probably doesn't want to be attempting to evaluate expressions on each side of a condition, it could do a simple textual comparison to catch mistakes like this.

@noamyogev84
Copy link
Contributor

Hi @jkillian ,I'd like to tackle this one.
Can you share some code pointers?

@adidahiya adidahiya added this to the 5.14.0 milestone Mar 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants