Skip to content

Commit

Permalink
Enable extensionAccessControl rule by default
Browse files Browse the repository at this point in the history
  • Loading branch information
nicklockwood committed Oct 13, 2020
1 parent e513ce7 commit 3ade6aa
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 30 deletions.
4 changes: 2 additions & 2 deletions Snapshots/Issues/697.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
4 changes: 2 additions & 2 deletions Snapshots/Layout/Layout/Layout+XML.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions Snapshots/Layout/Layout/LayoutBacked.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
}
Expand Down
6 changes: 3 additions & 3 deletions Snapshots/Layout/Layout/LayoutDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
}
4 changes: 2 additions & 2 deletions Snapshots/Layout/Layout/LayoutNode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions Snapshots/Layout/Layout/Shared/XMLNode+Layout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions Snapshots/Layout/Layout/UICollectionView+Layout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"] ??
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -322,7 +322,7 @@ extension UICollectionView {
}
}

public func registerLayout(
func registerLayout(
named: String,
bundle: Bundle = Bundle.main,
relativeTo: String = #file,
Expand All @@ -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
Expand Down
12 changes: 6 additions & 6 deletions Snapshots/Layout/Layout/UITableView+Layout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -316,7 +316,7 @@ extension UITableView {

// MARK: UITableViewHeaderFooterView recycling

public func registerLayout(
func registerLayout(
named: String,
bundle: Bundle = Bundle.main,
relativeTo: String = #file,
Expand All @@ -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")
Expand Down Expand Up @@ -389,7 +389,7 @@ extension UITableView {

// MARK: UITableViewCell recycling

public func registerLayout(
func registerLayout(
named: String,
bundle: Bundle = Bundle.main,
relativeTo: String = #file,
Expand All @@ -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")
Expand Down Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion Sources/Rules.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3ade6aa

Please sign in to comment.