mirror of
https://github.com/realm/SwiftLint.git
synced 2026-06-06 20:18:40 +00:00
989127cbe0
Many cases just used a static string that was nearly identical to the rule description as the `reason` parameter when initializing a StyleViolation.
35 lines
1.0 KiB
Swift
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
|
|
}
|