diff --git a/Rules.md b/Rules.md index ab2b5c706d8..c502fa62eab 100644 --- a/Rules.md +++ b/Rules.md @@ -8483,6 +8483,10 @@ fileprivate struct Foo { private func bar() {} } private struct Foo { private func bar(id: String) } ``` +```swift +extension Foo { public func bar() {} } +``` + ```swift private func foo(id: String) {} ``` @@ -8495,10 +8499,6 @@ private func foo(id: String) {} struct Foo { public func bar() {} } ``` -```swift -extension Foo { public func bar() {} } -``` - ```swift enum Foo { public func bar() {} } ``` diff --git a/Source/SwiftLintFramework/Models/AccessControlLevel.swift b/Source/SwiftLintFramework/Models/AccessControlLevel.swift index f5006afece1..c796a94e5c3 100644 --- a/Source/SwiftLintFramework/Models/AccessControlLevel.swift +++ b/Source/SwiftLintFramework/Models/AccessControlLevel.swift @@ -51,10 +51,10 @@ extension AccessControlLevel: Comparable { private var priority: Int { switch self { case .private: return 1 - case .fileprivate: return 2 - case .internal: return 3 - case .public: return 4 - case .open: return 5 + case .fileprivate: return 1 + case .internal: return 2 + case .public: return 3 + case .open: return 4 } } diff --git a/Source/SwiftLintFramework/Rules/LowerACLThanBodyRule.swift b/Source/SwiftLintFramework/Rules/LowerACLThanBodyRule.swift index beeb5dfb8bb..bf8986c471e 100644 --- a/Source/SwiftLintFramework/Rules/LowerACLThanBodyRule.swift +++ b/Source/SwiftLintFramework/Rules/LowerACLThanBodyRule.swift @@ -27,14 +27,14 @@ public struct LowerACLThanParentRule: OptInRule, ConfigurationProviderRule { "open class Foo { open func bar() {} }", "fileprivate struct Foo { private func bar() {} }", "private struct Foo { private func bar(id: String) }", + "extension Foo { public func bar() {} }", + "private struct Foo { fileprivate func bar() {} }", "private func foo(id: String) {}" ], triggeringExamples: [ "struct Foo { public func bar() {} }", - "extension Foo { public func bar() {} }", "enum Foo { public func bar() {} }", "public class Foo { open func bar() }", - "private struct Foo { fileprivate func bar() {} }", "class Foo { public private(set) var bar: String? }" ] ) @@ -70,17 +70,16 @@ public struct LowerACLThanParentRule: OptInRule, ConfigurationProviderRule { private extension SwiftDeclarationKind { var isRelevantDeclaration: Bool { switch self { - case .`associatedtype`, .enumcase, .enumelement, .functionAccessorAddress, - .functionAccessorDidset, .functionAccessorGetter, .functionAccessorMutableaddress, - .functionAccessorSetter, .functionAccessorWillset, .functionDestructor, .genericTypeParam, .module, - .precedenceGroup, .varLocal, .varParameter: + case .`associatedtype`, .enumcase, .enumelement, .`extension`, .`extensionClass`, .`extensionEnum`, + .extensionProtocol, .extensionStruct, .functionAccessorAddress, .functionAccessorDidset, + .functionAccessorGetter, .functionAccessorMutableaddress, .functionAccessorSetter, + .functionAccessorWillset, .functionDestructor, .genericTypeParam, .module, .precedenceGroup, .varLocal, + .varParameter: return false - case .`class`, .`enum`, .`extension`, .`extensionClass`, .`extensionEnum`, - .extensionProtocol, .extensionStruct, .functionConstructor, - .functionFree, .functionMethodClass, .functionMethodInstance, .functionMethodStatic, - .functionOperator, .functionOperatorInfix, .functionOperatorPostfix, .functionOperatorPrefix, - .functionSubscript, .`protocol`, .`struct`, .`typealias`, .varClass, - .varGlobal, .varInstance, .varStatic: + case .`class`, .`enum`, .functionConstructor, .functionFree, .functionMethodClass, .functionMethodInstance, + .functionMethodStatic, .functionOperator, .functionOperatorInfix, .functionOperatorPostfix, + .functionOperatorPrefix, .functionSubscript, .`protocol`, .`struct`, .`typealias`, .varClass, .varGlobal, + .varInstance, .varStatic: return true } }