When a public extension has a single property with private(set), the property receives a warning that it should use an extension access modifier.
This isn't possible since private(set) cannot be moved from the property to the extension.
Complete output when running SwiftLint, including the stack trace and command used
$ swiftlint lint
Linting Swift files in current working directory
Linting 'test.swift' (1/1)
test.swift:3:5: warning: Extension Access Modifier Violation: Prefer to use extension access modifiers (extension_access_modifier)
Done linting! Found 1 violation, 0 serious in 1 file.
Environment
SwiftLint version (run swiftlint version to be sure)? 0.55.1
Installation method used (Homebrew, CocoaPods, building from source, etc)? homebrew
Paste your configuration file: n/a
opt_in_rules:
- extension_access_modifier
Are you using nested configurations? No
If so, paste their relative paths and respective contents.
Which Xcode version are you using (check xcodebuild -version)? 15.4
Do you have a sample that shows the issue? Yes
public class Foo {}
public extension Foo {
private(set) var value: Int {
get { 1 }
set {}
}
}
Single line to run it
echo "class Foo {}\npublic extension Foo {\n private(set) var value {\n get { 0 }\n set { print(newValue) }\n }\n}" | swiftlint lint --no-cache --use-stdin --enable-all-rules
New Issue Checklist
Describe the bug
When a
public
extension has a single property withprivate(set)
, the property receives a warning that it should use an extension access modifier.This isn't possible since private(set) cannot be moved from the property to the extension.
Complete output when running SwiftLint, including the stack trace and command used
Environment
swiftlint version
to be sure)? 0.55.1xcodebuild -version
)? 15.4Single line to run it