redundant_optional_initialization - ApplebaumIan/BitbucketAPI GitHub Wiki
Initializing an optional variable with nil is redundant.
- Identifier: redundant_optional_initialization
- Enabled by default: Enabled
- Supports autocorrection: Yes
- Kind: idiomatic
- Analyzer rule: No
- Minimum Swift compiler version: 3.0.0
- Default configuration: warning
var myVar: Int?let myVar: Int? = nilvar myVar: Int? = 0func foo(bar: Int? = 0) { }var myVar: Optional<Int>let myVar: Optional<Int> = nilvar myVar: Optional<Int> = 0var foo: Int? {
if bar != nil { }
return 0
}var foo: Int? = {
if bar != nil { }
return 0
}()lazy var test: Int? = nilfunc funcName() {
var myVar: String?
}func funcName() {
let myVar: String? = nil
}var myVar: Int?↓ = nilvar myVar: Optional<Int>↓ = nilvar myVar: Int?↓=nilvar myVar: Optional<Int>↓=nil
)func funcName() {
var myVar: String?↓ = nil
}