Skip to content

redundant_optional_initialization removes opening bracket before property observer  #3718

Closed
@maikasshoff

Description

New Issue Checklist

Describe the bug

The redundant_optional_initialization rule removes the opening bracket before a property observer which causes a syntax issue. For example

var foo: String? = nil {
  didSet {
    print("foo")
  }
}

is changed to

var foo: String?
  didSet {
    print("foo")
  }
}
Complete output when running SwiftLint, including the stack trace and command used
$ swiftlint lint       

Linting Swift files in current working directory
Linting 'Foo.swift' (1/1)
/Foo.swift:3:21: warning: Redundant Optional Initialization Violation: Initializing an optional variable with nil is redundant. (redundant_optional_initialization)
Done linting! Found 1 violation, 0 serious in 1 file.

Environment

$ swiftlint version
swiftlint version
0.44.0

@iressler

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions