Files
SwiftLint/Source/SwiftLintFramework/Models/StyleViolation.swift
T
JP Simard 989127cbe0 [StyleViolation] use RuleDescription's description when reason is nil
Many cases just used a static string that was nearly identical to the rule
description as the `reason` parameter when initializing a StyleViolation.
2015-11-17 10:25:57 -08:00

35 lines
1.0 KiB
Swift

//
// StyleViolation.swift
// SwiftLint
//
// Created by JP Simard on 2015-05-16.
// Copyright (c) 2015 Realm. All rights reserved.
//
public struct StyleViolation: CustomStringConvertible, Equatable {
public let ruleDescription: RuleDescription
public let severity: ViolationSeverity
public let location: Location
public let reason: String
public var description: String {
return XcodeReporter.generateForSingleViolation(self)
}
public init(ruleDescription: RuleDescription, severity: ViolationSeverity = .Warning,
location: Location, reason: String? = nil) {
self.ruleDescription = ruleDescription
self.severity = severity
self.location = location
self.reason = reason ?? ruleDescription.description
}
}
// MARK: Equatable
public func == (lhs: StyleViolation, rhs: StyleViolation) -> Bool {
return lhs.ruleDescription == rhs.ruleDescription &&
lhs.location == rhs.location &&
lhs.severity == rhs.severity &&
lhs.reason == rhs.reason
}