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.
uncuddled else folded into statement position
still needs autocorrect
- Loading branch information
Michael Skiba
committed
Jun 9, 2016
1 parent
314f7db
commit 7a56338
Showing
6 changed files
with
188 additions
and
112 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 was deleted.
Oops, something went wrong.
59 changes: 59 additions & 0 deletions
59
Source/SwiftLintFramework/Rules/RuleConfigurations/StatementPositionConfiguration.swift
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,59 @@ | ||
// | ||
// StatementPositionConfiguration.swift | ||
// SwiftLint | ||
// | ||
// Created by Michael Skiba on 6/8/16. | ||
// Copyright © 2016 Realm. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public enum StatmentModeConfiguration: String { | ||
case Standard, UncuddledElse | ||
|
||
init(value: AnyObject) throws { | ||
guard let string = (value as? String)?.lowercaseString else { | ||
throw ConfigurationError.UnknownConfiguration | ||
} | ||
if string == StatmentModeConfiguration.Standard.rawValue.lowercaseString { | ||
self = .Standard | ||
} else if string == StatmentModeConfiguration.UncuddledElse.rawValue.lowercaseString { | ||
self = .UncuddledElse | ||
} else { | ||
throw ConfigurationError.UnknownConfiguration | ||
} | ||
} | ||
|
||
} | ||
|
||
public struct StatmentConfiguration: RuleConfiguration, Equatable { | ||
public var consoleDescription: String { | ||
return "(statement mode) \(statementMode.rawValue), " + | ||
"(severity) \(severity.consoleDescription)" | ||
} | ||
|
||
var statementMode: StatmentModeConfiguration | ||
var severity: SeverityConfiguration | ||
|
||
public init(statementMode: StatmentModeConfiguration, | ||
severity: SeverityConfiguration) { | ||
self.statementMode = statementMode | ||
self.severity = severity | ||
} | ||
|
||
public mutating func applyConfiguration(configuration: AnyObject) throws { | ||
guard let configurationDict = configuration as? [String: AnyObject] else { | ||
throw ConfigurationError.UnknownConfiguration | ||
} | ||
if let statementModeConfiguration = configurationDict["statementMode"] { | ||
try statementMode = StatmentModeConfiguration(value: statementModeConfiguration) | ||
} | ||
if let severityConfiguration = configurationDict["severity"] { | ||
try severity.applyConfiguration(severityConfiguration) | ||
} | ||
} | ||
} | ||
|
||
public func == (lhs: StatmentConfiguration, rhs: StatmentConfiguration) -> Bool { | ||
return lhs.statementMode == rhs.statementMode && lhs.severity == rhs.severity | ||
} |
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