From 3ade6aaed05f6362fde42cb955b22ce23e8d40f3 Mon Sep 17 00:00:00 2001 From: Nick Lockwood Date: Fri, 25 Sep 2020 23:48:05 +0100 Subject: [PATCH] Enable `extensionAccessControl` rule by default --- Snapshots/Issues/697.swift | 4 ++-- Snapshots/Layout/Layout/Layout+XML.swift | 4 ++-- Snapshots/Layout/Layout/LayoutBacked.swift | 4 ++-- Snapshots/Layout/Layout/LayoutDelegate.swift | 6 +++--- Snapshots/Layout/Layout/LayoutNode.swift | 4 ++-- .../Layout/Layout/Shared/XMLNode+Layout.swift | 14 +++++++------- .../Layout/Layout/UICollectionView+Layout.swift | 10 +++++----- Snapshots/Layout/Layout/UITableView+Layout.swift | 12 ++++++------ Sources/Rules.swift | 1 - 9 files changed, 29 insertions(+), 30 deletions(-) diff --git a/Snapshots/Issues/697.swift b/Snapshots/Issues/697.swift index 8c4d142a2..6b945433a 100644 --- a/Snapshots/Issues/697.swift +++ b/Snapshots/Issues/697.swift @@ -19,8 +19,8 @@ import FirebaseFirestore import Foundation -extension Firestore { - public struct Decoder { +public extension Firestore { + struct Decoder { fileprivate static let documentRefUserInfoKey = CodingUserInfoKey(rawValue: "DocumentRefUserInfoKey") diff --git a/Snapshots/Layout/Layout/Layout+XML.swift b/Snapshots/Layout/Layout/Layout+XML.swift index 5ab76849c..13e9b26e7 100755 --- a/Snapshots/Layout/Layout/Layout+XML.swift +++ b/Snapshots/Layout/Layout/Layout+XML.swift @@ -2,8 +2,8 @@ import Foundation -extension Layout { - public init(xmlData: Data, url: URL? = nil, relativeTo: String? = #file) throws { +public extension Layout { + init(xmlData: Data, url: URL? = nil, relativeTo: String? = #file) throws { let xml: [XMLNode] do { xml = try XMLParser.parse(data: xmlData, options: .skipComments) diff --git a/Snapshots/Layout/Layout/LayoutBacked.swift b/Snapshots/Layout/Layout/LayoutBacked.swift index ed5a061e1..387a21905 100755 --- a/Snapshots/Layout/Layout/LayoutBacked.swift +++ b/Snapshots/Layout/Layout/LayoutBacked.swift @@ -8,9 +8,9 @@ public protocol LayoutBacked: class { /* weak */ var layoutNode: LayoutNode? { get } } -extension LayoutBacked where Self: NSObject { +public extension LayoutBacked where Self: NSObject { /// Default implementation of the layoutNode property - public internal(set) weak var layoutNode: LayoutNode? { + internal(set) weak var layoutNode: LayoutNode? { get { return _layoutNode } set { _setLayoutNode(layoutNode, retained: false) } } diff --git a/Snapshots/Layout/Layout/LayoutDelegate.swift b/Snapshots/Layout/Layout/LayoutDelegate.swift index 3aad73803..1d0fcb489 100755 --- a/Snapshots/Layout/Layout/LayoutDelegate.swift +++ b/Snapshots/Layout/Layout/LayoutDelegate.swift @@ -14,10 +14,10 @@ public protocol LayoutDelegate: class { func layoutValue(forKey key: String) throws -> Any? } -extension LayoutDelegate { +public extension LayoutDelegate { /// Default error handler implementation - bubbles error up to the first responder /// that will handle it, or displays LayoutConsole if no handler is found - public func layoutError(_ error: LayoutError) { + func layoutError(_ error: LayoutError) { DispatchQueue.main.async { var responder = (self as? UIResponder)?.next while responder != nil { @@ -32,7 +32,7 @@ extension LayoutDelegate { } /// Default implementation - returns nothing - public func layoutValue(forKey _: String) throws -> Any? { + func layoutValue(forKey _: String) throws -> Any? { return nil } } diff --git a/Snapshots/Layout/Layout/LayoutNode.swift b/Snapshots/Layout/Layout/LayoutNode.swift index 4af5a9877..f930b02ba 100755 --- a/Snapshots/Layout/Layout/LayoutNode.swift +++ b/Snapshots/Layout/Layout/LayoutNode.swift @@ -3129,8 +3129,8 @@ extension NSObject { private var viewSwizzled = false -extension UIView { - fileprivate static func _swizzle() { +private extension UIView { + static func _swizzle() { guard !viewSwizzled else { return } replace(#selector(layoutSubviews), of: self, with: #selector(layout_layoutSubviews)) viewSwizzled = true diff --git a/Snapshots/Layout/Layout/Shared/XMLNode+Layout.swift b/Snapshots/Layout/Layout/Shared/XMLNode+Layout.swift index c238a6817..de99e7062 100755 --- a/Snapshots/Layout/Layout/Shared/XMLNode+Layout.swift +++ b/Snapshots/Layout/Layout/Shared/XMLNode+Layout.swift @@ -2,8 +2,8 @@ import Foundation -extension XMLNode { - var isLayout: Bool { +public extension XMLNode { + internal var isLayout: Bool { switch self { case let .node(name, attributes, children): guard name.isCapitalized else { @@ -23,32 +23,32 @@ extension XMLNode { } } - public var isParameter: Bool { + var isParameter: Bool { guard case .node("param", _, _) = self else { return false } return true } - public var isMacro: Bool { + var isMacro: Bool { guard case .node("macro", _, _) = self else { return false } return true } - public var isChildren: Bool { + var isChildren: Bool { guard case .node("children", _, _) = self else { return false } return true } - public var isParameterOrMacro: Bool { + var isParameterOrMacro: Bool { return isParameter || isMacro } - public var parameters: [String: String] { + var parameters: [String: String] { var params = [String: String]() for child in children where child.isParameter { let attributes = child.attributes diff --git a/Snapshots/Layout/Layout/UICollectionView+Layout.swift b/Snapshots/Layout/Layout/UICollectionView+Layout.swift index 9e36f2d4a..f41d4c28f 100755 --- a/Snapshots/Layout/Layout/UICollectionView+Layout.swift +++ b/Snapshots/Layout/Layout/UICollectionView+Layout.swift @@ -11,8 +11,8 @@ private class Box { } } -extension UICollectionViewLayout { - fileprivate static func defaultLayout(for node: LayoutNode) -> UICollectionViewFlowLayout { +private extension UICollectionViewLayout { + static func defaultLayout(for node: LayoutNode) -> UICollectionViewFlowLayout { let flowLayout = UICollectionViewFlowLayout() if node.expressions["collectionViewLayout.itemSize"] ?? node.expressions["collectionViewLayout.itemSize.width"] ?? @@ -274,7 +274,7 @@ extension UICollectionViewController: LayoutBacked { private var cellDataKey = 0 private var nodesKey = 0 -extension UICollectionView { +public extension UICollectionView { private enum LayoutData { case success(Layout, Any, [String: Any]) case failure(Error) @@ -322,7 +322,7 @@ extension UICollectionView { } } - public func registerLayout( + func registerLayout( named: String, bundle: Bundle = Bundle.main, relativeTo: String = #file, @@ -347,7 +347,7 @@ extension UICollectionView { } } - public func dequeueReusableCellNode(withIdentifier identifier: String, for indexPath: IndexPath) -> LayoutNode { + func dequeueReusableCellNode(withIdentifier identifier: String, for indexPath: IndexPath) -> LayoutNode { do { guard let layoutsData = objc_getAssociatedObject(self, &cellDataKey) as? NSMutableDictionary, let layoutData = layoutsData[identifier] as? LayoutData diff --git a/Snapshots/Layout/Layout/UITableView+Layout.swift b/Snapshots/Layout/Layout/UITableView+Layout.swift index 0244dedbc..83df6e5f5 100755 --- a/Snapshots/Layout/Layout/UITableView+Layout.swift +++ b/Snapshots/Layout/Layout/UITableView+Layout.swift @@ -281,7 +281,7 @@ private var cellDataKey = 0 private var headerDataKey = 0 private var nodesKey = 0 -extension UITableView { +public extension UITableView { private enum LayoutData { case success(Layout, Any, [String: Any]) case failure(Error) @@ -316,7 +316,7 @@ extension UITableView { // MARK: UITableViewHeaderFooterView recycling - public func registerLayout( + func registerLayout( named: String, bundle: Bundle = Bundle.main, relativeTo: String = #file, @@ -343,7 +343,7 @@ extension UITableView { } } - public func dequeueReusableHeaderFooterNode(withIdentifier identifier: String) -> LayoutNode? { + func dequeueReusableHeaderFooterNode(withIdentifier identifier: String) -> LayoutNode? { if let view = dequeueReusableHeaderFooterView(withIdentifier: identifier) { guard let node = view.layoutNode else { preconditionFailure("\(type(of: view)) is not a Layout-managed view") @@ -389,7 +389,7 @@ extension UITableView { // MARK: UITableViewCell recycling - public func registerLayout( + func registerLayout( named: String, bundle: Bundle = Bundle.main, relativeTo: String = #file, @@ -416,7 +416,7 @@ extension UITableView { } } - public func dequeueReusableCellNode(withIdentifier identifier: String) -> LayoutNode? { + func dequeueReusableCellNode(withIdentifier identifier: String) -> LayoutNode? { if let cell = dequeueReusableCell(withIdentifier: identifier) { guard let node = cell.layoutNode else { preconditionFailure("\(type(of: cell)) is not a Layout-managed view") @@ -456,7 +456,7 @@ extension UITableView { } } - public func dequeueReusableCellNode(withIdentifier identifier: String, for _: IndexPath) -> LayoutNode { + func dequeueReusableCellNode(withIdentifier identifier: String, for _: IndexPath) -> LayoutNode { guard let node = dequeueReusableCellNode(withIdentifier: identifier) else { let layoutsData = objc_getAssociatedObject(self, &cellDataKey) as? NSMutableDictionary if layoutsData?[identifier] == nil { diff --git a/Sources/Rules.swift b/Sources/Rules.swift index 4d57c7be7..55c203a55 100644 --- a/Sources/Rules.swift +++ b/Sources/Rules.swift @@ -4956,7 +4956,6 @@ public struct _FormatRules { public let extensionAccessControl = FormatRule( help: "Configure the placement of an extension's access control keyword.", - disabledByDefault: true, options: ["extensionacl"] ) { formatter in formatter.mapRecursiveDeclarations { declaration -> Formatter.Declaration in