Don't trigger ClosingBraceRule across line breaks

Closes #592
This commit is contained in:
Josh Friend
2016-04-05 09:56:43 -04:00
parent b2c4be5241
commit a4d32cfa67
2 changed files with 10 additions and 3 deletions
+4
View File
@@ -18,6 +18,10 @@
[Norio Nomura](https://github.com/norio-nomura)
[#593](https://github.com/realm/SwiftLint/issues/593)
* `ClosingBraceRule` no longer triggers across line breaks.
[Josh Friend](https://github.com/joshfriend)
[#592](https://github.com/realm/SwiftLint/issues/592)
## 0.9.2: Multiple Exhaust Codes
##### Breaking
@@ -14,7 +14,7 @@ private let whitespaceAndNewlineCharacterSet = NSCharacterSet.whitespaceAndNewli
extension File {
private func violatingClosingBraceRanges() -> [NSRange] {
return matchPattern(
"(\\}\\s+\\))",
"(\\}[ \\t]+\\))",
excludingSyntaxKinds: SyntaxKind.commentAndStringKinds()
)
}
@@ -32,16 +32,19 @@ public struct ClosingBraceRule: CorrectableRule, ConfigurationProviderRule {
description: "Closing brace with closing parenthesis " +
"should not have any whitespaces in the middle.",
nonTriggeringExamples: [
"[].map({ })"
"[].map({ })",
"[].map(\n { }\n)"
],
triggeringExamples: [
"[].map({ ↓} )"
"[].map({ ↓} )",
"[].map({ }\t)"
],
corrections: [
"[].map({ } )\n": "[].map({ })\n"
]
)
public func validateFile(file: File) -> [StyleViolation] {
return file.violatingClosingBraceRanges().map {
StyleViolation(ruleDescription: self.dynamicType.description,