mirror of
https://github.com/realm/SwiftLint.git
synced 2026-06-06 20:18:40 +00:00
treat single values as an array in the configuration dictionary
This commit is contained in:
@@ -38,6 +38,12 @@
|
||||
[JP Simard](https://github.com/jpsim)
|
||||
[#386](https://github.com/realm/SwiftLint/issues/386)
|
||||
|
||||
* All top-level keys in a configuration file that accept an array now also
|
||||
accept a single value.
|
||||
e.g. `included: Source` is equivalent to `included:\n - Source`.
|
||||
[JP Simard](https://github.com/jpsim)
|
||||
[#120](https://github.com/realm/SwiftLint/issues/120)
|
||||
|
||||
##### Bug Fixes
|
||||
|
||||
* Fix case sensitivity of keywords for `valid_docs`.
|
||||
|
||||
@@ -104,9 +104,15 @@ public struct Configuration: Equatable {
|
||||
"future release.")
|
||||
}
|
||||
|
||||
func defaultStringArray(object: AnyObject?) -> [String] {
|
||||
return [String].arrayOf(object) ?? []
|
||||
}
|
||||
|
||||
// Use either new 'opt_in_rules' or deprecated 'enabled_rules' for now.
|
||||
let optInRules = dict[ConfigurationKey.OptInRules.rawValue] as? [String] ??
|
||||
dict[ConfigurationKey.EnabledRules.rawValue] as? [String] ?? []
|
||||
let optInRules = defaultStringArray(
|
||||
dict[ConfigurationKey.OptInRules.rawValue] ??
|
||||
dict[ConfigurationKey.EnabledRules.rawValue]
|
||||
)
|
||||
|
||||
// Log an error when supplying invalid keys in the configuration dictionary
|
||||
let validKeys = [
|
||||
@@ -126,11 +132,11 @@ public struct Configuration: Equatable {
|
||||
}
|
||||
|
||||
self.init(
|
||||
disabledRules: dict[ConfigurationKey.DisabledRules.rawValue] as? [String] ?? [],
|
||||
disabledRules: defaultStringArray(dict[ConfigurationKey.DisabledRules.rawValue]),
|
||||
optInRules: optInRules,
|
||||
whitelistRules: dict[ConfigurationKey.WhitelistRules.rawValue] as? [String] ?? [],
|
||||
included: dict[ConfigurationKey.Included.rawValue] as? [String] ?? [],
|
||||
excluded: dict[ConfigurationKey.Excluded.rawValue] as? [String] ?? [],
|
||||
whitelistRules: defaultStringArray(dict[ConfigurationKey.WhitelistRules.rawValue]),
|
||||
included: defaultStringArray(dict[ConfigurationKey.Included.rawValue]),
|
||||
excluded: defaultStringArray(dict[ConfigurationKey.Excluded.rawValue]),
|
||||
reporter: dict[ConfigurationKey.Reporter.rawValue] as? String ??
|
||||
XcodeReporter.identifier,
|
||||
useNestedConfigs: dict[ConfigurationKey.UseNestedConfigs.rawValue] as? Bool ?? false,
|
||||
|
||||
Reference in New Issue
Block a user