-
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.
Rewrite
for_where
, adding allow_for_as_filter
config
Fixes #4040
- Loading branch information
1 parent
0fbd03c
commit 29c18c3
Showing
3 changed files
with
116 additions
and
63 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
20 changes: 20 additions & 0 deletions
20
Source/SwiftLintFramework/Rules/RuleConfigurations/ForWhereRuleConfiguration.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,20 @@ | ||
public struct ForWhereRuleConfiguration: RuleConfiguration, Equatable { | ||
private(set) var severityConfiguration = SeverityConfiguration(.warning) | ||
private(set) var allowForAsFilter = false | ||
|
||
public var consoleDescription: String { | ||
return severityConfiguration.consoleDescription + ", allow_for_as_filter: \(allowForAsFilter)" | ||
} | ||
|
||
public mutating func apply(configuration: Any) throws { | ||
guard let configuration = configuration as? [String: Any] else { | ||
throw ConfigurationError.unknownConfiguration | ||
} | ||
|
||
allowForAsFilter = configuration["allow_for_as_filter"] as? Bool ?? false | ||
|
||
if let severityString = configuration["severity"] as? String { | ||
try severityConfiguration.apply(configuration: severityString) | ||
} | ||
} | ||
} |