Skip to content

Commit

Permalink
Don't log if indentation isn't set in config
Browse files Browse the repository at this point in the history
Fixes #1998
  • Loading branch information
jpsim committed Jan 10, 2018
1 parent 569937f commit e70710b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@

#### Bug Fixes

* None.
* No longer log if the `indentation` key isn't set in the configuration file.
[JP Simard](https://github.com/jpsim)
[#1998](https://github.com/realm/SwiftLint/issues/1998)

## 0.24.1: Dented Tumbler

Expand Down
18 changes: 14 additions & 4 deletions Source/SwiftLintFramework/Extensions/Configuration+Parsing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@ extension Configuration {
].map({ $0.rawValue }) + ruleList.allValidIdentifiers()
}

private static func getIndentationLogIfInvalid(from dict: [String: Any]) -> IndentationStyle {
if let rawIndentation = dict[Key.indentation.rawValue] {
if let indentationStyle = Configuration.IndentationStyle(rawIndentation) {
return indentationStyle
}

queuedPrintError("Invalid configuration for '\(Key.indentation)'. Falling back to default.")
return .default
}

return .default
}

public init?(dict: [String: Any], ruleList: RuleList = masterRuleList, enableAllRules: Bool = false,
cachePath: String? = nil) {
func defaultStringArray(_ object: Any?) -> [String] {
Expand All @@ -62,10 +75,7 @@ extension Configuration {
let whitelistRules = defaultStringArray(dict[Key.whitelistRules.rawValue])
let included = defaultStringArray(dict[Key.included.rawValue])
let excluded = defaultStringArray(dict[Key.excluded.rawValue])
let indentation = Configuration.IndentationStyle(dict[Key.indentation.rawValue]) ?? {
queuedPrintError("Invalid configuration for '\(Key.indentation)'. Falling back to default.")
return .default
}()
let indentation = Configuration.getIndentationLogIfInvalid(from: dict)

Configuration.warnAboutDeprecations(configurationDictionary: dict, disabledRules: disabledRules,
optInRules: optInRules, whitelistRules: whitelistRules, ruleList: ruleList)
Expand Down

0 comments on commit e70710b

Please sign in to comment.