yoda_condition - ApplebaumIan/BitbucketAPI GitHub Wiki
Yoda condition rule
The variable should be placed on the left, the constant on the right of a comparison operator.
- Identifier: yoda_condition
- Enabled by default: Disabled
- Supports autocorrection: No
- Kind: lint
- Analyzer rule: No
- Minimum Swift compiler version: 3.0.0
- Default configuration: warning
Non Triggering Examples
if foo == 42 {}
if foo <= 42.42 {}
guard foo >= 42 else { return }
guard foo != "str str" else { return }
while foo < 10 { }
while foo > 1 { }
while foo + 1 == 2
if optionalValue?.property ?? 0 == 2
if foo == nil
Triggering Examples
↓if 42 == foo {}
↓if 42.42 >= foo {}
↓guard 42 <= foo else { return }
↓guard "str str" != foo else { return }
↓while 10 > foo { }
↓while 1 < foo { }
↓if nil == foo