skip Principle Class

This commit is contained in:
Roy Cao 2019-12-16 16:35:39 +08:00
parent ac399e4418
commit f8ab5fa941
4 changed files with 23 additions and 1 deletions

View File

@ -7,4 +7,5 @@ public enum RuleType: String, Decodable, CaseIterable {
case attributes
case xml
case comment
case superClass = "super_class"
}

View File

@ -39,6 +39,7 @@ let blacklistSources: [SourceDetail] = [SourceDetail(name: "AppDelegate", source
SourceDetail(name: "viewWillAppear(_:)", sourceKind: .function),
SourceDetail(name: "viewWillDisappear(_:)", sourceKind: .function),
SourceDetail(name: "viewDidDisappear(_:)", sourceKind: .function),
SourceDetail(name: "CodingKeys", sourceKind: .enum)
SourceDetail(name: "CodingKeys", sourceKind: .enum),
SourceDetail(name: "NotificationService", sourceKind: .class)
]

View File

@ -26,6 +26,8 @@ struct RuleFactory {
return XMLRule()
case .comment:
return CommentRule()
case .superClass:
return SuperClassRule()
}
}
}

View File

@ -0,0 +1,18 @@
import Foundation
import SwiftSyntax
/// Skip class inherited from specific class
struct SuperClassRule: SourceCollectRule {
static let blacklist: [String] = ["NotificationService",
"PreviewProvider"]
func skip(_ node: Syntax) -> Bool {
if let node = node as? InheritableSyntax {
if SuperClassRule.blacklist.contains(where: node.isInherited(from:)) {
return true
}
}
return false
}
}