-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2392 from daltonclaybrook/collection-alignment
New Rule - Collection Element Alignment
- Loading branch information
Showing
8 changed files
with
492 additions
and
0 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
28 changes: 28 additions & 0 deletions
28
Source/SwiftLintFramework/Rules/RuleConfigurations/CollectionAlignmentConfiguration.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,28 @@ | ||
public struct CollectionAlignmentConfiguration: RuleConfiguration, Equatable { | ||
private(set) var severityConfiguration = SeverityConfiguration(.warning) | ||
private(set) var alignColons = false | ||
|
||
init() {} | ||
|
||
public var consoleDescription: String { | ||
return severityConfiguration.consoleDescription + ", align_colons: \(alignColons)" | ||
} | ||
|
||
public mutating func apply(configuration: Any) throws { | ||
guard let configuration = configuration as? [String: Any] else { | ||
throw ConfigurationError.unknownConfiguration | ||
} | ||
|
||
alignColons = configuration["align_colons"] as? Bool ?? false | ||
|
||
if let severityString = configuration["severity"] as? String { | ||
try severityConfiguration.apply(configuration: severityString) | ||
} | ||
} | ||
|
||
public static func == (lhs: CollectionAlignmentConfiguration, | ||
rhs: CollectionAlignmentConfiguration) -> Bool { | ||
return lhs.alignColons == rhs.alignColons && | ||
lhs.severityConfiguration == rhs.severityConfiguration | ||
} | ||
} |
Oops, something went wrong.