Redundant Access Control for Setter

Property setter access level shouldn’t be explicit if it’s the same as the variable access level

  • Identifier: redundant_set_access_control
  • Enabled by default: Yes
  • Supports autocorrection: No
  • Kind: idiomatic
  • Analyzer rule: No
  • Minimum Swift compiler version: 5.0.0
  • Default configuration:
    KeyValue
    severity warning

Non Triggering Examples

private(set) public var foo: Int
public let foo: Int
public var foo: Int
var foo: Int
private final class A {
  private(set) var value: Int
}
extension Color {
    public internal(set) static var someColor = Color.anotherColor
}

Triggering Examples

private(set) private var foo: Int
fileprivate(set) fileprivate var foo: Int
internal(set) internal var foo: Int
public(set) public var foo: Int
open class Foo {
  open(set) open var bar: Int
}
class A {
  internal(set) var value: Int
}
internal class A {
  internal(set) var value: Int
}
fileprivate class A {
  fileprivate(set) var value: Int
}