Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positive of extension_access_modifier on property with private(set) #5623

Closed
2 tasks done
CraigSiemens opened this issue Jun 13, 2024 · 0 comments · Fixed by #5625
Closed
2 tasks done

False positive of extension_access_modifier on property with private(set) #5623

CraigSiemens opened this issue Jun 13, 2024 · 0 comments · Fixed by #5625
Labels
bug Unexpected and reproducible misbehavior.

Comments

@CraigSiemens
Copy link
Contributor

New Issue Checklist

Describe the bug

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  
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected and reproducible misbehavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants