Files
SwiftLint/Source/SwiftLintFramework/Models/RuleDescription.swift
T
JP Simard 2bcea4b04d Add ability for SwiftLint to lint files with full type-checked AST awareness (#2379)
* Add LintableFilesVisitor

* Move LintCommand logic into LintOrAnalyzeCommand

to prepare for the upcoming analyze command

* Add AnalyzeCommand (not fully implemented yet in SwiftLintFramework)

* Add analyzerRules configuration member

* Add AnalyzerRule protocol

* Pass compiler arguments to validate/correct

* Add requiresFileOnDisk member to RuleDescription

This will be used by AnalyzerRules because they need a file on disk
to pass in the compiler arguments to SourceKit.

* Exclusively run AnalyzerRules when the Linter has compiler arguments

* Enable testing AnalyzerRules in TestHelpers

* Add ExplicitSelfRule

* Update documentation

* Fix `analyze --autocorrect`

* Improve performance of CompilerArgumentsExtractor

* Fix lint command actually running analyze

* Move File operations in TestHelpers into a private extension

* Add analyzer column to rules command and markdown documentation

* Use a Set literal

* Make AnalyzerRule inherit from OptInRule

* Mention analyzer_rules in readme

* Mention that analyzer rules are slow
2018-09-02 00:13:27 -07:00

43 lines
1.6 KiB
Swift

public struct RuleDescription: Equatable {
public let identifier: String
public let name: String
public let description: String
public let kind: RuleKind
public let nonTriggeringExamples: [String]
public let triggeringExamples: [String]
public let corrections: [String: String]
public let deprecatedAliases: Set<String>
public let minSwiftVersion: SwiftVersion
public let requiresFileOnDisk: Bool
public var consoleDescription: String { return "\(name) (\(identifier)): \(description)" }
public var allIdentifiers: [String] {
return Array(deprecatedAliases) + [identifier]
}
public init(identifier: String, name: String, description: String, kind: RuleKind,
minSwiftVersion: SwiftVersion = .three,
nonTriggeringExamples: [String] = [], triggeringExamples: [String] = [],
corrections: [String: String] = [:],
deprecatedAliases: Set<String> = [],
requiresFileOnDisk: Bool = false) {
self.identifier = identifier
self.name = name
self.description = description
self.kind = kind
self.nonTriggeringExamples = nonTriggeringExamples
self.triggeringExamples = triggeringExamples
self.corrections = corrections
self.deprecatedAliases = deprecatedAliases
self.minSwiftVersion = minSwiftVersion
self.requiresFileOnDisk = requiresFileOnDisk
}
}
// MARK: Equatable
public func == (lhs: RuleDescription, rhs: RuleDescription) -> Bool {
return lhs.identifier == rhs.identifier
}