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.
Add option that allows skipping aligned constants (realm#3391)
- Loading branch information
1 parent
67165f7
commit ba58d57
Showing
4 changed files
with
120 additions
and
11 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
24 changes: 24 additions & 0 deletions
24
...ce/SwiftLintFramework/Rules/RuleConfigurations/OperatorUsageWhitespaceConfiguration.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,24 @@ | ||
public struct OperatorUsageWhitespaceConfiguration: RuleConfiguration, Equatable { | ||
private(set) var severityConfiguration = SeverityConfiguration(.warning) | ||
private(set) var linesLookAround = 2 | ||
private(set) var skipAlignedConstants = true | ||
|
||
public var consoleDescription: String { | ||
return severityConfiguration.consoleDescription | ||
+ ", lines_look_around: \(linesLookAround)" | ||
+ ", skip_aligned_constants: \(skipAlignedConstants)" | ||
} | ||
|
||
public mutating func apply(configuration: Any) throws { | ||
guard let configuration = configuration as? [String: Any] else { | ||
throw ConfigurationError.unknownConfiguration | ||
} | ||
|
||
linesLookAround = configuration["lines_look_around"] as? Int ?? 2 | ||
skipAlignedConstants = configuration["skip_aligned_constants"] as? Bool ?? true | ||
|
||
if let severityString = configuration["severity"] as? String { | ||
try severityConfiguration.apply(configuration: severityString) | ||
} | ||
} | ||
} |
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