mirror of
https://github.com/realm/SwiftLint.git
synced 2026-06-06 20:18:40 +00:00
48 lines
1.3 KiB
Swift
48 lines
1.3 KiB
Swift
//
|
|
// Linter.swift
|
|
// SwiftLint
|
|
//
|
|
// Created by JP Simard on 2015-05-16.
|
|
// Copyright (c) 2015 Realm. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
import SwiftXPC
|
|
import SourceKittenFramework
|
|
|
|
public struct Linter {
|
|
private let file: File
|
|
|
|
public var styleViolations: [StyleViolation] {
|
|
return reduce(
|
|
[
|
|
LineLengthRule().validateFile(file),
|
|
LeadingWhitespaceRule().validateFile(file),
|
|
TrailingWhitespaceRule().validateFile(file),
|
|
TrailingNewlineRule().validateFile(file),
|
|
ForceCastRule().validateFile(file),
|
|
FileLengthRule().validateFile(file),
|
|
TodoRule().validateFile(file),
|
|
ColonRule().validateFile(file),
|
|
TypeNameRule().validateFile(file),
|
|
VariableNameRule().validateFile(file),
|
|
TypeBodyLengthRule().validateFile(file),
|
|
FunctionBodyLengthRule().validateFile(file),
|
|
NestingRule().validateFile(file)
|
|
], [], +)
|
|
}
|
|
|
|
public static var explainableRules: [RuleExample] {
|
|
return [ColonRule()]
|
|
}
|
|
|
|
/**
|
|
Initialize a Linter by passing in a File.
|
|
|
|
:param: file File to lint.
|
|
*/
|
|
public init(file: File) {
|
|
self.file = file
|
|
}
|
|
}
|