Skip to content

Files

Latest commit

 

History

History
57 lines (30 loc) · 754 Bytes

redundant_set_access_control.md

File metadata and controls

57 lines (30 loc) · 754 Bytes

Pattern: Redundant access level for property setter

Issue: -

Description

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

Examples of correct code:

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
}

Examples of incorrect code:

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
}


fileprivate class A {fileprivate(set) var value: Int
}