I added Swiftlint to a project and I'm having trouble understanding what the warning is for extension_access_modifier
. I see it mainly on a class that is declared as public, but there are extensions littered throughout the codebase that adds functionality.
public class Foo {
}
// In SomeOtherClass.swift
extension Foo { // Extension Access Modifier Violation: Prefer to use extension access modifiers
public func baz()
}
Whenever there is extension Foo
in another class, I get that warning on the extension. Would someone explain what it is?
It's clearer to express that your extension is public, rather than all its members:
Prefer:
public extension Foo {
func bar() { ... }
func baz() { ... }
func qux() { ... }
}
over
extension Foo {
public func bar() { ... }
public func baz() { ... }
public func qux() { ... }
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With