forked from realm/SwiftLint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
100 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// | ||
// RuleIdentifier.swift | ||
// SwiftLint | ||
// | ||
// Created by Frederick Pietschmann on 3/5/18. | ||
// Copyright © 2018 Realm. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public enum RuleIdentifier: Hashable, ExpressibleByStringLiteral { | ||
case all | ||
case some(identifier: String) | ||
|
||
private static let allStringRepresentation = "all" | ||
|
||
public var hashValue: Int { | ||
switch self { | ||
case .all: | ||
return -1 | ||
|
||
case .some(let identifier): | ||
return identifier.hashValue | ||
} | ||
} | ||
|
||
public var stringRepresentation: String { | ||
switch self { | ||
case .all: | ||
return RuleIdentifier.allStringRepresentation | ||
|
||
case .some(let identifier): | ||
return identifier | ||
} | ||
} | ||
|
||
public init(_ value: String) { | ||
self = value == RuleIdentifier.allStringRepresentation ? .all : .some(identifier: value) | ||
} | ||
|
||
public init(stringLiteral value: String) { | ||
self = RuleIdentifier(value) | ||
} | ||
|
||
public static func == (lhs: RuleIdentifier, rhs: RuleIdentifier) -> Bool { | ||
return lhs.hashValue == rhs.hashValue | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters