Skip to content

Files

Latest commit

 

History

History
428 lines (149 loc) · 3.55 KB

identical_operands.md

File metadata and controls

428 lines (149 loc) · 3.55 KB

Pattern: Comparing two identical operands

Issue: -

Description

Comparing two identical operands is likely a mistake.

Examples of correct code:

1 == 2


foo == bar


prefixedFoo == foo


foo.aProperty == foo.anotherProperty


self.aProperty == self.anotherProperty


"1 == 1"


self.aProperty == aProperty


lhs.aProperty == rhs.aProperty


lhs.identifier == rhs.identifier


i == index


$0 == 0


keyValues?.count ?? 0  == 0


1 != 2


foo != bar


prefixedFoo != foo


foo.aProperty != foo.anotherProperty


self.aProperty != self.anotherProperty


"1 != 1"


self.aProperty != aProperty


lhs.aProperty != rhs.aProperty


lhs.identifier != rhs.identifier


i != index


$0 != 0


keyValues?.count ?? 0  != 0


1 === 2


foo === bar


prefixedFoo === foo


foo.aProperty === foo.anotherProperty


self.aProperty === self.anotherProperty


"1 === 1"


self.aProperty === aProperty


lhs.aProperty === rhs.aProperty


lhs.identifier === rhs.identifier


i === index


$0 === 0


keyValues?.count ?? 0  === 0


1 !== 2


foo !== bar


prefixedFoo !== foo


foo.aProperty !== foo.anotherProperty


self.aProperty !== self.anotherProperty


"1 !== 1"


self.aProperty !== aProperty


lhs.aProperty !== rhs.aProperty


lhs.identifier !== rhs.identifier


i !== index


$0 !== 0


keyValues?.count ?? 0  !== 0


1 > 2


foo > bar


prefixedFoo > foo


foo.aProperty > foo.anotherProperty


self.aProperty > self.anotherProperty


"1 > 1"


self.aProperty > aProperty


lhs.aProperty > rhs.aProperty


lhs.identifier > rhs.identifier


i > index


$0 > 0


keyValues?.count ?? 0  > 0


1 >= 2


foo >= bar


prefixedFoo >= foo


foo.aProperty >= foo.anotherProperty


self.aProperty >= self.anotherProperty


"1 >= 1"


self.aProperty >= aProperty


lhs.aProperty >= rhs.aProperty


lhs.identifier >= rhs.identifier


i >= index


$0 >= 0


keyValues?.count ?? 0  >= 0


1 < 2


foo < bar


prefixedFoo < foo


foo.aProperty < foo.anotherProperty


self.aProperty < self.anotherProperty


"1 < 1"


self.aProperty < aProperty


lhs.aProperty < rhs.aProperty


lhs.identifier < rhs.identifier


i < index


$0 < 0


keyValues?.count ?? 0  < 0


1 <= 2


foo <= bar


prefixedFoo <= foo


foo.aProperty <= foo.anotherProperty


self.aProperty <= self.anotherProperty


"1 <= 1"


self.aProperty <= aProperty


lhs.aProperty <= rhs.aProperty


lhs.identifier <= rhs.identifier


i <= index


$0 <= 0


keyValues?.count ?? 0  <= 0


func evaluate(_ mode: CommandMode) -> Result<AutoCorrectOptions, CommandantError<CommandantError<()>>>

Examples of incorrect code:

1 == 1


foo == foo


foo.aProperty == foo.aProperty


self.aProperty == self.aProperty


$0 == $0


1 != 1


foo != foo


foo.aProperty != foo.aProperty


self.aProperty != self.aProperty


$0 != $0


1 === 1


foo === foo


foo.aProperty === foo.aProperty


self.aProperty === self.aProperty


$0 === $0


1 !== 1


foo !== foo


foo.aProperty !== foo.aProperty


self.aProperty !== self.aProperty


$0 !== $0


1 > 1


foo > foo


foo.aProperty > foo.aProperty


self.aProperty > self.aProperty


$0 > $0


1 >= 1


foo >= foo


foo.aProperty >= foo.aProperty


self.aProperty >= self.aProperty


$0 >= $0


1 < 1


foo < foo


foo.aProperty < foo.aProperty


self.aProperty < self.aProperty


$0 < $0


1 <= 1


foo <= foo


foo.aProperty <= foo.aProperty


self.aProperty <= self.aProperty


$0 <= $0

Further Reading