Empty Count
Prefer checking isEmpty
over comparing count
to zero
- Identifier:
empty_count
- Enabled by default: No
- Supports autocorrection: Yes
- Kind: performance
- Analyzer rule: No
- Minimum Swift compiler version: 5.0.0
- Default configuration:
Key Value severity error only_after_dot false
Non Triggering Examples
var count = 0
[Int]().isEmpty
[Int]().count > 1
[Int]().count == 1
[Int]().count == 0xff
[Int]().count == 0b01
[Int]().count == 0o07
discount == 0
order.discount == 0
Triggering Examples
[Int]().↓count == 0
0 == [Int]().↓count
[Int]().↓count==0
[Int]().↓count > 0
[Int]().↓count != 0
[Int]().↓count == 0x0
[Int]().↓count == 0x00_00
[Int]().↓count == 0b00
[Int]().↓count == 0o00
↓count == 0