Files
SwiftLint/Source/SwiftLintFramework/Rules/ForceCastRule.swift
T
JP Simard c6221d4997 ColonRule
2015-05-18 05:18:56 +02:00

24 lines
671 B
Swift

//
// ForceCastRule.swift
// SwiftLint
//
// Created by JP Simard on 2015-05-16.
// Copyright (c) 2015 Realm. All rights reserved.
//
import SourceKittenFramework
struct ForceCastRule: Rule {
static let identifier = "force_cast"
static let parameters = [RuleParameter<Void>]()
static func validateFile(file: File) -> [StyleViolation] {
return file.matchPattern("as!", withSyntaxKinds: [.Keyword]).map { range in
return StyleViolation(type: .ForceCast,
location: Location(file: file, offset: range.location),
severity: .High,
reason: "Force casts should be avoided")
}
}
}